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

Labels sync targets with the SyncTargetKey for reverse lookup #1672

Merged
merged 4 commits into from
Aug 4, 2022

Conversation

jmprusi
Copy link
Member

@jmprusi jmprusi commented Aug 3, 2022

This PR adds a new label to SyncTarget resources internal.workload.kcp.dev/key this label contains the SyncTargetKey, a hash generated with the ToSyncTargetKey() helper func.

  • Generalises the virtualworkspaceURLs controller, now is used for interacting with synctargets in a more generic way.
  • Exposes the SyncTargetKey of a SyncTarget in the kubectl view:
> kubectl get synctargets -o wide
NAME       LOCATION   READY   SYNCED API RESOURCES   KEY                                      AGE
cluster1   cluster1   False                          adVHlRJKckuJCsdmmK0eWIfPom0mHOqz6wVYvC   19s

@openshift-ci openshift-ci bot added the kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API label Aug 3, 2022
@jmprusi jmprusi force-pushed the jmprusi/label-synctargets branch from 1163243 to ebdecd3 Compare August 3, 2022 15:15
@jmprusi jmprusi force-pushed the jmprusi/label-synctargets branch from ebdecd3 to 9800241 Compare August 3, 2022 15:43
@jmprusi jmprusi requested a review from sttts August 3, 2022 16:46
klog.Errorf("failed to patch sync target: %v", err)
return err
}
klog.V(4).InfoS("patched synctarget", "name", newSyncTarget.Name, "workspace", logicalcluster.From(newSyncTarget))
Copy link
Member

Choose a reason for hiding this comment

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

nit: would do that before the patch and include the actual patch bytes, and V(2).

Copy link
Member Author

Choose a reason for hiding this comment

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

done

klog.Errorf("failed to patch sync target status: %v", err)
return err
}
klog.V(4).InfoS("patched synctarget status", "name", newSyncTarget.Name, "workspace", logicalcluster.From(newSyncTarget))
Copy link
Member

Choose a reason for hiding this comment

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

same

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@@ -34,6 +34,13 @@ import (
func (c *Controller) reconcile(syncTarget *workloadv1alpha1.SyncTarget, workspaceShards []*v1alpha1.ClusterWorkspaceShard) (*workloadv1alpha1.SyncTarget, error) {
syncTargetCopy := syncTarget.DeepCopy()

labels := syncTargetCopy.GetLabels()
Copy link
Member

Choose a reason for hiding this comment

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

you can edit syncTargetCopy.Labels directly. No need for Get/SetLabel.

Copy link
Member Author

Choose a reason for hiding this comment

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

that panics.

Copy link
Member

Choose a reason for hiding this comment

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

no. Of course you have to create the map if it is nil. But no need for calling setter and getter.

@jmprusi jmprusi force-pushed the jmprusi/label-synctargets branch from 9800241 to aab6669 Compare August 3, 2022 17:03
@jmprusi jmprusi force-pushed the jmprusi/label-synctargets branch from aab6669 to 9effac7 Compare August 3, 2022 23:28
@sttts
Copy link
Member

sttts commented Aug 4, 2022

/lgtm
/approve
/retest

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Aug 4, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Aug 4, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sttts

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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 4, 2022
@openshift-ci openshift-ci bot merged commit 83d048d into kcp-dev:main Aug 4, 2022
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. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants