Skip to content

Commit b8c1073

Browse files
committed
[Feature] [Platform] Update Failed Releases
1 parent f72a052 commit b8c1073

File tree

7 files changed

+73
-41
lines changed

7 files changed

+73
-41
lines changed

.golangci.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ linters-settings:
195195
pkg: github.com/arangodb/kube-arangodb/pkg/util/constants
196196
- alias: tcache
197197
pkg: github.com/arangodb/kube-arangodb/pkg/util/tests/cache
198+
- alias: helmRelease
199+
pkg: helm.sh/helm/v3/pkg/release
198200
- alias: apps
199201
pkg: k8s.io/api/apps/v1
200202
- alias: batch

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- (Bugfix) (Platform) Fix topology for Gateways
77
- (Feature) (Platform) Dump CLI switch to Services
88
- (Feature) (Platform) Fix ImagePullSecrets Merge
9+
- (Feature) (Platform) Update Failed Releases
910

1011
## [1.3.2](https://github.com/arangodb/kube-arangodb/tree/1.3.2) (2025-11-20)
1112
- (Bugfix) (Platform) Increase memory limit for Inventory

integrations/scheduler/v2/definition/helpers.go

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ package definition
2222

2323
import (
2424
"helm.sh/helm/v3/pkg/action"
25-
"helm.sh/helm/v3/pkg/release"
25+
helmRelease "helm.sh/helm/v3/pkg/release"
2626
"k8s.io/apimachinery/pkg/labels"
2727
"k8s.io/apimachinery/pkg/runtime/schema"
2828
"k8s.io/apimachinery/pkg/selection"
@@ -31,50 +31,50 @@ import (
3131
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/helm"
3232
)
3333

34-
func (i SchedulerV2ReleaseInfoStatus) AsHelmStatus() release.Status {
34+
func (i SchedulerV2ReleaseInfoStatus) AsHelmStatus() helmRelease.Status {
3535
switch i {
3636
case SchedulerV2ReleaseInfoStatus_SCHEDULER_V2_RELEASE_INFO_STATUS_UNKNOWN_UNSPECIFIED:
37-
return release.StatusUnknown
37+
return helmRelease.StatusUnknown
3838
case SchedulerV2ReleaseInfoStatus_SCHEDULER_V2_RELEASE_INFO_STATUS_DEPLOYED:
39-
return release.StatusDeployed
39+
return helmRelease.StatusDeployed
4040
case SchedulerV2ReleaseInfoStatus_SCHEDULER_V2_RELEASE_INFO_STATUS_UNINSTALLED:
41-
return release.StatusUninstalled
41+
return helmRelease.StatusUninstalled
4242
case SchedulerV2ReleaseInfoStatus_SCHEDULER_V2_RELEASE_INFO_STATUS_SUPERSEDED:
43-
return release.StatusSuperseded
43+
return helmRelease.StatusSuperseded
4444
case SchedulerV2ReleaseInfoStatus_SCHEDULER_V2_RELEASE_INFO_STATUS_FAILED:
45-
return release.StatusFailed
45+
return helmRelease.StatusFailed
4646
case SchedulerV2ReleaseInfoStatus_SCHEDULER_V2_RELEASE_INFO_STATUS_UNINSTALLING:
47-
return release.StatusUninstalling
47+
return helmRelease.StatusUninstalling
4848
case SchedulerV2ReleaseInfoStatus_SCHEDULER_V2_RELEASE_INFO_STATUS_PENDINGINSTALL:
49-
return release.StatusPendingInstall
49+
return helmRelease.StatusPendingInstall
5050
case SchedulerV2ReleaseInfoStatus_SCHEDULER_V2_RELEASE_INFO_STATUS_PENDINGUPGRADE:
51-
return release.StatusPendingUpgrade
51+
return helmRelease.StatusPendingUpgrade
5252
case SchedulerV2ReleaseInfoStatus_SCHEDULER_V2_RELEASE_INFO_STATUS_PENDINGROLLBACK:
53-
return release.StatusPendingRollback
53+
return helmRelease.StatusPendingRollback
5454
default:
55-
return release.StatusUnknown
55+
return helmRelease.StatusUnknown
5656
}
5757
}
5858

59-
func FromHelmStatus(in release.Status) SchedulerV2ReleaseInfoStatus {
59+
func FromHelmStatus(in helmRelease.Status) SchedulerV2ReleaseInfoStatus {
6060
switch in {
61-
case release.StatusUnknown:
61+
case helmRelease.StatusUnknown:
6262
return SchedulerV2ReleaseInfoStatus_SCHEDULER_V2_RELEASE_INFO_STATUS_UNKNOWN_UNSPECIFIED
63-
case release.StatusDeployed:
63+
case helmRelease.StatusDeployed:
6464
return SchedulerV2ReleaseInfoStatus_SCHEDULER_V2_RELEASE_INFO_STATUS_DEPLOYED
65-
case release.StatusUninstalled:
65+
case helmRelease.StatusUninstalled:
6666
return SchedulerV2ReleaseInfoStatus_SCHEDULER_V2_RELEASE_INFO_STATUS_UNINSTALLED
67-
case release.StatusSuperseded:
67+
case helmRelease.StatusSuperseded:
6868
return SchedulerV2ReleaseInfoStatus_SCHEDULER_V2_RELEASE_INFO_STATUS_SUPERSEDED
69-
case release.StatusFailed:
69+
case helmRelease.StatusFailed:
7070
return SchedulerV2ReleaseInfoStatus_SCHEDULER_V2_RELEASE_INFO_STATUS_FAILED
71-
case release.StatusUninstalling:
71+
case helmRelease.StatusUninstalling:
7272
return SchedulerV2ReleaseInfoStatus_SCHEDULER_V2_RELEASE_INFO_STATUS_UNINSTALLING
73-
case release.StatusPendingInstall:
73+
case helmRelease.StatusPendingInstall:
7474
return SchedulerV2ReleaseInfoStatus_SCHEDULER_V2_RELEASE_INFO_STATUS_PENDINGINSTALL
75-
case release.StatusPendingUpgrade:
75+
case helmRelease.StatusPendingUpgrade:
7676
return SchedulerV2ReleaseInfoStatus_SCHEDULER_V2_RELEASE_INFO_STATUS_PENDINGUPGRADE
77-
case release.StatusPendingRollback:
77+
case helmRelease.StatusPendingRollback:
7878
return SchedulerV2ReleaseInfoStatus_SCHEDULER_V2_RELEASE_INFO_STATUS_PENDINGROLLBACK
7979
default:
8080
return SchedulerV2ReleaseInfoStatus_SCHEDULER_V2_RELEASE_INFO_STATUS_UNKNOWN_UNSPECIFIED

pkg/apis/platform/v1alpha1/service_status_release.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
package v1alpha1
2222

2323
import (
24-
"helm.sh/helm/v3/pkg/release"
24+
helmRelease "helm.sh/helm/v3/pkg/release"
2525
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
2626
)
2727

@@ -33,7 +33,7 @@ type ArangoPlatformServiceStatusRelease struct {
3333
}
3434

3535
type ArangoPlatformServiceStatusReleaseInfo struct {
36-
FirstDeployed *meta.Time `json:"first_deployed,omitempty"`
37-
LastDeployed *meta.Time `json:"last_deployed,omitempty"`
38-
Status release.Status `json:"status,omitempty"`
36+
FirstDeployed *meta.Time `json:"first_deployed,omitempty"`
37+
LastDeployed *meta.Time `json:"last_deployed,omitempty"`
38+
Status helmRelease.Status `json:"status,omitempty"`
3939
}

pkg/apis/platform/v1beta1/service_status_release.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
package v1beta1
2222

2323
import (
24-
"helm.sh/helm/v3/pkg/release"
24+
helmRelease "helm.sh/helm/v3/pkg/release"
2525
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
2626
)
2727

@@ -33,7 +33,7 @@ type ArangoPlatformServiceStatusRelease struct {
3333
}
3434

3535
type ArangoPlatformServiceStatusReleaseInfo struct {
36-
FirstDeployed *meta.Time `json:"first_deployed,omitempty"`
37-
LastDeployed *meta.Time `json:"last_deployed,omitempty"`
38-
Status release.Status `json:"status,omitempty"`
36+
FirstDeployed *meta.Time `json:"first_deployed,omitempty"`
37+
LastDeployed *meta.Time `json:"last_deployed,omitempty"`
38+
Status helmRelease.Status `json:"status,omitempty"`
3939
}

pkg/handlers/platform/service/handler.go

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"time"
2626

2727
"helm.sh/helm/v3/pkg/action"
28+
helmRelease "helm.sh/helm/v3/pkg/release"
2829
apiErrors "k8s.io/apimachinery/pkg/api/errors"
2930
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
3031
"k8s.io/client-go/kubernetes"
@@ -413,7 +414,35 @@ func (h *handler) HandleRelease(ctx context.Context, item operation.Item, extens
413414
return true, operator.Reconcile("Release Upgraded")
414415
}
415416

416-
return false, nil
417+
switch status.Release.Info.Status {
418+
case helmRelease.StatusDeployed:
419+
return false, nil
420+
421+
case helmRelease.StatusFailed:
422+
// Try to upgrade
423+
logger.WrapObj(item).Info("Upgrade Helm Release")
424+
425+
_, err = h.helm.Upgrade(ctx, extension.GetName(), helm.Chart(status.ChartInfo.Definition), helm.Values(status.Values), func(in *action.Upgrade) {
426+
in.Namespace = extension.GetNamespace()
427+
428+
in.Labels = labels.GetLabels(status.Deployment.GetName(), status.Chart.GetName())
429+
430+
in.Timeout = 20 * time.Minute
431+
})
432+
if err != nil {
433+
h.eventRecorder.Warning(extension, "Release Upgrade Failed", "Release upgrade failed: %s", err.Error())
434+
435+
return false, err
436+
}
437+
438+
status.Release = extractReleaseStatus(release, expectedChecksum)
439+
440+
h.eventRecorder.Normal(extension, "Release Upgraded", "Release upgraded with version %d on chart %s (%s)", status.Release.Version, status.ChartInfo.Details.Name, status.ChartInfo.Details.Version)
441+
442+
return true, operator.Reconcile("Release Upgraded")
443+
}
444+
445+
return false, operator.Stop("Invalid release status: %s", status.Release.Info.Status)
417446
}
418447

419448
func extractReleaseStatus(in *helm.Release, hash string) *platformApi.ArangoPlatformServiceStatusRelease {

pkg/util/k8sutil/helm/types.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
"time"
2626

2727
"helm.sh/helm/v3/pkg/chart"
28-
"helm.sh/helm/v3/pkg/release"
28+
helmRelease "helm.sh/helm/v3/pkg/release"
2929
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
3030
"k8s.io/apimachinery/pkg/runtime"
3131
"k8s.io/apimachinery/pkg/runtime/schema"
@@ -34,7 +34,7 @@ import (
3434
"github.com/arangodb/kube-arangodb/pkg/util/errors"
3535
)
3636

37-
func fromHelmRelease(in *release.Release) (Release, error) {
37+
func fromHelmRelease(in *helmRelease.Release) (Release, error) {
3838
var r Release
3939

4040
if in == nil {
@@ -88,7 +88,7 @@ func fromHelmReleaseChartMetadata(in *chart.Metadata) *ReleaseChartMetadata {
8888
return &r
8989
}
9090

91-
func fromHelmReleaseInfo(in *release.Info) (ReleaseInfo, error) {
91+
func fromHelmReleaseInfo(in *helmRelease.Info) (ReleaseInfo, error) {
9292
var r ReleaseInfo
9393

9494
if in == nil {
@@ -191,13 +191,13 @@ func (r *ReleaseChartMetadata) GetVersion() string {
191191
}
192192

193193
type ReleaseInfo struct {
194-
FirstDeployed time.Time `json:"first_deployed,omitempty"`
195-
LastDeployed time.Time `json:"last_deployed,omitempty"`
196-
Deleted time.Time `json:"deleted,omitempty"`
197-
Description string `json:"description,omitempty"`
198-
Status release.Status `json:"status,omitempty"`
199-
Notes string `json:"notes,omitempty"`
200-
Resources Resources `json:"resources,omitempty"`
194+
FirstDeployed time.Time `json:"first_deployed,omitempty"`
195+
LastDeployed time.Time `json:"last_deployed,omitempty"`
196+
Deleted time.Time `json:"deleted,omitempty"`
197+
Description string `json:"description,omitempty"`
198+
Status helmRelease.Status `json:"status,omitempty"`
199+
Notes string `json:"notes,omitempty"`
200+
Resources Resources `json:"resources,omitempty"`
201201
}
202202

203203
type Resources []Resource

0 commit comments

Comments
 (0)