Skip to content

Commit

Permalink
Push last changes
Browse files Browse the repository at this point in the history
  • Loading branch information
roberth1988 committed Sep 29, 2020
1 parent 5f46e78 commit e71caa5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion cleaner/cleaner.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (c *HangingDropletsCleaner) Collect(ch chan<- prometheus.Metric) {

func (c *HangingDropletsCleaner) shouldRemoveDroplet(droplet godo.Droplet, machines []Machine) bool {
for _, machine := range machines {
if droplet.Name == machine.Name && machine.DropletId != "" {
if droplet.Name == machine.Name && machine.DropletId != 0 {
return false
}
}
Expand Down
10 changes: 5 additions & 5 deletions cleaner/cleaner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func TestCleanerNoDroplets(t *testing.T) {
machines = []Machine{
{
Name: "runner-abc123-test-1",
DropletId: "",
DropletId: 0,
},
}
return
Expand Down Expand Up @@ -171,7 +171,7 @@ func TestCleanerDropletsAndMachinesNotMatching(t *testing.T) {
machines = []Machine{
{
Name: "runner-abc123-test-1",
DropletId: "0",
DropletId: 0,
},
}
return
Expand Down Expand Up @@ -214,7 +214,7 @@ func TestCleanerDropletsAndMachinesPartiallyMatching(t *testing.T) {
machines = []Machine{
{
Name: "runner-abc123-test-1",
DropletId: "0",
DropletId: 0,
},
}
return
Expand Down Expand Up @@ -257,11 +257,11 @@ func TestCleanerDropletsAndMachinesMatching(t *testing.T) {
machines = []Machine{
{
Name: "runner-abc123-test-1",
DropletId: "0",
DropletId: 0,
},
{
Name: "runner-abc123-test-2",
DropletId: "0",
DropletId: 0,
},
}
return
Expand Down
10 changes: 5 additions & 5 deletions cleaner/machines_finder.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type MachinesFinder struct {

type Machine struct {
Name string
DropletId string
DropletId float64
}

func (m *MachinesFinder) ListMachines(runnerPrefixRegexp *regexp.Regexp) ([]Machine, error) {
Expand All @@ -35,8 +35,8 @@ func (m *MachinesFinder) ListMachines(runnerPrefixRegexp *regexp.Regexp) ([]Mach
continue
}

configFile := fmt.Sprintf("%s/config.json", name)
dropletId := ""
configFile := fmt.Sprintf("%s/%s/config.json", m.machinesDirectory, name)
dropletId := float64(0)

if _, err := os.Stat(configFile); os.IsNotExist(err) {
return nil, err
Expand All @@ -58,9 +58,9 @@ func (m *MachinesFinder) ListMachines(runnerPrefixRegexp *regexp.Regexp) ([]Mach

if driverConfig, ok := dockerMachineConfigParsed["Driver"].(map[string]interface{}); ok {

dropletIdString := driverConfig["DropletID"].(string)
dropletIdString := driverConfig["DropletID"].(float64)

if dropletIdString != "0" {
if dropletIdString != 0 {
dropletId = dropletIdString
}
}
Expand Down

0 comments on commit e71caa5

Please sign in to comment.