-
Notifications
You must be signed in to change notification settings - Fork 70
add KEP 238, to add controller revision #261
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
Conversation
@kerthcet PTAL as well |
the value of the template hash generated by the LWS object, with the template hash that the leader pod | ||
hash. Because the leader pod spec is determined by the statefulset controller, there is a guarantee that | ||
it will always have the right pod spec. So, if the template hashes don't match, it means that the leader pod was created | ||
using the old pod spec, meaning the old worker pod spec needs to be used. |
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.
what if there was another update that caused this difference? or is that not possible (meaning do we block updates if an update is currently in progress)?
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.
We don't block updates if an update is in progress.
It is a good point, there's a scenario where another update causes the difference. If an update is started from 1 to 2, and then is updated to 3, if the update to 3 happens when the leader pod has been updated to 2, but the worker pod hasn't, then the worker pod will be created with 1, causing the discrepancy again.
To address this, we could do something like this
func constructWorkerStatefulSetApplyConfiguration(currentRevision) {
if updatedTemplateHash != leaderPod.Labels[templateHash] {
originalLws, err := ApplyRevision(&lws, currentRevision)
podTemplateSpec = *originalLws.WorkerTemplate.DeepCopy()
if !TemplateHashMatches(leaderPod.Labels[templateHash], originalLws) {
originalLws, err := GetRevision(leaderPod.Labels[templateHash])
}
}
}
// iterates through the list of revisions and returns the lws object with the matching template hash
func GetRevision(string templateHash) {
revisions := ListRevisions()
for _, revision := range revisions {
lws, err := ApplyRevision(&lws, revision)
if lws.Labels[templateHash] == templateHash {
return lws
}
}
}
Wdyt?
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.
sounds good, so we try to find the correct revision by finding the one with a matching hash, makes sense.
} | ||
``` | ||
|
||
Once the update has been determined to be done, `currentRevision` will be set to be the value of `updateRevision` |
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.
can you clarify when updateRevision gets created/set?
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.
updateRevision
gets created when there isn't an existing revision that has already been created. So the pseudocode is
func GetLeaderWorkerSetRevisions(ctx, r.Client, lws) {
revisions := ListControllerRevisions()
updateRevision := NewRevision(lws)
equalRevisions := FindEqualRevisions(revisions, updateRevision)
if len(equalRevisions) == 0 {
CreateControllerRevision(lws, updateRevision)
}else if equalRevision(revisions[len(revisions) - 1], equalRevisions[equalCount-1]) {
// in this case, updateRevision is the same as currentRevision, so no update is occuring
updateRevision = equalRevisions[equalCount-1]
}
}
CurrentRevision doesn't get updated/changed unless lws.CurrentRevision
is nil. So during an update, updateRevision
and currentRevision
will be different until the update is complete.
/retest |
// LeaderWorkerSetStatus defines the observed state of LeaderWorkerSet | ||
type LeaderWorkerSetStatus struct { | ||
// currentRevision, if not empty, indicates the version of lws | ||
// used to generate the worker pods in sequence [0,currentReplicas) |
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.
can you define what is currentReplicas, replicas and updatedReplicas?
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 simplify this as follows:
- Create a ControllerRevision each time we set the leader sts with a different template hash (here);
- In the pod reconciler, we simply lookup the revision with a matching template hash
- Truncate history each time an update is done, leaving only the controllerRevision with a matching hash of the current template
With this, no need for maintain anything in status.
Makes sense, I'll update the KEP with those changes, and add changes to fix #281 |
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.
Discussed offline:
- Nothing will be tracked in lws status
- We will use the template hash as a label on each new controller revision that gets created. This key is stored as a label on the leaders sts.
On each lws reconcile:
- Use the hash key on the leader sts to lookup the latest controller revision
- If one exists, compare the existing controller revision with the current lws spec:
- If different, trigger an update
- If the same, don't trigger an update
- If no one exists, create one and don't trigger an update
- Each time an update is done, trim the controller revisions and only keep the one with the same hash key as the current leaders sts
One each leader pod reconcile:
- Use the hash key to lookup the controller revision
- Use the worker template in the controller revision to create workers sts
func templateUpdated(sts, lws) bool { | ||
controllerRevision := GetLeaderWorkerSetRevisionFromTemplateHash(sts.Labels[templateHash]) | ||
baselineLws:= controllerutils.ApplyRevision(lws, controllerRevision) | ||
return !utils.EqualLeaderWorkerTemplates(baselineLws, lws) |
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.
we also need to check some parameters of the LWS spec itself, specifically the subdomain policy
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.
Yes, equalLeaderWorkerTemplates
would check both lws.spec.leaderWorkerTemplate
and checking subdomainPolicy
, also treating networkConfig == nil
as subdomainShared
just like it is done for templateHash
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ahg-g, Edwinhr716 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What type of PR is this?
/kind documentation
What this PR does / why we need it
Kep for the fix for #238 #240 #281
Which issue(s) this PR fixes
Fixes #
Special notes for your reviewer
Does this PR introduce a user-facing change?