-
Notifications
You must be signed in to change notification settings - Fork 1.6k
add status wiping section to apply kep #1123
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
add status wiping section to apply kep #1123
Conversation
|
@apelisse I started with the section. Not sure about the interface (or mostly where it should be). I spent some time trying to verify how this could work out, but haven't got a finished path yet. Happy for a second look. |
|
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
|
/remove-lifecycle stale |
e286092 to
012406c
Compare
| type ResetFieldsProvider interface { | ||
| // ResetFieldsFor returns a set of fields for the provided version that get reset before persisting the object. | ||
| // If no fieldset is defined for a version, nil is returned. | ||
| ResetFieldsFor(version string) *fieldpath.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.
The name ResetFieldsFor may not be ideal. Reset could als be read as action, which it is not in this case.
Haven't found a better name yet, open for suggestions.
WipedFields did not match, as fields don't really get wiped but some of them (like generation) just get modified.
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 naming them method something like ResetList or FieldResetList could be a better name based on my understanding that the function returns the fields that will be reset (please correct me if I am wrong)
Alternatively you could name it along the lines of ResetDryRun since DryRun usually means it does not perform any actions but returns usable data
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.
Not sure about ResetList as it might be misunderstood the same way it currently could.
Maybe it's just me, but as mentioned in my comment to me I could understand people reading ResetAnything and think "oh, it resets things".
English could use "Resetted" :D
DryRun is also not really what it does, as a dry run indicates a run, of the action. This doesn't run anything, just provide information to run.
Also DryRun is used in other areas and I wouldn't want to mix them up.
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.
yeah that makes sense. I was just pitching ideas. I think the name you gave it is good enough
keps/sig-api-machinery/0006-apply.md
Outdated
|
|
||
| if !diff.IsSame() { | ||
| // TODO: define good error message | ||
| return nil, nil, fmt.Errorf("apply contained fields a user should not change:\n%s", diff) |
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.
The error should probably be an api error? Like a conflict.
|
|
||
| var resetFieldsByVersion = map[string]*fieldpath.Set{ | ||
| "v1": fieldpath.NewSet( | ||
| fieldpath.MakePathOrDie("status"), |
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.
How does this method return an error? Maybe you should use fieldpath.MakePath instead since fieldpath.MakePathOrDie panics instead of returning an error
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.
They panic, yes.
This is done when starting the apiserver and if it panics here it indicates a developer error. It's the same we do when building the fieldset we currently wipe from managed fields.
If I remember correctly the only way this could fail is on an invalid symbol on the path. Anyways, it should be nothing that can happen at random but only when the developer made a mistake and it immediately surfaces in every test.
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.
That sounds good to me.
Im still curious where the error is returned. Your use of resetFieldsByVersion has an ok parameter
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.
resetFieldsByVersion is a map.
In golang, if you lookup a key inside a map and that key does not exist you get a zero value.
The additional return (ok) provides a boolean indicating the key exists or not.
https://blog.golang.org/go-maps-in-action
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.
But thanks for pointing out, before I rebased, this was not returning a pointer but now it might not be required anymore to do this and I could directly return the value.
| // If no fieldset is defined for a version, nil is returned. | ||
| func (podStrategy) ResetFieldsFor(version string) *fieldpath.Set { | ||
| set, ok := resetFieldsByVersion[version] | ||
| if !ok { |
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.
consider kloging the error
|
@apelisse do you think this is good to go? |
|
I think that's correct, thanks |
|
|
||
| (TODO: update this section with current design) | ||
|
|
||
| What are the caveats to the implementation? |
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 suspect we could entirely remove that section, but probably in a different PR.
| type ResetFieldsProvider interface { | ||
| // ResetFieldsFor returns a set of fields for the provided version that get reset before persisting the object. | ||
| // If no fieldset is defined for a version, nil is returned. | ||
| ResetFieldsFor(version string) *fieldpath.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.
version string is not super explicit, is it APIVersion?
|
/assign @lavalamp |
|
/lgtm I think we can work out the exact names in the code change PRs and come back and update the KEP after that. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: apelisse, kwiesmueller, lavalamp 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 |
Address the Status Wiping Issue for Server-Side Apply reported in kubernetes/kubernetes#75564
/sig api-machinery
/wg apply
/cc @apelisse @jennybuckley