Skip to content

Commit

Permalink
Remove the remnants of checking for the namespace label.
Browse files Browse the repository at this point in the history
  • Loading branch information
metlos committed Oct 3, 2024
1 parent 1ade6a6 commit 3389b7d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 32 deletions.
6 changes: 2 additions & 4 deletions setup/users/create_users.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,11 @@ func getMemberClusterName(cl client.Client, hostOperatorNamespace, memberOperato
var memberCluster toolchainv1alpha1.ToolchainCluster
err := k8swait.Poll(configuration.DefaultRetryInterval, configuration.DefaultTimeout, func() (bool, error) {
clusters := &toolchainv1alpha1.ToolchainClusterList{}
if err := cl.List(context.TODO(), clusters, client.InNamespace(hostOperatorNamespace), client.MatchingLabels{
"namespace": memberOperatorNamespace,
}); err != nil {
if err := cl.List(context.TODO(), clusters, client.InNamespace(hostOperatorNamespace)); err != nil {
return false, err
}
for _, cluster := range clusters.Items {
if condition.IsTrue(cluster.Status.Conditions, toolchainv1alpha1.ConditionReady) {
if cluster.Status.OperatorNamespace == memberOperatorNamespace && condition.IsTrue(cluster.Status.Conditions, toolchainv1alpha1.ConditionReady) {
memberCluster = cluster
return true, nil
}
Expand Down
4 changes: 1 addition & 3 deletions setup/users/create_users_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,9 @@ func TestCreate(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{
Namespace: hostOperatorNamespace,
Name: "member-abcd",
Labels: map[string]string{
"namespace": memberOperatorNamespace,
},
},
Status: toolchainv1alpha1.ToolchainClusterStatus{
OperatorNamespace: memberOperatorNamespace,
Conditions: []toolchainv1alpha1.Condition{
{
Type: toolchainv1alpha1.ConditionReady,
Expand Down
18 changes: 0 additions & 18 deletions test/e2e/toolchaincluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ func verifyToolchainCluster(t *testing.T, await *wait.Awaitility, otherAwait *wa

toolchainCluster := newToolchainCluster(await.Namespace, name,
secretRef(secretCopy.Name),
owner(current.Labels["ownerClusterName"]),
namespace(current.Labels["namespace"]),
capacityExhausted, // make sure this cluster cannot be used in other e2e tests
)

Expand Down Expand Up @@ -115,8 +113,6 @@ func verifyToolchainCluster(t *testing.T, await *wait.Awaitility, otherAwait *wa

toolchainCluster := newToolchainCluster(await.Namespace, name,
secretRef(secretCopy.Name),
owner(current.Labels["ownerClusterName"]),
namespace(current.Labels["namespace"]),
capacityExhausted, // make sure this cluster cannot be used in other e2e tests
)

Expand Down Expand Up @@ -184,20 +180,6 @@ var capacityExhausted clusterOption = func(c *toolchainv1alpha1.ToolchainCluster
c.Labels["toolchain.dev.openshift.com/capacity-exhausted"] = strconv.FormatBool(true)
}

// Owner sets the 'ownerClusterName' label
func owner(name string) clusterOption {
return func(c *toolchainv1alpha1.ToolchainCluster) {
c.Labels["ownerClusterName"] = name
}
}

// Namespace sets the 'namespace' label
func namespace(name string) clusterOption {
return func(c *toolchainv1alpha1.ToolchainCluster) {
c.Labels["namespace"] = name
}
}

// SecretRef sets the SecretRef in the cluster's Spec
func secretRef(ref string) clusterOption {
return func(c *toolchainv1alpha1.ToolchainCluster) {
Expand Down
10 changes: 3 additions & 7 deletions testsupport/wait/awaitility.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,17 +172,15 @@ func (a *Awaitility) WaitForToolchainClusterWithCondition(t *testing.T, namespac
// and running in the given expected namespace. It also checks if the CR has the ClusterConditionType
func (a *Awaitility) GetToolchainCluster(t *testing.T, namespace string, cdtype toolchainv1alpha1.ConditionType) (toolchainv1alpha1.ToolchainCluster, bool, error) {
clusters := &toolchainv1alpha1.ToolchainClusterList{}
if err := a.Client.List(context.TODO(), clusters, client.InNamespace(a.Namespace), client.MatchingLabels{
"namespace": namespace,
}); err != nil {
if err := a.Client.List(context.TODO(), clusters, client.InNamespace(a.Namespace)); err != nil {
return toolchainv1alpha1.ToolchainCluster{}, false, err
}
if len(clusters.Items) == 0 {
t.Logf("no toolchaincluster resource with expected labels: namespace='%s'", namespace)
}
// assume there is zero or 1 match only
for _, cl := range clusters.Items {
if cd.IsTrue(cl.Status.Conditions, cdtype) {
if cl.Status.OperatorNamespace == namespace && cd.IsTrue(cl.Status.Conditions, cdtype) {
return cl, true, nil
}
}
Expand Down Expand Up @@ -559,9 +557,7 @@ func UntilToolchainClusterHasConditionFalseStatusAndReason(expected toolchainv1a
func UntilToolchainClusterHasOperatorNamespace(expectedNs string) ToolchainClusterWaitCriterion {
return ToolchainClusterWaitCriterion{
Match: func(toolchainCluster *toolchainv1alpha1.ToolchainCluster) bool {
// TODO: remove the check for the legacy label once both host and member operators are upgraded to the
// new version of the operator.
return toolchainCluster.Status.OperatorNamespace == expectedNs || toolchainCluster.Labels["namespace"] == expectedNs
return toolchainCluster.Status.OperatorNamespace == expectedNs
},
}
}
Expand Down

0 comments on commit 3389b7d

Please sign in to comment.