From 621f9470cca84a5e5e73d407447e70e3005b4b02 Mon Sep 17 00:00:00 2001 From: sethiyash Date: Wed, 3 Jan 2024 13:46:51 +0530 Subject: [PATCH] Using name namespace methods and refactor imports Signed-off-by: sethiyash --- cmd/controller/run.go | 8 +++---- pkg/app/app.go | 1 - pkg/app/app_deploy.go | 1 + pkg/app/app_fetch.go | 1 - pkg/app/app_reconcile.go | 22 +++++++++---------- pkg/app/app_template.go | 3 ++- pkg/app/crd_app.go | 11 +++++----- pkg/metrics/metrics.go | 1 + pkg/packageinstall/app.go | 5 +++-- pkg/packageinstall/packageinstall.go | 8 +++---- .../packageinstall_deletion_test.go | 2 +- .../packageinstall_downgrade_test.go | 2 +- pkg/packageinstall/packageinstall_test.go | 2 +- pkg/packageinstall/reconciler.go | 1 + pkg/pkgrepository/app.go | 1 - pkg/pkgrepository/app_deploy.go | 1 + pkg/pkgrepository/app_factory.go | 2 +- pkg/pkgrepository/app_reconcile.go | 14 ++++++------ 18 files changed, 43 insertions(+), 43 deletions(-) diff --git a/cmd/controller/run.go b/cmd/controller/run.go index 243552c53..4ed897a27 100644 --- a/cmd/controller/run.go +++ b/cmd/controller/run.go @@ -189,6 +189,7 @@ func Run(opts Options, runLog logr.Logger) error { // initialize cluster access once - it contains a service account token cache which should be only setup once. kubeconf := kubeconfig.NewKubeconfig(coreClient, runLog) compInfo := componentinfo.NewComponentInfo(coreClient, kubeconf, Version) + appMetrics := &metrics.Metrics{ReconcileCountMetrics: countMetrics, ReconcileTimeMetrics: reconcileTimeMetrics} cacheFolderApps := memdir.NewTmpDir("cache-appcr") err = cacheFolderApps.Create() @@ -200,7 +201,7 @@ func Run(opts Options, runLog logr.Logger) error { CoreClient: coreClient, AppClient: kcClient, KcConfig: kcConfig, - AppMetrics: &metrics.Metrics{ReconcileCountMetrics: countMetrics, ReconcileTimeMetrics: reconcileTimeMetrics}, + AppMetrics: appMetrics, CmdRunner: sidecarCmdExec, Kubeconf: kubeconf, CompInfo: compInfo, @@ -231,8 +232,7 @@ func Run(opts Options, runLog logr.Logger) error { kcClient, opts.PackagingGlobalNS, runLog.WithName("handler")) reconciler := pkginstall.NewReconciler(kcClient, pkgClient, coreClient, pkgToPkgInstallHandler, - runLog.WithName("pkgi"), compInfo, kcConfig, &metrics.Metrics{ReconcileCountMetrics: countMetrics, - ReconcileTimeMetrics: reconcileTimeMetrics}) + runLog.WithName("pkgi"), compInfo, kcConfig, appMetrics) ctrl, err := controller.New("pkgi", mgr, controller.Options{ Reconciler: reconciler, @@ -259,7 +259,7 @@ func Run(opts Options, runLog logr.Logger) error { CoreClient: coreClient, AppClient: kcClient, KcConfig: kcConfig, - AppMetrics: &metrics.Metrics{ReconcileCountMetrics: countMetrics, ReconcileTimeMetrics: reconcileTimeMetrics}, + AppMetrics: appMetrics, CmdRunner: sidecarCmdExec, Kubeconf: kubeconf, CacheFolder: cacheFolderPkgRepoApps, diff --git a/pkg/app/app.go b/pkg/app/app.go index f68f8d7a3..23d626fd5 100644 --- a/pkg/app/app.go +++ b/pkg/app/app.go @@ -59,7 +59,6 @@ type App struct { opts Opts appMetrics *metrics.Metrics - isFirstReconcile bool pendingStatusUpdate bool flushAllStatusUpdates bool metadata *deploy.Meta diff --git a/pkg/app/app_deploy.go b/pkg/app/app_deploy.go index 33e0dea42..9bc6afcc7 100644 --- a/pkg/app/app_deploy.go +++ b/pkg/app/app_deploy.go @@ -5,6 +5,7 @@ package app import ( "fmt" + "github.com/vmware-tanzu/carvel-kapp-controller/pkg/apis/kappctrl/v1alpha1" ctldep "github.com/vmware-tanzu/carvel-kapp-controller/pkg/deploy" "github.com/vmware-tanzu/carvel-kapp-controller/pkg/exec" diff --git a/pkg/app/app_fetch.go b/pkg/app/app_fetch.go index 07a12f0e1..fd0ca8eab 100644 --- a/pkg/app/app_fetch.go +++ b/pkg/app/app_fetch.go @@ -20,7 +20,6 @@ const ( ) func (a *App) fetch(dstPath string) (string, exec.CmdRunResult) { - // fetch init stage if len(a.app.Spec.Fetch) == 0 { return "", exec.NewCmdRunResultWithErr(fmt.Errorf("Expected at least one fetch option")) } diff --git a/pkg/app/app_reconcile.go b/pkg/app/app_reconcile.go index 260acf856..d80809f48 100644 --- a/pkg/app/app_reconcile.go +++ b/pkg/app/app_reconcile.go @@ -106,9 +106,9 @@ func (a *App) reconcileDeploy() error { func (a *App) reconcileFetchTemplateDeploy() exec.CmdRunResult { reconcileStartTime := time.Now() - a.isFirstReconcile = a.appMetrics.ReconcileCountMetrics.GetReconcileAttemptCounterValue("app", a.app.Name, a.app.Namespace) == 1 + a.appMetrics.IsFirstReconcile = a.appMetrics.ReconcileCountMetrics.GetReconcileAttemptCounterValue(appResourceType, a.Name(), a.Namespace()) == 1 defer func() { - a.appMetrics.ReconcileTimeMetrics.RegisterOverallTime(appResourceType, a.app.Name, a.app.Namespace, a.isFirstReconcile, + a.appMetrics.ReconcileTimeMetrics.RegisterOverallTime(appResourceType, a.Name(), a.Namespace(), a.appMetrics.IsFirstReconcile, time.Since(reconcileStartTime)) }() @@ -138,7 +138,7 @@ func (a *App) reconcileFetchTemplateDeploy() exec.CmdRunResult { UpdatedAt: metav1.NewTime(time.Now().UTC()), } - a.appMetrics.ReconcileTimeMetrics.RegisterFetchTime(appResourceType, a.app.Name, a.app.Namespace, a.isFirstReconcile, + a.appMetrics.ReconcileTimeMetrics.RegisterFetchTime(appResourceType, a.Name(), a.Namespace(), a.appMetrics.IsFirstReconcile, a.app.Status.Fetch.UpdatedAt.Sub(a.app.Status.Fetch.StartedAt.Time)) err := a.updateStatus("marking fetch completed") @@ -162,7 +162,7 @@ func (a *App) reconcileFetchTemplateDeploy() exec.CmdRunResult { UpdatedAt: metav1.NewTime(time.Now().UTC()), } - a.appMetrics.ReconcileTimeMetrics.RegisterTemplateTime(appResourceType, a.app.Name, a.app.Namespace, a.isFirstReconcile, + a.appMetrics.ReconcileTimeMetrics.RegisterTemplateTime(appResourceType, a.Name(), a.Namespace(), a.appMetrics.IsFirstReconcile, a.app.Status.Template.UpdatedAt.Sub(templateStartTime)) err = a.updateStatus("marking template completed") @@ -213,7 +213,7 @@ func (a *App) updateLastDeploy(result exec.CmdRunResult) exec.CmdRunResult { }, } - a.appMetrics.ReconcileTimeMetrics.RegisterDeployTime(appResourceType, a.app.Name, a.app.Namespace, a.isFirstReconcile, + a.appMetrics.ReconcileTimeMetrics.RegisterDeployTime(appResourceType, a.Name(), a.Namespace(), a.appMetrics.IsFirstReconcile, a.Status().Deploy.UpdatedAt.Sub(a.Status().Deploy.StartedAt.Time)) return result @@ -267,7 +267,7 @@ func (a *App) setReconciling() { Status: corev1.ConditionTrue, }) - a.appMetrics.ReconcileCountMetrics.RegisterReconcileAttempt(appResourceType, a.app.Name, a.app.Namespace) + a.appMetrics.ReconcileCountMetrics.RegisterReconcileAttempt(appResourceType, a.Name(), a.Namespace()) a.app.Status.FriendlyDescription = "Reconciling" } @@ -283,7 +283,7 @@ func (a *App) setReconcileCompleted(result exec.CmdRunResult) { a.app.Status.ConsecutiveReconcileFailures++ a.app.Status.ConsecutiveReconcileSuccesses = 0 a.app.Status.FriendlyDescription = fmt.Sprintf("Reconcile failed: %s", result.ErrorStr()) - a.appMetrics.ReconcileCountMetrics.RegisterReconcileFailure(appResourceType, a.app.Name, a.app.Namespace) + a.appMetrics.ReconcileCountMetrics.RegisterReconcileFailure(appResourceType, a.Name(), a.Namespace()) a.setUsefulErrorMessage(result) } else { a.app.Status.Conditions = append(a.app.Status.Conditions, v1alpha1.Condition{ @@ -294,7 +294,7 @@ func (a *App) setReconcileCompleted(result exec.CmdRunResult) { a.app.Status.ConsecutiveReconcileSuccesses++ a.app.Status.ConsecutiveReconcileFailures = 0 a.app.Status.FriendlyDescription = "Reconcile succeeded" - a.appMetrics.ReconcileCountMetrics.RegisterReconcileSuccess(appResourceType, a.app.Name, a.app.Namespace) + a.appMetrics.ReconcileCountMetrics.RegisterReconcileSuccess(appResourceType, a.Name(), a.Namespace()) a.app.Status.UsefulErrorMessage = "" } } @@ -307,7 +307,7 @@ func (a *App) setDeleting() { Status: corev1.ConditionTrue, }) - a.appMetrics.ReconcileCountMetrics.RegisterReconcileDeleteAttempt(appResourceType, a.app.Name, a.app.Namespace) + a.appMetrics.ReconcileCountMetrics.RegisterReconcileDeleteAttempt(appResourceType, a.Name(), a.Namespace()) a.app.Status.FriendlyDescription = "Deleting" } @@ -323,10 +323,10 @@ func (a *App) setDeleteCompleted(result exec.CmdRunResult) { a.app.Status.ConsecutiveReconcileFailures++ a.app.Status.ConsecutiveReconcileSuccesses = 0 a.app.Status.FriendlyDescription = fmt.Sprintf("Delete failed: %s", result.ErrorStr()) - a.appMetrics.ReconcileCountMetrics.RegisterReconcileDeleteFailed(appResourceType, a.app.Name, a.app.Namespace) + a.appMetrics.ReconcileCountMetrics.RegisterReconcileDeleteFailed(appResourceType, a.Name(), a.Namespace()) a.setUsefulErrorMessage(result) } else { - a.appMetrics.ReconcileCountMetrics.DeleteMetrics(appResourceType, a.app.Name, a.app.Namespace) + a.appMetrics.ReconcileCountMetrics.DeleteMetrics(appResourceType, a.Name(), a.Namespace()) } } diff --git a/pkg/app/app_template.go b/pkg/app/app_template.go index 6c296a694..91b335aa5 100644 --- a/pkg/app/app_template.go +++ b/pkg/app/app_template.go @@ -5,10 +5,11 @@ package app import ( "fmt" + "strings" + "github.com/vmware-tanzu/carvel-kapp-controller/pkg/apis/kappctrl/v1alpha1" "github.com/vmware-tanzu/carvel-kapp-controller/pkg/exec" ctltpl "github.com/vmware-tanzu/carvel-kapp-controller/pkg/template" - "strings" ) func (a *App) template(dirPath string) exec.CmdRunResult { diff --git a/pkg/app/crd_app.go b/pkg/app/crd_app.go index 20d1cf91e..0b3fcbe7d 100644 --- a/pkg/app/crd_app.go +++ b/pkg/app/crd_app.go @@ -21,11 +21,10 @@ import ( ) type CRDApp struct { - app *App - appModel *kcv1alpha1.App - log logr.Logger - countMetrics *metrics.ReconcileCountMetrics - appClient kcclient.Interface + app *App + appModel *kcv1alpha1.App + log logr.Logger + appClient kcclient.Interface } // NewCRDApp creates new CRD app @@ -33,7 +32,7 @@ func NewCRDApp(appModel *kcv1alpha1.App, log logr.Logger, appMetrics *metrics.Me templateFactory template.Factory, deployFactory deploy.Factory, compInfo ComponentInfo, opts Opts) *CRDApp { - crdApp := &CRDApp{appModel: appModel, log: log, countMetrics: appMetrics.ReconcileCountMetrics, appClient: appClient} + crdApp := &CRDApp{appModel: appModel, log: log, appClient: appClient} crdApp.app = NewApp(*appModel, Hooks{ BlockDeletion: crdApp.blockDeletion, diff --git a/pkg/metrics/metrics.go b/pkg/metrics/metrics.go index 7fbf6c75a..4434534e9 100644 --- a/pkg/metrics/metrics.go +++ b/pkg/metrics/metrics.go @@ -7,4 +7,5 @@ package metrics type Metrics struct { *ReconcileCountMetrics *ReconcileTimeMetrics + IsFirstReconcile bool } diff --git a/pkg/packageinstall/app.go b/pkg/packageinstall/app.go index 23ce2c658..23ce547d7 100644 --- a/pkg/packageinstall/app.go +++ b/pkg/packageinstall/app.go @@ -5,6 +5,9 @@ package packageinstall import ( "fmt" + "sort" + "strings" + "github.com/vmware-tanzu/carvel-kapp-controller/pkg/apis/kappctrl/v1alpha1" kcv1alpha1 "github.com/vmware-tanzu/carvel-kapp-controller/pkg/apis/kappctrl/v1alpha1" pkgingv1alpha1 "github.com/vmware-tanzu/carvel-kapp-controller/pkg/apis/packaging/v1alpha1" @@ -12,8 +15,6 @@ import ( "github.com/vmware-tanzu/carvel-kapp-controller/pkg/client/clientset/versioned/scheme" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" - "sort" - "strings" ) const ( diff --git a/pkg/packageinstall/packageinstall.go b/pkg/packageinstall/packageinstall.go index 0b7b6cd5c..2ae9614fb 100644 --- a/pkg/packageinstall/packageinstall.go +++ b/pkg/packageinstall/packageinstall.go @@ -6,7 +6,6 @@ package packageinstall import ( "context" "fmt" - "github.com/vmware-tanzu/carvel-kapp-controller/pkg/metrics" "time" "github.com/go-logr/logr" @@ -18,6 +17,7 @@ import ( pkgclient "github.com/vmware-tanzu/carvel-kapp-controller/pkg/apiserver/client/clientset/versioned" kcclient "github.com/vmware-tanzu/carvel-kapp-controller/pkg/client/clientset/versioned" "github.com/vmware-tanzu/carvel-kapp-controller/pkg/client/clientset/versioned/scheme" + "github.com/vmware-tanzu/carvel-kapp-controller/pkg/metrics" "github.com/vmware-tanzu/carvel-kapp-controller/pkg/reconciler" "github.com/vmware-tanzu/carvel-vendir/pkg/vendir/versions" verv1alpha1 "github.com/vmware-tanzu/carvel-vendir/pkg/vendir/versions/v1alpha1" @@ -58,8 +58,6 @@ type PackageInstallCR struct { opts Opts pkgMetrics *metrics.Metrics - - firstReconcile bool } // nolint: revive @@ -112,10 +110,10 @@ func (pi *PackageInstallCR) reconcile(modelStatus *reconciler.Status) (reconcile pi.pkgMetrics.ReconcileCountMetrics.RegisterReconcileAttempt(packageInstallType, pi.model.Name, pi.model.Namespace) reconcileStartTime := time.Now() - pi.firstReconcile = pi.pkgMetrics.ReconcileCountMetrics.GetReconcileAttemptCounterValue("pkgi", pi.model.Name, pi.model.Namespace) == 1 + pi.pkgMetrics.IsFirstReconcile = pi.pkgMetrics.ReconcileCountMetrics.GetReconcileAttemptCounterValue(packageInstallType, pi.model.Name, pi.model.Namespace) == 1 defer func() { pi.pkgMetrics.ReconcileTimeMetrics.RegisterOverallTime(packageInstallType, pi.model.Name, pi.model.Namespace, - pi.firstReconcile, time.Since(reconcileStartTime)) + pi.pkgMetrics.IsFirstReconcile, time.Since(reconcileStartTime)) }() err := pi.blockDeletion() diff --git a/pkg/packageinstall/packageinstall_deletion_test.go b/pkg/packageinstall/packageinstall_deletion_test.go index 1e574adcc..3545808fd 100644 --- a/pkg/packageinstall/packageinstall_deletion_test.go +++ b/pkg/packageinstall/packageinstall_deletion_test.go @@ -4,7 +4,6 @@ package packageinstall import ( - "github.com/vmware-tanzu/carvel-kapp-controller/pkg/metrics" "testing" "github.com/k14s/semver/v4" @@ -13,6 +12,7 @@ import ( pkgingv1alpha1 "github.com/vmware-tanzu/carvel-kapp-controller/pkg/apis/packaging/v1alpha1" fakeapiserver "github.com/vmware-tanzu/carvel-kapp-controller/pkg/apiserver/client/clientset/versioned/fake" fakekappctrl "github.com/vmware-tanzu/carvel-kapp-controller/pkg/client/clientset/versioned/fake" + "github.com/vmware-tanzu/carvel-kapp-controller/pkg/metrics" versions "github.com/vmware-tanzu/carvel-vendir/pkg/vendir/versions/v1alpha1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes/fake" diff --git a/pkg/packageinstall/packageinstall_downgrade_test.go b/pkg/packageinstall/packageinstall_downgrade_test.go index c3a76ce24..fa6a089ef 100644 --- a/pkg/packageinstall/packageinstall_downgrade_test.go +++ b/pkg/packageinstall/packageinstall_downgrade_test.go @@ -4,7 +4,6 @@ package packageinstall import ( - "github.com/vmware-tanzu/carvel-kapp-controller/pkg/metrics" "testing" "github.com/k14s/semver/v4" @@ -15,6 +14,7 @@ import ( datapkgingv1alpha1 "github.com/vmware-tanzu/carvel-kapp-controller/pkg/apiserver/apis/datapackaging/v1alpha1" fakeapiserver "github.com/vmware-tanzu/carvel-kapp-controller/pkg/apiserver/client/clientset/versioned/fake" fakekappctrl "github.com/vmware-tanzu/carvel-kapp-controller/pkg/client/clientset/versioned/fake" + "github.com/vmware-tanzu/carvel-kapp-controller/pkg/metrics" versions "github.com/vmware-tanzu/carvel-vendir/pkg/vendir/versions/v1alpha1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/schema" diff --git a/pkg/packageinstall/packageinstall_test.go b/pkg/packageinstall/packageinstall_test.go index c217c5c99..69677d6e7 100644 --- a/pkg/packageinstall/packageinstall_test.go +++ b/pkg/packageinstall/packageinstall_test.go @@ -5,7 +5,6 @@ package packageinstall import ( "fmt" - "github.com/vmware-tanzu/carvel-kapp-controller/pkg/metrics" "reflect" "testing" @@ -17,6 +16,7 @@ import ( datapkgingv1alpha1 "github.com/vmware-tanzu/carvel-kapp-controller/pkg/apiserver/apis/datapackaging/v1alpha1" fakeapiserver "github.com/vmware-tanzu/carvel-kapp-controller/pkg/apiserver/client/clientset/versioned/fake" fakekappctrl "github.com/vmware-tanzu/carvel-kapp-controller/pkg/client/clientset/versioned/fake" + "github.com/vmware-tanzu/carvel-kapp-controller/pkg/metrics" versions "github.com/vmware-tanzu/carvel-vendir/pkg/vendir/versions/v1alpha1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/packageinstall/reconciler.go b/pkg/packageinstall/reconciler.go index 99637679b..aacf59d7d 100644 --- a/pkg/packageinstall/reconciler.go +++ b/pkg/packageinstall/reconciler.go @@ -6,6 +6,7 @@ package packageinstall import ( "context" "fmt" + "github.com/go-logr/logr" kappctrlv1alpha1 "github.com/vmware-tanzu/carvel-kapp-controller/pkg/apis/kappctrl/v1alpha1" pkgingv1alpha1 "github.com/vmware-tanzu/carvel-kapp-controller/pkg/apis/packaging/v1alpha1" diff --git a/pkg/pkgrepository/app.go b/pkg/pkgrepository/app.go index 3f0bc1c8c..e4304821a 100644 --- a/pkg/pkgrepository/app.go +++ b/pkg/pkgrepository/app.go @@ -34,7 +34,6 @@ type App struct { log logr.Logger - isFirstReconcile bool pendingStatusUpdate bool flushAllStatusUpdates bool } diff --git a/pkg/pkgrepository/app_deploy.go b/pkg/pkgrepository/app_deploy.go index 7b8b236e4..1f5bc6131 100644 --- a/pkg/pkgrepository/app_deploy.go +++ b/pkg/pkgrepository/app_deploy.go @@ -5,6 +5,7 @@ package pkgrepository import ( "fmt" + "github.com/vmware-tanzu/carvel-kapp-controller/pkg/apis/kappctrl/v1alpha1" ctldep "github.com/vmware-tanzu/carvel-kapp-controller/pkg/deploy" "github.com/vmware-tanzu/carvel-kapp-controller/pkg/exec" diff --git a/pkg/pkgrepository/app_factory.go b/pkg/pkgrepository/app_factory.go index 198ce4fed..930d29cf3 100644 --- a/pkg/pkgrepository/app_factory.go +++ b/pkg/pkgrepository/app_factory.go @@ -4,7 +4,6 @@ package pkgrepository import ( - "github.com/vmware-tanzu/carvel-kapp-controller/pkg/metrics" "path/filepath" "github.com/go-logr/logr" @@ -17,6 +16,7 @@ import ( "github.com/vmware-tanzu/carvel-kapp-controller/pkg/fetch" "github.com/vmware-tanzu/carvel-kapp-controller/pkg/kubeconfig" "github.com/vmware-tanzu/carvel-kapp-controller/pkg/memdir" + "github.com/vmware-tanzu/carvel-kapp-controller/pkg/metrics" "github.com/vmware-tanzu/carvel-kapp-controller/pkg/template" "k8s.io/client-go/kubernetes" ) diff --git a/pkg/pkgrepository/app_reconcile.go b/pkg/pkgrepository/app_reconcile.go index 5386fd428..3013436f5 100644 --- a/pkg/pkgrepository/app_reconcile.go +++ b/pkg/pkgrepository/app_reconcile.go @@ -23,7 +23,7 @@ func (a *App) Reconcile(force bool) (reconcile.Result, error) { var err error - a.appMetrics.ReconcileCountMetrics.InitMetrics("pkgr", a.Name(), a.Namespace()) + a.appMetrics.ReconcileCountMetrics.InitMetrics(packageRepoResourceType, a.Name(), a.Namespace()) switch { case a.app.Spec.Paused: @@ -95,9 +95,9 @@ func (a *App) reconcileDeploy() error { func (a *App) reconcileFetchTemplateDeploy() exec.CmdRunResult { reconcileStartTime := time.Now() - a.isFirstReconcile = a.appMetrics.ReconcileCountMetrics.GetReconcileAttemptCounterValue(packageRepoResourceType, a.app.Name, a.app.Namespace) == 1 + a.appMetrics.IsFirstReconcile = a.appMetrics.ReconcileCountMetrics.GetReconcileAttemptCounterValue(packageRepoResourceType, a.Name(), a.Namespace()) == 1 defer func() { - a.appMetrics.ReconcileTimeMetrics.RegisterOverallTime(packageRepoResourceType, a.app.Name, a.app.Namespace, a.isFirstReconcile, + a.appMetrics.ReconcileTimeMetrics.RegisterOverallTime(packageRepoResourceType, a.Name(), a.Namespace(), a.appMetrics.IsFirstReconcile, time.Since(reconcileStartTime)) }() @@ -127,7 +127,7 @@ func (a *App) reconcileFetchTemplateDeploy() exec.CmdRunResult { UpdatedAt: metav1.NewTime(time.Now().UTC()), } - a.appMetrics.ReconcileTimeMetrics.RegisterFetchTime(packageRepoResourceType, a.app.Name, a.app.Namespace, a.isFirstReconcile, + a.appMetrics.ReconcileTimeMetrics.RegisterFetchTime(packageRepoResourceType, a.Name(), a.Namespace(), a.appMetrics.IsFirstReconcile, a.app.Status.Fetch.UpdatedAt.Sub(a.app.Status.Fetch.StartedAt.Time)) err := a.updateStatus("marking fetch completed") @@ -151,7 +151,7 @@ func (a *App) reconcileFetchTemplateDeploy() exec.CmdRunResult { UpdatedAt: metav1.NewTime(time.Now().UTC()), } - a.appMetrics.ReconcileTimeMetrics.RegisterTemplateTime(packageRepoResourceType, a.app.Name, a.app.Namespace, a.isFirstReconcile, + a.appMetrics.ReconcileTimeMetrics.RegisterTemplateTime(packageRepoResourceType, a.Name(), a.Namespace(), a.appMetrics.IsFirstReconcile, a.app.Status.Template.UpdatedAt.Sub(templateStartTime)) err = a.updateStatus("marking template completed") @@ -181,7 +181,7 @@ func (a *App) updateLastDeploy(result exec.CmdRunResult) exec.CmdRunResult { UpdatedAt: metav1.NewTime(time.Now().UTC()), } - a.appMetrics.ReconcileTimeMetrics.RegisterDeployTime(packageRepoResourceType, a.app.Name, a.app.Namespace, a.isFirstReconcile, + a.appMetrics.ReconcileTimeMetrics.RegisterDeployTime(packageRepoResourceType, a.Name(), a.Namespace(), a.appMetrics.IsFirstReconcile, a.Status().Deploy.UpdatedAt.Sub(a.Status().Deploy.StartedAt.Time)) a.updateStatus("marking last deploy") @@ -215,7 +215,7 @@ func (a *App) setReconciling() { Status: corev1.ConditionTrue, }) - a.appMetrics.ReconcileCountMetrics.RegisterReconcileAttempt("pkgr", a.app.Name, a.app.Namespace) + a.appMetrics.ReconcileCountMetrics.RegisterReconcileAttempt(packageRepoResourceType, a.Name(), a.Namespace()) a.app.Status.FriendlyDescription = "Reconciling" }