Fix deleting UIDs tracking expectations

Change-Id: I5dad644cf5cb232ebed0950a14b35a781a38eeb0
This commit is contained in:
Aldo Culquicondor 2022-08-05 11:59:56 -04:00
parent bd9444c1cf
commit c1e0dac461
2 changed files with 12 additions and 2 deletions

View File

@ -105,8 +105,11 @@ func (u *uidTrackingExpectations) finalizerRemovalObserved(jobKey, deleteKey str
// DeleteExpectations deletes the UID set.
func (u *uidTrackingExpectations) deleteExpectations(jobKey string) {
if err := u.store.Delete(jobKey); err != nil {
klog.ErrorS(err, "deleting tracking annotation UID expectations", "job", jobKey)
set := u.getSet(jobKey)
if set != nil {
if err := u.store.Delete(set); err != nil {
klog.ErrorS(err, "Could not delete tracking annotation UID expectations", "job", jobKey)
}
}
}

View File

@ -108,4 +108,11 @@ func TestUIDTrackingExpectations(t *testing.T) {
t.Errorf("Unexpected keys for job %s (-want,+got):\n%s", track.job, diff)
}
}
for _, track := range tracks {
expectations.deleteExpectations(track.job)
uids := expectations.getSet(track.job)
if uids != nil {
t.Errorf("Wanted expectations for job %s to be cleared, but they were not", track.job)
}
}
}