Skip to content

Commit

Permalink
address coderabbit feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
bohendo committed Oct 5, 2023
1 parent ae6f312 commit 17f55e6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cmd/cloudexec/user_data.sh.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 5 additions & 7 deletions pkg/digitalocean/digitalocean.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions pkg/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 17f55e6

Please sign in to comment.