Skip to content

Accept filter instead of exclude mask for ignored fields #265

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

Merged
merged 7 commits into from
Nov 1, 2024

Conversation

jpbetz
Copy link
Contributor

@jpbetz jpbetz commented Oct 29, 2024

/sig api-machinery

kubernetes/kubernetes#128266 needs a way of expressing reset fields that can express "exclude all fields except for the container resource fields modifiable via /resize".

This provides a way to pass a filter instead of a field exclusion set.

@k8s-ci-robot k8s-ci-robot added the sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. label Oct 29, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jpbetz

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 added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Oct 29, 2024
@k8s-ci-robot k8s-ci-robot requested a review from apelisse October 29, 2024 16:07
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 29, 2024
@jpbetz jpbetz force-pushed the reset-filter branch 7 times, most recently from 8f46de6 to d45b3ed Compare October 30, 2024 03:51
@AnishShah
Copy link

/lgtm

@k8s-ci-robot
Copy link
Contributor

@AnishShah: changing LGTM is restricted to collaborators

In response to this:

/lgtm

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@jpbetz
Copy link
Contributor Author

jpbetz commented Oct 30, 2024

/assign @thockin
Do you have reviewer permissions in this repo? @AnishShah doesn't have /lgtm in this realm.

@thockin
Copy link
Contributor

thockin commented Oct 30, 2024

I don't think I do. I am trying to understand it and figure out how much I want to complain about the structure of it vs. accepting it as-is :)

@jpbetz
Copy link
Contributor Author

jpbetz commented Oct 30, 2024

I don't think I do. I am trying to understand it and figure out how much I want to complain about the structure of it vs. accepting it as-is :)

I don't mean to rush you. I'm thinking purely about the logistics of how to get a PR in this repo merged when it is ready. I'll hold to merge on your review.

Copy link
Contributor

@thockin thockin left a comment

Choose a reason for hiding this comment

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

I wrote and then deleted a dozen comments, as I understood it better on each reading. I did not review all the set logic, but looking at it for the ergonomics of defining patterns.

@k8s-ci-robot k8s-ci-robot removed the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 31, 2024
@k8s-ci-robot k8s-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Oct 31, 2024
@jpbetz
Copy link
Contributor Author

jpbetz commented Oct 31, 2024

@thockin @AnishShah feedback applied.

@jpbetz jpbetz force-pushed the reset-filter branch 5 times, most recently from 673670f to 4fa0d92 Compare October 31, 2024 17:02
Copy link
Contributor

@thockin thockin left a comment

Choose a reason for hiding this comment

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

LGTM, but I am not approver here. I understand the design, though.

For posterity, Joe and I discussed this in real time. He tells me it's fine and does not change SSA behavior:

Given input (indent for clarity only), which has exactly two "leaf" fields:

{
    "foo"                         /* struct */,
        "foo.bar"                 /* struct */,
            "foo.bar.bat"         /* struct */,
                "foo.bar.bat.qux" /* LEAF string */,
        "foo.zrb",                /* LEAF string */
}

Consider a strategy that has GetResetFields() => "foo.bar.bat". That would produce:

{
    "foo", "foo.bar", "foo.zrb"
    // note: "foo.bar.bat" and its children are culled
    // note: "foo.bar" remains, though it is empty
}

If we inverted it to an Include("foo.zrb"), that would produce:

{
    "foo", "foo.zrb"
    // note: only path elements leading to "foo.zrb" remain
}

In particular, note that "foo.bar" is absent. We didn't prune it from the old case, even though it is "empty". It didn't match anything in the new case.

In neither case did we match the "leaf" fields under "foo.bar.bat/*" (as expected).

Copy link

@cici37 cici37 left a comment

Choose a reason for hiding this comment

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

/lgtm
/hold in case others wanna take a look.

@@ -17,6 +17,8 @@ limitations under the License.
package fieldpath

import (
"fmt"
"sigs.k8s.io/structured-merge-diff/v4/value"
Copy link

Choose a reason for hiding this comment

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

nit: import sorting

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 31, 2024
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 31, 2024
@jpbetz
Copy link
Contributor Author

jpbetz commented Nov 1, 2024

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 1, 2024
@k8s-ci-robot k8s-ci-robot merged commit ccf7a06 into kubernetes-sigs:master Nov 1, 2024
5 checks passed
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. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants