feat: Automatically trigger pod rollout for appsv1 resources when AuthProxyWorkload changes.#197
Merged
feat: Automatically trigger pod rollout for appsv1 resources when AuthProxyWorkload changes.#197
Conversation
b70585b to
e3ee326
Compare
enocom
reviewed
Feb 7, 2023
|
|
||
| var status metav1.ConditionStatus | ||
| var result ctrl.Result | ||
| if upToDate { |
Member
There was a problem hiding this comment.
Small Go nit:
status := metav1.ConditionFalse
result := requeueNow
if upToDate {
status = metav1.ConditionTrue
result = ctrl.Result{}
}| // on the pod. | ||
| func PodAnnotation(r *cloudsqlapi.AuthProxyWorkload) (string, string) { | ||
| return fmt.Sprintf("%s/%s", cloudsqlapi.AnnotationPrefix, r.Name), | ||
| strconv.FormatInt(r.Generation, 10) |
Collaborator
Author
There was a problem hiding this comment.
10 is "format this int64 in base 10"
Member
There was a problem hiding this comment.
🤦 Let's just use fmt.Sprintf("%d", r.Generation) in that. I somehow totally read over FormatInt.
| } | ||
|
|
||
| // test that annotation was set properly | ||
| if !reflect.DeepEqual(wl.PodTemplateAnnotations(), wantAnnotations) { |
Member
There was a problem hiding this comment.
reflect.DeepEqual is fine here, but FYI there is https://github.com/google/go-cmp which is helpful for more sophistication comparisons.
|
|
||
| // Check if the correct annotation exists | ||
| an := wl.PodTemplateAnnotations() | ||
| if an != nil { |
Member
There was a problem hiding this comment.
if an != nil && an[k] == v {
return false
}
hessjcg
commented
Feb 7, 2023
Collaborator
Author
hessjcg
left a comment
There was a problem hiding this comment.
Updated and ready for a new review.
|
|
||
| // Check if the correct annotation exists | ||
| an := wl.PodTemplateAnnotations() | ||
| if an != nil { |
|
|
||
| var status metav1.ConditionStatus | ||
| var result ctrl.Result | ||
| if upToDate { |
| // on the pod. | ||
| func PodAnnotation(r *cloudsqlapi.AuthProxyWorkload) (string, string) { | ||
| return fmt.Sprintf("%s/%s", cloudsqlapi.AnnotationPrefix, r.Name), | ||
| strconv.FormatInt(r.Generation, 10) |
Collaborator
Author
There was a problem hiding this comment.
10 is "format this int64 in base 10"
Collaborator
Author
|
/gcbrun |
enocom
approved these changes
Feb 7, 2023
b1d3823 to
ddbb207
Compare
Collaborator
Author
|
/gcbrun |
hessjcg
pushed a commit
that referenced
this pull request
Feb 21, 2023
Features - Add new field RolloutStrategy control automatic rollout (#202) (090b88d) - Add new terraform project for e2e test resources (#181) (0140592) - Add script to run terraform with input validation. (#182) (857444a) - Add support for Unix sockets. (#205) (8177a35), closes #47 - Add telemetry settings to configure health check port (#210) (3ede42d) - Add the e2e test job for Cloud Build (#184) (dc2990c) - Automatic changes to workloads when an AuthProxyWorload is deleted (#200) (e11caed) - Automatically trigger pod rollout for appsv1 resources when AuthProxyWorkload changes. (#197) (3b0359b) - Separate terraform for project setup and permissions (#179) (8f43657) - Validate AuthProxyWorkload spec.selector field (#209) (98c460b) - Validate AuthProxyWorkload updates to prevent changes to the workload selector. (#211) (4304283) Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> Co-authored-by: Release PR Generate Bot action release-please[bot] <release-please[bot]@users.noreply.github.com>
This file contains hidden or 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
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.
Given an AuthProxyWorkload resource that has been applied to StatefulSet, DaemonSet,
ReplicaSet, and/or Deployment workloads, when that AuthProxyWorkload is updated, the operator
will add or modify an annotation on the PodTemplateSpec of that workload, causing k8s to
replace the workload's pods following the workload's rollout strategy, thus applying the
AuthProxyWorkload's configuration change.
Related to #187.
The code for this feature will be split across a few PRs for clarity. These are the first 4:
AutomaticRolloutEnabledfield to the AuthProxyWorkload resource.