Skip to content
This repository has been archived by the owner on May 22, 2020. It is now read-only.

Commit

Permalink
check for CRD on machine create
Browse files Browse the repository at this point in the history
  • Loading branch information
jessicaochen committed Dec 1, 2017
1 parent 9472e03 commit 0116fea
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cluster-api/cloud/google/pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"github.com/golang/glog"
)

var machineControllerImage = "gcr.io/k8s-cluster-api/machine-controller:0.15"
var machineControllerImage = "gcr.io/k8s-cluster-api/machine-controller:0.16"

func init() {
if img, ok := os.LookupEnv("MACHINE_CONTROLLER_IMAGE"); ok {
Expand Down
2 changes: 1 addition & 1 deletion cluster-api/machine-controller/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PROJECT=k8s-cluster-api
NAME=machine-controller
VERSION=0.15
VERSION=0.16

staticbuild:
CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' .
Expand Down
11 changes: 11 additions & 0 deletions cluster-api/machine-controller/controller/machinecontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type MachineController struct {
clusterClient *client.ClusterAPIV1Alpha1Client
actuator cloud.MachineActuator
nodeWatcher *NodeWatcher
machineClient client.MachinesInterface
runner *asyncRunner
}

Expand Down Expand Up @@ -82,6 +83,7 @@ func NewMachineController(config *Configuration) *MachineController {
clusterClient: clusterClient,
actuator: actuator,
nodeWatcher: nodeWatcher,
machineClient: machineClient,
runner: newAsyncRunner(),
}
}
Expand Down Expand Up @@ -197,6 +199,15 @@ func (c *MachineController) create(machine *clusterv1.Machine) error {
return err
}

// Sometimes old events get replayed even though they have already been processed by this
// controller. Temporarily work around this by checking if the machine CRD actually exists
// on create.
_, err = c.machineClient.Get(machine.ObjectMeta.Name, metav1.GetOptions{})
if err != nil {
glog.Errorf("Skipping machine create due to error getting machine %v: %v\n", machine.ObjectMeta.Name, err)
return err
}

return c.actuator.Create(cluster, machine)
}

Expand Down

0 comments on commit 0116fea

Please sign in to comment.