diff --git a/Gopkg.lock b/Gopkg.lock index c6bd28cf5e..f508fd6f66 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -414,8 +414,8 @@ version = "v1.5.0" [[projects]] - branch = "openshift-4.0-cluster-api-0.0.0-alpha.4" - digest = "1:7ac2d0246b09e9066ff66824b8686d4dd8ff6158cf7cbd058972a1a1e41b7df9" + branch = "openshift-4.2-cluster-api-0.0.0-alpha.4" + digest = "1:d67ab3b4d46616ef4c7d482dd8a88dbe4634f3a35dd354720cb7a4d6b2f59fa1" name = "github.com/openshift/cluster-api" packages = [ "cmd/clusterctl/clientcmd", @@ -446,7 +446,7 @@ "pkg/util", ] pruneopts = "T" - revision = "261136cbb6fbf4cf27f00b9da13a17f27ad4e1b1" + revision = "9941763fab7237205d6eb162cae1bfb1d0096058" [[projects]] branch = "master" diff --git a/Gopkg.toml b/Gopkg.toml index e9bf750972..709de544cd 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -48,7 +48,7 @@ required = [ [[override]] name = "github.com/openshift/cluster-api" - branch = "openshift-4.0-cluster-api-0.0.0-alpha.4" + branch = "openshift-4.2-cluster-api-0.0.0-alpha.4" [[override]] name = "k8s.io/code-generator" diff --git a/pkg/cloud/openstack/deployer.go b/pkg/cloud/openstack/deployer.go index 8fec94882e..084af4c6a2 100644 --- a/pkg/cloud/openstack/deployer.go +++ b/pkg/cloud/openstack/deployer.go @@ -23,6 +23,7 @@ import ( "strings" clustercommon "github.com/openshift/cluster-api/pkg/apis/cluster/common" + clusterv1 "github.com/openshift/cluster-api/pkg/apis/cluster/v1alpha1" machinev1 "github.com/openshift/cluster-api/pkg/apis/machine/v1beta1" "github.com/openshift/cluster-api/pkg/util" "k8s.io/klog" @@ -45,7 +46,7 @@ func NewDeploymentClient() *DeploymentClient { return &DeploymentClient{} } -func (*DeploymentClient) GetIP(cluster *machinev1.Cluster, machine *machinev1.Machine) (string, error) { +func (*DeploymentClient) GetIP(cluster *clusterv1.Cluster, machine *machinev1.Machine) (string, error) { if machine.ObjectMeta.Annotations != nil { if ip, ok := machine.ObjectMeta.Annotations[OpenstackIPAnnotationKey]; ok { klog.Infof("Returning IP from machine annotation %s", ip) @@ -56,7 +57,7 @@ func (*DeploymentClient) GetIP(cluster *machinev1.Cluster, machine *machinev1.Ma return "", errors.New("could not get IP") } -func (d *DeploymentClient) GetKubeConfig(cluster *machinev1.Cluster, master *machinev1.Machine) (string, error) { +func (d *DeploymentClient) GetKubeConfig(cluster *clusterv1.Cluster, master *machinev1.Machine) (string, error) { ip, err := d.GetIP(cluster, master) if err != nil { return "", err diff --git a/pkg/cloud/openstack/machine/actuator.go b/pkg/cloud/openstack/machine/actuator.go index b565dd2d64..8a2d9f3434 100644 --- a/pkg/cloud/openstack/machine/actuator.go +++ b/pkg/cloud/openstack/machine/actuator.go @@ -28,6 +28,7 @@ import ( "k8s.io/apimachinery/pkg/api/equality" + clusterv1 "github.com/openshift/cluster-api/pkg/apis/cluster/v1alpha1" machinev1 "github.com/openshift/cluster-api/pkg/apis/machine/v1beta1" apierrors "github.com/openshift/cluster-api/pkg/errors" "github.com/openshift/cluster-api/pkg/util" @@ -86,7 +87,7 @@ func getTimeout(name string, timeout int) time.Duration { return time.Duration(timeout) } -func (oc *OpenstackClient) Create(ctx context.Context, cluster *machinev1.Cluster, machine *machinev1.Machine) error { +func (oc *OpenstackClient) Create(ctx context.Context, cluster *clusterv1.Cluster, machine *machinev1.Machine) error { if cluster == nil { return fmt.Errorf("The cluster is nil, check your cluster configuration") } @@ -154,7 +155,9 @@ func (oc *OpenstackClient) Create(ctx context.Context, cluster *machinev1.Cluste var userDataRendered string if len(userData) > 0 && !disableTemplating { - if machine.Spec.Versions.ControlPlane != "" { + // if machine.Spec.Versions.ControlPlane != "" { + // FIXME(mandre) not sure this is right + if machine.ObjectMeta.Name != "" { userDataRendered, err = masterStartupScript(cluster, machine, string(userData)) if err != nil { return oc.handleMachineError(machine, apierrors.CreateMachine( @@ -251,7 +254,7 @@ func (oc *OpenstackClient) Create(ctx context.Context, cluster *machinev1.Cluste return oc.updateAnnotation(machine, instance.ID) } -func (oc *OpenstackClient) Delete(ctx context.Context, cluster *machinev1.Cluster, machine *machinev1.Machine) error { +func (oc *OpenstackClient) Delete(ctx context.Context, cluster *clusterv1.Cluster, machine *machinev1.Machine) error { machineService, err := clients.NewInstanceServiceFromMachine(oc.params.KubeClient, machine) if err != nil { return err @@ -277,7 +280,7 @@ func (oc *OpenstackClient) Delete(ctx context.Context, cluster *machinev1.Cluste return nil } -func (oc *OpenstackClient) Update(ctx context.Context, cluster *machinev1.Cluster, machine *machinev1.Machine) error { +func (oc *OpenstackClient) Update(ctx context.Context, cluster *clusterv1.Cluster, machine *machinev1.Machine) error { if cluster == nil { return fmt.Errorf("The cluster is nil, check your cluster configuration") } @@ -305,7 +308,9 @@ func (oc *OpenstackClient) Update(ctx context.Context, cluster *machinev1.Cluste return nil } - if currentMachine.Spec.Versions.ControlPlane != "" { + // if currentMachine.Spec.Versions.ControlPlane != "" { + // FIXME(mandre) not sure this is right + if currentMachine.ObjectMeta.Name != "" { // TODO: add master inplace klog.Errorf("master inplace update failed: not support master in place update now") } else { @@ -339,7 +344,7 @@ func (oc *OpenstackClient) Update(ctx context.Context, cluster *machinev1.Cluste return nil } -func (oc *OpenstackClient) Exists(ctx context.Context, cluster *machinev1.Cluster, machine *machinev1.Machine) (bool, error) { +func (oc *OpenstackClient) Exists(ctx context.Context, cluster *clusterv1.Cluster, machine *machinev1.Machine) (bool, error) { instance, err := oc.instanceExists(machine) if err != nil { return false, err @@ -447,7 +452,6 @@ func (oc *OpenstackClient) requiresUpdate(a *machinev1.Machine, b *machinev1.Mac // Do not want status changes. Do want changes that impact machine provisioning return !reflect.DeepEqual(a.Spec.ObjectMeta, b.Spec.ObjectMeta) || !reflect.DeepEqual(a.Spec.ProviderSpec, b.Spec.ProviderSpec) || - !reflect.DeepEqual(a.Spec.Versions, b.Spec.Versions) || a.ObjectMeta.Name != b.ObjectMeta.Name } diff --git a/pkg/cloud/openstack/machine/machineScript.go b/pkg/cloud/openstack/machine/machineScript.go index 2a39fab7ff..ad1ed25814 100644 --- a/pkg/cloud/openstack/machine/machineScript.go +++ b/pkg/cloud/openstack/machine/machineScript.go @@ -23,13 +23,14 @@ import ( "fmt" + clusterv1 "github.com/openshift/cluster-api/pkg/apis/cluster/v1alpha1" machinev1 "github.com/openshift/cluster-api/pkg/apis/machine/v1beta1" openstackconfigv1 "sigs.k8s.io/cluster-api-provider-openstack/pkg/apis/openstackproviderconfig/v1alpha1" ) type setupParams struct { Token string - Cluster *machinev1.Cluster + Cluster *clusterv1.Cluster Machine *machinev1.Machine MachineSpec *openstackconfigv1.OpenstackProviderSpec @@ -41,7 +42,7 @@ type setupParams struct { func init() { } -func masterStartupScript(cluster *machinev1.Cluster, machine *machinev1.Machine, script string) (string, error) { +func masterStartupScript(cluster *clusterv1.Cluster, machine *machinev1.Machine, script string) (string, error) { machineSpec, err := openstackconfigv1.MachineSpecFromProviderSpec(machine.Spec.ProviderSpec) if err != nil { return "", err @@ -67,7 +68,7 @@ func masterStartupScript(cluster *machinev1.Cluster, machine *machinev1.Machine, return buf.String(), nil } -func nodeStartupScript(cluster *machinev1.Cluster, machine *machinev1.Machine, token, script string) (string, error) { +func nodeStartupScript(cluster *clusterv1.Cluster, machine *machinev1.Machine, token, script string) (string, error) { machineSpec, err := openstackconfigv1.MachineSpecFromProviderSpec(machine.Spec.ProviderSpec) if err != nil { return "", err @@ -104,12 +105,12 @@ func nodeStartupScript(cluster *machinev1.Cluster, machine *machinev1.Machine, t return buf.String(), nil } -func getEndpoint(apiEndpoint machinev1.APIEndpoint) string { +func getEndpoint(apiEndpoint clusterv1.APIEndpoint) string { return fmt.Sprintf("%s:%d", apiEndpoint.Host, apiEndpoint.Port) } // Just a temporary hack to grab a single range from the config. -func getSubnet(netRange machinev1.NetworkRanges) string { +func getSubnet(netRange clusterv1.NetworkRanges) string { if len(netRange.CIDRBlocks) == 0 { return "" } diff --git a/vendor/github.com/openshift/cluster-api/cmd/manager/main.go b/vendor/github.com/openshift/cluster-api/cmd/manager/main.go index 1ffccaba69..251e23f676 100644 --- a/vendor/github.com/openshift/cluster-api/cmd/manager/main.go +++ b/vendor/github.com/openshift/cluster-api/cmd/manager/main.go @@ -19,6 +19,7 @@ package main import ( "flag" "log" + "time" "github.com/openshift/cluster-api/pkg/apis" "github.com/openshift/cluster-api/pkg/controller" @@ -32,8 +33,14 @@ import ( func main() { flag.Set("logtostderr", "true") klog.InitFlags(nil) - flag.Parse() + watchNamespace := flag.String("namespace", "", + "Namespace that the controller watches to reconcile cluster-api objects. If unspecified, the controller watches for cluster-api objects across all namespaces.") + flag.Parse() + if *watchNamespace != "" { + log.Printf("Watching cluster-api objects only in namespace %q for reconciliation.", *watchNamespace) + } + log.Printf("Registering Components.") // Get a config to talk to the apiserver cfg, err := config.GetConfig() if err != nil { @@ -41,7 +48,11 @@ func main() { } // Create a new Cmd to provide shared dependencies and start components - mgr, err := manager.New(cfg, manager.Options{}) + syncPeriod := 10 * time.Minute + mgr, err := manager.New(cfg, manager.Options{ + SyncPeriod: &syncPeriod, + Namespace: *watchNamespace, + }) if err != nil { log.Fatal(err) }