Skip to content

Commit

Permalink
Adding percentage done indicator to status config map
Browse files Browse the repository at this point in the history
  • Loading branch information
crobby committed Aug 10, 2023
1 parent 43f19e4 commit 9f577f6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/agent/clean/active_directory.go
Expand Up @@ -51,6 +51,7 @@ const (
AttributeObjectGUID = "objectGUID"
migrateStatusSkipped = "skippedUsers"
migrateStatusMissing = "missingUsers"
migrationStatusPercentage = "percentDone"
)

var validHexPattern = regexp.MustCompile("^[0-9a-f]+$")
Expand Down Expand Up @@ -383,7 +384,7 @@ func UnmigrateAdGUIDUsers(clientConfig *restclient.Config, dryRun bool, deleteMi
}
}

for _, userToMigrate := range usersToMigrate {
for i, userToMigrate := range usersToMigrate {
// If any of the binding replacements fail, then the resulting rancher state for this user is inconsistent
// and we should NOT attempt to modify the user or delete any of its duplicates. This situation is unusual
// and must be investigated by the local admin.
Expand Down Expand Up @@ -412,6 +413,12 @@ func UnmigrateAdGUIDUsers(clientConfig *restclient.Config, dryRun bool, deleteMi
updateModifiedUser(userToMigrate, sc)
}
}
percentDone := float64(i+1) / float64(len(usersToMigrate)) * 100
progress := fmt.Sprintf("%.0f%%", percentDone)
err = updateMigrationStatus(sc, migrationStatusPercentage, progress)
if err != nil {
logrus.Errorf("unable to update migration status: %v", err)
}
}

err = updateMigrationStatus(sc, activedirectory.StatusMigrationField, activedirectory.StatusMigrationFinished)
Expand Down

0 comments on commit 9f577f6

Please sign in to comment.