fix: resolve the apprelease upgrade issue (#6214)

* Update executor.go

Signed-off-by: 凌波 <lingbo@lingbohome.com>

* fix: apprelease upgrade

Signed-off-by: lingbo <lingbo@lingbohome.com>

* upgrade job on success, clean up apprelease status.message

Signed-off-by: lingbo <lingbo@lingbohome.com>

* adjust apprelease status.message

Signed-off-by: lingbo <lingbo@lingbohome.com>

* optimize: streamline apprelease upgrade logic

Signed-off-by: lingbo <lingbo@lingbohome.com>

* adjust upgrade code

Signed-off-by: lingbo <lingbo@lingbohome.com>

* Adding status.message during apprelease installations and upgrades

Signed-off-by: lingbo <lingbo@lingbohome.com>

* fix: Supplement the missing status in the apprelease life cycle.Message, solve the problem that the front-end status and message tips display do not match.

Signed-off-by: lingbo <lingbo@lingbohome.com>

---------

Signed-off-by: 凌波 <lingbo@lingbohome.com>
Signed-off-by: lingbo <lingbo@lingbohome.com>
This commit is contained in:
凌波
2024-09-29 16:39:21 +08:00
committed by GitHub
parent 083927137d
commit 69d4c2a6cd
2 changed files with 50 additions and 25 deletions

View File

@@ -62,14 +62,15 @@ func (r *AppReleaseReconciler) createOrUpgradeAppRelease(ctx context.Context, rl
helm.SetKubeconfig(kubeconfig),
}
state := appv2.StatusCreated
if rls.Spec.AppType == appv2.AppTypeHelm {
_, err := executor.Get(ctx, rls.Name, options...)
if err != nil && err.Error() == "release: not found" {
klog.Infof("release %s not found, begin to create", rls.Name)
}
if err == nil {
klog.Infof("release %s found, begin to upgrade status", rls.Name)
return r.updateStatus(ctx, rls, appv2.StatusCreated)
klog.Infof("release %s found, begin to upgrade", rls.Name)
state = appv2.StatusUpgraded
}
}
@@ -85,7 +86,7 @@ func (r *AppReleaseReconciler) createOrUpgradeAppRelease(ctx context.Context, rl
return r.updateStatus(ctx, rls, appv2.StatusFailed, err.Error())
}
return r.updateStatus(ctx, rls, appv2.StatusCreated)
return r.updateStatus(ctx, rls, state, "Deploying")
}
func (r *AppReleaseReconciler) getExecutor(apprls *appv2.ApplicationRelease, kubeConfig []byte, runClient client.Client) (executor helm.Executor, err error) {