Skip to content

Conversation

@kwiesmueller
Copy link
Member

Address the Status Wiping Issue for Server-Side Apply reported in kubernetes/kubernetes#75564

/sig api-machinery
/wg apply
/cc @apelisse @jennybuckley

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. wg/apply cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/kep Categorizes KEP tracking issues and PRs modifying the KEP directory size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 30, 2019
@kwiesmueller
Copy link
Member Author

@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.
Especially where the code should be in the end and how to make it available to fieldManager is on my mind.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 12, 2019
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Oct 10, 2019
@kwiesmueller
Copy link
Member Author

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Dec 10, 2019
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
Copy link
Member Author

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.

Copy link
Contributor

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

Copy link
Member Author

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.

Copy link
Contributor

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


if !diff.IsSame() {
// TODO: define good error message
return nil, nil, fmt.Errorf("apply contained fields a user should not change:\n%s", diff)
Copy link
Member Author

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"),
Copy link
Contributor

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

Copy link
Member Author

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.

Copy link
Contributor

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

Copy link
Member Author

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

Copy link
Member Author

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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider kloging the error

@kwiesmueller kwiesmueller changed the title [WIP] add status wiping section to apply kep add status wiping section to apply kep Jan 9, 2020
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 9, 2020
@kwiesmueller
Copy link
Member Author

@apelisse do you think this is good to go?

@apelisse
Copy link
Member

apelisse commented Jan 9, 2020

I think that's correct, thanks
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 9, 2020

(TODO: update this section with current design)

What are the caveats to the implementation?
Copy link
Member

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
Copy link
Member

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?

@apelisse
Copy link
Member

apelisse commented Jan 9, 2020

/assign @lavalamp
for approval

@lavalamp
Copy link
Contributor

lavalamp commented Jan 10, 2020

/lgtm
/approve

I think we can work out the exact names in the code change PRs and come back and update the KEP after that.

@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/kep Categorizes KEP tracking issues and PRs modifying the KEP directory lgtm "Looks good to me", indicates that a PR is ready to be merged. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants