Skip to content

Conversation

embik
Copy link
Member

@embik embik commented Jul 14, 2025

Summary

This PR implements the API changes we wanted to get into v1alpha2 before we cut the release solidifying the API version. It's been mainly discussed on Slack: https://kubernetes.slack.com/archives/C021U8WSAFK/p1749552577773639. I don't think a strong consensus has been reached but the general direction is what this PR proposes.

It removes the all and resourceSelector fields from the PermissionClaim type (i.e. remove the object selector configuration from the APIExport on the service provider side). It instead adds a selector field in AcceptablePermissionClaim (the wrapper type used for permission claims in APIBindings) which allows the API consumer to scope access of an API provider to a specific resource.

Conversions have been added so that if a permission claim in an APIBinding had all: true, it would automatically translate into selector.matchAll: true (and back). To allow API roundtripping without loss of information, permission claims are now stored in an annotation when converting from v1alpha1 to v1alpha2, so that resourceSelector can be restored upon converting back to v1alpha1.

A few more things this PR does:

  • Update the usage of APIExport and APIBindings across the code base.
  • Split conversion tests in v1alpha2 package into two files.
  • Rename PermissionClaim.Equal to PermissionClaim.EqualGRI. Equal is used by cmp to compare objects, so (acceptable) permission claims were only compared partially, which shadowed some bugs in my code early on.
  • Switch compared objects in conversion tests so that the diff output was more readable.

What Type of PR Is This?

/kind cleanup
/kind api-change

Related Issue(s)

Fixes #3456

Release Notes

NONE

@kcp-ci-bot kcp-ci-bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesn't merit a release note. dco-signoff: yes Indicates the PR's author has signed the DCO. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API labels Jul 14, 2025
@kcp-ci-bot
Copy link
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@kcp-ci-bot kcp-ci-bot added area/cli Issues or PRs related to CLI changes size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jul 14, 2025
@embik embik force-pushed the permission-claims-v1alpha2 branch from c63a31f to 17cf504 Compare July 15, 2025 11:41
@embik embik marked this pull request as ready for review July 15, 2025 11:56
@kcp-ci-bot kcp-ci-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 15, 2025
@embik embik force-pushed the permission-claims-v1alpha2 branch from 17cf504 to 1f528c8 Compare July 15, 2025 12:07
@embik
Copy link
Member Author

embik commented Jul 15, 2025

/hold

Since I want to discuss this PR with @xmudrii.

@kcp-ci-bot kcp-ci-bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 15, 2025
@embik embik force-pushed the permission-claims-v1alpha2 branch from 08aff20 to 6e05872 Compare July 15, 2025 15:11
@embik
Copy link
Member Author

embik commented Jul 15, 2025

/retest

…ding

On-behalf-of: SAP <marvin.beckers@sap.com>
Signed-off-by: Marvin Beckers <marvin@kubermatic.com>
@embik embik force-pushed the permission-claims-v1alpha2 branch from 6e05872 to f4fc17b Compare July 18, 2025 15:48
embik added 4 commits July 21, 2025 11:43
On-behalf-of: SAP <marvin.beckers@sap.com>
Signed-off-by: Marvin Beckers <marvin@kubermatic.com>
On-behalf-of: SAP <marvin.beckers@sap.com>
Signed-off-by: Marvin Beckers <marvin@kubermatic.com>
Signed-off-by: Marvin Beckers <marvin@kubermatic.com>
Signed-off-by: Marvin Beckers <marvin@kubermatic.com>
@embik embik force-pushed the permission-claims-v1alpha2 branch from f4fc17b to e35699e Compare July 21, 2025 09:45
Comment on lines +119 to +123
v2obj := v2.(*APIExport)
delete(v2obj.Annotations, PermissionClaimsV1Alpha1Annotation)
if len(v2obj.Annotations) == 0 {
v2obj.Annotations = nil
}
Copy link
Member

Choose a reason for hiding this comment

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

This is fine, but we should have a quick test to make sure the behavior around this annotation is correct.

@kcp-ci-bot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 083c7f231252d207ecee3f1cdf903dfcec7ebed2

@mjudeikis
Copy link
Contributor

/hold

I think this is wrong. This moves permission claim responsibility to APIBinding from APIExport. This means that now you can have a need to check " accepted claims and state of them" on each binding. This will put big operational strain on the provider. Meaning on each reconcile loop provider needs to check what is the state of APIBinding and adjust reconciler for this. If user says 'selector=label=foo' provider will need to inject this.

@mjudeikis
Copy link
Contributor

/hold cancel
Plan is to mutate on provider side so should be ok there,

@kcp-ci-bot kcp-ci-bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 23, 2025
embik added 2 commits July 24, 2025 08:54
On-behalf-of: SAP <marvin.beckers@sap.com>
Signed-off-by: Marvin Beckers <marvin@kubermatic.com>
On-behalf-of: SAP <marvin.beckers@sap.com>
Signed-off-by: Marvin Beckers <marvin@kubermatic.com>
@kcp-ci-bot kcp-ci-bot removed the lgtm Indicates that a PR is ready to be merged. label Jul 24, 2025
@kcp-ci-bot kcp-ci-bot requested a review from xmudrii July 24, 2025 11:18
@embik
Copy link
Member Author

embik commented Jul 24, 2025

/retest

@embik
Copy link
Member Author

embik commented Jul 24, 2025

/retest

Known flake: #3444

@xrstf
Copy link
Contributor

xrstf commented Jul 24, 2025

/approve

@kcp-ci-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: xmudrii, xrstf

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

@kcp-ci-bot kcp-ci-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 24, 2025
@mjudeikis
Copy link
Contributor

/lgtm

@kcp-ci-bot kcp-ci-bot added the lgtm Indicates that a PR is ready to be merged. label Jul 24, 2025
@kcp-ci-bot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 3b2c2de7032b7d7600be6f7f2c70694e46d26128

@kcp-ci-bot kcp-ci-bot merged commit 3f9ad25 into kcp-dev:main Jul 24, 2025
14 checks passed
@embik embik deleted the permission-claims-v1alpha2 branch July 24, 2025 15:17
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. area/cli Issues or PRs related to CLI changes dco-signoff: yes Indicates the PR's author has signed the DCO. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm Indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

api: Clean up the PermissionClaims API in v1alpha2
6 participants