Skip to content

Commit

Permalink
fix: set status.phase for Plan
Browse files Browse the repository at this point in the history
  • Loading branch information
dkoshkin committed Sep 22, 2023
1 parent 46eeb5c commit ecc175c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
11 changes: 11 additions & 0 deletions api/v1alpha1/plan_phase_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package v1alpha1

type PlanPhase string

const (
// PlanPhaseNoSuitableMachineImage is the phase when there is no suitable machine image.
PlanPhaseNoSuitableMachineImage = PlanPhase("NoSuitableMachineImage")

// PlanPhaseFoundMachineImage is the phase when a suitable machine image has been found.
PlanPhaseFoundMachineImage = PlanPhase("FoundMachineImage")
)
6 changes: 6 additions & 0 deletions api/v1alpha1/plan_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ type PlanStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file

// Phase represents the current phase of image building
// E.g. NoSuitableMachineImage, FoundMachineImage.
// +optional
Phase PlanPhase `json:"phase,omitempty"`

// MachineImageDetails holds the details for a MachineImage with the highest version within the range.
MachineImageDetails *MachineImageDetails `json:"machineImageDetails"`

Expand All @@ -69,6 +74,7 @@ type MachineImageDetails struct {
//+kubebuilder:resource:categories=kubernetes-upgrader
//+kubebuilder:printcolumn:name="Version Range",type="string",JSONPath=`.spec.versionRange`
//+kubebuilder:printcolumn:name="Latest Version",type="string",JSONPath=`.status.machineImageDetails.version`
//+kubebuilder:printcolumn:name="Phase",type="string",JSONPath=`.status.phase`

// Plan is the Schema for the plans API.
type Plan struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ spec:
- jsonPath: .status.machineImageDetails.version
name: Latest Version
type: string
- jsonPath: .status.phase
name: Phase
type: string
name: v1alpha1
schema:
openAPIV3Schema:
Expand Down Expand Up @@ -154,6 +157,10 @@ spec:
type: string
type: object
x-kubernetes-map-type: atomic
phase:
description: Phase represents the current phase of image building
E.g. NoSuitableMachineImage, FoundMachineImage.
type: string
required:
- machineImageDetails
- machineImageRef
Expand Down
2 changes: 2 additions & 0 deletions internal/controller/plan_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ func (r *PlanReconciler) reconcileNormal(
"LatestVersionNotFound",
"Did not find a suitable MachineImage, requeueing",
)
plan.Status.Phase = kubernetesupgraderv1.PlanPhaseNoSuitableMachineImage
return ctrl.Result{RequeueAfter: planRequeueDelay}, nil
}

Expand All @@ -142,6 +143,7 @@ func (r *PlanReconciler) reconcileNormal(
}
// Update the Plan status with the latest MachineImage.
plan.Status.MachineImageRef = latestVersion.GetObjectReference()
plan.Status.Phase = kubernetesupgraderv1.PlanPhaseFoundMachineImage

return ctrl.Result{}, nil
}
Expand Down

0 comments on commit ecc175c

Please sign in to comment.