forked from toolshed/abra
feat: abra app logs shows task errors (!395)
The log command now checks for the ready state in the task list. If it is not ready. It shows the task logs. This might look like this: ``` ERRO[0000] Service abra-test-recipe_default_app: State rejected: No such image: ngaaaax:1.21.0 ERRO[0000] Service abra-test-recipe_default_app: State preparing: ERRO[0000] Service abra-test-recipe_default_app: State rejected: No such image: ngaaaax:1.21.0 ERRO[0000] Service abra-test-recipe_default_app: State rejected: No such image: ngaaaax:1.21.0 ERRO[0000] Service abra-test-recipe_default_app: State rejected: No such image: ngaaaax:1.21.0 ``` Closes coop-cloud/organising#518 Reviewed-on: coop-cloud/abra#395 Reviewed-by: decentral1se <decentral1se@noreply.git.coopcloud.tech> Co-authored-by: p4u1 <p4u1_f4u1@riseup.net> Co-committed-by: p4u1 <p4u1_f4u1@riseup.net>
This commit is contained in:
@ -77,14 +77,32 @@ func StackName(appName string) string {
|
||||
return stackName
|
||||
}
|
||||
|
||||
// Filters retrieves exact app filters for querying the container runtime. Due
|
||||
// to upstream issues, filtering works different depending on what you're
|
||||
// Filters retrieves app filters for querying the container runtime. By default
|
||||
// it filters on all services in the app. It is also possible to pass an
|
||||
// otional list of service names, which get filtered instead.
|
||||
//
|
||||
// Due to upstream issues, filtering works different depending on what you're
|
||||
// querying. So, for example, secrets don't work with regex! The caller needs
|
||||
// to implement their own validation that the right secrets are matched. In
|
||||
// order to handle these cases, we provide the `appendServiceNames` /
|
||||
// `exactMatch` modifiers.
|
||||
func (a App) Filters(appendServiceNames, exactMatch bool) (filters.Args, error) {
|
||||
func (a App) Filters(appendServiceNames, exactMatch bool, services ...string) (filters.Args, error) {
|
||||
filters := filters.NewArgs()
|
||||
if len(services) > 0 {
|
||||
for _, serviceName := range services {
|
||||
filters.Add("name", ServiceFilter(a.StackName(), serviceName, exactMatch))
|
||||
}
|
||||
return filters, nil
|
||||
}
|
||||
|
||||
if appendServiceNames {
|
||||
f := fmt.Sprintf("%s", a.StackName())
|
||||
if exactMatch {
|
||||
f = fmt.Sprintf("^%s", f)
|
||||
}
|
||||
filters.Add("name", f)
|
||||
return filters, nil
|
||||
}
|
||||
|
||||
composeFiles, err := GetComposeFiles(a.Recipe, a.Env)
|
||||
if err != nil {
|
||||
@ -98,28 +116,23 @@ func (a App) Filters(appendServiceNames, exactMatch bool) (filters.Args, error)
|
||||
}
|
||||
|
||||
for _, service := range compose.Services {
|
||||
var filter string
|
||||
|
||||
if appendServiceNames {
|
||||
if exactMatch {
|
||||
filter = fmt.Sprintf("^%s_%s", a.StackName(), service.Name)
|
||||
} else {
|
||||
filter = fmt.Sprintf("%s_%s", a.StackName(), service.Name)
|
||||
}
|
||||
} else {
|
||||
if exactMatch {
|
||||
filter = fmt.Sprintf("^%s", a.StackName())
|
||||
} else {
|
||||
filter = fmt.Sprintf("%s", a.StackName())
|
||||
}
|
||||
}
|
||||
|
||||
filters.Add("name", filter)
|
||||
f := ServiceFilter(a.StackName(), service.Name, exactMatch)
|
||||
filters.Add("name", f)
|
||||
}
|
||||
|
||||
return filters, nil
|
||||
}
|
||||
|
||||
// ServiceFilter creates a filter string for filtering a service in the docker
|
||||
// container runtime. When exact match is true, it uses regex to match the
|
||||
// string exactly.
|
||||
func ServiceFilter(stack, service string, exact bool) string {
|
||||
if exact {
|
||||
return fmt.Sprintf("^%s_%s", stack, service)
|
||||
}
|
||||
return fmt.Sprintf("%s_%s", stack, service)
|
||||
}
|
||||
|
||||
// ByServer sort a slice of Apps
|
||||
type ByServer []App
|
||||
|
||||
@ -340,7 +353,7 @@ func TemplateAppEnvSample(recipeName, appName, server, domain string) error {
|
||||
return fmt.Errorf("%s already exists?", appEnvPath)
|
||||
}
|
||||
|
||||
err = ioutil.WriteFile(appEnvPath, envSample, 0664)
|
||||
err = ioutil.WriteFile(appEnvPath, envSample, 0o664)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -602,7 +615,7 @@ func GetLabel(compose *composetypes.Config, stackName string, label string) stri
|
||||
|
||||
// GetTimeoutFromLabel reads the timeout value from docker label "coop-cloud.${STACK_NAME}.TIMEOUT" and returns 50 as default value
|
||||
func GetTimeoutFromLabel(compose *composetypes.Config, stackName string) (int, error) {
|
||||
var timeout = 50 // Default Timeout
|
||||
timeout := 50 // Default Timeout
|
||||
var err error = nil
|
||||
if timeoutLabel := GetLabel(compose, stackName, "timeout"); timeoutLabel != "" {
|
||||
logrus.Debugf("timeout label: %s", timeoutLabel)
|
||||
|
Reference in New Issue
Block a user