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

Commit c87f1c0

Browse files
authored
Merge pull request #447 from jessicaochen/delete_clean
cleanup nodes on delete and annotations on clone
2 parents a02bba6 + 939f69c commit c87f1c0

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
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.14"
30+
var machineControllerImage = "gcr.io/k8s-cluster-api/machine-controller:0.15"
3131

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

cluster-api/examples/machineset/scale.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ func clone(old clusterv1.Machine) *clusterv1.Machine {
134134
newMachine.ObjectMeta = metav1.ObjectMeta{}
135135
newMachine.ObjectMeta.GenerateName = old.ObjectMeta.GenerateName
136136
newMachine.ObjectMeta.Labels = old.ObjectMeta.Labels
137-
newMachine.ObjectMeta.Annotations = old.ObjectMeta.Annotations
137+
// Do not copy annotations as they currently contain info like machine name/location etc.
138+
// newMachine.ObjectMeta.Annotations = old.ObjectMeta.Annotations
138139
newMachine.ObjectMeta.ClusterName = old.ObjectMeta.ClusterName
139140

140141
// Completely wipe out the status as well

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.14
3+
VERSION=0.15
44

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

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,17 +197,18 @@ func (c *MachineController) create(machine *clusterv1.Machine) error {
197197
return err
198198
}
199199

200-
//TODO: check if the actual machine does not already exist
201200
return c.actuator.Create(cluster, machine)
202-
//TODO: wait for machine to become a node
203-
//TODO: link node to machine CRD
204201
}
205202

206203
func (c *MachineController) delete(machine *clusterv1.Machine) error {
207-
//TODO: check if the actual machine does not exist
208-
//TODO: delink node from machine CRD
209204
c.kubeClientSet.CoreV1().Nodes().Delete(machine.ObjectMeta.Name, &metav1.DeleteOptions{})
210-
return c.actuator.Delete(machine)
205+
if err := c.actuator.Delete(machine); err != nil {
206+
return err
207+
}
208+
// Do a second node cleanup after the delete completes in case the node joined the cluster
209+
// while the deletion of the machine was mid-way.
210+
c.kubeClientSet.CoreV1().Nodes().Delete(machine.ObjectMeta.Name, &metav1.DeleteOptions{})
211+
return nil
211212
}
212213

213214
func (c *MachineController) update(old_machine *clusterv1.Machine, new_machine *clusterv1.Machine) error {

0 commit comments

Comments
 (0)