Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions percona/controller/pgcluster/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ func (r *PGClusterReconciler) reconcileCustomExtensions(ctx context.Context, cr
}

if cr.CompareVersion("2.6.0") >= 0 {
var removedExtension []string
var removedExtensions []string
installedExtensions := cr.Status.InstalledCustomExtensions
crExtensions := make(map[string]struct{})
for _, ext := range extensionNames {
Expand All @@ -709,13 +709,13 @@ func (r *PGClusterReconciler) reconcileCustomExtensions(ctx context.Context, cr
for _, ext := range installedExtensions {
// If an object exists in installedExtensions but not in crExtensions, the extension should be deleted.
if _, ok := crExtensions[ext]; !ok {
removedExtension = append(removedExtension, ext)
removedExtensions = append(removedExtensions, ext)
}
}

if len(removedExtension) > 0 {
if len(removedExtensions) > 0 {
disable := func(ctx context.Context, exec postgres.Executor) error {
return errors.WithStack(disableCustomExtensionsInDB(ctx, exec, removedExtension))
return errors.WithStack(disableCustomExtensionsInDB(ctx, exec, removedExtensions))
}

primary, err := perconaPG.GetPrimaryPod(ctx, r.Client, cr)
Expand Down Expand Up @@ -765,9 +765,11 @@ func disableCustomExtensionsInDB(ctx context.Context, exec postgres.Executor, cu
},
)

log.V(1).Info("extension was disabled ", "extensionName", extensionName)
if err != nil {
return errors.Wrap(err, "drop custom extension")
}

return errors.Wrap(err, "custom extension deletion")
log.V(1).Info("extension was disabled ", "extensionName", extensionName)
}

return nil
Expand Down
Loading