@@ -22,21 +22,25 @@ func (m *DefaultGroupMigrator) Migrate(ctx context.Context) error {
22
22
return fmt .Errorf ("failed to initialize managers: %w" , err )
23
23
}
24
24
25
- // Create default group
26
- if err := m .createDefaultGroup (ctx ); err != nil {
27
- return fmt .Errorf ("failed to create default group: %w" , err )
25
+ // Create default group if it doesn't exist
26
+ defaultGroupExists , err := m .groupManager .Exists (ctx , groups .DefaultGroupName )
27
+ if err != nil {
28
+ return fmt .Errorf ("failed to check if default group exists: %w" , err )
29
+ }
30
+ if ! defaultGroupExists {
31
+ if err := m .createDefaultGroup (ctx ); err != nil {
32
+ return fmt .Errorf ("failed to create default group: %w" , err )
33
+ }
28
34
}
29
35
30
- // Migrate workloads to default group
36
+ // Migrate workloads to default group if they don't have a group assigned
31
37
migratedCount , err := m .migrateWorkloadsToDefaultGroup (ctx )
32
38
if err != nil {
33
39
return fmt .Errorf ("failed to migrate workloads: %w" , err )
34
40
}
35
41
36
42
if migratedCount > 0 {
37
43
fmt .Printf ("\n Successfully migrated %d workloads to default group '%s'\n " , migratedCount , groups .DefaultGroupName )
38
- } else {
39
- fmt .Println ("No workloads needed migration to default group" )
40
44
}
41
45
42
46
// Migrate client configurations from global config to default group
@@ -108,12 +112,10 @@ func (m *DefaultGroupMigrator) migrateClientConfigs(ctx context.Context) error {
108
112
109
113
// If there are no registered clients, nothing to migrate
110
114
if len (appConfig .Clients .RegisteredClients ) == 0 {
111
- logger .Infof ("No client configurations to migrate" )
115
+ logger .Debugf ("No client configurations to migrate" )
112
116
return nil
113
117
}
114
118
115
- fmt .Printf ("Migrating %d client configurations to default group...\n " , len (appConfig .Clients .RegisteredClients ))
116
-
117
119
// Get the default group
118
120
defaultGroup , err := m .groupManager .Get (ctx , groups .DefaultGroupName )
119
121
if err != nil {
@@ -151,10 +153,10 @@ func (m *DefaultGroupMigrator) migrateClientConfigs(ctx context.Context) error {
151
153
if err != nil {
152
154
logger .Warnf ("Failed to clear global client configurations after migration: %v" , err )
153
155
} else {
154
- logger .Infof ("Cleared global client configurations" )
156
+ logger .Debugf ("Cleared global client configurations" )
155
157
}
156
158
} else {
157
- logger .Infof ("No client configurations needed migration" )
159
+ logger .Debugf ("No client configurations needed migration" )
158
160
}
159
161
160
162
return nil
0 commit comments