Fix claim mutation guard for allocated pools

This commit is contained in:
copilot-swe-agent[bot]
2026-06-23 21:46:46 +00:00
committed by GitHub
parent 4e9e529cfd
commit 14fa3bb61d
2 changed files with 7 additions and 7 deletions
+6 -6
View File
@@ -511,7 +511,7 @@ var _ = Describe("ResourcePoolClaim Tests", Ordered, Label("resourcepool", "clai
}, defaultTimeoutInterval, defaultPollInterval).Should(Succeed())
})
By("Allow on patching resources for claim (Increase)", func() {
By("Error on patching resources for claim (Increase) while allocated but unused", func() {
Eventually(func() error {
stat := &capsulev1beta2.ResourcePoolClaim{}
err := k8sClient.Get(context.TODO(), client.ObjectKey{Name: claim.Name, Namespace: claim.Namespace}, stat)
@@ -525,10 +525,10 @@ var _ = Describe("ResourcePoolClaim Tests", Ordered, Label("resourcepool", "clai
}
return k8sClient.Update(context.TODO(), stat)
}, defaultTimeoutInterval, defaultPollInterval).Should(Succeed())
}, defaultTimeoutInterval, defaultPollInterval).ShouldNot(Succeed())
})
By("Allow on patching resources for claim (Decrease)", func() {
By("Error on patching resources for claim (Decrease) while allocated but unused", func() {
Eventually(func() error {
stat := &capsulev1beta2.ResourcePoolClaim{}
if err := k8sClient.Get(
@@ -547,10 +547,10 @@ var _ = Describe("ResourcePoolClaim Tests", Ordered, Label("resourcepool", "clai
}
return k8sClient.Update(context.TODO(), stat)
}, defaultTimeoutInterval, defaultPollInterval).Should(Succeed())
}, defaultTimeoutInterval, defaultPollInterval).ShouldNot(Succeed())
})
By("Allow on patching pool name", func() {
By("Error on patching pool name while allocated but unused", func() {
Eventually(func() error {
stat := &capsulev1beta2.ResourcePoolClaim{}
@@ -560,7 +560,7 @@ var _ = Describe("ResourcePoolClaim Tests", Ordered, Label("resourcepool", "clai
stat.Spec.Pool = "some-random-pool"
return k8sClient.Update(context.TODO(), stat)
}, defaultTimeoutInterval, defaultPollInterval).Should(Succeed())
}, defaultTimeoutInterval, defaultPollInterval).ShouldNot(Succeed())
})
By("Delete Pool", func() {
@@ -76,7 +76,7 @@ func (h *claimValidationHandler) OnUpdate(
return ad.ErroredResponse(fmt.Errorf("failed to decode new object: %w", err))
}
if oldClaim.IsBoundInResourcePool() {
if oldClaim.Status.Pool.UID != "" {
if oldClaim.Spec.Pool != newClaim.Spec.Pool || !reflect.DeepEqual(oldClaim.Spec.ResourceClaims, newClaim.Spec.ResourceClaims) {
return ad.Denyf("cannot change the requested resources while claim is allocated to a resourcepool %s", oldClaim.Status.Pool.Name)
}