Skip to content

Commit e30d9b8

Browse files
committed
Test pass now 🎉
Signed-off-by: Vince Prignano <[email protected]>
1 parent 688f73d commit e30d9b8

39 files changed

+592
-439
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,5 @@ config/ci/rbac/role_binding.yaml
4242
config/ci/rbac/role.yaml
4343
config/ci/manager/manager.yaml
4444

45+
config/crds-v1alpha1
46+

Makefile

+10
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,16 @@ generate-manifests: ## Generate manifests e.g. CRD, RBAC etc.
123123
crd \
124124
rbac:roleName=manager-role \
125125
output:crd:dir=./config/crds
126+
## Hack for MachineClass. This type has been deprecated in v1alpha2.
127+
## Generating the types with the above command results in an error during tests,
128+
## specifically `per-version schemas may not all be set to identical values (top-level validation should be used instead)`.
129+
## This might be a bug in controller-tools that generates a multi-version CRD where only a single version is available.
130+
go run vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go \
131+
paths=./pkg/apis/cluster/v1alpha1 \
132+
crd:trivialVersions=true \
133+
output:crd:dir=./config/crds-v1alpha1
134+
cp -f ./config/crds-v1alpha1/cluster.k8s.io_machineclasses.yaml ./config/crds/
135+
## Copy files in CI folders.
126136
cp -f ./config/rbac/role*.yaml ./config/ci/rbac/
127137
cp -f ./config/manager/manager*.yaml ./config/ci/manager/
128138

cmd/clusterctl/validation/validate_cluster_api_objects_suite_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ var cfg *rest.Config
3333

3434
func TestMain(m *testing.M) {
3535
t := &envtest.Environment{
36-
CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "config", "crds")},
36+
CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "config", "crds")},
37+
KubeAPIServerFlags: append(envtest.DefaultKubeAPIServerFlags, "--feature-gates=CustomResourceWebhookConversion=true"),
3738
}
3839
apis.AddToScheme(scheme.Scheme)
3940

cmd/clusterctl/validation/validate_cluster_api_objects_test.go

+9
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@ import (
2323
"path"
2424
"testing"
2525

26+
corev1 "k8s.io/api/core/v1"
2627
v1 "k8s.io/api/core/v1"
2728
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2829
"k8s.io/apimachinery/pkg/types"
30+
"k8s.io/utils/pointer"
2931
"sigs.k8s.io/cluster-api/pkg/apis/cluster/common"
3032
"sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha2"
3133
"sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha2/testutil"
@@ -56,6 +58,13 @@ func getMachineWithError(machineName, namespace string, nodeRef *v1.ObjectRefere
5658
Name: machineName,
5759
Namespace: namespace,
5860
},
61+
Spec: v1alpha2.MachineSpec{
62+
InfrastructureRef: corev1.TypedLocalObjectReference{
63+
APIGroup: pointer.StringPtr("infrastructure.clusters.k8s.io"),
64+
Kind: "InfrastructureRef",
65+
Name: "machine-infrastructure",
66+
},
67+
},
5968
Status: newMachineStatus(nodeRef, errorReason, errorMessage),
6069
}
6170
}

cmd/example-provider/BUILD.bazel

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ go_library(
1212
"//pkg/controller/cluster:go_default_library",
1313
"//pkg/controller/machine:go_default_library",
1414
"//pkg/provider/example/actuators/cluster:go_default_library",
15-
"//pkg/provider/example/actuators/machine:go_default_library",
1615
"//vendor/k8s.io/klog:go_default_library",
1716
"//vendor/sigs.k8s.io/controller-runtime/pkg/client/config:go_default_library",
1817
"//vendor/sigs.k8s.io/controller-runtime/pkg/manager:go_default_library",

cmd/example-provider/main.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
capicluster "sigs.k8s.io/cluster-api/pkg/controller/cluster"
2727
capimachine "sigs.k8s.io/cluster-api/pkg/controller/machine"
2828
"sigs.k8s.io/cluster-api/pkg/provider/example/actuators/cluster"
29-
"sigs.k8s.io/cluster-api/pkg/provider/example/actuators/machine"
3029
"sigs.k8s.io/controller-runtime/pkg/client/config"
3130
"sigs.k8s.io/controller-runtime/pkg/manager"
3231
"sigs.k8s.io/controller-runtime/pkg/runtime/signals"
@@ -55,17 +54,14 @@ func main() {
5554
// Initialize cluster actuator.
5655
clusterActuator, _ := cluster.NewClusterActuator(cs.ClusterV1alpha2(), recorder)
5756

58-
// Initialize machine actuator.
59-
machineActuator, _ := machine.NewMachineActuator(cs.ClusterV1alpha2(), recorder)
60-
6157
// Register cluster deployer
6258
common.RegisterClusterProvisioner("example", clusterActuator)
6359

6460
if err := clusterapis.AddToScheme(mgr.GetScheme()); err != nil {
6561
klog.Fatal(err)
6662
}
6763

68-
capimachine.AddWithActuator(mgr, machineActuator)
64+
capimachine.Add(mgr)
6965
capicluster.AddWithActuator(mgr, clusterActuator)
7066

7167
if err := mgr.Start(signals.SetupSignalHandler()); err != nil {

config/crds/cluster.k8s.io_clusters.yaml

-4
Original file line numberDiff line numberDiff line change
@@ -523,8 +523,6 @@ spec:
523523
type: object
524524
served: true
525525
storage: false
526-
subresources:
527-
status: {}
528526
- name: v1alpha2
529527
schema:
530528
openAPIV3Schema:
@@ -948,8 +946,6 @@ spec:
948946
from this field, akin to component config.
949947
type: object
950948
type: object
951-
required:
952-
- clusterNetwork
953949
type: object
954950
status:
955951
properties:

config/crds/cluster.k8s.io_machineclasses.yaml

+366-370
Large diffs are not rendered by default.

config/crds/cluster.k8s.io_machinedeployments.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,6 @@ spec:
943943
labelSelectorPath: .status.labelSelector
944944
specReplicasPath: .spec.replicas
945945
statusReplicasPath: .status.replicas
946-
status: {}
947946
- name: v1alpha2
948947
schema:
949948
openAPIV3Schema:

config/crds/cluster.k8s.io_machines.yaml

+1-17
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,7 @@ spec:
1414
- ma
1515
scope: Namespaced
1616
versions:
17-
- additionalPrinterColumns:
18-
- JSONPath: .spec.providerID
19-
description: Provider ID
20-
name: ProviderID
21-
type: string
22-
- JSONPath: .status.phase
23-
description: Machine status such as Terminating/Pending/Running/Failed etc
24-
name: Phase
25-
type: string
26-
- JSONPath: .status.nodeRef.name
27-
description: Node name associated with this machine
28-
name: NodeName
29-
priority: 1
30-
type: string
31-
name: v1alpha1
17+
- name: v1alpha1
3218
schema:
3319
openAPIV3Schema:
3420
description: / [Machine] Machine is the Schema for the machines API
@@ -852,8 +838,6 @@ spec:
852838
type: object
853839
served: true
854840
storage: false
855-
subresources:
856-
status: {}
857841
- additionalPrinterColumns:
858842
- JSONPath: .spec.providerID
859843
description: Provider ID

config/crds/cluster.k8s.io_machinesets.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,6 @@ spec:
905905
labelSelectorPath: .status.labelSelector
906906
specReplicasPath: .spec.replicas
907907
statusReplicasPath: .status.replicas
908-
status: {}
909908
- name: v1alpha2
910909
schema:
911910
openAPIV3Schema:

pkg/apis/cluster/v1alpha1/cluster_types.go

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ const ClusterFinalizer = "cluster.cluster.k8s.io"
3232
// Cluster is the Schema for the clusters API
3333
// +k8s:openapi-gen=true
3434
// +kubebuilder:resource:path=clusters,shortName=cl
35-
// +kubebuilder:subresource:status
3635
type Cluster struct {
3736
metav1.TypeMeta `json:",inline"`
3837
metav1.ObjectMeta `json:"metadata,omitempty"`

pkg/apis/cluster/v1alpha1/machine_types.go

-4
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@ const (
3838
// Machine is the Schema for the machines API
3939
// +k8s:openapi-gen=true
4040
// +kubebuilder:resource:path=machines,shortName=ma
41-
// +kubebuilder:subresource:status
42-
// +kubebuilder:printcolumn:name="ProviderID",type="string",JSONPath=".spec.providerID",description="Provider ID"
43-
// +kubebuilder:printcolumn:name="Phase",type="string",JSONPath=".status.phase",description="Machine status such as Terminating/Pending/Running/Failed etc"
44-
// +kubebuilder:printcolumn:name="NodeName",type="string",JSONPath=".status.nodeRef.name",description="Node name associated with this machine",priority=1
4541
type Machine struct {
4642
metav1.TypeMeta `json:",inline"`
4743
metav1.ObjectMeta `json:"metadata,omitempty"`

pkg/apis/cluster/v1alpha1/machinedeployment_types.go

-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ type MachineDeploymentStatus struct {
168168
// MachineDeployment is the Schema for the machinedeployments API
169169
// +k8s:openapi-gen=true
170170
// +kubebuilder:resource:path=machinedeployments,shortName=md
171-
// +kubebuilder:subresource:status
172171
// +kubebuilder:subresource:scale:specpath=.spec.replicas,statuspath=.status.replicas,selectorpath=.status.labelSelector
173172
type MachineDeployment struct {
174173
metav1.TypeMeta `json:",inline"`

pkg/apis/cluster/v1alpha1/machineset_types.go

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import (
3333
// MachineSet ensures that a specified number of machines replicas are running at any given time.
3434
// +k8s:openapi-gen=true
3535
// +kubebuilder:resource:path=machinesets,shortName=ms
36-
// +kubebuilder:subresource:status
3736
// +kubebuilder:subresource:scale:specpath=.spec.replicas,statuspath=.status.replicas,selectorpath=.status.labelSelector
3837
type MachineSet struct {
3938
metav1.TypeMeta `json:",inline"`

pkg/apis/cluster/v1alpha1/v1alpha1_suite_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ var c client.Client
3333

3434
func TestMain(m *testing.M) {
3535
t := &envtest.Environment{
36-
CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "..", "config", "crds")},
36+
CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "..", "config", "crds")},
37+
KubeAPIServerFlags: append(envtest.DefaultKubeAPIServerFlags, "--feature-gates=CustomResourceWebhookConversion=true"),
3738
}
3839

3940
err := SchemeBuilder.AddToScheme(scheme.Scheme)

pkg/apis/cluster/v1alpha2/BUILD.bazel

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ go_library(
55
srcs = [
66
"cluster_types.go",
77
"common_type.go",
8+
"defaults.go",
89
"doc.go",
910
"machine_types.go",
1011
"machinedeployment_types.go",
@@ -41,10 +42,12 @@ go_test(
4142
deps = [
4243
"//vendor/github.com/onsi/gomega:go_default_library",
4344
"//vendor/golang.org/x/net/context:go_default_library",
45+
"//vendor/k8s.io/api/core/v1:go_default_library",
4446
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
4547
"//vendor/k8s.io/apimachinery/pkg/types:go_default_library",
4648
"//vendor/k8s.io/client-go/kubernetes/scheme:go_default_library",
4749
"//vendor/k8s.io/client-go/rest:go_default_library",
50+
"//vendor/k8s.io/utils/pointer:go_default_library",
4851
"//vendor/sigs.k8s.io/controller-runtime/pkg/client:go_default_library",
4952
"//vendor/sigs.k8s.io/controller-runtime/pkg/envtest:go_default_library",
5053
],

pkg/apis/cluster/v1alpha2/cluster_types.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ type Cluster struct {
4949
type ClusterSpec struct {
5050
// Cluster network configuration
5151
// +optional
52-
ClusterNetwork ClusterNetworkingConfig `json:"clusterNetwork"`
52+
ClusterNetwork *ClusterNetworkingConfig `json:"clusterNetwork,omitempty"`
5353

5454
// Provider-specific serialized configuration to use during
5555
// cluster creation. It is recommended that providers maintain

pkg/apis/cluster/v1alpha2/machine_types_test.go

+11-1
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ import (
2121

2222
"github.com/onsi/gomega"
2323
"golang.org/x/net/context"
24+
corev1 "k8s.io/api/core/v1"
2425
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2526
"k8s.io/apimachinery/pkg/types"
27+
"k8s.io/utils/pointer"
2628
)
2729

2830
func TestStorageMachine(t *testing.T) {
@@ -34,7 +36,15 @@ func TestStorageMachine(t *testing.T) {
3436
ObjectMeta: metav1.ObjectMeta{
3537
Name: "foo",
3638
Namespace: "default",
37-
}}
39+
},
40+
Spec: MachineSpec{
41+
InfrastructureRef: corev1.TypedLocalObjectReference{
42+
APIGroup: pointer.StringPtr("infrastructure.clusters.k8s.io"),
43+
Kind: "InfrastructureRef",
44+
Name: "machine-infrastructure",
45+
},
46+
},
47+
}
3848
g := gomega.NewGomegaWithT(t)
3949

4050
// Test Create

pkg/apis/cluster/v1alpha2/machinedeployment_types_test.go

+15-1
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ import (
2121

2222
"github.com/onsi/gomega"
2323
"golang.org/x/net/context"
24+
corev1 "k8s.io/api/core/v1"
2425
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2526
"k8s.io/apimachinery/pkg/types"
27+
"k8s.io/utils/pointer"
2628
)
2729

2830
func TestStorageMachineDeployment(t *testing.T) {
@@ -34,7 +36,19 @@ func TestStorageMachineDeployment(t *testing.T) {
3436
ObjectMeta: metav1.ObjectMeta{
3537
Name: "foo",
3638
Namespace: "default",
37-
}}
39+
},
40+
Spec: MachineDeploymentSpec{
41+
Template: MachineTemplateSpec{
42+
Spec: MachineSpec{
43+
InfrastructureRef: corev1.TypedLocalObjectReference{
44+
APIGroup: pointer.StringPtr("infrastructure.clusters.k8s.io"),
45+
Kind: "InfrastructureRef",
46+
Name: "machine-infrastructure",
47+
},
48+
},
49+
},
50+
},
51+
}
3852
g := gomega.NewGomegaWithT(t)
3953

4054
// Test Create

pkg/apis/cluster/v1alpha2/machineset_types_test.go

+15-1
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ import (
2121

2222
"github.com/onsi/gomega"
2323
"golang.org/x/net/context"
24+
corev1 "k8s.io/api/core/v1"
2425
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2526
"k8s.io/apimachinery/pkg/types"
27+
"k8s.io/utils/pointer"
2628
)
2729

2830
func TestStorageMachineSet(t *testing.T) {
@@ -34,7 +36,19 @@ func TestStorageMachineSet(t *testing.T) {
3436
ObjectMeta: metav1.ObjectMeta{
3537
Name: "foo",
3638
Namespace: "default",
37-
}}
39+
},
40+
Spec: MachineSetSpec{
41+
Template: MachineTemplateSpec{
42+
Spec: MachineSpec{
43+
InfrastructureRef: corev1.TypedLocalObjectReference{
44+
APIGroup: pointer.StringPtr("infrastructure.clusters.k8s.io"),
45+
Kind: "InfrastructureRef",
46+
Name: "machine-infrastructure",
47+
},
48+
},
49+
},
50+
},
51+
}
3852
g := gomega.NewGomegaWithT(t)
3953

4054
// Test Create

pkg/apis/cluster/v1alpha2/testutil/testutil.go

+1-11
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,6 @@ import "sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha2"
2121
// GetVanillaCluster return a bare minimum functional cluster resource object
2222
func GetVanillaCluster() v1alpha2.Cluster {
2323
return v1alpha2.Cluster{
24-
Spec: v1alpha2.ClusterSpec{
25-
ClusterNetwork: v1alpha2.ClusterNetworkingConfig{
26-
Services: v1alpha2.NetworkRanges{
27-
CIDRBlocks: []string{"10.96.0.0/12"},
28-
},
29-
Pods: v1alpha2.NetworkRanges{
30-
CIDRBlocks: []string{"192.168.0.0/16"},
31-
},
32-
ServiceDomain: "cluster.local",
33-
},
34-
},
24+
Spec: v1alpha2.ClusterSpec{},
3525
}
3626
}

pkg/apis/cluster/v1alpha2/v1alpha2_suite_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ var c client.Client
3333

3434
func TestMain(m *testing.M) {
3535
t := &envtest.Environment{
36-
CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "..", "config", "crds")},
36+
CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "..", "config", "crds")},
37+
KubeAPIServerFlags: append(envtest.DefaultKubeAPIServerFlags, "--feature-gates=CustomResourceWebhookConversion=true"),
3738
}
3839

3940
err := SchemeBuilder.AddToScheme(scheme.Scheme)

pkg/apis/cluster/v1alpha2/zz_generated.deepcopy.go

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

pkg/controller/BUILD.bazel

-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ go_library(
55
srcs = [
66
"add_machinedeployment.go",
77
"add_machineset.go",
8-
"add_node.go",
98
"add_noderef.go",
109
"controller.go",
1110
],
@@ -14,7 +13,6 @@ go_library(
1413
deps = [
1514
"//pkg/controller/machinedeployment:go_default_library",
1615
"//pkg/controller/machineset:go_default_library",
17-
"//pkg/controller/node:go_default_library",
1816
"//pkg/controller/noderef:go_default_library",
1917
"//vendor/sigs.k8s.io/controller-runtime/pkg/manager:go_default_library",
2018
],

pkg/controller/cluster/cluster_reconciler_suite_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ var cfg *rest.Config
3434

3535
func TestMain(m *testing.M) {
3636
t := &envtest.Environment{
37-
CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "config", "crds")},
37+
CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "config", "crds")},
38+
KubeAPIServerFlags: append(envtest.DefaultKubeAPIServerFlags, "--feature-gates=CustomResourceWebhookConversion=true"),
3839
}
3940
apis.AddToScheme(scheme.Scheme)
4041

0 commit comments

Comments
 (0)