Use lazy copy for annotations

This commit is contained in:
Nikola Jokic
2026-07-23 17:26:18 +02:00
parent ac2864816d
commit ab1c70d8e3
8 changed files with 364 additions and 170 deletions
@@ -1670,6 +1670,28 @@ var _ = Describe("Test EphemeralRunnerSet actionable revision cleanup", func() {
}
}
waitForCachedActionableRevision := func(controller *EphemeralRunnerSetReconciler, key types.NamespacedName, specRevision, appliedRevision int64) {
Eventually(func(g Gomega) {
cached := new(v1alpha1.EphemeralRunnerSet)
g.Expect(controller.Get(ctx, key, cached)).To(Succeed())
g.Expect(cached.Spec.ActionableRevision).To(Equal(specRevision))
g.Expect(cached.Status.AppliedActionableRevision).To(Equal(appliedRevision))
g.Expect(cached.Finalizers).To(ContainElement(EphemeralRunnerSetFinalizerName))
}, ephemeralRunnerSetTestTimeout, ephemeralRunnerSetTestInterval).Should(Succeed())
}
waitForCachedRunningRunners := func(controller *EphemeralRunnerSetReconciler, namespace, owner string, expected int) {
Eventually(func(g Gomega) {
runners := new(v1alpha1.EphemeralRunnerList)
g.Expect(controller.List(ctx, runners, client.InNamespace(namespace), client.MatchingFields{resourceOwnerKey: owner})).To(Succeed())
state := newEphemeralRunnersByStates(runners)
g.Expect(state.running).To(HaveLen(expected))
for _, runner := range state.running {
g.Expect(runner.Status.RunnerID).NotTo(BeZero())
}
}, ephemeralRunnerSetTestTimeout, ephemeralRunnerSetTestInterval).Should(Succeed())
}
BeforeEach(func() {
ctx = context.Background()
autoscalingNS, mgr = createNamespace(GinkgoT(), k8sClient)
@@ -1904,6 +1926,9 @@ var _ = Describe("Test EphemeralRunnerSet actionable revision cleanup", func() {
err = k8sClient.Patch(ctx, specUpdated, client.MergeFrom(current))
Expect(err).NotTo(HaveOccurred())
waitForCachedActionableRevision(controller, request.NamespacedName, 4, 3)
waitForCachedRunningRunners(controller, autoscalingNS.Name, ephemeralRunnerSet.Name, 1)
_, err = controller.Reconcile(ctx, request)
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(ContainSubstring("remove failed"))