Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: improve errors for multiregion deployments #15326

Merged
merged 1 commit into from
Nov 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions command/deployment_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,11 +478,10 @@ func getDeployment(client *api.Deployments, dID string) (match *api.Deployment,
return nil, nil, err
}

l := len(deploys)
switch {
case l == 0:
switch len(deploys) {
case 0:
return nil, nil, fmt.Errorf("Deployment ID %q matched no deployments", dID)
case l == 1:
case 1:
return deploys[0], nil, nil
default:
return nil, deploys, nil
Expand All @@ -508,7 +507,8 @@ func formatDeployment(c *api.Client, d *api.Deployment, uuidLength int) string {
if d.IsMultiregion {
regions, err := fetchMultiRegionDeployments(c, d)
if err != nil {
base += "\n\nError fetching Multiregion deployments\n\n"
base += "\n\nError fetching multiregion deployment\n\n"
base += fmt.Sprintf("%v\n\n", err)
} else if len(regions) > 0 {
base += "\n\n[bold]Multiregion Deployment[reset]\n"
base += formatMultiregionDeployment(regions, uuidLength)
Expand All @@ -534,7 +534,7 @@ func fetchMultiRegionDeployments(c *api.Client, d *api.Deployment) (map[string]*

job, _, err := c.Jobs().Info(d.JobID, &api.QueryOptions{})
if err != nil {
return nil, err
return nil, fmt.Errorf("Error fetching job: %v", err)
}

requests := make(chan regionResult, len(job.Multiregion.Regions))
Expand Down Expand Up @@ -566,7 +566,7 @@ func fetchRegionDeployment(c *api.Client, d *api.Deployment, region *api.Multire
opts := &api.QueryOptions{Region: region.Name}
deploys, _, err := c.Jobs().Deployments(d.JobID, false, opts)
if err != nil {
return nil, err
return nil, fmt.Errorf("Error fetching deployments for job %s: %v", d.JobID, err)
}
for _, dep := range deploys {
if dep.JobVersion == d.JobVersion {
Expand Down