-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
🐛 When infrastructureRef is nil, set InfrastructureReadyCondition to true #10909
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -172,6 +172,50 @@ func TestClusterReconciler(t *testing.T) { | |
}, timeout).Should(BeTrue()) | ||
}) | ||
|
||
t.Run("Should successfully patch a cluster object if the spec diff is empty but the status conditions diff is not", func(t *testing.T) { | ||
g := NewWithT(t) | ||
|
||
// Setup | ||
cluster := &clusterv1.Cluster{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
GenerateName: "test3-", | ||
Namespace: ns.Name, | ||
}, | ||
} | ||
g.Expect(env.Create(ctx, cluster)).To(Succeed()) | ||
key := client.ObjectKey{Name: cluster.Name, Namespace: cluster.Namespace} | ||
defer func() { | ||
err := env.Delete(ctx, cluster) | ||
g.Expect(err).ToNot(HaveOccurred()) | ||
}() | ||
|
||
// Wait for reconciliation to happen. | ||
g.Eventually(func() bool { | ||
if err := env.Get(ctx, key, cluster); err != nil { | ||
return false | ||
} | ||
return len(cluster.Finalizers) > 0 | ||
}, timeout).Should(BeTrue()) | ||
|
||
// Patch | ||
g.Eventually(func() bool { | ||
ph, err := patch.NewHelper(cluster, env) | ||
g.Expect(err).ToNot(HaveOccurred()) | ||
conditions.MarkTrue(cluster, clusterv1.InfrastructureReadyCondition) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this a diff? Isn't the cluster controller also setting this condition to true in reconcile? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the controller running? Wouldn't the above patch also be the same? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. l.192 seems to suggest that the controller is running :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ran both tests through the debugger. The patch here is literally a no-op (same in the pre-existing test) |
||
g.Expect(ph.Patch(ctx, cluster, patch.WithStatusObservedGeneration{})).To(Succeed()) | ||
return true | ||
}, timeout).Should(BeTrue()) | ||
|
||
// Assertions | ||
g.Eventually(func() bool { | ||
instance := &clusterv1.Cluster{} | ||
if err := env.Get(ctx, key, instance); err != nil { | ||
return false | ||
} | ||
return conditions.IsTrue(cluster, clusterv1.InfrastructureReadyCondition) | ||
}, timeout).Should(BeTrue()) | ||
}) | ||
|
||
t.Run("Should successfully patch a cluster object if both the spec diff and status diff are non empty", func(t *testing.T) { | ||
g := NewWithT(t) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you provide some context what use case this test is testing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be some other controller also patching InfrastructureReady to true in parallel to the cluster controller?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only added it for completeness, seems this really tests the patch helper?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same test, but for
cluster.Status.InfrastructureReady = true
is above this oneThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I didn't realize this is ~ a copy of an existing test :D
I was wondering what use case you're trying to test here :)