Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: set status.phase for Plan #71

Merged
merged 1 commit into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions api/v1alpha1/plan_phase_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright 2023 Dimitri Koshkin. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

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
Loading