Merge pull request #71 from negz/scheduleharder

Requeue when no resource claims match labels or default annotations
This commit is contained in:
Nic Cope 2019-11-01 09:59:14 -07:00 committed by GitHub
commit 1b6638be27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 8 deletions

View File

@ -130,9 +130,12 @@ func (r *ClaimDefaultingReconciler) Reconcile(req reconcile.Request) (reconcile.
}
if len(defaults) == 0 {
// None of our classes are annotated as the default.
// There's nothing for us to do.
return reconcile.Result{Requeue: false}, nil
// None of our classes are annotated as the default. We can't be sure
// whether another controller owns the default class, or whether there
// is no default class, so we requeue after a short wait. We'll abort
// the next reconcile immediately if another controller defaulted the
// claim.
return reconcile.Result{RequeueAfter: aShortWait}, nil
}
random := rand.New(rand.NewSource(time.Now().UnixNano()))

View File

@ -132,7 +132,7 @@ func TestClaimDefaultingReconciler(t *testing.T) {
of: ClaimKind(MockGVK(&MockClaim{})),
to: ClassKind(MockGVK(&MockClass{})),
},
want: want{result: reconcile.Result{Requeue: false}},
want: want{result: reconcile.Result{RequeueAfter: aShortWait}},
},
"UpdateClaimError": {
args: args{

View File

@ -133,9 +133,11 @@ func (r *ClaimSchedulingReconciler) Reconcile(req reconcile.Request) (reconcile.
}
if len(classes.Items) == 0 {
// None of our classes matched the class selector.
// There's nothing for us to do.
return reconcile.Result{Requeue: false}, nil
// None of our classes matched the selector. We can't be sure whether
// another controller owns classes that matched the selector, or whether
// no classes match, so we requeue after a short wait. We'll abort the
// next reconcile immediately if another controller scheduled the claim.
return reconcile.Result{RequeueAfter: aShortWait}, nil
}
random := rand.New(rand.NewSource(time.Now().UnixNano()))

View File

@ -131,7 +131,7 @@ func TestClaimSchedulingReconciler(t *testing.T) {
of: ClaimKind(MockGVK(&MockClaim{})),
to: ClassKind(MockGVK(&MockClass{})),
},
want: want{result: reconcile.Result{Requeue: false}},
want: want{result: reconcile.Result{RequeueAfter: aShortWait}},
},
"UpdateClaimError": {
args: args{