mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 17:11:49 +00:00
chore(sg): cloud ephemeral fix instance check (#62988)
* fix instance check * fix name sanitization
This commit is contained in:
parent
52059fc947
commit
bc73643a5d
@ -95,15 +95,14 @@ func createDeploymentForVersion(ctx context.Context, email, name, version string
|
||||
|
||||
// Check if the deployment already exists
|
||||
pending.Updatef("Checking if deployment %q already exists", name)
|
||||
_, err = cloudClient.GetInstance(ctx, name)
|
||||
if err != nil {
|
||||
if !errors.Is(err, ErrInstanceNotFound) {
|
||||
return errors.Wrapf(err, "failed to check if instance %q already exists", name)
|
||||
} else {
|
||||
pending.Complete(output.Linef(output.EmojiFailure, output.StyleFailure, "Deployment of %q failed", name))
|
||||
// Deployment exists
|
||||
return ErrDeploymentExists
|
||||
}
|
||||
inst, err := cloudClient.GetInstance(ctx, name)
|
||||
if err != nil && !errors.Is(err, ErrInstanceNotFound) {
|
||||
return errors.Wrapf(err, "failed to check if instance %q already exists", name)
|
||||
}
|
||||
if inst != nil {
|
||||
pending.Complete(output.Linef(output.EmojiFailure, output.StyleFailure, "Deployment of %q failed", name))
|
||||
// Deployment exists
|
||||
return ErrDeploymentExists
|
||||
}
|
||||
|
||||
pending.Updatef("Fetching license key...")
|
||||
@ -113,13 +112,13 @@ func createDeploymentForVersion(ctx context.Context, email, name, version string
|
||||
return err
|
||||
}
|
||||
spec := NewDeploymentSpec(
|
||||
sanitizeInstanceName(name),
|
||||
name,
|
||||
version,
|
||||
license,
|
||||
)
|
||||
|
||||
pending.Updatef("Creating deployment %q for version %q", spec.Name, spec.Version)
|
||||
inst, err := cloudClient.CreateInstance(ctx, spec)
|
||||
inst, err = cloudClient.CreateInstance(ctx, spec)
|
||||
if err != nil {
|
||||
pending.Complete(output.Linef(output.EmojiFailure, output.StyleFailure, "Deployment of %q failed", spec.Name))
|
||||
return errors.Wrapf(err, "failed to deploy %q of version %s", spec.Name, spec.Version)
|
||||
@ -186,7 +185,7 @@ func determineDeploymentName(originalName, version, email, branch string) string
|
||||
deploymentName = branch
|
||||
}
|
||||
|
||||
return deploymentName
|
||||
return sanitizeInstanceName(deploymentName)
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -37,7 +37,7 @@ func upgradeDeploymentForVersion(ctx context.Context, email, name, version strin
|
||||
}
|
||||
|
||||
spec := NewDeploymentSpec(
|
||||
sanitizeInstanceName(name),
|
||||
name,
|
||||
version,
|
||||
"", // we don't need a license during upgrade
|
||||
)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user