@@ -35,22 +35,23 @@ const (
3535 hubAddon = "hub-addon"
3636)
3737
38- func handleAddonConfig (ctx context.Context , kClient client.Client , addonC * addonapi.Clientset , fc * v1alpha1.FleetConfig ) error {
38+ func handleAddonConfig (ctx context.Context , kClient client.Client , addonC * addonapi.Clientset , fc * v1alpha1.FleetConfig ) ( bool , error ) {
3939 logger := log .FromContext (ctx )
4040 logger .V (0 ).Info ("handleAddOnConfig" , "fleetconfig" , fc .Name )
4141
42+ requestedAddOns := fc .Spec .AddOnConfigs
43+
4244 // get existing addons
4345 createdAddOns , err := addonC .AddonV1alpha1 ().AddOnTemplates ().List (ctx , metav1.ListOptions {LabelSelector : v1alpha1 .ManagedBySelector .String ()})
4446 if err != nil {
45- return err
47+ logger .V (1 ).Info ("failed to list AddOnTemplates, ensure CRDs are installed." , "error" , err )
48+ return len (requestedAddOns ) > 0 , err
4649 }
4750
48- requestedAddOns := fc .Spec .AddOnConfigs
49-
5051 // nothing to do
5152 if len (requestedAddOns ) == 0 && len (createdAddOns .Items ) == 0 {
5253 logger .V (5 ).Info ("no addons to reconcile" )
53- return nil
54+ return false , nil
5455 }
5556
5657 // compare existing to requested
@@ -83,15 +84,15 @@ func handleAddonConfig(ctx context.Context, kClient client.Client, addonC *addon
8384 // do deletes first, then creates.
8485 err = handleAddonDelete (ctx , addonC , fc , addonsToDelete )
8586 if err != nil {
86- return err
87+ return true , err
8788 }
8889
8990 err = handleAddonCreate (ctx , kClient , fc , addonsToCreate )
9091 if err != nil {
91- return err
92+ return true , err
9293 }
9394
94- return nil
95+ return true , nil
9596}
9697
9798func handleAddonCreate (ctx context.Context , kClient client.Client , fc * v1alpha1.FleetConfig , addons []v1alpha1.AddOnConfig ) error {
@@ -408,7 +409,7 @@ func isHubAddOnMatching(installed v1alpha1.InstalledHubAddOn, desired v1alpha1.H
408409 installed .BundleVersion == bundleVersion
409410}
410411
411- func handleHubAddons (ctx context.Context , addonC * addonapi.Clientset , fc * v1alpha1.FleetConfig ) error {
412+ func handleHubAddons (ctx context.Context , addonC * addonapi.Clientset , fc * v1alpha1.FleetConfig ) ( bool , error ) {
412413 logger := log .FromContext (ctx )
413414 logger .V (0 ).Info ("handleHubAddons" , "fleetconfig" , fc .Name )
414415
@@ -419,7 +420,7 @@ func handleHubAddons(ctx context.Context, addonC *addonapi.Clientset, fc *v1alph
419420 // nothing to do
420421 if len (desiredAddOns ) == 0 && len (installedAddOns ) == 0 {
421422 logger .V (5 ).Info ("no hub addons to reconcile" )
422- return nil
423+ return false , nil
423424 }
424425
425426 // Find addons that need to be uninstalled (present in installed, missing from desired or version mismatch)
@@ -447,12 +448,12 @@ func handleHubAddons(ctx context.Context, addonC *addonapi.Clientset, fc *v1alph
447448 // do uninstalls first, then installs
448449 err := handleHubAddonUninstall (ctx , addonsToUninstall , fc )
449450 if err != nil {
450- return err
451+ return true , err
451452 }
452453
453454 err = handleHubAddonInstall (ctx , addonC , addonsToInstall , bundleVersion , fc )
454455 if err != nil {
455- return err
456+ return true , err
456457 }
457458
458459 // build the new installed addons list
@@ -465,7 +466,7 @@ func handleHubAddons(ctx context.Context, addonC *addonapi.Clientset, fc *v1alph
465466 })
466467 }
467468 fc .Status .InstalledHubAddOns = newInstalledAddOns
468- return nil
469+ return true , nil
469470}
470471
471472func handleHubAddonUninstall (ctx context.Context , addons []v1alpha1.InstalledHubAddOn , fc * v1alpha1.FleetConfig ) error {
0 commit comments