Skip to content

Commit

Permalink
handle storage state with no migration
Browse files Browse the repository at this point in the history
  • Loading branch information
sanchezl committed Feb 4, 2020
1 parent 1abfac2 commit 77bd1ac
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pkg/trigger/discovery_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,24 @@ func (mt *MigrationTrigger) processDiscoveryResource(r metav1.APIResource) {
storageVersionChanged := (getErr == nil && ss.Status.CurrentStorageVersionHash != r.StorageVersionHash)
notFound := (getErr != nil && errors.IsNotFound(getErr))

var expectedMigrationNotFound bool
if !(stale || notFound || storageVersionChanged) && len(ss.Status.PersistedStorageVersionHashes) == 1 && (ss.Status.PersistedStorageVersionHashes[0] == migrationv1alpha1.Unknown) {
m, err := mt.migrationInformer.GetIndexer().ByIndex(controller.ResourceIndex, controller.ToIndex(toGroupResource(r)))
if err != nil {
utilruntime.HandleError(getErr)
return
}
expectedMigrationNotFound = len(m) == 0
}

if stale {
if err := mt.client.MigrationV1alpha1().StorageStates().Delete(storageStateName(toGroupResource(r)), nil); err != nil {
utilruntime.HandleError(err)
return
}
}

if stale || storageVersionChanged || notFound {
if stale || storageVersionChanged || notFound || expectedMigrationNotFound {
// Note that this means historical migration objects are deleted.
if err := mt.relaunchMigration(r); err != nil {
utilruntime.HandleError(err)
Expand Down

0 comments on commit 77bd1ac

Please sign in to comment.