Skip to content

Commit f792076

Browse files
authored
Adopt CAPI v2beta2 status changes and respective controller changes for IBMPowerVSMachine (#2272)
* Add v1beta2 conditions to IBMPowerVSMachine * Add watch-filter flag to enable controller to watch for label * Add v1beta2 condition constants * Standardise controller and update logs * Test fixes after controller changes * Remove println in test files
1 parent 20dead9 commit f792076

11 files changed

+744
-403
lines changed

Diff for: api/v1beta1/ibmpowervs_conversion.go

+5
Original file line numberDiff line numberDiff line change
@@ -208,3 +208,8 @@ func Convert_v1beta2_IBMPowerVSClusterStatus_To_v1beta1_IBMPowerVSClusterStatus(
208208
func Convert_v1beta2_IBMPowerVSImageSpec_To_v1beta1_IBMPowerVSImageSpec(in *infrav1beta2.IBMPowerVSImageSpec, out *IBMPowerVSImageSpec, s apiconversion.Scope) error {
209209
return autoConvert_v1beta2_IBMPowerVSImageSpec_To_v1beta1_IBMPowerVSImageSpec(in, out, s)
210210
}
211+
212+
func Convert_v1beta2_IBMPowerVSMachineStatus_To_v1beta1_IBMPowerVSMachineStatus(in *infrav1beta2.IBMPowerVSMachineStatus, out *IBMPowerVSMachineStatus, s apiconversion.Scope) error {
213+
// CAPI V1Beta2 was added in CAPIBM v1beta2
214+
return autoConvert_v1beta2_IBMPowerVSMachineStatus_To_v1beta1_IBMPowerVSMachineStatus(in, out, s)
215+
}

Diff for: api/v1beta1/zz_generated.conversion.go

+6-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: api/v1beta2/conditions_consts.go

+56
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,62 @@ import (
2020
capiv1beta1 "sigs.k8s.io/cluster-api/api/v1beta1"
2121
)
2222

23+
// IBMPowerVSMachine's InstanceReady condition and corresponding reasons that will be used in v1Beta2 API version.
24+
const (
25+
// IBMPowerVSMachineReadyV1Beta2Condition is true if the IBMPowerVSMachine's deletionTimestamp is not set, IBMPowerVSMachine's
26+
// IBMPowerVSMachineInstanceReadyV1Beta2Condition is true.
27+
IBMPowerVSMachineReadyV1Beta2Condition = capiv1beta1.ReadyV1Beta2Condition
28+
29+
// IBMPowerVSMachineReadyV1Beta2Reason surfaces when the IBMPowerVSMachine readiness criteria is met.
30+
IBMPowerVSMachineReadyV1Beta2Reason = capiv1beta1.ReadyV1Beta2Reason
31+
32+
// IBMPowerVSMachineNotReadyV1Beta2Reason surfaces when the IBMPowerVSMachine readiness criteria is not met.
33+
IBMPowerVSMachineNotReadyV1Beta2Reason = capiv1beta1.NotReadyV1Beta2Reason
34+
35+
// IBMPowerVSMachineReadyUnknownV1Beta2Reason surfaces when at least one IBMPowerVSMachine readiness criteria is unknown
36+
// and no IBMPowerVSMachine readiness criteria is not met.
37+
IBMPowerVSMachineReadyUnknownV1Beta2Reason = capiv1beta1.ReadyUnknownV1Beta2Reason
38+
)
39+
40+
const (
41+
// IBMPowerVSMachineInstanceReadyV1Beta2Condition documents the status of the instance that is controlled
42+
// by the IBMPowerVSMachine.
43+
IBMPowerVSMachineInstanceReadyV1Beta2Condition = "InstanceReady"
44+
45+
// IBMPowerVSMachineInstanceReadyV1Beta2Reason surfaces when the instance that is controlled
46+
// by the IBMPowerVSMachine is ready.
47+
IBMPowerVSMachineInstanceReadyV1Beta2Reason = "InstanceReady"
48+
49+
// IBMPowerVSMachineInstanceNotReadyV1Beta2Reason surfaces when the instance that is controlled
50+
// by the IBMPowerVSMachine is not ready.
51+
IBMPowerVSMachineInstanceNotReadyV1Beta2Reason = "InstanceNotReady"
52+
53+
// IBMPowerVSMachineInstanceWaitingForClusterInfrastructureReadyV1Beta2Reason documents the virtual machine that is controller by
54+
// IBMPowerVSMachine waiting for the cluster infrastructure to be ready.
55+
// TODO: Use when CAPI version is updated: IBMPowerVSMachineInstanceWaitingForClusterInfrastructureReadyV1Beta2Reason = capiv1beta1.WaitingForClusterInfrastructureReadyV1Beta2Reason.
56+
IBMPowerVSMachineInstanceWaitingForClusterInfrastructureReadyV1Beta2Reason = "WaitingForClusterInfrastructureReady"
57+
58+
// IBMPowerVSMachineInstanceWaitingForControlPlaneInitializedV1Beta2Reason documents the virtual machine that is controller by IBMPowerVSMachine waiting
59+
// for the control plane to be initialized.
60+
// TODO: Use when CAPI version is updated: IBMPowerVSMachineInstanceWaitingForControlPlaneInitializedV1Beta2Reason = capiv1beta1.WaitingForControlPlaneInitializedV1Beta2Reason.
61+
IBMPowerVSMachineInstanceWaitingForControlPlaneInitializedV1Beta2Reason = "WaitingForControlPlaneInitialized"
62+
63+
// IBMPowerVSMachineInstanceWaitingForBootstrapDataV1Beta2Reason documents the virtual machine that is controller by IBMPowerVSMachine waiting for the bootstrap
64+
// data to be ready.
65+
// TODO: Use when CAPI version is updated: IBMPowerVSMachineInstanceWaitingForBootstrapDataV1Beta2Reason = capiv1beta1.WaitingForBootstrapDataV1Beta2Reason.
66+
IBMPowerVSMachineInstanceWaitingForBootstrapDataV1Beta2Reason = "WaitingForBootstrapData"
67+
68+
// IBMPowerVSMachineInstanceDeletingV1Beta2Reason surfaces when the virtual machine controller by IBMPowerVSMachine is deleting.
69+
IBMPowerVSMachineInstanceDeletingV1Beta2Reason = capiv1beta1.DeletingV1Beta2Reason
70+
71+
// IBMPowerVSMachineInstanceLoadBalancerConfigurationFailedV1Beta2Reason surfaces when configuring the virtual machine IP to load balancer fails.
72+
IBMPowerVSMachineInstanceLoadBalancerConfigurationFailedV1Beta2Reason = "LoadBalancerConfigurationFailed"
73+
74+
// IBMPowerVSMachineInstanceWaitingForNetworkAddressV1Beta2Reason surfaces when the PowerVS instance that is controlled
75+
// by the IBMPowerVSMachine waiting for the machine network settings to be reported after machine being powered on.
76+
IBMPowerVSMachineInstanceWaitingForNetworkAddressV1Beta2Reason = "WaitingForNetworkAddress"
77+
)
78+
2379
const (
2480
// InstanceProvisionFailedReason used for failures during instance provisioning.
2581
InstanceProvisionFailedReason = "InstanceProvisionFailed"

Diff for: api/v1beta2/ibmpowervsmachine_types.go

+38
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,9 @@ type IBMPowerVSMachineStatus struct {
197197
// Any transient errors that occur during the reconciliation of Machines
198198
// can be added as events to the Machine object and/or logged in the
199199
// controller's output.
200+
//
201+
// Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details.
202+
//
200203
// +optional
201204
FailureReason *string `json:"failureReason,omitempty"`
202205

@@ -216,6 +219,9 @@ type IBMPowerVSMachineStatus struct {
216219
// Any transient errors that occur during the reconciliation of Machines
217220
// can be added as events to the Machine object and/or logged in the
218221
// controller's output.
222+
//
223+
// Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please see https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more details.
224+
//
219225
// +optional
220226
FailureMessage *string `json:"failureMessage,omitempty"`
221227

@@ -228,6 +234,22 @@ type IBMPowerVSMachineStatus struct {
228234

229235
// Zone specifies the Power VS Service instance zone.
230236
Zone *string `json:"zone,omitempty"`
237+
238+
// v1beta2 groups all the fields that will be added or modified in IBMPowerVSMachine's status with the V1Beta2 version.
239+
// +optional
240+
V1Beta2 *IBMPowerVSMachineV1Beta2Status `json:"v1beta2,omitempty"`
241+
}
242+
243+
// IBMPowerVSMachineV1Beta2Status groups all the fields that will be added or modified in IBMPowerVSMachineStatus with the V1Beta2 version.
244+
// See https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/proposals/20240916-improve-status-in-CAPI-resources.md for more context.
245+
type IBMPowerVSMachineV1Beta2Status struct {
246+
// conditions represents the observations of a IBMPowerVSMachine's current state.
247+
// Known condition types are Ready, InstanceReady and Paused.
248+
// +optional
249+
// +listType=map
250+
// +listMapKey=type
251+
// +kubebuilder:validation:MaxItems=32
252+
Conditions []metav1.Condition `json:"conditions,omitempty"`
231253
}
232254

233255
// +kubebuilder:object:root=true
@@ -261,6 +283,22 @@ func (r *IBMPowerVSMachine) SetConditions(conditions capiv1beta1.Conditions) {
261283
r.Status.Conditions = conditions
262284
}
263285

286+
// GetV1Beta2Conditions returns the set of conditions for this object.
287+
func (r *IBMPowerVSMachine) GetV1Beta2Conditions() []metav1.Condition {
288+
if r.Status.V1Beta2 == nil {
289+
return nil
290+
}
291+
return r.Status.V1Beta2.Conditions
292+
}
293+
294+
// SetV1Beta2Conditions sets conditions for an API object.
295+
func (r *IBMPowerVSMachine) SetV1Beta2Conditions(conditions []metav1.Condition) {
296+
if r.Status.V1Beta2 == nil {
297+
r.Status.V1Beta2 = &IBMPowerVSMachineV1Beta2Status{}
298+
}
299+
r.Status.V1Beta2.Conditions = conditions
300+
}
301+
264302
//+kubebuilder:object:root=true
265303

266304
// IBMPowerVSMachineList contains a list of IBMPowerVSMachine.

Diff for: api/v1beta2/zz_generated.deepcopy.go

+28
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)