diff --git a/cluster-autoscaler/processors/provreq/injector.go b/cluster-autoscaler/processors/provreq/injector.go index 023a2b202c70..4217951f49a7 100644 --- a/cluster-autoscaler/processors/provreq/injector.go +++ b/cluster-autoscaler/processors/provreq/injector.go @@ -71,17 +71,6 @@ func (p *ProvisioningRequestPodsInjector) IsAvailableForProvisioning(pr *provreq return true } -// MarkAsAccepted marks the ProvisioningRequest as accepted. -func (p *ProvisioningRequestPodsInjector) MarkAsAccepted(pr *provreqwrapper.ProvisioningRequest) error { - provreqconditions.AddOrUpdateCondition(pr, v1.Accepted, metav1.ConditionTrue, provreqconditions.AcceptedReason, provreqconditions.AcceptedMsg, metav1.NewTime(p.clock.Now())) - if _, err := p.client.UpdateProvisioningRequest(pr.ProvisioningRequest); err != nil { - klog.Errorf("failed add Accepted condition to ProvReq %s/%s, err: %v", pr.Namespace, pr.Name, err) - return err - } - p.lastProvisioningRequestProcessTime = p.clock.Now() - return nil -} - // MarkAsFailed marks the ProvisioningRequest as failed. func (p *ProvisioningRequestPodsInjector) MarkAsFailed(pr *provreqwrapper.ProvisioningRequest, reason string, message string) { provreqconditions.AddOrUpdateCondition(pr, v1.Failed, metav1.ConditionTrue, reason, message, metav1.NewTime(p.clock.Now())) @@ -120,9 +109,6 @@ func (p *ProvisioningRequestPodsInjector) GetPodsFromNextRequest( p.MarkAsFailed(pr, provreqconditions.FailedToCreatePodsReason, err.Error()) continue } - if err := p.MarkAsAccepted(pr); err != nil { - continue - } return podsFromProvReq, nil } diff --git a/cluster-autoscaler/processors/provreq/injector_test.go b/cluster-autoscaler/processors/provreq/injector_test.go index 0e51026c254c..d9d45720cc2b 100644 --- a/cluster-autoscaler/processors/provreq/injector_test.go +++ b/cluster-autoscaler/processors/provreq/injector_test.go @@ -21,7 +21,6 @@ import ( "testing" "time" - apimeta "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" v1 "k8s.io/autoscaler/cluster-autoscaler/apis/provisioningrequest/autoscaling.x-k8s.io/v1" "k8s.io/autoscaler/cluster-autoscaler/provisioningrequest/provreqclient" @@ -83,25 +82,21 @@ func TestProvisioningRequestPodsInjector(t *testing.T) { provReqs []*provreqwrapper.ProvisioningRequest existingUnsUnschedulablePodCount int wantUnscheduledPodCount int - wantUpdatedConditionName string }{ { name: "New ProvisioningRequest, pods are injected and Accepted condition is added", provReqs: []*provreqwrapper.ProvisioningRequest{newProvReqA, provisionedAcceptedProvReqB}, wantUnscheduledPodCount: podsA, - wantUpdatedConditionName: newProvReqA.Name, }, { name: "New ProvisioningRequest, pods are injected and Accepted condition is updated", provReqs: []*provreqwrapper.ProvisioningRequest{newAcceptedProvReqA, provisionedAcceptedProvReqB}, wantUnscheduledPodCount: podsA, - wantUpdatedConditionName: newAcceptedProvReqA.Name, }, { name: "Provisioned=False, pods are injected", provReqs: []*provreqwrapper.ProvisioningRequest{notProvisionedAcceptedProvReqB, failedProvReq}, wantUnscheduledPodCount: podsB, - wantUpdatedConditionName: notProvisionedAcceptedProvReqB.Name, }, { name: "Provisioned=True, no pods are injected", @@ -124,7 +119,6 @@ func TestProvisioningRequestPodsInjector(t *testing.T) { provReqs: []*provreqwrapper.ProvisioningRequest{newProvReqA}, existingUnsUnschedulablePodCount: 50, wantUnscheduledPodCount: podsA + 50, - wantUpdatedConditionName: newProvReqA.Name, }, } for _, tc := range testCases { @@ -139,14 +133,6 @@ func TestProvisioningRequestPodsInjector(t *testing.T) { if len(getUnscheduledPods) != tc.wantUnscheduledPodCount { t.Errorf("%s failed: injector.Process return %d unscheduled pods, want %d", tc.name, len(getUnscheduledPods), tc.wantUnscheduledPodCount) } - if tc.wantUpdatedConditionName == "" { - continue - } - pr, _ := client.ProvisioningRequestNoCache("ns", tc.wantUpdatedConditionName) - accepted := apimeta.FindStatusCondition(pr.Status.Conditions, v1.Accepted) - if accepted == nil || accepted.LastTransitionTime != metav1.NewTime(now) { - t.Errorf("%s: injector.Process hasn't update accepted condition for ProvisioningRequest %s", tc.name, tc.wantUpdatedConditionName) - } } } diff --git a/cluster-autoscaler/provisioningrequest/besteffortatomic/provisioning_class.go b/cluster-autoscaler/provisioningrequest/besteffortatomic/provisioning_class.go index 122312b622cc..f21e507c0eeb 100644 --- a/cluster-autoscaler/provisioningrequest/besteffortatomic/provisioning_class.go +++ b/cluster-autoscaler/provisioningrequest/besteffortatomic/provisioning_class.go @@ -94,6 +94,7 @@ func (o *bestEffortAtomicProvClass) Provision( // For provisioning requests, unschedulablePods are actually all injected pods. Some may even be schedulable! actuallyUnschedulablePods, err := o.filterOutSchedulable(unschedulablePods) + conditions.AddOrUpdateCondition(pr, v1.Accepted, metav1.ConditionTrue, conditions.AcceptedReason, conditions.AcceptedMsg, metav1.Now()) if err != nil { conditions.AddOrUpdateCondition(pr, v1.Provisioned, metav1.ConditionFalse, conditions.FailedToCheckCapacityReason, conditions.FailedToCheckCapacityMsg, metav1.Now()) if _, updateErr := o.client.UpdateProvisioningRequest(pr.ProvisioningRequest); updateErr != nil { diff --git a/cluster-autoscaler/provisioningrequest/checkcapacity/provisioningclass.go b/cluster-autoscaler/provisioningrequest/checkcapacity/provisioningclass.go index 1a3b45cbbaf5..244c9a0bd280 100644 --- a/cluster-autoscaler/provisioningrequest/checkcapacity/provisioningclass.go +++ b/cluster-autoscaler/provisioningrequest/checkcapacity/provisioningclass.go @@ -138,6 +138,7 @@ func (o *checkCapacityProvClass) checkcapacity(unschedulablePods []*apiv1.Pod, p var capacityAvailable bool err, cleanupErr := clustersnapshot.WithForkedSnapshot(o.context.ClusterSnapshot, func() (bool, error) { st, _, err := o.schedulingSimulator.TrySchedulePods(o.context.ClusterSnapshot, unschedulablePods, scheduling.ScheduleAnywhere, true) + conditions.AddOrUpdateCondition(provReq, v1.Accepted, metav1.ConditionTrue, conditions.AcceptedReason, conditions.AcceptedMsg, metav1.Now()) if len(st) < len(unschedulablePods) || err != nil { conditions.AddOrUpdateCondition(provReq, v1.Provisioned, metav1.ConditionFalse, conditions.CapacityIsNotFoundReason, "Capacity is not found, CA will try to find it later.", metav1.Now()) capacityAvailable = false