diff --git a/cmd/cloudexec/user_data.sh.tmpl b/cmd/cloudexec/user_data.sh.tmpl index 51d7898..d6ab66f 100644 --- a/cmd/cloudexec/user_data.sh.tmpl +++ b/cmd/cloudexec/user_data.sh.tmpl @@ -131,7 +131,7 @@ cleanup() { echo "Uploading results..." s3cmd put -r ~/output/* "s3://${BUCKET_NAME}/job-${JOB_ID}/output/" else - echo "Skipping results upload, no files found in ~/ouput" + echo "Skipping results upload, no files found in ~/output" fi if [[ -s ${stdout_log} ]]; then diff --git a/pkg/digitalocean/digitalocean.go b/pkg/digitalocean/digitalocean.go index 25b5c2a..245a593 100644 --- a/pkg/digitalocean/digitalocean.go +++ b/pkg/digitalocean/digitalocean.go @@ -216,23 +216,22 @@ func CreateDroplet(config config.Config, username string, region string, size st } func GetDropletById(config config.Config, id int64) (Droplet, error) { - var droplet Droplet // create a client doClient, err := initializeDOClient(config.DigitalOcean.ApiKey) if err != nil { - return droplet, err + return Droplet{}, err } dropletInfo, _, err := doClient.Droplets.Get(context.TODO(), int(id)) if err != nil { - return droplet, fmt.Errorf("Failed to get droplet by id: %v", err) + return Droplet{}, fmt.Errorf("Failed to get droplet by id: %v", err) } pubIp, err := dropletInfo.PublicIPv4() if err != nil { - return droplet, fmt.Errorf("Failed to fetch droplet IP: %w", err) + return Droplet{}, fmt.Errorf("Failed to fetch droplet IP: %w", err) } - droplet = Droplet{ + return Droplet{ Name: dropletInfo.Name, ID: int64(dropletInfo.ID), IP: pubIp, @@ -243,8 +242,7 @@ func GetDropletById(config config.Config, id int64) (Droplet, error) { Memory: int64(dropletInfo.Memory), HourlyCost: float64(dropletInfo.Size.PriceHourly), }, - } - return droplet, nil + }, nil } // GetDropletsByName returns a list of droplets with the given tag using a godo client diff --git a/pkg/state/state.go b/pkg/state/state.go index 13633ae..3347afd 100644 --- a/pkg/state/state.go +++ b/pkg/state/state.go @@ -210,6 +210,9 @@ func GetJobIdsByInstance(config config.Config, bucketName string) (map[int64][]i return instanceToJobIds, nil } for _, job := range existingState.Jobs { + if job.Droplet.ID == 0 { + return nil, fmt.Errorf("Uninitialized droplet id for job %v", job.ID) + } instanceToJobIds[job.Droplet.ID] = append(instanceToJobIds[job.Droplet.ID], job.ID) } return instanceToJobIds, nil