diff --git a/Makefile b/Makefile index a9960a68c2..19159080b9 100644 --- a/Makefile +++ b/Makefile @@ -91,7 +91,15 @@ build-e2e: .PHONY: k8s-e2e k8s-e2e: ## Run k8s specific e2e test # KUBECONFIG and SSH_PK dirs needs to be mounted inside a container if tests are run in containers - go test -timeout 20m -v sigs.k8s.io/cluster-api-provider-aws/test/machines -kubeconfig $${KUBECONFIG:-~/.kube/config} -ssh-key $${SSH_PK:-~/.ssh/id_rsa} -actuator-image $${ACTUATOR_IMAGE:-gcr.io/k8s-cluster-api/aws-machine-controller:0.0.1} -cluster-id $${ENVIRONMENT_ID:-""} -ginkgo.v + go test -timeout 20m \ + -v sigs.k8s.io/cluster-api-provider-aws/test/machines \ + -kubeconfig $${KUBECONFIG:-~/.kube/config} \ + -ssh-key $${SSH_PK:-~/.ssh/id_rsa} \ + -machine-controller-image $${ACTUATOR_IMAGE:-gcr.io/k8s-cluster-api/aws-machine-controller:0.0.1} \ + -machine-manager-image $${ACTUATOR_IMAGE:-gcr.io/k8s-cluster-api/aws-machine-controller:0.0.1} \ + -nodelink-controller-image $$(docker run registry.svc.ci.openshift.org/openshift/origin-release:v4.0 image machine-api-operator) \ + -cluster-id $${ENVIRONMENT_ID:-""} \ + -ginkgo.v .PHONY: test-e2e validate-e2e: ## Run e2e validation/gating test diff --git a/cmd/aws-actuator/main.go b/cmd/aws-actuator/main.go index fc5221e2bb..86c7be3b86 100644 --- a/cmd/aws-actuator/main.go +++ b/cmd/aws-actuator/main.go @@ -355,6 +355,10 @@ func bootstrapCommand() *cobra.Command { glog.Info(msg) } + clusterFramework.MachineControllerImage = "openshift/origin-aws-machine-controllers:v4.0.0" + clusterFramework.MachineManagerImage = "openshift/origin-aws-machine-controllers:v4.0.0" + clusterFramework.NodelinkControllerImage = "registry.svc.ci.openshift.org/openshift/origin-v4.0-2019-01-03-031244@sha256:152c0a4ea7cda1731e45af87e33909421dcde7a8fcf4e973cd098a8bae892c50" + glog.Info("Waiting for all nodes to come up") err = clusterFramework.WaitForNodesToGetReady(1) if err != nil { @@ -366,7 +370,7 @@ func bootstrapCommand() *cobra.Command { return err } - clusterFramework.DeployClusterAPIStack(testNamespace.Name, "openshift/origin-aws-machine-controllers:v4.0.0", "") + clusterFramework.DeployClusterAPIStack(testNamespace.Name, "") clusterFramework.CreateClusterAndWait(testCluster) createSecretAndWait(clusterFramework, awsCredentialsSecret) diff --git a/pkg/apis/awsproviderconfig/v1alpha1/register.go b/pkg/apis/awsproviderconfig/v1alpha1/register.go index 6df05ad742..7be24fcb93 100644 --- a/pkg/apis/awsproviderconfig/v1alpha1/register.go +++ b/pkg/apis/awsproviderconfig/v1alpha1/register.go @@ -74,9 +74,9 @@ func NewCodec() (*AWSProviderConfigCodec, error) { } // DecodeProviderConfig deserialises an object from the provider config -func (codec *AWSProviderConfigCodec) DecodeProviderConfig(providerConfig *clusterv1.ProviderConfig, out runtime.Object) error { - if providerConfig.Value != nil { - _, _, err := codec.decoder.Decode(providerConfig.Value.Raw, nil, out) +func (codec *AWSProviderConfigCodec) DecodeProviderConfig(providerSpec *clusterv1.ProviderSpec, out runtime.Object) error { + if providerSpec.Value != nil { + _, _, err := codec.decoder.Decode(providerSpec.Value.Raw, nil, out) if err != nil { return fmt.Errorf("decoding failure: %v", err) } @@ -85,12 +85,12 @@ func (codec *AWSProviderConfigCodec) DecodeProviderConfig(providerConfig *cluste } // EncodeProviderConfig serialises an object to the provider config -func (codec *AWSProviderConfigCodec) EncodeProviderConfig(in runtime.Object) (*clusterv1.ProviderConfig, error) { +func (codec *AWSProviderConfigCodec) EncodeProviderConfig(in runtime.Object) (*clusterv1.ProviderSpec, error) { var buf bytes.Buffer if err := codec.encoder.Encode(in, &buf); err != nil { return nil, fmt.Errorf("encoding failed: %v", err) } - return &clusterv1.ProviderConfig{ + return &clusterv1.ProviderSpec{ Value: &runtime.RawExtension{Raw: buf.Bytes()}, }, nil } diff --git a/pkg/cloud/aws/actuators/machine/actuator_test.go b/pkg/cloud/aws/actuators/machine/actuator_test.go index ec3c1d81c8..fc4e85807f 100644 --- a/pkg/cloud/aws/actuators/machine/actuator_test.go +++ b/pkg/cloud/aws/actuators/machine/actuator_test.go @@ -53,8 +53,8 @@ func TestMachineEvents(t *testing.T) { } machineInvalidProviderConfig := machine.DeepCopy() - machineInvalidProviderConfig.Spec.ProviderConfig.Value = nil - machineInvalidProviderConfig.Spec.ProviderConfig.ValueFrom = nil + machineInvalidProviderConfig.Spec.ProviderSpec.Value = nil + machineInvalidProviderConfig.Spec.ProviderSpec.ValueFrom = nil workerMachine := machine.DeepCopy() workerMachine.Labels[providerconfigv1.MachineTypeLabel] = "worker" @@ -228,8 +228,8 @@ func TestActuator(t *testing.T) { } machineInvalidProviderConfig := machine.DeepCopy() - machineInvalidProviderConfig.Spec.ProviderConfig.Value = nil - machineInvalidProviderConfig.Spec.ProviderConfig.ValueFrom = nil + machineInvalidProviderConfig.Spec.ProviderSpec.Value = nil + machineInvalidProviderConfig.Spec.ProviderSpec.ValueFrom = nil machineNoClusterID := machine.DeepCopy() delete(machineNoClusterID.Labels, providerconfigv1.ClusterIDLabel) @@ -636,7 +636,7 @@ func TestAvailabiltyZone(t *testing.T) { } machinePc := &providerconfigv1.AWSMachineProviderConfig{} - if err = codec.DecodeProviderConfig(&machine.Spec.ProviderConfig, machinePc); err != nil { + if err = codec.DecodeProviderConfig(&machine.Spec.ProviderSpec, machinePc); err != nil { t.Fatal(err) } @@ -654,7 +654,7 @@ func TestAvailabiltyZone(t *testing.T) { if err != nil { t.Fatal(err) } - machine.Spec.ProviderConfig = *config + machine.Spec.ProviderSpec = *config fakeKubeClient := kubernetesfake.NewSimpleClientset(awsCredentialsSecret, userDataSecret) diff --git a/pkg/cloud/aws/actuators/machine/stubs.go b/pkg/cloud/aws/actuators/machine/stubs.go index cdf497869d..723e5b2cf6 100644 --- a/pkg/cloud/aws/actuators/machine/stubs.go +++ b/pkg/cloud/aws/actuators/machine/stubs.go @@ -120,7 +120,7 @@ func stubMachine() (*clusterv1.Machine, *providerconfigv1.AWSMachineProviderConf }, Spec: clusterv1.MachineSpec{ - ProviderConfig: *config, + ProviderSpec: *config, }, } diff --git a/pkg/cloud/aws/actuators/machine/utils.go b/pkg/cloud/aws/actuators/machine/utils.go index 118ef7fe36..83c9b67cee 100644 --- a/pkg/cloud/aws/actuators/machine/utils.go +++ b/pkg/cloud/aws/actuators/machine/utils.go @@ -139,32 +139,42 @@ func terminateInstances(client awsclient.Client, instances []*ec2.Instance) erro // ProviderConfigFromMachine gets the machine provider config MachineSetSpec from the // specified cluster-api MachineSpec. func ProviderConfigFromMachine(client client.Client, machine *clusterv1.Machine, codec *providerconfigv1.AWSProviderConfigCodec) (*providerconfigv1.AWSMachineProviderConfig, error) { - var providerConfig runtime.RawExtension + var providerSpecRawExtention runtime.RawExtension + + // TODO(jchaloup): Remove providerConfig once all consumers migrate to providerSpec + providerSpec := machine.Spec.ProviderConfig + // providerSpec has higher priority over providerConfig + if machine.Spec.ProviderSpec.Value != nil || machine.Spec.ProviderSpec.ValueFrom != nil { + providerSpec = machine.Spec.ProviderSpec + glog.Infof("Falling to default providerSpec\n") + } else { + glog.Infof("Falling to providerConfig\n") + } - if machine.Spec.ProviderConfig.Value == nil && machine.Spec.ProviderConfig.ValueFrom == nil { + if providerSpec.Value == nil && providerSpec.ValueFrom == nil { return nil, fmt.Errorf("unable to find machine provider config: neither Spec.ProviderConfig.Value nor Spec.ProviderConfig.ValueFrom set") } - // If no machine.Spec.ProviderConfig.Value then we lookup for machineClass - if machine.Spec.ProviderConfig.Value != nil { - providerConfig = *machine.Spec.ProviderConfig.Value + // If no providerSpec.Value then we lookup for machineClass + if providerSpec.Value != nil { + providerSpecRawExtention = *providerSpec.Value } else { - if machine.Spec.ProviderConfig.ValueFrom.MachineClass == nil { + if providerSpec.ValueFrom.MachineClass == nil { return nil, fmt.Errorf("unable to find MachineClass on Spec.ProviderConfig.ValueFrom") } machineClass := &clusterv1.MachineClass{} key := types.NamespacedName{ - Namespace: machine.Spec.ProviderConfig.ValueFrom.MachineClass.Namespace, - Name: machine.Spec.ProviderConfig.ValueFrom.MachineClass.Name, + Namespace: providerSpec.ValueFrom.MachineClass.Namespace, + Name: providerSpec.ValueFrom.MachineClass.Name, } if err := client.Get(context.Background(), key, machineClass); err != nil { return nil, err } - providerConfig = machineClass.ProviderConfig + providerSpecRawExtention = machineClass.ProviderSpec } var config providerconfigv1.AWSMachineProviderConfig - if err := codec.DecodeProviderConfig(&clusterv1.ProviderConfig{Value: &providerConfig}, &config); err != nil { + if err := codec.DecodeProviderConfig(&clusterv1.ProviderSpec{Value: &providerSpecRawExtention}, &config); err != nil { return nil, err } return &config, nil diff --git a/pkg/cloud/aws/actuators/machine/utils_test.go b/pkg/cloud/aws/actuators/machine/utils_test.go index 4429477a74..0e2b36a3c1 100644 --- a/pkg/cloud/aws/actuators/machine/utils_test.go +++ b/pkg/cloud/aws/actuators/machine/utils_test.go @@ -60,7 +60,7 @@ func TestProviderConfigFromMachine(t *testing.T) { Namespace: "openshift-cluster-api", Name: "testClass", }, - ProviderConfig: *encodedProviderConfig.Value, + ProviderSpec: *encodedProviderConfig.Value, } testCases := []struct { @@ -79,7 +79,7 @@ func TestProviderConfigFromMachine(t *testing.T) { Kind: "Machine", }, Spec: clusterv1.MachineSpec{ - ProviderConfig: *encodedProviderConfig, + ProviderSpec: *encodedProviderConfig, }, }, }, @@ -96,8 +96,8 @@ func TestProviderConfigFromMachine(t *testing.T) { Kind: "Machine", }, Spec: clusterv1.MachineSpec{ - ProviderConfig: clusterv1.ProviderConfig{ - ValueFrom: &clusterv1.ProviderConfigSource{ + ProviderSpec: clusterv1.ProviderSpec{ + ValueFrom: &clusterv1.ProviderSpecSource{ MachineClass: &clusterv1.MachineClassRef{ ObjectReference: &corev1.ObjectReference{ Kind: "MachineClass", diff --git a/test/machines/machines_test.go b/test/machines/machines_test.go index 35312d6ac0..829c5340f3 100644 --- a/test/machines/machines_test.go +++ b/test/machines/machines_test.go @@ -59,7 +59,7 @@ var _ = framework.SigKubeDescribe("Machines", func() { _, err = f.KubeClient.CoreV1().Namespaces().Create(testNamespace) Expect(err).NotTo(HaveOccurred()) - f.DeployClusterAPIStack(testNamespace.Name, f.ActuatorImage, "") + f.DeployClusterAPIStack(testNamespace.Name, "") }) AfterEach(func() { @@ -67,7 +67,7 @@ var _ = framework.SigKubeDescribe("Machines", func() { machinesToDelete.Delete() if testNamespace != nil { - f.DestroyClusterAPIStack(testNamespace.Name, f.ActuatorImage, "") + f.DestroyClusterAPIStack(testNamespace.Name, "") log.Infof(testNamespace.Name+": %#v", testNamespace) By(fmt.Sprintf("Destroying %q namespace", testNamespace.Name)) f.KubeClient.CoreV1().Namespaces().Delete(testNamespace.Name, &metav1.DeleteOptions{}) @@ -243,8 +243,12 @@ var _ = framework.SigKubeDescribe("Machines", func() { dnsName, err := acw.GetPublicDNSName(masterMachine) Expect(err).NotTo(HaveOccurred()) - err = f.UploadDockerImageToInstance(f.ActuatorImage, dnsName) + err = f.UploadDockerImageToInstance(f.MachineControllerImage, dnsName) Expect(err).NotTo(HaveOccurred()) + if f.MachineManagerImage != f.MachineControllerImage { + err = f.UploadDockerImageToInstance(f.MachineManagerImage, dnsName) + Expect(err).NotTo(HaveOccurred()) + } // Deploy the cluster API stack inside the master machine sshConfig, err := framework.DefaultSSHConfig() @@ -255,7 +259,7 @@ var _ = framework.SigKubeDescribe("Machines", func() { _, err = clusterFramework.KubeClient.CoreV1().Namespaces().Create(testNamespace) Expect(err).NotTo(HaveOccurred()) - clusterFramework.DeployClusterAPIStack(testNamespace.Name, f.ActuatorImage, "") + clusterFramework.DeployClusterAPIStack(testNamespace.Name, "") By("Deploy worker nodes through machineset") masterPrivateIP, err := acw.GetPrivateIP(masterMachine) diff --git a/test/utils/manifests.go b/test/utils/manifests.go index 9f98f99491..c7867f25a8 100644 --- a/test/utils/manifests.go +++ b/test/utils/manifests.go @@ -25,7 +25,7 @@ func GenerateAwsCredentialsSecretFromEnv(secretName, namespace string) *apiv1.Se } } -func TestingMachineProviderConfig(awsCredentialsSecretName string, clusterID string) (clusterv1alpha1.ProviderConfig, error) { +func TestingMachineProviderConfig(awsCredentialsSecretName string, clusterID string) (clusterv1alpha1.ProviderSpec, error) { publicIP := true machinePc := &providerconfigv1.AWSMachineProviderConfig{ AMI: providerconfigv1.AWSResourceReference{ @@ -89,16 +89,16 @@ func TestingMachineProviderConfig(awsCredentialsSecretName string, clusterID str codec, err := providerconfigv1.NewCodec() if err != nil { - return clusterv1alpha1.ProviderConfig{}, fmt.Errorf("failed creating codec: %v", err) + return clusterv1alpha1.ProviderSpec{}, fmt.Errorf("failed creating codec: %v", err) } config, err := codec.EncodeProviderConfig(machinePc) if err != nil { - return clusterv1alpha1.ProviderConfig{}, fmt.Errorf("EncodeToProviderConfig failed: %v", err) + return clusterv1alpha1.ProviderSpec{}, fmt.Errorf("EncodeToProviderConfig failed: %v", err) } return *config, nil } -func MasterMachineProviderConfig(awsCredentialsSecretName, masterUserDataSecretName, clusterID string) (clusterv1alpha1.ProviderConfig, error) { +func MasterMachineProviderConfig(awsCredentialsSecretName, masterUserDataSecretName, clusterID string) (clusterv1alpha1.ProviderSpec, error) { publicIP := true machinePc := &providerconfigv1.AWSMachineProviderConfig{ AMI: providerconfigv1.AWSResourceReference{ @@ -151,16 +151,16 @@ func MasterMachineProviderConfig(awsCredentialsSecretName, masterUserDataSecretN codec, err := providerconfigv1.NewCodec() if err != nil { - return clusterv1alpha1.ProviderConfig{}, fmt.Errorf("failed creating codec: %v", err) + return clusterv1alpha1.ProviderSpec{}, fmt.Errorf("failed creating codec: %v", err) } config, err := codec.EncodeProviderConfig(machinePc) if err != nil { - return clusterv1alpha1.ProviderConfig{}, fmt.Errorf("EncodeToProviderConfig failed: %v", err) + return clusterv1alpha1.ProviderSpec{}, fmt.Errorf("EncodeToProviderConfig failed: %v", err) } return *config, nil } -func WorkerMachineSetProviderConfig(awsCredentialsSecretName, workerUserDataSecretName, clusterID string) (clusterv1alpha1.ProviderConfig, error) { +func WorkerMachineSetProviderConfig(awsCredentialsSecretName, workerUserDataSecretName, clusterID string) (clusterv1alpha1.ProviderSpec, error) { publicIP := true machinePc := &providerconfigv1.AWSMachineProviderConfig{ AMI: providerconfigv1.AWSResourceReference{ @@ -213,11 +213,11 @@ func WorkerMachineSetProviderConfig(awsCredentialsSecretName, workerUserDataSecr codec, err := providerconfigv1.NewCodec() if err != nil { - return clusterv1alpha1.ProviderConfig{}, fmt.Errorf("failed creating codec: %v", err) + return clusterv1alpha1.ProviderSpec{}, fmt.Errorf("failed creating codec: %v", err) } config, err := codec.EncodeProviderConfig(machinePc) if err != nil { - return clusterv1alpha1.ProviderConfig{}, fmt.Errorf("EncodeToProviderConfig failed: %v", err) + return clusterv1alpha1.ProviderSpec{}, fmt.Errorf("EncodeToProviderConfig failed: %v", err) } return *config, nil } diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1/machine_types.go b/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1/machine_types.go index 5a10bba39f..0825301642 100644 --- a/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1/machine_types.go +++ b/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1/machine_types.go @@ -63,6 +63,10 @@ type MachineSpec struct { // +optional ProviderSpec ProviderSpec `json:"providerSpec"` + // Provider-specific configuration to use during node creation. + // +optional + ProviderConfig ProviderSpec `json:"providerConfig"` + // Versions of key software to use. This field is optional at cluster // creation time, and omitting the field indicates that the cluster // installation tool should select defaults for the user. These diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1/zz_generated.deepcopy.go b/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1/zz_generated.deepcopy.go index 9b0a035208..3f9b9cdb3b 100644 --- a/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1/zz_generated.deepcopy.go +++ b/vendor/sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1/zz_generated.deepcopy.go @@ -632,6 +632,7 @@ func (in *MachineSpec) DeepCopyInto(out *MachineSpec) { } } in.ProviderSpec.DeepCopyInto(&out.ProviderSpec) + in.ProviderConfig.DeepCopyInto(&out.ProviderConfig) out.Versions = in.Versions if in.ConfigSource != nil { in, out := &in.ConfigSource, &out.ConfigSource