Skip to content

Commit

Permalink
Fixing a bug when provisioned condition is missing (#2151)
Browse files Browse the repository at this point in the history
* Fix bug when provisioned condition is missing

* Clarify the comments.

* Update pkg/controller/admissionchecks/provisioning/controller.go

Co-authored-by: Yuki Iwai <yuki.iwai.tz@gmail.com>

* Update pkg/controller/admissionchecks/provisioning/controller.go

Co-authored-by: Yuki Iwai <yuki.iwai.tz@gmail.com>

---------

Co-authored-by: Yuki Iwai <yuki.iwai.tz@gmail.com>
  • Loading branch information
pajakd and tenzen-y committed May 7, 2024
1 parent 57de1cd commit de1fe1f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
12 changes: 7 additions & 5 deletions pkg/controller/admissionchecks/provisioning/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -531,14 +531,16 @@ func (c *Controller) syncCheckStates(ctx context.Context, wl *kueue.Workload, ch
updated = true
// add the pod podSetUpdates
checkState.PodSetUpdates = podSetUpdates(wl, pr)
// propagate the message from the provisioning request status into the workload
// to change to the "successfully provisioned" message after provisioning
updateCheckMessage(&checkState, apimeta.FindStatusCondition(pr.Status.Conditions, autoscaling.Provisioned).Message)
}
case prAccepted:
// we propagate the message from the provisioning request status into the workload
// this happens for provisioned = false (ETA updates) and also for provisioned = true
// to change to the "successfully provisioned" message after provisioning
updated = updateCheckMessage(&checkState, apimeta.FindStatusCondition(pr.Status.Conditions, autoscaling.Provisioned).Message) || updated
updated = updateCheckState(&checkState, kueue.CheckStatePending) || updated
if provisionedCond := apimeta.FindStatusCondition(pr.Status.Conditions, autoscaling.Provisioned); provisionedCond != nil {
// propagate the ETA update from the provisioning request into the workload
updated = updateCheckMessage(&checkState, provisionedCond.Message) || updated
updated = updateCheckState(&checkState, kueue.CheckStatePending) || updated
}
default:
updated = updateCheckState(&checkState, kueue.CheckStatePending) || updated
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ var _ = ginkgo.Describe("Provisioning", ginkgo.Ordered, ginkgo.ContinueOnFailure
Namespace: wlKey.Namespace,
Name: provisioning.GetProvisioningRequestName(wlKey.Name, ac.Name, 1),
}
ginkgo.By("Setting the provision request as Not Provisioned and providing ETA", func() {
ginkgo.By("Setting the provision request as Accepted", func() {
createdRequest := &autoscaling.ProvisioningRequest{}
gomega.Eventually(func() error {
err := k8sClient.Get(ctx, provReqKey, createdRequest)
Expand All @@ -329,6 +329,16 @@ var _ = ginkgo.Describe("Provisioning", ginkgo.Ordered, ginkgo.ContinueOnFailure
Status: metav1.ConditionTrue,
Reason: "Reason",
})
return k8sClient.Status().Update(ctx, createdRequest)
}, util.Timeout, util.Interval).Should(gomega.Succeed())
})
ginkgo.By("Setting the provision request as Not Provisioned and providing ETA", func() {
createdRequest := &autoscaling.ProvisioningRequest{}
gomega.Eventually(func() error {
err := k8sClient.Get(ctx, provReqKey, createdRequest)
if err != nil {
return err
}
apimeta.SetStatusCondition(&createdRequest.Status.Conditions, metav1.Condition{
Type: autoscaling.Provisioned,
Status: metav1.ConditionFalse,
Expand Down

0 comments on commit de1fe1f

Please sign in to comment.