Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,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"
Expand Down
11 changes: 9 additions & 2 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
func main() {

flag.Set("logtostderr", "true")
watchNamespace := flag.String("namespace", "", "Namespace that the controller watches to reconcile machine-api objects. If unspecified, the controller watches for machine-api objects across all namespaces.")
klog.InitFlags(nil)
flag.Parse()

Expand All @@ -41,8 +42,14 @@ func main() {
klog.Fatal(err)
}

// Create a new Cmd to provide shared dependencies and start components
mgr, err := manager.New(cfg, manager.Options{})
// Setup a Manager
opts := manager.Options{}
if *watchNamespace != "" {
opts.Namespace = *watchNamespace
klog.Infof("Watching machine-api objects only in namespace %q for reconciliation.", opts.Namespace)
}

mgr, err := manager.New(cfg, opts)
if err != nil {
klog.Fatal(err)
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/cloud/openstack/deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
Expand All @@ -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
Expand Down
16 changes: 9 additions & 7 deletions pkg/cloud/openstack/machine/actuator.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,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"
Expand Down Expand Up @@ -74,7 +75,7 @@ func NewActuator(params openstack.ActuatorParams) (*OpenstackClient, error) {
}, nil
}

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 {
kubeClient := oc.params.KubeClient

machineService, err := clients.NewInstanceServiceFromMachine(kubeClient, machine)
Expand Down Expand Up @@ -138,7 +139,8 @@ func (oc *OpenstackClient) Create(ctx context.Context, cluster *machinev1.Cluste

var userDataRendered string
if len(userData) > 0 && !disableTemplating {
if machine.Spec.Versions.ControlPlane != "" {
// FIXME(mandre) Find the right way to check if machine is part of the control plane
if machine.ObjectMeta.Name != "" {
userDataRendered, err = masterStartupScript(cluster, machine, string(userData))
if err != nil {
return oc.handleMachineError(machine, apierrors.CreateMachine(
Expand Down Expand Up @@ -233,7 +235,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
Expand All @@ -259,7 +261,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 {
status, err := oc.instanceStatus(machine)
if err != nil {
return err
Expand All @@ -283,7 +285,8 @@ func (oc *OpenstackClient) Update(ctx context.Context, cluster *machinev1.Cluste
return nil
}

if currentMachine.Spec.Versions.ControlPlane != "" {
// FIXME(mandre) Find the right way to check if machine is part of the control plane
if currentMachine.ObjectMeta.Name != "" {
// TODO: add master inplace
klog.Errorf("master inplace update failed: not support master in place update now")
} else {
Expand Down Expand Up @@ -315,7 +318,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
Expand Down Expand Up @@ -423,7 +426,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
}

Expand Down
11 changes: 6 additions & 5 deletions pkg/cloud/openstack/machine/machineScript.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 ""
}
Expand Down
11 changes: 6 additions & 5 deletions pkg/cloud/openstack/machine/machineScript_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package machine
import (
"testing"

clusterv1 "github.com/openshift/cluster-api/pkg/apis/cluster/v1alpha1"
machinev1 "github.com/openshift/cluster-api/pkg/apis/machine/v1beta1"
"sigs.k8s.io/yaml"
)
Expand All @@ -14,7 +15,7 @@ value:
`

func TestNodeStartupScriptEmpty(t *testing.T) {
cluster := &machinev1.Cluster{}
cluster := &clusterv1.Cluster{}
machine := &machinev1.Machine{}
err := yaml.Unmarshal([]byte(providerSpecYAML), &machine.Spec.ProviderSpec)
if err != nil {
Expand All @@ -40,7 +41,7 @@ func TestNodeStartupScriptEmpty(t *testing.T) {
}

func TestNodeStartupScriptEndpointError(t *testing.T) {
cluster := &machinev1.Cluster{}
cluster := &clusterv1.Cluster{}
machine := &machinev1.Machine{}
err := yaml.Unmarshal([]byte(providerSpecYAML), &machine.Spec.ProviderSpec)
if err != nil {
Expand All @@ -59,9 +60,9 @@ func TestNodeStartupScriptEndpointError(t *testing.T) {
}

func TestNodeStartupScriptWithEndpoint(t *testing.T) {
cluster := machinev1.Cluster{}
cluster.Status.APIEndpoints = make([]machinev1.APIEndpoint, 1)
cluster.Status.APIEndpoints[0] = machinev1.APIEndpoint{
cluster := clusterv1.Cluster{}
cluster.Status.APIEndpoints = make([]clusterv1.APIEndpoint, 1)
cluster.Status.APIEndpoints[0] = clusterv1.APIEndpoint{
Host: "example.com",
Port: 8080,
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading