Skip to content
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 workspace paths as annotations to synced objects #15

Merged
merged 6 commits into from
Feb 3, 2025

Conversation

xrstf
Copy link
Contributor

@xrstf xrstf commented Jan 31, 2025

Summary

This PR adds a new option to PublishedResources: enableWorkspacePaths. When set to true, the syncer will put the kcp workspace path as an additional annotation on the synced objects.

Related issue(s)

Fixes #11

Release Notes

Add `spec.enableWorkspacePaths` to PublishedResources to enable storing the kcp workspace path (e.g. "root:myorg:team1") as an annotation on the synced objects in the service cluster.

@kcp-ci-bot kcp-ci-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. dco-signoff: yes Indicates the PR's author has signed the DCO. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jan 31, 2025
@xrstf xrstf requested a review from embik January 31, 2025 15:09
Copy link
Member

@embik embik left a comment

Choose a reason for hiding this comment

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

Some questions I'm wondering about.

Comment on lines 171 to 172
path := lc.Annotations[kcpcore.LogicalClusterPathAnnotationKey]
syncContext = syncContext.WithClusterPath(logicalcluster.NewPath(path))
Copy link
Member

Choose a reason for hiding this comment

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

Should we handle the case that this annotation is empty and throw an error? Is this a valid or invalid scenario?

Comment on lines +138 to +140
if err := kcpdevcorev1alpha1.AddToScheme(scheme); err != nil {
return nil, fmt.Errorf("failed to register scheme %s: %w", kcpdevcorev1alpha1.SchemeGroupVersion, err)
}
Copy link
Member

Choose a reason for hiding this comment

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

Remind me, does adding the scheme require it to be available in the endpoint? Will this fail on setups that don't enable this optional flag?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To my knowledge, this simply prepares the local client to work with types from the given scheme. This does not change anything about the wire protocol between us and the apiserver. The client will not suddenly do an API discovery and fail if the type doesn't exist.

// path. This is optional because it requires additional requests to kcp and
// should only be used if the cluster path is of interest on the
// service cluster side.
EnableClusterPaths bool `json:"enableClusterPaths,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick q: Should we be talking about "cluster paths" or "workspace paths" here? Because logical clusters don't really have paths, the path mapping happens through workspaces.

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'm all yours regarding naming this flag. Within the codebase, I kinda liked the duality of clusterName and clusterPath, both variables have the same length and same prefix and just mhmhmhmhmhmhm chef's kiss, ya know?

Copy link
Member

Choose a reason for hiding this comment

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

Let's go with workspace path please.

@xrstf xrstf changed the title ✨ Add cluster paths as annotations to synced objects ✨ Add workspace paths as annotations to synced objects Feb 3, 2025
Copy link
Member

@embik embik left a comment

Choose a reason for hiding this comment

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

/approve

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

LGTM label has been added.

Git tree hash: 081d020ddc01587c0b265b2c1d80a32f739f3b0e

@kcp-ci-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: embik

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 Feb 3, 2025
@kcp-ci-bot kcp-ci-bot merged commit 997725a into main Feb 3, 2025
12 checks passed
@kcp-ci-bot kcp-ci-bot deleted the add-cluster-paths branch February 3, 2025 14:28
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. dco-signoff: yes Indicates the PR's author has signed the DCO. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. 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.

feature: cluster path labels on synced objects
3 participants