-
Notifications
You must be signed in to change notification settings - Fork 981
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
allow delete only if annotations meet configured criteria #1069
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FxKu
requested review from
avaczi,
CyberDem0n,
erthalion,
Jan-M,
RafiaSabih and
sdudoladov
as code owners
July 21, 2020 08:09
FxKu
changed the title
[WIP] allow delete only if annotations meet configured criteria
allow delete only if annotations meet configured criteria
Jul 29, 2020
Jan-M
reviewed
Jul 29, 2020
Jan-M
reviewed
Jul 29, 2020
Jan-M
reviewed
Aug 11, 2020
pkg/controller/postgresql.go
Outdated
// only allow deletion if delete annotations are set and conditions are met | ||
if eventType == EventDelete { | ||
if err := c.meetsClusterDeleteAnnotations(informerOldSpec); err != nil { | ||
c.logger.WithField("cluster-name", clusterName).Warnf("skipping %q event as delete criteria not fulfilled: %s", eventType, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
skipping %q event as delete criteria not fulfilled: %s
To
Ignoring delete event for cluster %q - manifest does not fulfill delete requirements (annotations): %s
FxKu
force-pushed
the
cluster-delete-annotations
branch
4 times, most recently
from
August 11, 2020 14:27
5e22b01
to
9932757
Compare
FxKu
force-pushed
the
cluster-delete-annotations
branch
from
August 13, 2020 12:20
9932757
to
4feb301
Compare
👍 |
1 similar comment
👍 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Right now a Postgres cluster can be easily removed with
kubectl delete pg acid-minimal-cluster
. If clusters are called very similar it might happen that one accidently removes the wrong resource. While it could be recovered from S3 pretty quickly (depending on the size, of course) a few more steps might be necessary to get back to normal operating mode.To avoid all the stress, this PRs introduces a simple delete protection mechanism, that checks for existing annotations in the manifest before allowing the delete process to continue. Actually, we would assume this is something to be set in the K8s infrastructure, which blocks a delete request already at the ApiServer level. With this approach here, the CR still gets removed but all managed child resources remain. Either if the cluster was deleted accidentally or the delete annotations were forgotten, one has to recreate the cluster again to continue.
The two delete protection checks are:
The name for the two annotations keys can be configured. Each check can be disabled individually if the option is not set (empty). This is also the default.
This PR also fixes three more things: