-
Notifications
You must be signed in to change notification settings - Fork 4
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
Implementing promotion algorithm defined in level-triggered architecture rfc #203
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.
A small simplification suggestion, but overall looks good to me. For the simplifications, obviously one of them as they conflict with each other.
I don't know if it's important to check first env separately (like you have other plans in the future that would be easier to have it as a separate check.
return ctrl.Result{}, nil | ||
} | ||
|
||
for i := 1; i < len(pipeline.Spec.Environments); i++ { |
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 think we can use a simple range
here, I don't see i
is use anyone where.
for _, env := range pipeline.Spec.Environments[1:] {
// ...
}
@@ -182,9 +185,74 @@ func (r *PipelineReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c | |||
pipeline.GetNamespace(), pipeline.GetName(), | |||
) | |||
|
|||
firstEnv := pipeline.Spec.Environments[0] | |||
|
|||
ok, latestRevision := checkAllTargetsHaveSameRevision(pipeline.Status.Environments[firstEnv.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.
If latestRevision
is set to empty string, we can merge this into the loop below and the check would be something like:
ok, revision := checkAllTargetsHaveSameRevision(pipeline.Status.Environments[env.Name])
if !ok {
// not all targets have the same revision, so we can't proceed
return ctrl.Result{}, nil
}
if latestRevision == "" {
latestRevision = revision
continue
}
if revision != latestRevision {
// the same as you have now.
}
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.
yep, that would work, thanks
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.
👍 for keeping this low impact (it doesn't splat across lots of files) and pretty accurate. I think the definition for when to trigger a promotion needs another iteration -- see my comment on controller.go#L199. If you can demonstrate that working as described, with tests (see comment on controller_test.go), we're there.
It's worth putting in a guard against nil pointer deference, too. The other comment, on checkAllTargets....()
, is just commentary -- do whatever works :-)
That's fine, making promotion actions work reliably is the subject of #197. |
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 following up on those previous comments. The way you've structured the algorithm, with the checkAll, checkAny, etc., makes it clear what's happening. Should it break if it successfully calls promote?
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.
All of my changes / comments have been addressed, thanks @luizbafilho. I think it's worth spending no more than an hour tidying, squashing fixups and making sure the git commits have good messages, before merging. This is a bit big to be one squashed merge.
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.
lgtm
c47aa79
to
26eb06a
Compare
Implements the algorithm defined in level-triggered architecture rfc.
Notes:
github.com/golang/mock
withgo.uber.org/mock
since the former is now unmaintained.Closes #195