Skip to content

Commit af0d4c8

Browse files
committed
Graduate MachinePools to stable API
1 parent 9a2d8cd commit af0d4c8

File tree

96 files changed

+1772
-1669
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+1772
-1669
lines changed

Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ generate-go-deepcopy: ## Run all generate-go-deepcopy-* targets
387387

388388
.PHONY: generate-go-deepcopy-core
389389
generate-go-deepcopy-core: $(CONTROLLER_GEN) ## Generate deepcopy go code for core
390-
$(MAKE) clean-generated-deepcopy SRC_DIRS="./api,./$(EXP_DIR)/api,./$(EXP_DIR)/addons/api,./$(EXP_DIR)/runtime/api,./$(EXP_DIR)/runtime/hooks/api"
390+
$(MAKE) clean-generated-deepcopy SRC_DIRS="./api,./$(EXP_DIR)/api,./$(EXP_DIR)/addons/api,./$(EXP_DIR)/runtime/api,./$(EXP_DIR)/runtime/hooks/api,./internal/apis/core"
391391
$(CONTROLLER_GEN) \
392392
object:headerFile=./hack/boilerplate/boilerplate.generatego.txt \
393393
paths=./api/... \
@@ -396,6 +396,7 @@ generate-go-deepcopy-core: $(CONTROLLER_GEN) ## Generate deepcopy go code for co
396396
paths=./$(EXP_DIR)/ipam/api/... \
397397
paths=./$(EXP_DIR)/runtime/api/... \
398398
paths=./$(EXP_DIR)/runtime/hooks/api/... \
399+
paths=./internal/apis/core/... \
399400
paths=./internal/runtime/test/... \
400401
paths=./cmd/clusterctl/... \
401402
paths=./internal/test/builder/...

api/v1beta1/condition_consts.go

+11
Original file line numberDiff line numberDiff line change
@@ -351,3 +351,14 @@ const (
351351
// the corresponding CRD).
352352
ClusterClassOutdatedRefVersionsReason = "OutdatedRefVersions"
353353
)
354+
355+
// Conditions and condition Reasons for the MachinePool object.
356+
357+
const (
358+
// ReplicasReadyCondition reports an aggregate of current status of the replicas controlled by the MachinePool.
359+
ReplicasReadyCondition ConditionType = "ReplicasReady"
360+
361+
// WaitingForReplicasReadyReason (Severity=Info) documents a machinepool waiting for the required replicas
362+
// to be ready.
363+
WaitingForReplicasReadyReason = "WaitingForReplicasReady"
364+
)

api/v1beta1/conversion.go

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ func (*ClusterClass) Hub() {}
2222
func (*ClusterClassList) Hub() {}
2323
func (*Machine) Hub() {}
2424
func (*MachineList) Hub() {}
25+
func (*MachinePool) Hub() {}
26+
func (*MachinePoolList) Hub() {}
2527
func (*MachineSet) Hub() {}
2628
func (*MachineSetList) Hub() {}
2729
func (*MachineDeployment) Hub() {}

api/v1beta1/index/machinepool.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
ctrl "sigs.k8s.io/controller-runtime"
2525
"sigs.k8s.io/controller-runtime/pkg/client"
2626

27-
expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1"
27+
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
2828
)
2929

3030
const (
@@ -39,7 +39,7 @@ const (
3939
// ByMachinePoolNode adds the machinepool node name index to the
4040
// managers cache.
4141
func ByMachinePoolNode(ctx context.Context, mgr ctrl.Manager) error {
42-
if err := mgr.GetCache().IndexField(ctx, &expv1.MachinePool{},
42+
if err := mgr.GetCache().IndexField(ctx, &clusterv1.MachinePool{},
4343
MachinePoolNodeNameField,
4444
MachinePoolByNodeName,
4545
); err != nil {
@@ -51,7 +51,7 @@ func ByMachinePoolNode(ctx context.Context, mgr ctrl.Manager) error {
5151

5252
// MachinePoolByNodeName contains the logic to index MachinePools by Node name.
5353
func MachinePoolByNodeName(o client.Object) []string {
54-
machinepool, ok := o.(*expv1.MachinePool)
54+
machinepool, ok := o.(*clusterv1.MachinePool)
5555
if !ok {
5656
panic(fmt.Sprintf("Expected a MachinePool but got a %T", o))
5757
}
@@ -70,7 +70,7 @@ func MachinePoolByNodeName(o client.Object) []string {
7070
// ByMachinePoolProviderID adds the machinepool providerID index to the
7171
// managers cache.
7272
func ByMachinePoolProviderID(ctx context.Context, mgr ctrl.Manager) error {
73-
if err := mgr.GetCache().IndexField(ctx, &expv1.MachinePool{},
73+
if err := mgr.GetCache().IndexField(ctx, &clusterv1.MachinePool{},
7474
MachinePoolProviderIDField,
7575
machinePoolByProviderID,
7676
); err != nil {
@@ -81,7 +81,7 @@ func ByMachinePoolProviderID(ctx context.Context, mgr ctrl.Manager) error {
8181
}
8282

8383
func machinePoolByProviderID(o client.Object) []string {
84-
machinepool, ok := o.(*expv1.MachinePool)
84+
machinepool, ok := o.(*clusterv1.MachinePool)
8585
if !ok {
8686
panic(fmt.Sprintf("Expected a MachinePool but got a %T", o))
8787
}

api/v1beta1/index/machinepool_test.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
corev1 "k8s.io/api/core/v1"
2424
"sigs.k8s.io/controller-runtime/pkg/client"
2525

26-
expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1"
26+
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
2727
)
2828

2929
func TestIndexMachinePoolByNodeName(t *testing.T) {
@@ -34,13 +34,13 @@ func TestIndexMachinePoolByNodeName(t *testing.T) {
3434
}{
3535
{
3636
name: "when the machinepool has no NodeRef",
37-
object: &expv1.MachinePool{},
37+
object: &clusterv1.MachinePool{},
3838
expected: []string{},
3939
},
4040
{
4141
name: "when the machinepool has valid NodeRefs",
42-
object: &expv1.MachinePool{
43-
Status: expv1.MachinePoolStatus{
42+
object: &clusterv1.MachinePool{
43+
Status: clusterv1.MachinePoolStatus{
4444
NodeRefs: []corev1.ObjectReference{
4545
{
4646
Name: "node1",
@@ -75,22 +75,22 @@ func TestIndexMachinePoolByProviderID(t *testing.T) {
7575
}{
7676
{
7777
name: "MachinePool has no providerID",
78-
object: &expv1.MachinePool{},
78+
object: &clusterv1.MachinePool{},
7979
expected: nil,
8080
},
8181
{
8282
name: "MachinePool has invalid providerID",
83-
object: &expv1.MachinePool{
84-
Spec: expv1.MachinePoolSpec{
83+
object: &clusterv1.MachinePool{
84+
Spec: clusterv1.MachinePoolSpec{
8585
ProviderIDList: []string{""},
8686
},
8787
},
8888
expected: []string{},
8989
},
9090
{
9191
name: "MachinePool has valid providerIDs",
92-
object: &expv1.MachinePool{
93-
Spec: expv1.MachinePoolSpec{
92+
object: &clusterv1.MachinePool{
93+
Spec: clusterv1.MachinePoolSpec{
9494
ProviderIDList: []string{validProviderID, otherValidProviderID},
9595
},
9696
},

exp/api/v1beta1/machinepool_types.go renamed to api/v1beta1/machinepool_types.go

+4-5
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
corev1 "k8s.io/api/core/v1"
2121
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2222

23-
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
2423
capierrors "sigs.k8s.io/cluster-api/errors"
2524
)
2625

@@ -43,7 +42,7 @@ type MachinePoolSpec struct {
4342
Replicas *int32 `json:"replicas,omitempty"`
4443

4544
// Template describes the machines that will be created.
46-
Template clusterv1.MachineTemplateSpec `json:"template"`
45+
Template MachineTemplateSpec `json:"template"`
4746

4847
// Minimum number of seconds for which a newly created machine instances should
4948
// be ready.
@@ -121,7 +120,7 @@ type MachinePoolStatus struct {
121120

122121
// Conditions define the current service state of the MachinePool.
123122
// +optional
124-
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
123+
Conditions Conditions `json:"conditions,omitempty"`
125124
}
126125

127126
// ANCHOR_END: MachinePoolStatus
@@ -229,12 +228,12 @@ type MachinePool struct {
229228
}
230229

231230
// GetConditions returns the set of conditions for this object.
232-
func (m *MachinePool) GetConditions() clusterv1.Conditions {
231+
func (m *MachinePool) GetConditions() Conditions {
233232
return m.Status.Conditions
234233
}
235234

236235
// SetConditions sets the conditions on this object.
237-
func (m *MachinePool) SetConditions(conditions clusterv1.Conditions) {
236+
func (m *MachinePool) SetConditions(conditions Conditions) {
238237
m.Status.Conditions = conditions
239238
}
240239

api/v1beta1/zz_generated.deepcopy.go

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

0 commit comments

Comments
 (0)