Skip to content

Use createOrUpdate pattern for pod environment configmap #191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

LimKianAn
Copy link
Contributor

So that we can later migrate to idiomatic controllerutil.CreateOrUpdate or even controllerutil.CreateOrPatch. Moreover, the logic related to the extended opeartor (zalando operator + pod environment configmap + sidecars configmap) is all shifted to OperatorManager, not mixed in PostgresController anymore.

@LimKianAn LimKianAn requested a review from majst01 March 26, 2021 21:03
@LimKianAn LimKianAn self-assigned this Mar 29, 2021
@LimKianAn LimKianAn added the enhancement New feature or request label Mar 29, 2021
@LimKianAn LimKianAn force-pushed the use-create-or-update-pattern branch from aed02b4 to fef8968 Compare March 31, 2021 07:38
@LimKianAn LimKianAn changed the title Use createOrUpdate pattern Use createOrUpdate pattern for pod environment configmap Mar 31, 2021
@LimKianAn LimKianAn marked this pull request as draft March 31, 2021 08:32
@LimKianAn LimKianAn marked this pull request as ready for review March 31, 2021 16:09
@LimKianAn LimKianAn requested review from eberlep and removed request for majst01 April 6, 2021 08:09
if err := r.ensureZalandoDependencies(ctx, instance); err != nil {
r.recorder.Eventf(instance, "Warning", "Error", "failed to install operator: %v", err)
return ctrl.Result{}, fmt.Errorf("error while ensuring Zalando dependencies: %w", err)
if err := r.CreateOrUpdateOperator(ctx, instance); err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I don't like the fact that we now always update the operator each time anything changes and that it will not be skipped if the operator is already installed.

Before this change, we once called this code when we initially created the namespace, and once on startup of the postgreslet. Now it will be called from the postgres_controller, meaning every time anything changes.

I would like this to stay as it was: Once on creation, once on startup and each time the backup-config changes.

Porposal

  • CreateOrUpdate stays the way it is (no check if it is already installed), CreateOrUpdatePodEnvironmentConfigMap will be exported
  • The postgres_controller checks if the operator is already installed and skips CreateOrUpdate if it is already installed (just like before)
  • The postgres_controller will no longer update the pod environment configmap
  • On startup, CreateOrUpdateOperator will be called (as before)
  • A new BackupConfigController will watch the backup-configs and update the PodEnvironmentConfigMaps if neccessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LimKianAn LimKianAn force-pushed the use-create-or-update-pattern branch from f1f755e to 7e6183f Compare April 6, 2021 13:58
@eberlep eberlep assigned eberlep and unassigned LimKianAn Apr 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Shift the logic of updating pod environment ConfigMap to OperatorManager
2 participants