From d1db2994d64d93062fce2c2465c8f8f3bb498228 Mon Sep 17 00:00:00 2001 From: Kyle Wuolle Date: Thu, 12 Dec 2024 10:30:47 -0800 Subject: [PATCH] Updated PR per review comments --- ...managedcluster_types.go => clusterdeployment_types.go} | 2 +- api/v1alpha1/indexers.go | 6 +++--- config/dev/adopted-clusterdeployment.yaml | 2 +- internal/controller/clusterdeployment_controller.go | 4 +--- internal/controller/management_controller.go | 4 +--- internal/telemetry/event.go | 8 ++++---- internal/telemetry/tracker.go | 2 +- .../crds/hmc.mirantis.com_clusterdeployments.yaml | 4 ++-- templates/provider/hmc/templates/deployment.yaml | 2 -- test/objects/clusterdeployment/clusterdeployment.go | 2 +- 10 files changed, 15 insertions(+), 21 deletions(-) rename api/v1alpha1/{managedcluster_types.go => clusterdeployment_types.go} (99%) diff --git a/api/v1alpha1/managedcluster_types.go b/api/v1alpha1/clusterdeployment_types.go similarity index 99% rename from api/v1alpha1/managedcluster_types.go rename to api/v1alpha1/clusterdeployment_types.go index 9e1434f0..e811b980 100644 --- a/api/v1alpha1/managedcluster_types.go +++ b/api/v1alpha1/clusterdeployment_types.go @@ -106,7 +106,7 @@ type ClusterDeploymentStatus struct { // +kubebuilder:object:root=true // +kubebuilder:subresource:status -// +kubebuilder:resource:shortName=mcluster;mcl +// +kubebuilder:resource:shortName=clusterd;cld // +kubebuilder:printcolumn:name="ready",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].status",description="Ready",priority=0 // +kubebuilder:printcolumn:name="status",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].message",description="Status",priority=0 // +kubebuilder:printcolumn:name="dryRun",type="string",JSONPath=".spec.dryRun",description="Dry Run",priority=1 diff --git a/api/v1alpha1/indexers.go b/api/v1alpha1/indexers.go index f1d87733..6dd06892 100644 --- a/api/v1alpha1/indexers.go +++ b/api/v1alpha1/indexers.go @@ -89,12 +89,12 @@ func ExtractServiceTemplateNamesFromClusterDeployment(rawObj client.Object) []st const ClusterDeploymentCredentialIndexKey = ".spec.credential" func setupClusterDeploymentCredentialIndexer(ctx context.Context, mgr ctrl.Manager) error { - return mgr.GetFieldIndexer().IndexField(ctx, &ClusterDeployment{}, ClusterDeploymentCredentialIndexKey, ExtractCredentialNameFromClusterDeployment) + return mgr.GetFieldIndexer().IndexField(ctx, &ClusterDeployment{}, ClusterDeploymentCredentialIndexKey, extractCredentialNameFromClusterDeployment) } -// ExtractCredentialNameFromClusterDeployment returns referenced Credential name +// extractCredentialNameFromClusterDeployment returns referenced Credential name // declared in a ClusterDeployment object. -func ExtractCredentialNameFromClusterDeployment(rawObj client.Object) []string { +func extractCredentialNameFromClusterDeployment(rawObj client.Object) []string { cluster, ok := rawObj.(*ClusterDeployment) if !ok { return nil diff --git a/config/dev/adopted-clusterdeployment.yaml b/config/dev/adopted-clusterdeployment.yaml index 36afd93a..026bf985 100644 --- a/config/dev/adopted-clusterdeployment.yaml +++ b/config/dev/adopted-clusterdeployment.yaml @@ -1,7 +1,7 @@ apiVersion: hmc.mirantis.com/v1alpha1 kind: ClusterDeployment metadata: - name: aws-dev + name: adopted-dev namespace: ${NAMESPACE} spec: template: adopted-cluster-0-0-4 diff --git a/internal/controller/clusterdeployment_controller.go b/internal/controller/clusterdeployment_controller.go index f7daef92..fd58aace 100644 --- a/internal/controller/clusterdeployment_controller.go +++ b/internal/controller/clusterdeployment_controller.go @@ -104,9 +104,7 @@ func (r *ClusterDeploymentReconciler) Reconcile(ctx context.Context, req ctrl.Re return r.reconcileUpdate(ctx, clusterDeployment) } -func (r *ClusterDeploymentReconciler) setStatusFromChildObjects( - ctx context.Context, clusterDeployment *hmc.ClusterDeployment, gvr schema.GroupVersionResource, conditions []string, -) (requeue bool, _ error) { +func (r *ClusterDeploymentReconciler) setStatusFromChildObjects(ctx context.Context, clusterDeployment *hmc.ClusterDeployment, gvr schema.GroupVersionResource, conditions []string) (requeue bool, _ error) { l := ctrl.LoggerFrom(ctx) resourceConditions, err := status.GetResourceConditions(ctx, clusterDeployment.Namespace, r.DynamicClient, gvr, diff --git a/internal/controller/management_controller.go b/internal/controller/management_controller.go index 45763d75..073d2431 100644 --- a/internal/controller/management_controller.go +++ b/internal/controller/management_controller.go @@ -116,7 +116,7 @@ func (r *ManagementReconciler) Update(ctx context.Context, management *hmc.Manag errs error statusAccumulator = &mgmtStatusAccumulator{ - providers: hmc.Providers{}, + providers: hmc.Providers{"infrastructure-internal"}, components: make(map[string]hmc.ComponentStatus), compatibilityContracts: make(map[string]hmc.CompatibilityContracts), } @@ -124,8 +124,6 @@ func (r *ManagementReconciler) Update(ctx context.Context, management *hmc.Manag requeue bool ) - statusAccumulator.providers = append(statusAccumulator.providers, "infrastructure-internal") - for _, component := range components { l.V(1).Info("reconciling components", "component", component) template := new(hmc.ProviderTemplate) diff --git a/internal/telemetry/event.go b/internal/telemetry/event.go index 9d806e65..3894a08d 100644 --- a/internal/telemetry/event.go +++ b/internal/telemetry/event.go @@ -21,8 +21,8 @@ import ( ) const ( - ClusterDeploymentCreateEvent = "cluster-deployment-create" - ClusterDeploymentHeartbeatEvent = "cluster-deployment-heartbeat" + clusterDeploymentCreateEvent = "cluster-deployment-create" + clusterDeploymentHeartbeatEvent = "cluster-deployment-heartbeat" ) func TrackClusterDeploymentCreate(id, clusterDeploymentID, template string, dryRun bool) error { @@ -32,7 +32,7 @@ func TrackClusterDeploymentCreate(id, clusterDeploymentID, template string, dryR "template": template, "dryRun": dryRun, } - return TrackEvent(ClusterDeploymentCreateEvent, id, props) + return TrackEvent(clusterDeploymentCreateEvent, id, props) } func TrackClusterDeploymentHeartbeat(id, clusterDeploymentID, clusterID, template, templateHelmChartVersion string, providers []string) error { @@ -44,7 +44,7 @@ func TrackClusterDeploymentHeartbeat(id, clusterDeploymentID, clusterID, templat "templateHelmChartVersion": templateHelmChartVersion, "providers": providers, } - return TrackEvent(ClusterDeploymentHeartbeatEvent, id, props) + return TrackEvent(clusterDeploymentHeartbeatEvent, id, props) } func TrackEvent(name, id string, properties map[string]any) error { diff --git a/internal/telemetry/tracker.go b/internal/telemetry/tracker.go index 3784c1e4..ecd785c3 100644 --- a/internal/telemetry/tracker.go +++ b/internal/telemetry/tracker.go @@ -50,7 +50,7 @@ func (t *Tracker) Start(ctx context.Context) error { func (t *Tracker) Tick(ctx context.Context) { l := log.FromContext(ctx).WithName("telemetry tracker") - logger := l.WithValues("event", ClusterDeploymentHeartbeatEvent) + logger := l.WithValues("event", clusterDeploymentHeartbeatEvent) err := t.trackClusterDeploymentHeartbeat(ctx) if err != nil { logger.Error(err, "failed to track an event") diff --git a/templates/provider/hmc/templates/crds/hmc.mirantis.com_clusterdeployments.yaml b/templates/provider/hmc/templates/crds/hmc.mirantis.com_clusterdeployments.yaml index 1c76d306..44b90107 100644 --- a/templates/provider/hmc/templates/crds/hmc.mirantis.com_clusterdeployments.yaml +++ b/templates/provider/hmc/templates/crds/hmc.mirantis.com_clusterdeployments.yaml @@ -12,8 +12,8 @@ spec: listKind: ClusterDeploymentList plural: clusterdeployments shortNames: - - mcluster - - mcl + - clusterd + - cld singular: clusterdeployment scope: Namespaced versions: diff --git a/templates/provider/hmc/templates/deployment.yaml b/templates/provider/hmc/templates/deployment.yaml index e95b1cd9..31ae1004 100644 --- a/templates/provider/hmc/templates/deployment.yaml +++ b/templates/provider/hmc/templates/deployment.yaml @@ -54,7 +54,6 @@ spec: port: 8081 initialDelaySeconds: 15 periodSeconds: 20 - timeoutSeconds: 6000 name: manager readinessProbe: httpGet: @@ -62,7 +61,6 @@ spec: port: 8081 initialDelaySeconds: 5 periodSeconds: 10 - timeoutSeconds: 6000 resources: {{- toYaml .Values.resources | nindent 10 }} securityContext: {{- toYaml .Values.containerSecurityContext diff --git a/test/objects/clusterdeployment/clusterdeployment.go b/test/objects/clusterdeployment/clusterdeployment.go index 2fcfb134..777572d8 100644 --- a/test/objects/clusterdeployment/clusterdeployment.go +++ b/test/objects/clusterdeployment/clusterdeployment.go @@ -26,7 +26,7 @@ const ( DefaultNamespace = metav1.NamespaceDefault ) -type Opt func(ClusterDeployment *v1alpha1.ClusterDeployment) +type Opt func(clusterDeployment *v1alpha1.ClusterDeployment) func NewClusterDeployment(opts ...Opt) *v1alpha1.ClusterDeployment { p := &v1alpha1.ClusterDeployment{