Skip to content

Commit

Permalink
Review
Browse files Browse the repository at this point in the history
  • Loading branch information
yaroslava-serdiuk committed Feb 19, 2024
1 parent 130ba49 commit d51aa97
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (p *ProvisioningRequestPodsInjector) Process(

//TODO(yaroslava): support exponential backoff
// Inject pods if ProvReq is new or it has Provisioned == False condition more than defaultRetryTime
if accepted == nil || provisioned != nil &&
if accepted == nil || provisioned != nil && provisioned.Status == metav1.ConditionFalse &&
provisioned.LastTransitionTime.Add(defaultRetryTime).Before(p.now()) {
provreqpods, err := provreqpods.PodsForProvisioningRequest(pr)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ func TestProvisioningRequestPodsInjector(t *testing.T) {
Status: metav1.ConditionFalse,
LastTransitionTime: metav1.NewTime(hourAgo),
}
unknownProvisioned := metav1.Condition{
Type: v1beta1.Provisioned,
Status: metav1.ConditionUnknown,
LastTransitionTime: metav1.NewTime(hourAgo),
}
notProvisionedRecently := metav1.Condition{
Type: v1beta1.Provisioned,
Status: metav1.ConditionFalse,
Expand All @@ -69,6 +74,7 @@ func TestProvisioningRequestPodsInjector(t *testing.T) {
provisionedAcceptedProvReqB := testProvisioningRequestWithCondition("provisioned-and-accepted", podsB, provisioned, accepted)
failedProvReq := testProvisioningRequestWithCondition("failed", podsA, failed)
notProvisionedRecentlyProvReqB := testProvisioningRequestWithCondition("provisioned-false-recently-B", podsB, notProvisionedRecently)
unknownProvisionedProvReqB := testProvisioningRequestWithCondition("provisioned-unknown-B", podsB, unknownProvisioned)

testCases := []struct {
name string
Expand Down Expand Up @@ -98,6 +104,10 @@ func TestProvisioningRequestPodsInjector(t *testing.T) {
name: "Provisioned=True, no pods are injected",
provReqs: []*provreqwrapper.ProvisioningRequest{provisionedAcceptedProvReqB, failedProvReq, notProvisionedRecentlyProvReqB},
},
{
name: "Provisioned=Unknown, no pods are injected",
provReqs: []*provreqwrapper.ProvisioningRequest{unknownProvisionedProvReqB, failedProvReq, notProvisionedRecentlyProvReqB},
},
}
for _, tc := range testCases {
client := provreqclient.NewFakeProvisioningRequestClient(context.Background(), t, tc.provReqs...)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ const (
// BookingExpired indicates that the ProvisioningRequest had Provisioned condition before
// and capacity reservation time is expired.
BookingExpired string = "BookingExpired"
// CapacityRevoked indicates that requested resources are not longer valid.
CapacityRevoked string = "CapacityRevoked"
// Provisioned indicates that all of the requested resources were created
// and are available in the cluster. CA will set this condition when the
// VM creation finishes successfully.
Expand Down

0 comments on commit d51aa97

Please sign in to comment.