diff --git a/controllers/postgres_controller.go b/controllers/postgres_controller.go index d2893b9c..f8a73bbe 100644 --- a/controllers/postgres_controller.go +++ b/controllers/postgres_controller.go @@ -485,15 +485,8 @@ func (r *PostgresReconciler) deleteUserPasswordsSecret(ctx context.Context, inst // ensureZalandoDependencies makes sure Zalando resources are installed in the service-cluster. func (r *PostgresReconciler) ensureZalandoDependencies(log logr.Logger, ctx context.Context, p *pg.Postgres, b *pg.BackupConfig) error { namespace := p.ToPeripheralResourceNamespace() - isInstalled, err := r.OperatorManager.IsOperatorInstalled(ctx, namespace) - if err != nil { - return fmt.Errorf("error while querying if zalando dependencies are installed: %w", err) - } - - if !isInstalled { - if err := r.OperatorManager.InstallOrUpdateOperator(ctx, namespace); err != nil { - return fmt.Errorf("error while installing zalando dependencies: %w", err) - } + if err := r.OperatorManager.InstallOrUpdateOperator(ctx, namespace); err != nil { + return fmt.Errorf("error while installing zalando dependencies: %w", err) } if err := r.updatePodEnvironmentConfigMap(log, ctx, p, b); err != nil { diff --git a/main.go b/main.go index e4740e5e..b7a20895 100644 --- a/main.go +++ b/main.go @@ -551,11 +551,6 @@ func main() { ctx := context.Background() - // update all existing operators to the current version - if err := opMgr.UpdateAllManagedOperators(ctx); err != nil { - setupLog.Error(err, "error updating the postgres operators") - } - setupLog.Info("starting service cluster manager", "version", v.V) go func() { if err := svcClusterMgr.Start(ctx); err != nil { diff --git a/pkg/operatormanager/operatormanager.go b/pkg/operatormanager/operatormanager.go index 1575be22..1f75418a 100644 --- a/pkg/operatormanager/operatormanager.go +++ b/pkg/operatormanager/operatormanager.go @@ -17,7 +17,6 @@ import ( pg "github.com/fi-ts/postgreslet/api/v1" "github.com/go-logr/logr" - zalando "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" rbacv1 "k8s.io/api/rbac/v1" @@ -40,9 +39,6 @@ const ( // PodEnvSecretName Name of the pod environment secret to create and use PodEnvSecretName string = "postgres-pod-secret" //nolint:gosec - operatorPodLabelName string = "name" - operatorPodLabelValue string = "postgres-operator" - // SidecarsCMFluentBitConfKey Name of the key containing the fluent-bit.conf config file SidecarsCMFluentBitConfKey string = "fluent-bit.conf" // SidecarsCMExporterQueriesKey Name of the key containing the queries.yaml config file @@ -54,9 +50,6 @@ const ( debugLogLevel int = 1 ) -// operatorPodMatchingLabels is for listing operator pods -var operatorPodMatchingLabels = client.MatchingLabels{operatorPodLabelName: operatorPodLabelValue} - // Options type Options struct { PspName string @@ -188,23 +181,6 @@ func (m *OperatorManager) IsOperatorDeletable(ctx context.Context, namespace str return true, nil } -// IsOperatorInstalled returns true when the operator is installed -func (m *OperatorManager) IsOperatorInstalled(ctx context.Context, namespace string) (bool, error) { - pods := &corev1.PodList{} - opts := []client.ListOption{ - client.InNamespace(namespace), - operatorPodMatchingLabels, - } - if err := m.client.List(ctx, pods, opts...); err != nil { - return false, client.IgnoreNotFound(err) - } - if len(pods.Items) == 0 { - return false, nil - } - m.log.Info("operator is installed", "ns", namespace) - return true, nil -} - // UninstallOperator uninstalls the operator func (m *OperatorManager) UninstallOperator(ctx context.Context, namespace string) error { items := m.list.Items @@ -672,29 +648,3 @@ func (m *OperatorManager) toObjectKey(obj runtime.Object, namespace string) (cli Name: name, }, nil } - -// UpdateAllManagedOperators Updates the manifests of all postgres operators managed by this postgreslet -func (m *OperatorManager) UpdateAllManagedOperators(ctx context.Context) error { - // fetch postgresql custom resource (running or otherwise) - m.log.Info("Fetching all zalando custom resources managed by this postgreslet") - matchingLabels := client.MatchingLabels{ - pg.PartitionIDLabelName: m.options.PartitionID, - } - zList := &zalando.PostgresqlList{} - opts := []client.ListOption{ - matchingLabels, - } - if err := m.client.List(ctx, zList, opts...); err != nil { - return client.IgnoreNotFound(err) - } - // update each namespace - for _, z := range zList.Items { - m.log.Info("Updating postgres operator installation", "ns", z.Namespace) - if err := m.InstallOrUpdateOperator(ctx, z.Namespace); err != nil { - return err - } - } - - m.log.Info("Done updating postgres operators in managed namespaces") - return nil -}