Skip to content

Commit 5251d2c

Browse files
authored
Refactor status handling and resource deletion (#38)
1 parent c22e1ca commit 5251d2c

10 files changed

+224
-588
lines changed

api/v1alpha1/metalstackcluster_types.go

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ const (
3131

3232
ClusterControlPlaneEndpointDefaultPort = 443
3333

34-
ClusterNodeNetworkEnsured clusterv1.ConditionType = "ClusterNodeNetworkEnsured"
35-
ClusterControlPlaneEndpointEnsured clusterv1.ConditionType = "ClusterControlPlaneEndpointEnsured"
34+
ClusterNodeNetworkEnsured clusterv1.ConditionType = "ClusterNodeNetworkEnsured"
35+
ClusterControlPlaneIPEnsured clusterv1.ConditionType = "ClusterControlPlaneIPEnsured"
3636
)
3737

3838
var (
@@ -52,14 +52,13 @@ type MetalStackClusterSpec struct {
5252
ProjectID string `json:"projectID"`
5353

5454
// NodeNetworkID is the network ID in metal-stack in which the worker nodes and the firewall of the cluster are placed.
55-
// If not provided this will automatically be acquired during reconcile. Note that this field is not patched after auto-acquisition.
56-
// The ID of the auto-acquired network can be looked up in the status resource instead.
55+
// If not provided this will automatically be acquired during reconcile.
5756
// +optional
5857
NodeNetworkID *string `json:"nodeNetworkID,omitempty"`
5958

6059
// ControlPlaneIP is the ip address in metal-stack on which the control plane will be exposed.
61-
// If this ip and the control plane endpoint are not provided this will automatically be acquired during reconcile. Note that this field is not patched after auto-acquisition.
62-
// The address of the auto-acquired ip can be looked up in the control plane endpoint.
60+
// If this ip and the control plane endpoint are not provided, an ephemeral ip will automatically be acquired during reconcile.
61+
// Static ip addresses will not be deleted.
6362
// +optional
6463
ControlPlaneIP *string `json:"controlPlaneIP,omitempty"`
6564

@@ -79,6 +78,7 @@ type APIEndpoint struct {
7978
// MetalStackClusterStatus defines the observed state of MetalStackCluster.
8079
type MetalStackClusterStatus struct {
8180
// Ready denotes that the cluster is ready.
81+
// +kubebuilder:default=false
8282
Ready bool `json:"ready"`
8383

8484
// FailureReason indicates that there is a fatal problem reconciling the
@@ -95,13 +95,6 @@ type MetalStackClusterStatus struct {
9595
// Conditions defines current service state of the MetalStackCluster.
9696
// +optional
9797
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
98-
99-
// NodeCIDR is set as soon as the node network was created.
100-
// +optional
101-
NodeCIDR *string `json:"nodeCIDR,omitempty"`
102-
// NodeNetworkID is set as soon as the node network was created.
103-
// +optional
104-
NodeNetworkID *string `json:"nodeNetworkID,omitempty"`
10598
}
10699

107100
// +kubebuilder:object:root=true

api/v1alpha1/metalstackmachine_types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ type MetalStackMachineSpec struct {
4949
// MetalStackMachineStatus defines the observed state of MetalStackMachine.
5050
type MetalStackMachineStatus struct {
5151
// Ready denotes that the machine is ready.
52+
// +kubebuilder:default=false
5253
Ready bool `json:"ready"`
5354

5455
// FailureReason indicates that there is a fatal problem reconciling the

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 0 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/infrastructure.cluster.x-k8s.io_metalstackclusters.yaml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,13 @@ spec:
8888
controlPlaneIP:
8989
description: |-
9090
ControlPlaneIP is the ip address in metal-stack on which the control plane will be exposed.
91-
If this ip and the control plane endpoint are not provided this will automatically be acquired during reconcile. Note that this field is not patched after auto-acquisition.
92-
The address of the auto-acquired ip can be looked up in the control plane endpoint.
91+
If this ip and the control plane endpoint are not provided, an ephemeral ip will automatically be acquired during reconcile.
92+
Static ip addresses will not be deleted.
9393
type: string
9494
nodeNetworkID:
9595
description: |-
9696
NodeNetworkID is the network ID in metal-stack in which the worker nodes and the firewall of the cluster are placed.
97-
If not provided this will automatically be acquired during reconcile. Note that this field is not patched after auto-acquisition.
98-
The ID of the auto-acquired network can be looked up in the status resource instead.
97+
If not provided this will automatically be acquired during reconcile.
9998
type: string
10099
partition:
101100
description: Partition is the data center partition in which the resources
@@ -168,14 +167,8 @@ spec:
168167
state, and will be set to a token value suitable for
169168
programmatic interpretation.
170169
type: string
171-
nodeCIDR:
172-
description: NodeCIDR is set as soon as the node network was created.
173-
type: string
174-
nodeNetworkID:
175-
description: NodeNetworkID is set as soon as the node network was
176-
created.
177-
type: string
178170
ready:
171+
default: false
179172
description: Ready denotes that the cluster is ready.
180173
type: boolean
181174
required:

config/crd/bases/infrastructure.cluster.x-k8s.io_metalstackmachines.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ spec:
160160
programmatic interpretation.
161161
type: string
162162
ready:
163+
default: false
163164
description: Ready denotes that the machine is ready.
164165
type: boolean
165166
required:

config/crd/bases/infrastructure.cluster.x-k8s.io_metalstackmachinetemplates.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ spec:
175175
programmatic interpretation.
176176
type: string
177177
ready:
178+
default: false
178179
description: Ready denotes that the machine is ready.
179180
type: boolean
180181
required:

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ require (
1010
github.com/onsi/gomega v1.36.0
1111
github.com/stretchr/testify v1.9.0
1212
go.uber.org/zap v1.27.0
13-
golang.org/x/sync v0.10.0
1413
k8s.io/api v0.31.3
1514
k8s.io/apimachinery v0.31.3
1615
k8s.io/client-go v0.31.3
@@ -107,6 +106,7 @@ require (
107106
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c // indirect
108107
golang.org/x/net v0.33.0 // indirect
109108
golang.org/x/oauth2 v0.24.0 // indirect
109+
golang.org/x/sync v0.10.0 // indirect
110110
golang.org/x/sys v0.28.0 // indirect
111111
golang.org/x/term v0.27.0 // indirect
112112
golang.org/x/text v0.21.0 // indirect

0 commit comments

Comments
 (0)