diff --git a/api/v1alpha1/federatedmanagedmetric_types.go b/api/v1alpha1/federatedmanagedmetric_types.go index 9d0ee5b..a497727 100644 --- a/api/v1alpha1/federatedmanagedmetric_types.go +++ b/api/v1alpha1/federatedmanagedmetric_types.go @@ -38,8 +38,8 @@ type FederatedManagedMetricSpec struct { // Projections []Projection `json:"projections,omitempty"` // Define in what interval the query should be recorded - // +kubebuilder:default:="12h" - CheckInterval metav1.Duration `json:"checkInterval,omitempty"` + // +kubebuilder:default:="10m" + Interval metav1.Duration `json:"interval,omitempty"` FederatedClusterAccessRef FederateClusterAccessRef `json:"federateClusterAccessRef,omitempty"` } diff --git a/api/v1alpha1/federatedmetric_types.go b/api/v1alpha1/federatedmetric_types.go index ffda699..e06fc30 100644 --- a/api/v1alpha1/federatedmetric_types.go +++ b/api/v1alpha1/federatedmetric_types.go @@ -41,8 +41,8 @@ type FederatedMetricSpec struct { Projections []Projection `json:"projections,omitempty"` // Define in what interval the query should be recorded - // +kubebuilder:default:="12h" - CheckInterval metav1.Duration `json:"checkInterval,omitempty"` + // +kubebuilder:default:="10m" + Interval metav1.Duration `json:"interval,omitempty"` FederatedClusterAccessRef FederateClusterAccessRef `json:"federateClusterAccessRef,omitempty"` } diff --git a/api/v1alpha1/managedmetric_types.go b/api/v1alpha1/managedmetric_types.go index 83fa167..d5f768e 100644 --- a/api/v1alpha1/managedmetric_types.go +++ b/api/v1alpha1/managedmetric_types.go @@ -43,8 +43,8 @@ type ManagedMetricSpec struct { // +optional FieldSelector string `json:"fieldSelector,omitempty"` // Define in what interval the query should be recorded - // +kubebuilder:default:="12h" - CheckInterval metav1.Duration `json:"checkInterval,omitempty"` + // +kubebuilder:default:="10m" + Interval metav1.Duration `json:"interval,omitempty"` RemoteClusterAccessRef `json:"remoteClusterAccessRef,omitempty"` } diff --git a/api/v1alpha1/metric_types.go b/api/v1alpha1/metric_types.go index e75ad40..4ccbf95 100644 --- a/api/v1alpha1/metric_types.go +++ b/api/v1alpha1/metric_types.go @@ -52,8 +52,8 @@ type MetricSpec struct { // +optional FieldSelector string `json:"fieldSelector,omitempty"` // Define in what interval the query should be recorded - // +kubebuilder:default:="12h" - CheckInterval metav1.Duration `json:"checkInterval,omitempty"` + // +kubebuilder:default:="10m" + Interval metav1.Duration `json:"interval,omitempty"` RemoteClusterAccessRef `json:"remoteClusterAccessRef,omitempty"` diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 760c5f2..b7c761b 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -223,7 +223,7 @@ func (in *FederatedManagedMetricList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *FederatedManagedMetricSpec) DeepCopyInto(out *FederatedManagedMetricSpec) { *out = *in - out.CheckInterval = in.CheckInterval + out.Interval = in.Interval out.FederatedClusterAccessRef = in.FederatedClusterAccessRef } @@ -332,7 +332,7 @@ func (in *FederatedMetricSpec) DeepCopyInto(out *FederatedMetricSpec) { *out = make([]Projection, len(*in)) copy(*out, *in) } - out.CheckInterval = in.CheckInterval + out.Interval = in.Interval out.FederatedClusterAccessRef = in.FederatedClusterAccessRef } @@ -480,7 +480,7 @@ func (in *ManagedMetricList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ManagedMetricSpec) DeepCopyInto(out *ManagedMetricSpec) { *out = *in - out.CheckInterval = in.CheckInterval + out.Interval = in.Interval out.RemoteClusterAccessRef = in.RemoteClusterAccessRef } @@ -617,7 +617,7 @@ func (in *MetricObservation) DeepCopy() *MetricObservation { func (in *MetricSpec) DeepCopyInto(out *MetricSpec) { *out = *in out.Target = in.Target - out.CheckInterval = in.CheckInterval + out.Interval = in.Interval out.RemoteClusterAccessRef = in.RemoteClusterAccessRef if in.Projections != nil { in, out := &in.Projections, &out.Projections diff --git a/cmd/embedded/crds/metrics.cloud.sap_federatedmanagedmetrics.yaml b/cmd/embedded/crds/metrics.cloud.sap_federatedmanagedmetrics.yaml index f65dc0f..d2f1e9a 100644 --- a/cmd/embedded/crds/metrics.cloud.sap_federatedmanagedmetrics.yaml +++ b/cmd/embedded/crds/metrics.cloud.sap_federatedmanagedmetrics.yaml @@ -40,10 +40,6 @@ spec: spec: description: FederatedManagedMetricSpec defines the desired state of FederatedManagedMetric properties: - checkInterval: - default: 12h - description: Define in what interval the query should be recorded - type: string description: type: string federateClusterAccessRef: @@ -58,6 +54,10 @@ spec: description: Define fields of your object to adapt filters of the query type: string + interval: + default: 10m + description: Define in what interval the query should be recorded + type: string labelSelector: description: Define labels of your object to adapt filters of the query diff --git a/cmd/embedded/crds/metrics.cloud.sap_federatedmetrics.yaml b/cmd/embedded/crds/metrics.cloud.sap_federatedmetrics.yaml index 600a671..2c7b1de 100644 --- a/cmd/embedded/crds/metrics.cloud.sap_federatedmetrics.yaml +++ b/cmd/embedded/crds/metrics.cloud.sap_federatedmetrics.yaml @@ -39,10 +39,6 @@ spec: spec: description: FederatedMetricSpec defines the desired state of FederatedMetric properties: - checkInterval: - default: 12h - description: Define in what interval the query should be recorded - type: string description: type: string federateClusterAccessRef: @@ -57,6 +53,10 @@ spec: description: Define fields of your object to adapt filters of the query type: string + interval: + default: 10m + description: Define in what interval the query should be recorded + type: string labelSelector: description: Define labels of your object to adapt filters of the query diff --git a/cmd/embedded/crds/metrics.cloud.sap_managedmetrics.yaml b/cmd/embedded/crds/metrics.cloud.sap_managedmetrics.yaml index 18747eb..ee02398 100644 --- a/cmd/embedded/crds/metrics.cloud.sap_managedmetrics.yaml +++ b/cmd/embedded/crds/metrics.cloud.sap_managedmetrics.yaml @@ -49,10 +49,6 @@ spec: spec: description: ManagedMetricSpec defines the desired state of ManagedMetric properties: - checkInterval: - default: 12h - description: Define in what interval the query should be recorded - type: string description: description: Sets the description that will be used to identify the metric in Dynatrace(or other providers) @@ -65,6 +61,10 @@ spec: description: Define the group of your object that should be instrumented (without version at the end) type: string + interval: + default: 10m + description: Define in what interval the query should be recorded + type: string kind: description: Decide which kind the metric should keep track of (needs to be plural version) diff --git a/cmd/embedded/crds/metrics.cloud.sap_metrics.yaml b/cmd/embedded/crds/metrics.cloud.sap_metrics.yaml index b3cc218..0cbf66e 100644 --- a/cmd/embedded/crds/metrics.cloud.sap_metrics.yaml +++ b/cmd/embedded/crds/metrics.cloud.sap_metrics.yaml @@ -49,10 +49,6 @@ spec: spec: description: MetricSpec defines the desired state of Metric properties: - checkInterval: - default: 12h - description: Define in what interval the query should be recorded - type: string description: description: Sets the description that will be used to identify the metric in Dynatrace(or other providers) @@ -61,6 +57,10 @@ spec: description: Define fields of your object to adapt filters of the query type: string + interval: + default: 10m + description: Define in what interval the query should be recorded + type: string labelSelector: description: Define labels of your object to adapt filters of the query diff --git a/config/crd/bases/metrics.cloud.sap_federatedmanagedmetrics.yaml b/config/crd/bases/metrics.cloud.sap_federatedmanagedmetrics.yaml index f65dc0f..d2f1e9a 100644 --- a/config/crd/bases/metrics.cloud.sap_federatedmanagedmetrics.yaml +++ b/config/crd/bases/metrics.cloud.sap_federatedmanagedmetrics.yaml @@ -40,10 +40,6 @@ spec: spec: description: FederatedManagedMetricSpec defines the desired state of FederatedManagedMetric properties: - checkInterval: - default: 12h - description: Define in what interval the query should be recorded - type: string description: type: string federateClusterAccessRef: @@ -58,6 +54,10 @@ spec: description: Define fields of your object to adapt filters of the query type: string + interval: + default: 10m + description: Define in what interval the query should be recorded + type: string labelSelector: description: Define labels of your object to adapt filters of the query diff --git a/config/crd/bases/metrics.cloud.sap_federatedmetrics.yaml b/config/crd/bases/metrics.cloud.sap_federatedmetrics.yaml index 600a671..2c7b1de 100644 --- a/config/crd/bases/metrics.cloud.sap_federatedmetrics.yaml +++ b/config/crd/bases/metrics.cloud.sap_federatedmetrics.yaml @@ -39,10 +39,6 @@ spec: spec: description: FederatedMetricSpec defines the desired state of FederatedMetric properties: - checkInterval: - default: 12h - description: Define in what interval the query should be recorded - type: string description: type: string federateClusterAccessRef: @@ -57,6 +53,10 @@ spec: description: Define fields of your object to adapt filters of the query type: string + interval: + default: 10m + description: Define in what interval the query should be recorded + type: string labelSelector: description: Define labels of your object to adapt filters of the query diff --git a/config/crd/bases/metrics.cloud.sap_managedmetrics.yaml b/config/crd/bases/metrics.cloud.sap_managedmetrics.yaml index 18747eb..ee02398 100644 --- a/config/crd/bases/metrics.cloud.sap_managedmetrics.yaml +++ b/config/crd/bases/metrics.cloud.sap_managedmetrics.yaml @@ -49,10 +49,6 @@ spec: spec: description: ManagedMetricSpec defines the desired state of ManagedMetric properties: - checkInterval: - default: 12h - description: Define in what interval the query should be recorded - type: string description: description: Sets the description that will be used to identify the metric in Dynatrace(or other providers) @@ -65,6 +61,10 @@ spec: description: Define the group of your object that should be instrumented (without version at the end) type: string + interval: + default: 10m + description: Define in what interval the query should be recorded + type: string kind: description: Decide which kind the metric should keep track of (needs to be plural version) diff --git a/config/crd/bases/metrics.cloud.sap_metrics.yaml b/config/crd/bases/metrics.cloud.sap_metrics.yaml index b3cc218..0cbf66e 100644 --- a/config/crd/bases/metrics.cloud.sap_metrics.yaml +++ b/config/crd/bases/metrics.cloud.sap_metrics.yaml @@ -49,10 +49,6 @@ spec: spec: description: MetricSpec defines the desired state of Metric properties: - checkInterval: - default: 12h - description: Define in what interval the query should be recorded - type: string description: description: Sets the description that will be used to identify the metric in Dynatrace(or other providers) @@ -61,6 +57,10 @@ spec: description: Define fields of your object to adapt filters of the query type: string + interval: + default: 10m + description: Define in what interval the query should be recorded + type: string labelSelector: description: Define labels of your object to adapt filters of the query diff --git a/examples/basic_metric.yaml b/examples/basic_metric.yaml index 47d0011..bc33cb5 100644 --- a/examples/basic_metric.yaml +++ b/examples/basic_metric.yaml @@ -9,7 +9,7 @@ spec: kind: release group: helm.crossplane.io version: v1beta1 - checkInterval: 1m # in minutes + interval: 1m # in minutes --- apiVersion: metrics.cloud.sap/v1alpha1 kind: Metric @@ -22,7 +22,7 @@ spec: kind: pod group: "" version: v1 - checkInterval: 1m # in minutes + interval: 1m # in minutes projections: - name: pod-namespace fieldPath: "metadata.namespace" @@ -38,7 +38,7 @@ spec: kind: pod group: "" version: v1 - checkInterval: 1m # in minutes + interval: 1m # in minutes #apiVersion: metrics.cloud.sap/v1alpha1 #kind: Metric diff --git a/examples/dev-core/metric.yaml b/examples/dev-core/metric.yaml index cb22af6..f03eed8 100644 --- a/examples/dev-core/metric.yaml +++ b/examples/dev-core/metric.yaml @@ -5,8 +5,9 @@ metadata: spec: name: dev-core-landscaperdeployment description: Number of LandscapperDeplyoments in the LS-DEV-CORE cluster - kind: LandscaperDeployment - group: landscaper-service.gardener.cloud - version: v1alpha1 - checkInterval: "1m" # in minutes + target: + kind: LandscaperDeployment + group: landscaper-service.gardener.cloud + version: v1alpha1 + interval: "1m" # in minutes --- diff --git a/examples/fed-managed-resoruces/crossplane-managed.yaml b/examples/fed-managed-resoruces/crossplane-managed.yaml index 240c94e..1c5e3d6 100644 --- a/examples/fed-managed-resoruces/crossplane-managed.yaml +++ b/examples/fed-managed-resoruces/crossplane-managed.yaml @@ -1,12 +1,12 @@ -apiVersion: metrics.cloud.sap/v1beta1 +apiVersion: metrics.cloud.sap/v1alpha1 kind: FederatedManagedMetric metadata: name: xfed-managed spec: name: xfed-managed description: crossplane managed resources - checkInterval: "1m" # in minutes - federateCaRef: + interval: "1m" # in minutes + federateClusterAccessRef: name: federate-ca-sample namespace: default --- diff --git a/examples/federated-resources/crdsdeletion.yaml b/examples/federated-resources/crdsdeletion.yaml index e3cae47..ec8ab4b 100644 --- a/examples/federated-resources/crdsdeletion.yaml +++ b/examples/federated-resources/crdsdeletion.yaml @@ -1,4 +1,4 @@ -apiVersion: metrics.cloud.sap/v1beta1 +apiVersion: metrics.cloud.sap/v1alpha1 kind: FederatedMetric metadata: name: xfed-crds-del @@ -7,16 +7,16 @@ spec: description: subaccounts target: group: apiextensions.k8s.io - resource: customresourcedefinitions + kind: customresourcedefinition version: v1 fieldSelector: "metadata.deletionTimestamp" - checkInterval: "1m" # in minutes + interval: "1m" # in minutes projections: - name: deletion fieldPath: "metadata.deletionTimestamp" - name: crd.name fieldPath: "metadata.name" - federateCaRef: + federateClusterAccessRef: name: federate-ca-sample namespace: default --- diff --git a/examples/federated-resources/entitlements.yaml b/examples/federated-resources/entitlements.yaml index 1b17967..15f47a6 100644 --- a/examples/federated-resources/entitlements.yaml +++ b/examples/federated-resources/entitlements.yaml @@ -1,4 +1,4 @@ -apiVersion: metrics.cloud.sap/v1beta1 +apiVersion: metrics.cloud.sap/v1alpha1 kind: FederatedMetric metadata: name: xfed-entitlements @@ -7,13 +7,13 @@ spec: description: entitlements target: group: account.btp.orchestrate.cloud.sap - resource: entitlements + kind: Entitlement version: v1alpha1 - checkInterval: "1m" # in minutes + interval: "1m" # in minutes projections: - name: servicename fieldPath: "spec.forProvider.serviceName" - federateCaRef: + federateClusterAccessRef: name: federate-ca-sample namespace: default --- diff --git a/examples/federated-resources/serviceinstances.yaml b/examples/federated-resources/serviceinstances.yaml index 1afe537..9931eb6 100644 --- a/examples/federated-resources/serviceinstances.yaml +++ b/examples/federated-resources/serviceinstances.yaml @@ -1,4 +1,4 @@ -apiVersion: metrics.cloud.sap/v1beta1 +apiVersion: metrics.cloud.sap/v1alpha1 kind: FederatedMetric metadata: name: xfed-instances @@ -7,10 +7,10 @@ spec: description: service instances target: group: services.cloud.sap.com - resource: serviceinstances + kind: ServiceInstance version: v1 - checkInterval: "1m" # in minutes - federateCaRef: + interval: "1m" # in minutes + federateClusterAccessRef: name: federate-ca-sample namespace: default --- diff --git a/examples/federated-resources/subaccounts.yaml b/examples/federated-resources/subaccounts.yaml index ac634c8..8ca22a7 100644 --- a/examples/federated-resources/subaccounts.yaml +++ b/examples/federated-resources/subaccounts.yaml @@ -1,4 +1,4 @@ -apiVersion: metrics.cloud.sap/v1beta1 +apiVersion: metrics.cloud.sap/v1alpha1 kind: FederatedMetric metadata: name: xfed-subaccounts @@ -7,13 +7,13 @@ spec: description: subaccounts target: group: account.btp.orchestrate.cloud.sap - resource: subaccounts + kind: Subaccount version: v1alpha1 - checkInterval: "1m" # in minutes + interval: "1m" # in minutes projections: - name: region fieldPath: "spec.forProvider.region" - federateCaRef: + federateClusterAccessRef: name: federate-ca-sample namespace: default --- diff --git a/examples/managed_metric.yaml b/examples/managed_metric.yaml index 035165f..26fb598 100644 --- a/examples/managed_metric.yaml +++ b/examples/managed_metric.yaml @@ -8,4 +8,4 @@ spec: kind: Release group: helm.crossplane.io version: v1beta1 - checkInterval: "1m" # in minutes + interval: "1m" # in minutes diff --git a/examples/remoteclusteraccess/metric_with_rca.yaml b/examples/remoteclusteraccess/metric_with_rca.yaml index 867e239..19952d9 100644 --- a/examples/remoteclusteraccess/metric_with_rca.yaml +++ b/examples/remoteclusteraccess/metric_with_rca.yaml @@ -5,10 +5,11 @@ metadata: spec: name: crate-mcp-metric description: Number of ManagedControlPlanes in the Crate cluster - kind: ManagedControlPlane - group: cola.cloud.sap - version: v1alpha1 - checkInterval: "1m" # in minutes + target: + kind: ManagedControlPlane + group: cola.cloud.sap + version: v1alpha1 + interval: "1m" # in minutes remoteClusterAccessRef: name: crate-cluster namespace: test-monitoring @@ -20,10 +21,11 @@ metadata: spec: name: crate-co-metric description: Number of CloudOrchestrators in the Crate cluster - kind: CloudOrchestrator - group: cola.cloud.sap - version: v1alpha1 - checkInterval: "1m" # in minutes + target: + kind: CloudOrchestrator + group: cola.cloud.sap + version: v1alpha1 + interval: "1m" # in minutes remoteClusterAccessRef: name: crate-cluster namespace: test-monitoring @@ -35,10 +37,11 @@ metadata: spec: name: crate-dataplane-metric description: Number of DataPlanes in the Crate cluster - kind: DataPlane - group: cola.cloud.sap - version: v1alpha1 - checkInterval: "1m" # in minutes + target: + kind: DataPlane + group: cola.cloud.sap + version: v1alpha1 + interval: "1m" # in minutes remoteClusterAccessRef: name: crate-cluster namespace: test-monitoring diff --git a/examples/v1beta1/fedmetric.yaml b/examples/v1beta1/fedmetric.yaml index 6ecfca2..a6d220d 100644 --- a/examples/v1beta1/fedmetric.yaml +++ b/examples/v1beta1/fedmetric.yaml @@ -1,4 +1,4 @@ -apiVersion: metrics.cloud.sap/v1beta1 +apiVersion: metrics.cloud.sap/v1alpha1 kind: FederatedMetric metadata: name: xfed-prov @@ -7,13 +7,13 @@ spec: description: crossplane providers target: group: pkg.crossplane.io - resource: providers + kind: Provider version: v1 - checkInterval: "1m" # in minutes + interval: "1m" # in minutes projections: - name: package fieldPath: "spec.package" - federateCaRef: + federateClusterAccessRef: name: federate-ca-sample namespace: default --- diff --git a/internal/controller/federatedmanagedmetric_controller.go b/internal/controller/federatedmanagedmetric_controller.go index cd13491..66f2c7a 100644 --- a/internal/controller/federatedmanagedmetric_controller.go +++ b/internal/controller/federatedmanagedmetric_controller.go @@ -83,7 +83,7 @@ func (r *FederatedManagedMetricReconciler) scheduleNextReconciliation(metric *v1 elapsed := time.Since(metric.Status.LastReconcileTime.Time) return ctrl.Result{ Requeue: true, - RequeueAfter: metric.Spec.CheckInterval.Duration - elapsed, + RequeueAfter: metric.Spec.Interval.Duration - elapsed, }, nil } @@ -92,7 +92,7 @@ func (r *FederatedManagedMetricReconciler) shouldReconcile(metric *v1alpha1.Fede return true } elapsed := time.Since(metric.Status.LastReconcileTime.Time) - return elapsed >= metric.Spec.CheckInterval.Duration + return elapsed >= metric.Spec.Interval.Duration } // Reconcile reads that state of the cluster for a FederatedManagedMetric object @@ -197,7 +197,7 @@ func (r *FederatedManagedMetricReconciler) Reconcile(ctx context.Context, req ct /* 4. Re-queue the metric after the frequency or 2 minutes if an error occurred */ - var requeueTime = metric.Spec.CheckInterval.Duration + var requeueTime = metric.Spec.Interval.Duration l.Info(fmt.Sprintf("generic metric '%s' re-queued for execution in %v minutes\n", metric.Spec.Name, requeueTime)) diff --git a/internal/controller/federatedmetric_controller.go b/internal/controller/federatedmetric_controller.go index 88c4131..01560a2 100644 --- a/internal/controller/federatedmetric_controller.go +++ b/internal/controller/federatedmetric_controller.go @@ -87,7 +87,7 @@ func scheduleNextReconciliation(metric *v1alpha1.FederatedMetric) (ctrl.Result, elapsed := time.Since(metric.Status.LastReconcileTime.Time) return ctrl.Result{ Requeue: true, - RequeueAfter: metric.Spec.CheckInterval.Duration - elapsed, + RequeueAfter: metric.Spec.Interval.Duration - elapsed, }, nil } @@ -96,7 +96,7 @@ func shouldReconcile(metric *v1alpha1.FederatedMetric) bool { return true } elapsed := time.Since(metric.Status.LastReconcileTime.Time) - return elapsed >= metric.Spec.CheckInterval.Duration + return elapsed >= metric.Spec.Interval.Duration } // +kubebuilder:rbac:groups=metrics.cloud.sap,resources=federatedmetrics,verbs=get;list;watch;create;update;patch;delete @@ -202,7 +202,7 @@ func (r *FederatedMetricReconciler) Reconcile(ctx context.Context, req ctrl.Requ /* 4. Requeue the metric after the frequency or after 2 minutes if an error occurred */ - var requeueTime = metric.Spec.CheckInterval.Duration + var requeueTime = metric.Spec.Interval.Duration l.Info(fmt.Sprintf("generic metric '%s' re-queued for execution in %v minutes\n", metric.Spec.Name, requeueTime)) diff --git a/internal/controller/managedmetric_controller.go b/internal/controller/managedmetric_controller.go index bdce95a..9b7b6ee 100644 --- a/internal/controller/managedmetric_controller.go +++ b/internal/controller/managedmetric_controller.go @@ -169,7 +169,7 @@ func (r *ManagedMetricReconciler) Reconcile(ctx context.Context, req ctrl.Reques if result.Error != nil { requeueTime = RequeueAfterError } else { - requeueTime = metric.Spec.CheckInterval.Duration + requeueTime = metric.Spec.Interval.Duration } l.Info(fmt.Sprintf("managed metric '%s' re-queued for execution in %v minutes\n", metric.Spec.Name, requeueTime)) diff --git a/internal/controller/metric_controller.go b/internal/controller/metric_controller.go index 871eda0..1f49f35 100644 --- a/internal/controller/metric_controller.go +++ b/internal/controller/metric_controller.go @@ -79,7 +79,7 @@ func (r *MetricReconciler) scheduleNextReconciliation(metric *v1alpha1.Metric) ( elapsed := time.Since(metric.Status.Observation.Timestamp.Time) return ctrl.Result{ Requeue: true, - RequeueAfter: metric.Spec.CheckInterval.Duration - elapsed, + RequeueAfter: metric.Spec.Interval.Duration - elapsed, }, nil } @@ -88,7 +88,7 @@ func (r *MetricReconciler) shouldReconcile(metric *v1alpha1.Metric) bool { return true } elapsed := time.Since(metric.Status.Observation.Timestamp.Time) - return elapsed >= metric.Spec.CheckInterval.Duration + return elapsed >= metric.Spec.Interval.Duration } func (r *MetricReconciler) handleGetError(err error, log logr.Logger) (ctrl.Result, error) { @@ -243,7 +243,7 @@ func (r *MetricReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr if result.Error != nil || errExport != nil { // Requeue faster on monitor or export error requeueTime = RequeueAfterError } else { - requeueTime = metric.Spec.CheckInterval.Duration + requeueTime = metric.Spec.Interval.Duration } l.Info(fmt.Sprintf("metric '%s' re-queued for execution in %v\n", metric.Spec.Name, requeueTime)) diff --git a/internal/controller/metric_controller_test.go b/internal/controller/metric_controller_test.go index 5aaa19c..e5c7830 100644 --- a/internal/controller/metric_controller_test.go +++ b/internal/controller/metric_controller_test.go @@ -125,7 +125,7 @@ func (r *TestMetricReconciler) Reconcile(ctx context.Context, req ctrl.Request) // Requeue return ctrl.Result{ Requeue: true, - RequeueAfter: metric.Spec.CheckInterval.Duration, + RequeueAfter: metric.Spec.Interval.Duration, }, nil } @@ -226,7 +226,7 @@ func testReconcileSecretNotFound(t *testing.T) { Group: "", Version: "v1", }, - CheckInterval: metav1.Duration{Duration: 5 * time.Minute}, + Interval: metav1.Duration{Duration: 5 * time.Minute}, }, } err := k8sClient.Create(ctx, metric) @@ -315,7 +315,7 @@ func testReconcileMetricHappyPath(t *testing.T) { Group: "", Version: "v1", }, - CheckInterval: metav1.Duration{Duration: 5 * time.Minute}, + Interval: metav1.Duration{Duration: 5 * time.Minute}, }, } err = k8sClient.Create(ctx, metric)