mirror of
https://github.com/projectcapsule/capsule.git
synced 2026-08-20 04:56:44 +00:00
Fix claim mutation guard for allocated pools
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user