fix: handle StackName / Name correctly
This commit is contained in:
parent
1b7836009f
commit
a556ca625b
|
@ -133,10 +133,9 @@ can take some time.
|
||||||
totalAppsCount++
|
totalAppsCount++
|
||||||
|
|
||||||
if status {
|
if status {
|
||||||
stackName := app.StackName()
|
|
||||||
status := "unknown"
|
status := "unknown"
|
||||||
version := "unknown"
|
version := "unknown"
|
||||||
if statusMeta, ok := statuses[stackName]; ok {
|
if statusMeta, ok := statuses[app.StackName()]; ok {
|
||||||
if currentVersion, exists := statusMeta["version"]; exists {
|
if currentVersion, exists := statusMeta["version"]; exists {
|
||||||
version = currentVersion
|
version = currentVersion
|
||||||
}
|
}
|
||||||
|
@ -191,7 +190,7 @@ can take some time.
|
||||||
|
|
||||||
appStats.server = app.Server
|
appStats.server = app.Server
|
||||||
appStats.recipe = app.Type
|
appStats.recipe = app.Type
|
||||||
appStats.appName = app.StackName()
|
appStats.appName = app.Name
|
||||||
appStats.domain = app.Domain
|
appStats.domain = app.Domain
|
||||||
|
|
||||||
stats.apps = append(stats.apps, appStats)
|
stats.apps = append(stats.apps, appStats)
|
||||||
|
|
|
@ -175,7 +175,7 @@ recipes.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := stack.RunDeploy(cl, deployOpts, compose, app.Type, internal.DontWaitConverge); err != nil {
|
if err := stack.RunDeploy(cl, deployOpts, compose, app.StackName(), internal.DontWaitConverge); err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ volumes as eligiblef or pruning once undeployed.
|
||||||
}
|
}
|
||||||
|
|
||||||
if !isDeployed {
|
if !isDeployed {
|
||||||
logrus.Fatalf("%s is not deployed?", stackName)
|
logrus.Fatalf("%s is not deployed?", app.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := internal.DeployOverview(app, deployedVersion, "continue with undeploy?"); err != nil {
|
if err := internal.DeployOverview(app, deployedVersion, "continue with undeploy?"); err != nil {
|
||||||
|
|
|
@ -188,7 +188,7 @@ recipes.
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := stack.RunDeploy(cl, deployOpts, compose, app.Type, internal.DontWaitConverge); err != nil {
|
if err := stack.RunDeploy(cl, deployOpts, compose, app.StackName(), internal.DontWaitConverge); err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,6 @@ import (
|
||||||
// DeployAction is the main command-line action for this package
|
// DeployAction is the main command-line action for this package
|
||||||
func DeployAction(c *cli.Context) error {
|
func DeployAction(c *cli.Context) error {
|
||||||
app := ValidateApp(c)
|
app := ValidateApp(c)
|
||||||
stackName := app.StackName()
|
|
||||||
|
|
||||||
if err := recipe.EnsureUpToDate(app.Type); err != nil {
|
if err := recipe.EnsureUpToDate(app.Type); err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
|
@ -43,18 +42,18 @@ func DeployAction(c *cli.Context) error {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Debugf("checking whether %s is already deployed", stackName)
|
logrus.Debugf("checking whether %s is already deployed", app.StackName())
|
||||||
|
|
||||||
isDeployed, deployedVersion, err := stack.IsDeployed(c.Context, cl, stackName)
|
isDeployed, deployedVersion, err := stack.IsDeployed(c.Context, cl, app.StackName())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if isDeployed {
|
if isDeployed {
|
||||||
if Force || Chaos {
|
if Force || Chaos {
|
||||||
logrus.Warnf("%s is already deployed but continuing (--force/--chaos)", stackName)
|
logrus.Warnf("%s is already deployed but continuing (--force/--chaos)", app.Name)
|
||||||
} else {
|
} else {
|
||||||
logrus.Fatalf("%s is already deployed", stackName)
|
logrus.Fatalf("%s is already deployed", app.Name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,7 +123,7 @@ func DeployAction(c *cli.Context) error {
|
||||||
}
|
}
|
||||||
deployOpts := stack.Deploy{
|
deployOpts := stack.Deploy{
|
||||||
Composefiles: composeFiles,
|
Composefiles: composeFiles,
|
||||||
Namespace: stackName,
|
Namespace: app.StackName(),
|
||||||
Prune: false,
|
Prune: false,
|
||||||
ResolveImage: stack.ResolveImageAlways,
|
ResolveImage: stack.ResolveImageAlways,
|
||||||
}
|
}
|
||||||
|
@ -151,7 +150,7 @@ func DeployAction(c *cli.Context) error {
|
||||||
logrus.Warn("skipping domain checks as requested")
|
logrus.Warn("skipping domain checks as requested")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := stack.RunDeploy(cl, deployOpts, compose, app.Env["TYPE"], DontWaitConverge); err != nil {
|
if err := stack.RunDeploy(cl, deployOpts, compose, app.Name, DontWaitConverge); err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,7 +172,7 @@ func DeployOverview(app config.App, version, message string) error {
|
||||||
server = "local"
|
server = "local"
|
||||||
}
|
}
|
||||||
|
|
||||||
table.Append([]string{server, deployConfig, app.Domain, app.StackName(), version})
|
table.Append([]string{server, deployConfig, app.Domain, app.Name, version})
|
||||||
table.Render()
|
table.Render()
|
||||||
|
|
||||||
if NoInput {
|
if NoInput {
|
||||||
|
@ -211,7 +210,7 @@ func NewVersionOverview(app config.App, currentVersion, newVersion, releaseNotes
|
||||||
server = "local"
|
server = "local"
|
||||||
}
|
}
|
||||||
|
|
||||||
table.Append([]string{server, deployConfig, app.Domain, app.StackName(), currentVersion, newVersion})
|
table.Append([]string{server, deployConfig, app.Domain, app.Name, currentVersion, newVersion})
|
||||||
table.Render()
|
table.Render()
|
||||||
|
|
||||||
if releaseNotes == "" {
|
if releaseNotes == "" {
|
||||||
|
|
|
@ -43,13 +43,17 @@ type App struct {
|
||||||
Path string
|
Path string
|
||||||
}
|
}
|
||||||
|
|
||||||
// StackName gets what the docker safe stack name is for the app
|
// StackName gets what the docker safe stack name is for the app. This should
|
||||||
|
// not not shown to the user, use a.Name for that. Give the output of this
|
||||||
|
// command to Docker only.
|
||||||
func (a App) StackName() string {
|
func (a App) StackName() string {
|
||||||
if _, exists := a.Env["STACK_NAME"]; exists {
|
if _, exists := a.Env["STACK_NAME"]; exists {
|
||||||
return a.Env["STACK_NAME"]
|
return a.Env["STACK_NAME"]
|
||||||
}
|
}
|
||||||
|
|
||||||
stackName := SanitiseAppName(a.Name)
|
stackName := SanitiseAppName(a.Name)
|
||||||
a.Env["STACK_NAME"] = stackName
|
a.Env["STACK_NAME"] = stackName
|
||||||
|
|
||||||
return stackName
|
return stackName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -158,7 +158,7 @@ func pruneServices(ctx context.Context, cl *dockerclient.Client, namespace conve
|
||||||
}
|
}
|
||||||
|
|
||||||
// RunDeploy is the swarm implementation of docker stack deploy
|
// RunDeploy is the swarm implementation of docker stack deploy
|
||||||
func RunDeploy(cl *dockerclient.Client, opts Deploy, cfg *composetypes.Config, recipeName string, dontWait bool) error {
|
func RunDeploy(cl *dockerclient.Client, opts Deploy, cfg *composetypes.Config, appName string, dontWait bool) error {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
if err := validateResolveImageFlag(&opts); err != nil {
|
if err := validateResolveImageFlag(&opts); err != nil {
|
||||||
|
@ -170,7 +170,7 @@ func RunDeploy(cl *dockerclient.Client, opts Deploy, cfg *composetypes.Config, r
|
||||||
opts.ResolveImage = ResolveImageNever
|
opts.ResolveImage = ResolveImageNever
|
||||||
}
|
}
|
||||||
|
|
||||||
return deployCompose(ctx, cl, opts, cfg, recipeName, dontWait)
|
return deployCompose(ctx, cl, opts, cfg, appName, dontWait)
|
||||||
}
|
}
|
||||||
|
|
||||||
// validateResolveImageFlag validates the opts.resolveImage command line option
|
// validateResolveImageFlag validates the opts.resolveImage command line option
|
||||||
|
@ -183,7 +183,7 @@ func validateResolveImageFlag(opts *Deploy) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func deployCompose(ctx context.Context, cl *dockerclient.Client, opts Deploy, config *composetypes.Config, recipeName string, dontWait bool) error {
|
func deployCompose(ctx context.Context, cl *dockerclient.Client, opts Deploy, config *composetypes.Config, appName string, dontWait bool) error {
|
||||||
namespace := convert.NewNamespace(opts.Namespace)
|
namespace := convert.NewNamespace(opts.Namespace)
|
||||||
|
|
||||||
if opts.Prune {
|
if opts.Prune {
|
||||||
|
@ -224,7 +224,7 @@ func deployCompose(ctx context.Context, cl *dockerclient.Client, opts Deploy, co
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return deployServices(ctx, cl, services, namespace, opts.SendRegistryAuth, opts.ResolveImage, recipeName, dontWait)
|
return deployServices(ctx, cl, services, namespace, opts.SendRegistryAuth, opts.ResolveImage, appName, dontWait)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getServicesDeclaredNetworks(serviceConfigs []composetypes.ServiceConfig) map[string]struct{} {
|
func getServicesDeclaredNetworks(serviceConfigs []composetypes.ServiceConfig) map[string]struct{} {
|
||||||
|
@ -340,7 +340,7 @@ func deployServices(
|
||||||
namespace convert.Namespace,
|
namespace convert.Namespace,
|
||||||
sendAuth bool,
|
sendAuth bool,
|
||||||
resolveImage string,
|
resolveImage string,
|
||||||
recipeName string,
|
appName string,
|
||||||
dontWait bool) error {
|
dontWait bool) error {
|
||||||
existingServices, err := GetStackServices(ctx, cl, namespace.Name())
|
existingServices, err := GetStackServices(ctx, cl, namespace.Name())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -437,9 +437,9 @@ func deployServices(
|
||||||
ch := make(chan error, len(serviceIDs))
|
ch := make(chan error, len(serviceIDs))
|
||||||
for serviceID, serviceName := range serviceIDs {
|
for serviceID, serviceName := range serviceIDs {
|
||||||
logrus.Debugf("waiting on %s to converge", serviceName)
|
logrus.Debugf("waiting on %s to converge", serviceName)
|
||||||
go func(sID, sName, rName string) {
|
go func(sID, sName, aName string) {
|
||||||
ch <- waitOnService(ctx, cl, sID, sName, rName)
|
ch <- WaitOnService(ctx, cl, sID, aName)
|
||||||
}(serviceID, serviceName, recipeName)
|
}(serviceID, serviceName, appName)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, serviceID := range serviceIDs {
|
for _, serviceID := range serviceIDs {
|
||||||
|
@ -469,7 +469,7 @@ func getStackConfigs(ctx context.Context, dockerclient client.APIClient, namespa
|
||||||
|
|
||||||
// https://github.com/docker/cli/blob/master/cli/command/service/helpers.go
|
// https://github.com/docker/cli/blob/master/cli/command/service/helpers.go
|
||||||
// https://github.com/docker/cli/blob/master/cli/command/service/progress/progress.go
|
// https://github.com/docker/cli/blob/master/cli/command/service/progress/progress.go
|
||||||
func waitOnService(ctx context.Context, cl *dockerclient.Client, serviceID, serviceName, recipeName string) error {
|
func WaitOnService(ctx context.Context, cl *dockerclient.Client, serviceID, appName string) error {
|
||||||
errChan := make(chan error, 1)
|
errChan := make(chan error, 1)
|
||||||
pipeReader, pipeWriter := io.Pipe()
|
pipeReader, pipeWriter := io.Pipe()
|
||||||
|
|
||||||
|
@ -498,8 +498,8 @@ If a service is failing to even start (run "abra app ps %s" to see what
|
||||||
services are running) there could be a few things. The follow command will
|
services are running) there could be a few things. The follow command will
|
||||||
try to smoke those out for you:
|
try to smoke those out for you:
|
||||||
|
|
||||||
abra app errors %s
|
abra app errors --watch %s
|
||||||
|
|
||||||
`, recipeName, timeout, recipeName, recipeName, recipeName))
|
`, appName, timeout, appName, appName, appName))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue