Skip to content

Commit

Permalink
Updated PR per review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kylewuolle committed Dec 12, 2024
1 parent 047904b commit d1db299
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions api/v1alpha1/indexers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion config/dev/adopted-clusterdeployment.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 1 addition & 3 deletions internal/controller/clusterdeployment_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 1 addition & 3 deletions internal/controller/management_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,14 @@ 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),
}

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)
Expand Down
8 changes: 4 additions & 4 deletions internal/telemetry/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion internal/telemetry/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ spec:
listKind: ClusterDeploymentList
plural: clusterdeployments
shortNames:
- mcluster
- mcl
- clusterd
- cld
singular: clusterdeployment
scope: Namespaced
versions:
Expand Down
2 changes: 0 additions & 2 deletions templates/provider/hmc/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,13 @@ spec:
port: 8081
initialDelaySeconds: 15
periodSeconds: 20
timeoutSeconds: 6000
name: manager
readinessProbe:
httpGet:
path: /readyz
port: 8081
initialDelaySeconds: 5
periodSeconds: 10
timeoutSeconds: 6000
resources: {{- toYaml .Values.resources | nindent 10
}}
securityContext: {{- toYaml .Values.containerSecurityContext
Expand Down
2 changes: 1 addition & 1 deletion test/objects/clusterdeployment/clusterdeployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down

0 comments on commit d1db299

Please sign in to comment.