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

SyncTarget Uniqueness #1600

Merged

Conversation

jmprusi
Copy link
Member

@jmprusi jmprusi commented Jul 22, 2022

This PR improves the uniqueness of the labels/annotations/finalizers that rely currently on the SyncTarget Name by replacing it with a hash generated from the SyncTarget Name + SyncTarget workspace.

  • Introduces a new helper in workloadv1alpha1: ToSyncTargetKey(syncTargetName, syncTargetWorkspace)
  • Replaces all usages of SyncTarget Name in labels/annotations/finalizers

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 22, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jul 22, 2022

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

@jmprusi jmprusi force-pushed the jmprusi/uniqueness-synctarget branch 3 times, most recently from 75c54f7 to 70acfbc Compare July 25, 2022 16:58
@jmprusi
Copy link
Member Author

jmprusi commented Jul 25, 2022

/test e2e

@jmprusi
Copy link
Member Author

jmprusi commented Jul 25, 2022

/retest

@jmprusi jmprusi force-pushed the jmprusi/uniqueness-synctarget branch from 70acfbc to c9aeb5c Compare July 26, 2022 08:50
@jmprusi
Copy link
Member Author

jmprusi commented Jul 26, 2022

/test all

@jmprusi jmprusi force-pushed the jmprusi/uniqueness-synctarget branch 2 times, most recently from a49af13 to ab779a3 Compare July 27, 2022 10:21
@jmprusi
Copy link
Member Author

jmprusi commented Jul 27, 2022

/retest

@kcp-dev kcp-dev deleted a comment from openshift-ci bot Jul 27, 2022
@kcp-dev kcp-dev deleted a comment from openshift-ci bot Jul 27, 2022
@jmprusi
Copy link
Member Author

jmprusi commented Jul 27, 2022

/test all

@jmprusi jmprusi changed the title SyncTarget Uniqueness [WIP] SyncTarget Uniqueness Jul 27, 2022
@jmprusi jmprusi marked this pull request as ready for review July 27, 2022 13:51
@openshift-ci openshift-ci bot requested review from ncdc and sttts July 27, 2022 13:52
@jmprusi
Copy link
Member Author

jmprusi commented Jul 27, 2022

/retest

@jmprusi jmprusi force-pushed the jmprusi/uniqueness-synctarget branch 2 times, most recently from a9173b5 to f58643d Compare July 28, 2022 19:59
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 28, 2022
@jmprusi jmprusi force-pushed the jmprusi/uniqueness-synctarget branch from f58643d to 54be0f4 Compare July 29, 2022 10:15
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 29, 2022
@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 Jul 29, 2022
@jmprusi jmprusi force-pushed the jmprusi/uniqueness-synctarget branch 2 times, most recently from 3d3d72a to a6150fe Compare July 29, 2022 11:01
@@ -48,7 +50,7 @@ const (
byWorkspace = ControllerName + "-byWorkspace" // will go away with scoping
)

type CreateAPIDefinitionFunc func(syncTargetName string, apiResourceSchema *apisv1alpha1.APIResourceSchema, version string, identityHash string) (apidefinition.APIDefinition, error)
type CreateAPIDefinitionFunc func(syncTargetName string, syncTargetWorkspace logicalcluster.Name, apiResourceSchema *apisv1alpha1.APIResourceSchema, version string, identityHash string) (apidefinition.APIDefinition, error)
Copy link
Member

Choose a reason for hiding this comment

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

switch order, cluster first

@@ -599,7 +599,7 @@ func (sf SyncerFixture) Start(t *testing.T) *StartedSyncerFixture {
// Not a kcp-synced namespace
continue
}
if locator.Workspace.String() != syncerConfig.SyncTargetWorkspace.String() {
if locator.SyncTarget.Workspace == syncerConfig.SyncTargetWorkspace.String() {
Copy link
Member

Choose a reason for hiding this comment

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

why does this only compare the workspace, not the name?

Copy link
Member

Choose a reason for hiding this comment

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

and why != => == ?

Copy link
Member

Choose a reason for hiding this comment

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

metav1.GetOptions{},
)
require.NoError(t, err)
syncTargetKey := workloadv1alpha1.ToSyncTargetKey(syncTarget.GetName(), logicalcluster.From(syncTarget))
Copy link
Member

Choose a reason for hiding this comment

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

why this change? Just take syncerFixture.SyncerConfig.SyncTargetName and syncerFixture.SyncerConfig.SyncTargetWorkspace ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I get the syncTarget for the UID (line 91) and then reuse the name/workspace here, but I can use the ones from fixture.

@@ -157,6 +157,7 @@ func TestPlacementUpdate(t *testing.T) {
},
}, metav1.CreateOptions{})
require.NoError(t, err)
syncTargetKey := workloadv1alpha1.ToSyncTargetKey(firstSyncTargetName, syncerFixture.SyncerConfig.SyncTargetWorkspace)
Copy link
Member

Choose a reason for hiding this comment

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

if there is a second synctarget around, call this firstSyncTargetKey

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

_, err := downstreamKubeClient.AppsV1().Deployments(downstreamNamespaceName).Get(ctx, upstreamDeployment.Name, metav1.GetOptions{})
if apierrors.IsNotFound(err) {
return true
}
require.NoError(t, err)
return false
}, 5*time.Second, time.Second, "downstream Deployment got deleted or there was an error", downstreamNamespaceName, upstreamDeployment.Name)
}, 5*time.Second, time.Second, "downstream Deployment %s/%s got deleted or there was an error", downstreamNamespaceName, upstreamDeployment.Name)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
}, 5*time.Second, time.Second, "downstream Deployment %s/%s got deleted or there was an error", downstreamNamespaceName, upstreamDeployment.Name)
}, 5*time.Second, time.Second, "downstream Deployment %s|%s got deleted or there was an error", downstreamNamespaceName, upstreamDeployment.Name)

@jmprusi jmprusi force-pushed the jmprusi/uniqueness-synctarget branch 2 times, most recently from 283e706 to 3c7c6ef Compare August 1, 2022 15:31
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 1, 2022
@jmprusi jmprusi force-pushed the jmprusi/uniqueness-synctarget branch from 3c7c6ef to 39dafd5 Compare August 1, 2022 15:41
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 1, 2022
@jmprusi jmprusi force-pushed the jmprusi/uniqueness-synctarget branch 2 times, most recently from 2435b2f to 1f302cd Compare August 1, 2022 17:43
@jmprusi
Copy link
Member Author

jmprusi commented Aug 1, 2022

/retest

@sttts sttts force-pushed the jmprusi/uniqueness-synctarget branch from 1f302cd to 02f26dc Compare August 1, 2022 21:00
@sttts
Copy link
Member

sttts commented Aug 1, 2022

Squashed.

/lgtm
/approve

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

openshift-ci bot commented Aug 1, 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 1, 2022
@sttts sttts force-pushed the jmprusi/uniqueness-synctarget branch from 02f26dc to fc38492 Compare August 1, 2022 21:01
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Aug 1, 2022
@sttts
Copy link
Member

sttts commented Aug 1, 2022

/lgtm

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

jmprusi commented Aug 1, 2022

/retest

@jmprusi
Copy link
Member Author

jmprusi commented Aug 1, 2022

/test e2e-multiple-runs

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.

3 participants