-
Notifications
You must be signed in to change notification settings - Fork 326
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
cli: Create Secrets With A Label #835
Conversation
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.
Great work, Saad!
A couple of comments/questions:
- Should we also add label if the secret exists? I think some commands already update the secret if it exists (e.g webhook-cert-manager), while others (like
server-acl-init
) don't. Adding a label if secret exists is nice because if someone runs a helm upgrade, all secrets would get updated with a label. - I think the commands need unit tests to check that the label is added.
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.
Great work! Very clear code. I would echo what @ishustava said and change the "consul-k8s"
string in both the CLI and Control Plane to be a constant that is passed around. That will make it easier for us to change later on if we need to.
1a71d07
to
cb12fe9
Compare
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.
Great work Saad! I've left some minor comments, but won't block the merge.
08f0204
to
2046c56
Compare
for _, secret := range secrets.Items { | ||
if strings.HasPrefix(secret.Name, foundReleaseName) { | ||
err := c.kubernetes.CoreV1().Secrets(foundReleaseNamespace).Delete(c.Ctx, secret.Name, metav1.DeleteOptions{}) | ||
if err != nil { | ||
return fmt.Errorf("deleteSecrets: error deleting Secret %q: %s", secret.Name, err) | ||
} | ||
secretNames = append(secretNames, secret.Name) | ||
err := c.kubernetes.CoreV1().Secrets(foundReleaseNamespace).Delete(c.Ctx, secret.Name, metav1.DeleteOptions{}) | ||
if err != nil { | ||
return fmt.Errorf("deleteSecrets: error deleting Secret %q: %s", secret.Name, err) | ||
} | ||
secretNames = append(secretNames, secret.Name) |
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.
I would move the instantiation of secretNames
to right above line 394, before you start the iteration. I would also change the name to deletedSecrets
so it's more clear what you are listing.
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.
I lean towards secretNames rather than changing it to deletedSecrets because they are the names of secrets to delete, but haven't been deleted yet.
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.
Great work on this, Saad! You should feel very proud of the work you've done in your time here. It's been a pleasure working with you!
bdc4a32
to
85fcdcf
Compare
… tests as well) and only delete secrets with that label in uninstall.go
…troduced a regression while resolving merge conflict.
6e1b28a
to
07d64ef
Compare
This reverts commit 07d64ef.
This reverts commit e895995.
This reverts commit e895995.
else. the control plane changes are in the image which were fine and passed the previous cli acceptance tests. cli: Create Secrets With A Label (#835) Every-time a secret is created, add a label "managed-by" which is equal to "consul-k8s". On uninstall, only delete those secrets with said label. Co-authored-by: Thomas Eckert <[email protected]> Co-authored-by: Nitya Dhanushkodi <[email protected]>
The cloud acceptance tests for the CLI have been failing (but passing in Kind) since merging 835. After reverting the whole PR and testing with several parts of that PR, it looks like the code itself wasn't causing issues, but rather the extensive go.mod updates. Those updates were not necessary for the PR (I was able to run go mod tidy with no changes), so I'm reverting those here so the tests will pass again.
Changes proposed in this PR:
How I've tested this PR:
Changed the uninstall test, and ensured any secret created with this label is deleted, while secrets lacking this label persist. Also some ad-hoc testing, running the
consul-k8s install
andconsul-k8s uninstall
command.How I expect reviewers to test this PR:
Code review.
Checklist: