Skip to content

Commit

Permalink
fix: make provider and version of addon consistent (#7007)
Browse files Browse the repository at this point in the history
  • Loading branch information
d976045024 committed Apr 22, 2024
1 parent 1c9f2cf commit 10b7e3a
Showing 1 changed file with 6 additions and 21 deletions.
27 changes: 6 additions & 21 deletions controllers/extensions/addon_controller_stages.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,6 @@ func (r *genIDProceedCheckStage) Handle(ctx context.Context) {
r.updateResultNErr(res, err)
return
}
err = setProviderAndVersion(r.reqCtx.Ctx, &r.stageCtx, addon)
if err != nil {
r.updateResultNErr(res, err)
return
}
r.setReconciled()
return
}
Expand Down Expand Up @@ -976,6 +971,7 @@ func enabledAddonWithDefaultValues(ctx context.Context, stageCtx *stageCtx,
if di.AddonInstallSpec.IsEmpty() {
addon.Annotations[AddonDefaultIsEmpty] = trueVal
}
setAddonProviderAndVersion(ctx, stageCtx, addon)
if err := stageCtx.reconciler.Client.Update(ctx, addon); err != nil {
stageCtx.setRequeueWithErr(err, "")
return
Expand Down Expand Up @@ -1088,22 +1084,11 @@ func findDataKey[V string | []byte](data map[string]V, refObj extensionsv1alpha1
return false
}

func setProviderAndVersion(ctx context.Context, stageCtx *stageCtx, addon *extensionsv1alpha1.Addon) error {
if addon.Spec.Provider == "" {
if addon.Labels != nil && len(addon.Labels["addon.kubeblocks.io/provider"]) != 0 {
addon.Spec.Provider = addon.Labels["addon.kubeblocks.io/provider"]
if err := stageCtx.reconciler.Client.Update(ctx, addon); err != nil {
return err
}
}
func setAddonProviderAndVersion(ctx context.Context, stageCtx *stageCtx, addon *extensionsv1alpha1.Addon) {
if addon.Spec.Provider == "" && addon.Labels != nil && len(addon.Labels["addon.kubeblocks.io/provider"]) != 0 {
addon.Spec.Provider = addon.Labels["addon.kubeblocks.io/provider"]
}
if addon.Spec.Version == "" {
if addon.Labels != nil && len(addon.Labels["addon.kubeblocks.io/version"]) != 0 {
addon.Spec.Version = addon.Labels["addon.kubeblocks.io/version"]
if err := stageCtx.reconciler.Client.Update(ctx, addon); err != nil {
return err
}
}
if addon.Spec.Version == "" && addon.Labels != nil && len(addon.Labels["addon.kubeblocks.io/version"]) != 0 {
addon.Spec.Version = addon.Labels["addon.kubeblocks.io/version"]
}
return nil
}

0 comments on commit 10b7e3a

Please sign in to comment.