From 4596aac04360c3b2967bde81e4d9d60564ca7ac2 Mon Sep 17 00:00:00 2001 From: Somefive Date: Thu, 2 Mar 2023 14:49:48 +0800 Subject: [PATCH] Feat: upgrade cluster-gateway to use v1.8.0-alpha.3 & fix time metrics bug (#5593) Signed-off-by: Somefive --- charts/vela-core/README.md | 2 +- charts/vela-core/values.yaml | 2 +- .../v1alpha2/application/application_controller.go | 4 +++- pkg/controller/core.oam.dev/v1alpha2/application/apply.go | 4 +++- .../core.oam.dev/v1alpha2/application/generator.go | 4 +++- .../core.oam.dev/v1alpha2/application/revision.go | 8 ++++++-- 6 files changed, 17 insertions(+), 7 deletions(-) diff --git a/charts/vela-core/README.md b/charts/vela-core/README.md index c1e3dbcc4..a3b5d5faa 100644 --- a/charts/vela-core/README.md +++ b/charts/vela-core/README.md @@ -112,7 +112,7 @@ helm install --create-namespace -n vela-system kubevela kubevela/vela-core --wai | `multicluster.clusterGateway.replicaCount` | ClusterGateway replica count | `1` | | `multicluster.clusterGateway.port` | ClusterGateway port | `9443` | | `multicluster.clusterGateway.image.repository` | ClusterGateway image repository | `oamdev/cluster-gateway` | -| `multicluster.clusterGateway.image.tag` | ClusterGateway image tag | `v1.7.0` | +| `multicluster.clusterGateway.image.tag` | ClusterGateway image tag | `v1.8.0-alpha.3` | | `multicluster.clusterGateway.image.pullPolicy` | ClusterGateway image pull policy | `IfNotPresent` | | `multicluster.clusterGateway.resources.limits.cpu` | ClusterGateway cpu limit | `100m` | | `multicluster.clusterGateway.resources.limits.memory` | ClusterGateway memory limit | `200Mi` | diff --git a/charts/vela-core/values.yaml b/charts/vela-core/values.yaml index 746668294..3105736c7 100644 --- a/charts/vela-core/values.yaml +++ b/charts/vela-core/values.yaml @@ -150,7 +150,7 @@ multicluster: port: 9443 image: repository: oamdev/cluster-gateway - tag: v1.7.0 + tag: v1.8.0-alpha.3 pullPolicy: IfNotPresent resources: limits: diff --git a/pkg/controller/core.oam.dev/v1alpha2/application/application_controller.go b/pkg/controller/core.oam.dev/v1alpha2/application/application_controller.go index 08437f40b..d35cb6056 100644 --- a/pkg/controller/core.oam.dev/v1alpha2/application/application_controller.go +++ b/pkg/controller/core.oam.dev/v1alpha2/application/application_controller.go @@ -290,7 +290,9 @@ func (r *Reconciler) stateKeep(logCtx monitorContext.Context, handler *AppHandle return } t := time.Now() - defer metrics.AppReconcileStageDurationHistogram.WithLabelValues("state-keep").Observe(time.Since(t).Seconds()) + defer func() { + metrics.AppReconcileStageDurationHistogram.WithLabelValues("state-keep").Observe(time.Since(t).Seconds()) + }() if err := handler.resourceKeeper.StateKeep(logCtx); err != nil { logCtx.Error(err, "Failed to run prevent-configuration-drift") r.Recorder.Event(app, event.Warning(velatypes.ReasonFailedStateKeep, err)) diff --git a/pkg/controller/core.oam.dev/v1alpha2/application/apply.go b/pkg/controller/core.oam.dev/v1alpha2/application/apply.go index fbcf2ea84..3f939ca77 100644 --- a/pkg/controller/core.oam.dev/v1alpha2/application/apply.go +++ b/pkg/controller/core.oam.dev/v1alpha2/application/apply.go @@ -413,7 +413,9 @@ type garbageCollectFunc func(ctx context.Context, h *AppHandler) error // - clean up legacy component revisions func garbageCollection(ctx context.Context, h *AppHandler) error { t := time.Now() - defer metrics.AppReconcileStageDurationHistogram.WithLabelValues("gc-rev").Observe(time.Since(t).Seconds()) + defer func() { + metrics.AppReconcileStageDurationHistogram.WithLabelValues("gc-rev").Observe(time.Since(t).Seconds()) + }() collectFuncs := []garbageCollectFunc{ garbageCollectFunc(cleanUpApplicationRevision), garbageCollectFunc(cleanUpWorkflowComponentRevision), diff --git a/pkg/controller/core.oam.dev/v1alpha2/application/generator.go b/pkg/controller/core.oam.dev/v1alpha2/application/generator.go index 8e2d392d2..04242e565 100644 --- a/pkg/controller/core.oam.dev/v1alpha2/application/generator.go +++ b/pkg/controller/core.oam.dev/v1alpha2/application/generator.go @@ -89,7 +89,9 @@ func (h *AppHandler) GenerateApplicationSteps(ctx monitorContext.Context, appRev *v1beta1.ApplicationRevision) (*wfTypes.WorkflowInstance, []wfTypes.TaskRunner, error) { t := time.Now() - defer metrics.AppReconcileStageDurationHistogram.WithLabelValues("generate-app-steps").Observe(time.Since(t).Seconds()) + defer func() { + metrics.AppReconcileStageDurationHistogram.WithLabelValues("generate-app-steps").Observe(time.Since(t).Seconds()) + }() appLabels := map[string]string{ oam.LabelAppName: app.Name, diff --git a/pkg/controller/core.oam.dev/v1alpha2/application/revision.go b/pkg/controller/core.oam.dev/v1alpha2/application/revision.go index c46864755..717322c13 100644 --- a/pkg/controller/core.oam.dev/v1alpha2/application/revision.go +++ b/pkg/controller/core.oam.dev/v1alpha2/application/revision.go @@ -908,7 +908,9 @@ func cleanUpApplicationRevision(ctx context.Context, h *AppHandler) error { return nil } t := time.Now() - defer metrics.AppReconcileStageDurationHistogram.WithLabelValues("gc-rev.apprev").Observe(time.Since(t).Seconds()) + defer func() { + metrics.AppReconcileStageDurationHistogram.WithLabelValues("gc-rev.apprev").Observe(time.Since(t).Seconds()) + }() sortedRevision, err := GetSortedAppRevisions(ctx, h.r.Client, h.app.Name, h.app.Namespace) if err != nil { return err @@ -962,7 +964,9 @@ func cleanUpWorkflowComponentRevision(ctx context.Context, h *AppHandler) error return nil } t := time.Now() - defer metrics.AppReconcileStageDurationHistogram.WithLabelValues("gc-rev.comprev").Observe(time.Since(t).Seconds()) + defer func() { + metrics.AppReconcileStageDurationHistogram.WithLabelValues("gc-rev.comprev").Observe(time.Since(t).Seconds()) + }() // collect component revision in use compRevisionInUse := map[string]map[string]struct{}{} ctx = auth.ContextWithUserInfo(ctx, h.app)