Skip to content

Commit

Permalink
Fixed empty machineID issue and enhanced print statements
Browse files Browse the repository at this point in the history
  • Loading branch information
prashanth26 committed Mar 4, 2019
1 parent 4da5d62 commit 5564f47
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
25 changes: 11 additions & 14 deletions pkg/controller/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ func (c *controller) machineDelete(machine *v1alpha1.Machine, driver driver.CMID

// If Finalizers are present
if finalizers := sets.NewString(machine.Finalizers...); finalizers.Has(DeleteFinalizerName) {
glog.V(2).Infof("Deleting Machine %s", machine.Name)
glog.V(2).Infof("Deleting Machine %q with MachineID %q", machine.Name, driver.MachineID)

// Getting the machine-ID on the cloud provider
machineID := driver.MachineID
Expand Down Expand Up @@ -492,20 +492,17 @@ func (c *controller) machineDelete(machine *v1alpha1.Machine, driver driver.CMID
}

// Check for existance of machine at cloud provider
_, err := driver.GetMachine(machineID)
if err == nil || status.Code(err) == codes.Unimplemented {
// Either there is no err
// or the GetMachine is not implemented
// then continue

err = driver.ShutDownMachine(machineID)
if err == nil || status.Code(err) == codes.Unimplemented {
// Either there is no err
// or the ShutDownMachine is not implemented
// then continue
err = driver.DeleteMachine(machineID)
}
_, err = driver.GetMachine(machineID)
if err != nil && status.Code(err) != codes.Unimplemented {
// If GetMachine was implemented and error occurred
glog.V(2).Infof("Get Machine called failed with the following error: %s", err)
}
err = driver.ShutDownMachine(machineID)
if err != nil && status.Code(err) != codes.Unimplemented {
// If ShutDownMachine was implemented and error occurred
glog.V(2).Infof("Shutdown Machine called failed with the following error: %s", err)
}
err = driver.DeleteMachine(machineID)
}

if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/machine_safety.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ func (c *controller) checkMachineClass(

listOfVMs, err := dvr.ListMachines()
if err != nil {
glog.Warningf("Orphan VM handler is not running. Failed to list VMs at provider. Err - %s", err)
glog.Warningf("Orphan VM handler is not running. Failed to list VMs at provider. \nErr - %s", err)
return
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/driver/cmi-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func (c *CMIDriverClient) GetMachine(MachineID string) (bool, error) {
defer closer.Close()

req := &cmipb.GetMachineRequest{
MachineID: c.MachineID,
MachineID: MachineID,
Secrets: c.Secret.Data,
}
ctx := context.Background()
Expand Down Expand Up @@ -219,7 +219,7 @@ func newGrpcConn(driverName string) (*grpc.ClientConn, error) {

network := "tcp"

glog.V(2).Infof("Creating new gRPC connection for [%s://%s] for driver: %s", network, addr, name)
glog.V(5).Infof("Creating new gRPC connection for [%s://%s] for driver: %s", network, addr, name)

return grpc.Dial(
addr,
Expand Down

0 comments on commit 5564f47

Please sign in to comment.