-
Notifications
You must be signed in to change notification settings - Fork 172
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
refactor(controller): rework annotation mechanics #1856
Conversation
✅ Deploy Preview for docs-kargo-akuity-io ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1856 +/- ##
==========================================
+ Coverage 46.13% 46.43% +0.30%
==========================================
Files 214 215 +1
Lines 13923 13965 +42
==========================================
+ Hits 6423 6485 +62
+ Misses 7214 7191 -23
- Partials 286 289 +3 ☔ View full report in Codecov by Sentry. |
f04ec70
to
6cd5013
Compare
127f248
to
319be30
Compare
Signed-off-by: Hidde Beydals <hidde@hhh.computer>
Signed-off-by: Hidde Beydals <hidde@hhh.computer>
Signed-off-by: Hidde Beydals <hidde@hhh.computer>
Signed-off-by: Hidde Beydals <hidde@hhh.computer>
Signed-off-by: Hidde Beydals <hidde@hhh.computer>
Signed-off-by: Hidde Beydals <hidde@hhh.computer>
Signed-off-by: Hidde Beydals <hidde@hhh.computer>
Signed-off-by: Hidde Beydals <hidde@hhh.computer>
Signed-off-by: Hidde Beydals <hidde@hhh.computer>
Signed-off-by: Hidde Beydals <hidde@hhh.computer>
Signed-off-by: Hidde Beydals <hidde@hhh.computer>
Signed-off-by: Hidde Beydals <hidde@hhh.computer>
Signed-off-by: Hidde Beydals <hidde@hhh.computer>
Signed-off-by: Hidde Beydals <hidde@hhh.computer>
70df291
to
08a17c8
Compare
Signed-off-by: Hidde Beydals <hidde@hhh.computer>
08a17c8
to
d5cd76e
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.
UI LGTM! The logic for evaluating if the stage is refreshing should be refactored into a shared utility function, but I won't block the PR for it - I can follow up with it.
Signed-off-by: Hidde Beydals <hidde@hhh.computer>
651d80f
to
6274e30
Compare
Before I merge, it would be great to have an approval from @devholic as well. Given I (carefully) reconstructed bits he has been eagerly working on, and I want to be sure I do not introduce any unforeseen side-effects. |
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.
Thanks for the awesome work! 🚀 LGTM
Signed-off-by: Hidde Beydals <hidde@hhh.computer>
Signed-off-by: Hidde Beydals <hidde@hhh.computer>
5ea95c7
to
e19b9dd
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.
UI LGTM
Related to: #1479
Also addresses a bit of: #1231 (tracking who aborted a verification request)
This pull request refactors the approach to working with annotations that express desires, such as "refresh this resource" or "abort this verification." It eliminates the need to delete an annotation once a request has been fulfilled, by introducing carefully scoped predicates and comparisons against the Status of a resource to determine if a request is new.
There are multiple advantages to this approach:
Outline of changes
kargo.akuity.io/refresh
Instead of deleting the annotation at the end of the reconciliation, the token value is mirrored to the
.status.lastHandledRefresh
field of the resource. This allows the initiator of the refresh request to wait until the value in the Status field matches the token of their request or equals the current annotation value.To enable a reconciler to detect new refresh requests, a
RefreshRequested
predicate is introduced. This predicate signals that a resource should be reconciled if the annotation is added or if the annotation value has changed compared to the previous annotation value.kargo.akuity/reverify
Instead of having two separate annotations to put in a request to reverify the current Freight of a Stage and to keep track of the actor who put in the request. The values have been unified into the
kargo.akuity/reverify
annotation which is now expected to contain a JSON object with all information with the following structure:To not create a burden for e.g.
kubectl
users, a Stage can still be annotated using a simple ID string value in which case the webhook will take care of transforming this into the expected JSON payload (including information about the actor).During reconciliation, the data from the annotation value is compared to the
.currentFreight.verficationHistory
to determine if a reverification should be performed. In addition, when it's determined that a verification attempt is due to a reverify request, the actor of this request is mirrored to the.verificationInfo.actor
field. When a Kubernetes Event is emitted for the verification process, the value of this field is used instead of annotation data to include metadata about the actor with the Event.To enable a reconciler to detect new reverify requests, a
ReverifyRequested
predicate is introduced. This predicate signals that a resource should be reconciled if the annotation is added or if the ID in the annotation payload has changed compared to the previous ID.kargo.akuity.io/abort
This annotation now relies on the same mechanics as introduced for
kargo.akuity/reverify
, and allows for tracking the actor which initiated the request.To enable a reconciler to detect new abort requests, an
AbortRequested
predicate is introduced. This predicate signals that a resource should be reconciled if the annotation is added or if the ID in the annotation payload has changed compared to the previous ID.Only small modifications were required to the reconciliation logic itself, as the abort request was already taken into account only when the verification process is still running and the value matches the ID of the current verification process. Since the former condition will be false as soon as the abort request is fulfilled, this minimized the changes to only mirroring the actor from the
VerificationRequest
to theVerificationInfo
in the Status.@devholic: specific commit of interest to you is 6cd5013.
@rbreeze, @rpelczar: I tried to make the frontend changes myself here... They are all related to the
kargo.akuity.io/refresh
annotation, and mainly involve waiting for the annotation value to equal the field in the Status – instead of the annotation being removed.