Skip to content

Conversation

@apelisse
Copy link
Contributor

@apelisse apelisse commented Feb 3, 2021

Fixes #171

This fixes a bug and slightly changes an existing behavior.

Struct that have a null value will now be owned, i.e.

struct:

will now be owned by whoever applies that (currently, these can't be owned, which means we may accidentally drop the empty struct).

Also, removing a struct will now remove all the items that are not owned by someone else in it (including things that are owned by an updater).

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Feb 3, 2021
@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 3, 2021
@apelisse
Copy link
Contributor Author

apelisse commented Feb 3, 2021

/assign @jpbetz @lavalamp

@jpbetz
Copy link
Contributor

jpbetz commented Feb 4, 2021

I just did a pass on the WG API Expression: Unsetting fields to make sure we're not contradicting anything we decided on there. I think we're OK.

@jpbetz
Copy link
Contributor

jpbetz commented Feb 4, 2021

Struct that have a null value will now be owned, i.e.

struct:

By "null" we really just mean "empty struct" here, right? In WG API Expression: Unsetting fields I remember that we were deliberately trying to avoid the distinction between struct: null and struct:.

@jpbetz
Copy link
Contributor

jpbetz commented Feb 4, 2021

Also, removing a struct will now remove all the items that are not owned by someone else in it (including things that are owned by an updater).

Can we say more about the motivation for this in the PR description? This seems to complicate how the ownership transfer mechanism of Server Side Apply behaves-- updater ownership is now handled differently. Or were we already handling it differently and I just wasn't aware?

fieldpath/set.go Outdated
}
}

// NestedSet returns a Set that contains all the fields in s, as well as
Copy link
Contributor

Choose a reason for hiding this comment

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

NestedSet is not a good name, I think the name should include something about ensuring all children are also members. RecursivelyCompletelyCoveredSet or something like that? EnsureAllChildrenAreMembers?

Copy link
Contributor

Choose a reason for hiding this comment

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

EnsureNodesAreMembers

mapOfMapsRecursive:
`,
Manager: "apply-one",
Object: ``,
Copy link
Contributor

Choose a reason for hiding this comment

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

hm I can see why you changed this test case but I think we need to know what the output is if clients change nothing?

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess my ask is, leave all the inputs the same and change the outputs in these tests. And copy the cases and modify them if you want to test different inputs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've made the change you requested. I understand that as a reviewer you want to see how the behavior changed, but I think the test is better the way it was written before.

v2.value = val
errs = append(errs, v2.toFieldSet()...)
if _, ok := t.FindField(key); !ok {
if val.IsNull() || (val.IsMap() && val.AsMap().Length() == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

zero length maps but not zero length lists? That's surprising?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, this is specific to struct fields with no values, it's not relevant for lists.

@apelisse apelisse force-pushed the fix-remove-structures branch from e373eba to e71bab7 Compare February 11, 2021 05:55
Object: typed.YAMLObject(`
struct:
name: a
complexField_%s: null
Copy link
Contributor

Choose a reason for hiding this comment

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

is this case still tested?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Joe had to write the test with the "dangling" struct only because of this bug that I'm fixing. This is the bug fix :-)

@lavalamp
Copy link
Contributor

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 11, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: apelisse, 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

@k8s-ci-robot k8s-ci-robot merged commit a4e00e9 into kubernetes-sigs:master Feb 11, 2021
This was referenced Mar 25, 2021
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. lgtm "Looks good to me", indicates that a PR is ready to be merged. 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.

Field deletion doesn't work well in SSA

4 participants