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

Commit 6021f6f

Browse files
authored
Merge pull request #452 from jessicaochen/safety
check for CRD on machine create
2 parents f33b50a + 0116fea commit 6021f6f

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

cluster-api/cloud/google/pods.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
"github.com/golang/glog"
2828
)
2929

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

3232
func init() {
3333
if img, ok := os.LookupEnv("MACHINE_CONTROLLER_IMAGE"); ok {

cluster-api/machine-controller/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
PROJECT=k8s-cluster-api
22
NAME=machine-controller
3-
VERSION=0.15
3+
VERSION=0.16
44

55
staticbuild:
66
CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' .

cluster-api/machine-controller/controller/machinecontroller.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ type MachineController struct {
4343
clusterClient *client.ClusterAPIV1Alpha1Client
4444
actuator cloud.MachineActuator
4545
nodeWatcher *NodeWatcher
46+
machineClient client.MachinesInterface
4647
runner *asyncRunner
4748
}
4849

@@ -82,6 +83,7 @@ func NewMachineController(config *Configuration) *MachineController {
8283
clusterClient: clusterClient,
8384
actuator: actuator,
8485
nodeWatcher: nodeWatcher,
86+
machineClient: machineClient,
8587
runner: newAsyncRunner(),
8688
}
8789
}
@@ -197,6 +199,15 @@ func (c *MachineController) create(machine *clusterv1.Machine) error {
197199
return err
198200
}
199201

202+
// Sometimes old events get replayed even though they have already been processed by this
203+
// controller. Temporarily work around this by checking if the machine CRD actually exists
204+
// on create.
205+
_, err = c.machineClient.Get(machine.ObjectMeta.Name, metav1.GetOptions{})
206+
if err != nil {
207+
glog.Errorf("Skipping machine create due to error getting machine %v: %v\n", machine.ObjectMeta.Name, err)
208+
return err
209+
}
210+
200211
return c.actuator.Create(cluster, machine)
201212
}
202213

0 commit comments

Comments
 (0)