@@ -15,7 +15,6 @@ import (
15
15
hiveinternalv1alpha1 "github.com/openshift/hive/apis/hiveinternal/v1alpha1"
16
16
corev1 "k8s.io/api/core/v1"
17
17
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
18
- "k8s.io/utils/pointer"
19
18
20
19
"k8s.io/apimachinery/pkg/types"
21
20
"k8s.io/cli-runtime/pkg/genericclioptions"
@@ -219,9 +218,6 @@ func (o *rotateSecretOptions) run() error {
219
218
"aws_secret_access_key" : []byte (* createAccessKeyOutput .AccessKey .SecretAccessKey ),
220
219
}
221
220
222
- // Escalte to backplane cluster admin
223
- o .flags .Impersonate = pointer .StringPtr ("backplane-cluster-admin" )
224
-
225
221
// Update existing osdManagedAdmin secret
226
222
err = common .UpdateSecret (o .kubeCli , o .accountCRName + "-secret" , common .AWSAccountNamespace , newOsdManagedAdminSecretData )
227
223
if err != nil {
@@ -234,6 +230,23 @@ func (o *rotateSecretOptions) run() error {
234
230
return err
235
231
}
236
232
233
+ fmt .Println ("AWS creds updated on hive." )
234
+
235
+ clusterDeployments := & hiveapiv1.ClusterDeploymentList {}
236
+ listOpts := []client.ListOption {
237
+ client .InNamespace (account .Spec .ClaimLinkNamespace ),
238
+ }
239
+
240
+ err = o .kubeCli .List (ctx , clusterDeployments , listOpts ... )
241
+ if err != nil {
242
+ return err
243
+ }
244
+
245
+ if len (clusterDeployments .Items ) == 0 {
246
+ return fmt .Errorf ("failed to retreive cluster deployments" )
247
+ }
248
+ cdName := clusterDeployments .Items [0 ].ObjectMeta .Name
249
+
237
250
// Create syncset to deploy the updated creds to the cluster for CCO
238
251
syncSetName := "aws-sync"
239
252
syncSet := & hiveapiv1.SyncSet {
@@ -242,6 +255,11 @@ func (o *rotateSecretOptions) run() error {
242
255
Namespace : account .Spec .ClaimLinkNamespace ,
243
256
},
244
257
Spec : hiveapiv1.SyncSetSpec {
258
+ ClusterDeploymentRefs : []corev1.LocalObjectReference {
259
+ {
260
+ Name : cdName ,
261
+ },
262
+ },
245
263
SyncSetCommonSpec : hiveapiv1.SyncSetCommonSpec {
246
264
ResourceApplyMode : "Upsert" ,
247
265
Secrets : []hiveapiv1.SecretMapping {
@@ -258,40 +276,29 @@ func (o *rotateSecretOptions) run() error {
258
276
},
259
277
},
260
278
}
279
+ fmt .Println ("Syncing AWS creds down to cluster." )
261
280
err = o .kubeCli .Create (ctx , syncSet )
262
281
if err != nil {
263
282
return err
264
283
}
265
284
266
- clusterDeployments := & hiveapiv1.ClusterDeploymentList {}
267
- listOpts := []client.ListOption {
268
- client .InNamespace (account .Spec .ClaimLinkNamespace ),
269
- }
270
-
271
- err = o .kubeCli .List (ctx , clusterDeployments , listOpts ... )
272
- if err != nil {
273
- return err
274
- }
275
-
276
- if len (clusterDeployments .Items ) == 0 {
277
- return fmt .Errorf ("failed to retreive cluster deployments" )
278
- }
279
- cdName := clusterDeployments .Items [0 ].ObjectMeta .Name
280
-
281
- syncStatus := & hiveinternalv1alpha1.ClusterSync {
285
+ fmt .Printf ("Watching Cluster Sync Status for deployment..." )
286
+ hiveinternalv1alpha1 .AddToScheme (o .kubeCli .Scheme ())
287
+ searchStatus := & hiveinternalv1alpha1.ClusterSync {
282
288
ObjectMeta : metav1.ObjectMeta {
283
289
Name : cdName ,
284
290
Namespace : account .Spec .ClaimLinkNamespace ,
285
291
},
286
292
}
287
-
288
- fmt .Printf ("Watching Cluster Sync Status for deployment..." )
289
-
293
+ foundStatus := & hiveinternalv1alpha1.ClusterSync {}
290
294
isSSSynced := false
291
- for i := 0 ; i < 5 ; i ++ {
292
- o .kubeCli .Get (ctx , client .ObjectKeyFromObject (syncStatus ), syncStatus )
295
+ for i := 0 ; i < 6 ; i ++ {
296
+ err = o .kubeCli .Get (ctx , client .ObjectKeyFromObject (searchStatus ), foundStatus )
297
+ if err != nil {
298
+ return err
299
+ }
293
300
294
- for _ , status := range syncStatus .Status .SyncSets {
301
+ for _ , status := range foundStatus .Status .SyncSets {
295
302
if status .Name == syncSetName {
296
303
if status .FirstSuccessTime != nil {
297
304
isSSSynced = true
@@ -301,15 +308,15 @@ func (o *rotateSecretOptions) run() error {
301
308
}
302
309
303
310
if isSSSynced {
304
- fmt .Printf ("Sync completed..." )
311
+ fmt .Printf ("\n Sync completed...\n " )
305
312
break
306
313
}
307
314
308
- fmt .Printf ("Sync not completed, sleeping 5 seconds and rechecking.. ." )
315
+ fmt .Printf ("." )
309
316
time .Sleep (time .Second * 5 )
310
317
}
311
318
if ! isSSSynced {
312
- return fmt .Errorf ("syncset failed to sync in 5mins . Please verify" )
319
+ return fmt .Errorf ("syncset failed to sync. Please verify" )
313
320
}
314
321
315
322
// Clean up the SS on hive
0 commit comments