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

Commit

Permalink
Merge pull request #447 from jessicaochen/delete_clean
Browse files Browse the repository at this point in the history
cleanup nodes on delete and annotations on clone
  • Loading branch information
jessicaochen authored Nov 30, 2017
2 parents a02bba6 + 939f69c commit c87f1c0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 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.14"
var machineControllerImage = "gcr.io/k8s-cluster-api/machine-controller:0.15"

func init() {
if img, ok := os.LookupEnv("MACHINE_CONTROLLER_IMAGE"); ok {
Expand Down
3 changes: 2 additions & 1 deletion cluster-api/examples/machineset/scale.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ func clone(old clusterv1.Machine) *clusterv1.Machine {
newMachine.ObjectMeta = metav1.ObjectMeta{}
newMachine.ObjectMeta.GenerateName = old.ObjectMeta.GenerateName
newMachine.ObjectMeta.Labels = old.ObjectMeta.Labels
newMachine.ObjectMeta.Annotations = old.ObjectMeta.Annotations
// Do not copy annotations as they currently contain info like machine name/location etc.
// newMachine.ObjectMeta.Annotations = old.ObjectMeta.Annotations
newMachine.ObjectMeta.ClusterName = old.ObjectMeta.ClusterName

// Completely wipe out the status as well
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.14
VERSION=0.15

staticbuild:
CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' .
Expand Down
13 changes: 7 additions & 6 deletions cluster-api/machine-controller/controller/machinecontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,17 +197,18 @@ func (c *MachineController) create(machine *clusterv1.Machine) error {
return err
}

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

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

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

0 comments on commit c87f1c0

Please sign in to comment.