Skip to content

Commit 247cae9

Browse files
mnenciaarmru
andauthored
fix(plugins): honour enabled flag on external cluster plugin configurations (#10932)
The function checked only whether `PluginConfiguration` was non-nil, skipping the `IsEnabled()` call that the sibling function `GetPluginConfigurationEnabledPluginNames` already makes. An explicitly-disabled external-cluster plugin was therefore still returned as active. Closes #10930 **Release note:** Fixed a bug where setting `enabled: false` on an external cluster plugin configuration was not honoured. Signed-off-by: Armando Ruocco <[email protected]> Co-authored-by: Armando Ruocco <[email protected]>
1 parent 73888b6 commit 247cae9

3 files changed

Lines changed: 31 additions & 7 deletions

File tree

‎api/v1/cluster_funcs.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ func (cluster *Cluster) GetJobEnabledPluginNames() (result []string) {
140140
func GetExternalClustersEnabledPluginNames(externalClusters []ExternalCluster) (result []string) {
141141
pluginNames := make([]string, 0, len(externalClusters))
142142
for _, externalCluster := range externalClusters {
143-
if externalCluster.PluginConfiguration != nil {
143+
if externalCluster.PluginConfiguration != nil && externalCluster.PluginConfiguration.IsEnabled() {
144144
pluginNames = append(pluginNames, externalCluster.PluginConfiguration.Name)
145145
}
146146
}

‎api/v1/cluster_funcs_test.go‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1866,3 +1866,28 @@ var _ = Describe("RecoveryTarget.BuildPostgresOptions", func() {
18661866
Expect(out).To(ContainSubstring(`recovery_target_lsn = '0/1\\6'` + "\n"))
18671867
})
18681868
})
1869+
1870+
var _ = Describe("GetExternalClustersEnabledPluginNames", func() {
1871+
falseVal := false
1872+
1873+
It("includes plugins with nil Enabled (defaults to enabled)", func() {
1874+
clusters := []ExternalCluster{
1875+
{PluginConfiguration: &PluginConfiguration{Name: "plugin-a"}},
1876+
}
1877+
Expect(GetExternalClustersEnabledPluginNames(clusters)).To(ConsistOf("plugin-a"))
1878+
})
1879+
1880+
It("excludes plugins with Enabled=false", func() {
1881+
clusters := []ExternalCluster{
1882+
{PluginConfiguration: &PluginConfiguration{Name: "plugin-a", Enabled: &falseVal}},
1883+
}
1884+
Expect(GetExternalClustersEnabledPluginNames(clusters)).To(BeEmpty())
1885+
})
1886+
1887+
It("excludes external clusters without a plugin configuration", func() {
1888+
clusters := []ExternalCluster{
1889+
{ConnectionParameters: map[string]string{"host": "pg.example.com"}},
1890+
}
1891+
Expect(GetExternalClustersEnabledPluginNames(clusters)).To(BeEmpty())
1892+
})
1893+
})

‎internal/controller/cluster_controller_test.go‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -618,10 +618,10 @@ var _ = Describe("getPluginsNeededForReconcile", func() {
618618
To(ConsistOf("plugin-a", "plugin-ext"))
619619
})
620620

621-
It("includes external-cluster plugins even when explicitly disabled", func() {
622-
// GetExternalClustersEnabledPluginNames does not consult
623-
// PluginConfiguration.Enabled — any non-nil PluginConfiguration on an
624-
// external cluster contributes its name. This test locks that in.
621+
It("excludes external-cluster plugins that are explicitly disabled", func() {
622+
// GetExternalClustersEnabledPluginNames honours
623+
// PluginConfiguration.Enabled, so a disabled plugin on an external
624+
// cluster does not contribute its name.
625625
cluster := &apiv1.Cluster{
626626
Spec: apiv1.ClusterSpec{
627627
ExternalClusters: []apiv1.ExternalCluster{
@@ -635,8 +635,7 @@ var _ = Describe("getPluginsNeededForReconcile", func() {
635635
},
636636
},
637637
}
638-
Expect(getPluginsNeededForReconcile(cluster)).
639-
To(ConsistOf("plugin-ext"))
638+
Expect(getPluginsNeededForReconcile(cluster)).To(BeEmpty())
640639
})
641640

642641
It("deduplicates plugin names that appear in both Spec.Plugins and external clusters", func() {

0 commit comments

Comments
 (0)