fix: correctly handle is-deployed check
Previously, checking if an app was deployed actually checked if there were any running processes. This is not only incorrect, but also fails to take into account applications that do not have running processes and are only used for one-off commands. This fix migrates apps to the new "deployed" property which is set in core-post-deploy. The result is a slightly faster "deployed" check that is correct and allows non-scaled apps to actually work. Closes #4398
This commit is contained in:
@@ -20,6 +20,16 @@ import (
|
||||
|
||||
type errfunc func() error
|
||||
|
||||
var (
|
||||
// DefaultProperties is a map of all valid common properties with corresponding default property values
|
||||
DefaultProperties = map[string]string{
|
||||
"deployed": "false",
|
||||
}
|
||||
|
||||
// GlobalProperties is a map of all valid global common properties
|
||||
GlobalProperties = map[string]bool{}
|
||||
)
|
||||
|
||||
// AppRoot returns the app root path
|
||||
func AppRoot(appName string) string {
|
||||
dokkuRoot := MustGetEnv("DOKKU_ROOT")
|
||||
@@ -279,9 +289,19 @@ func GetAppImageName(appName, imageTag, imageRepo string) (imageName string) {
|
||||
|
||||
// IsDeployed returns true if given app has a running container
|
||||
func IsDeployed(appName string) bool {
|
||||
scheduler := GetAppScheduler(appName)
|
||||
_, err := PlugnTriggerOutput("scheduler-is-deployed", []string{scheduler, appName}...)
|
||||
return err == nil
|
||||
deployed := PropertyGetDefault("common", appName, "deployed", "")
|
||||
if deployed == "" {
|
||||
deployed = "false"
|
||||
scheduler := GetAppScheduler(appName)
|
||||
_, err := PlugnTriggerOutput("scheduler-is-deployed", []string{scheduler, appName}...)
|
||||
if err == nil {
|
||||
deployed = "true"
|
||||
}
|
||||
|
||||
CommandPropertySet("common", appName, "deployed", deployed, DefaultProperties, GlobalProperties)
|
||||
}
|
||||
|
||||
return deployed == "true"
|
||||
}
|
||||
|
||||
// MustGetEnv returns env variable or fails if it's not set
|
||||
|
||||
Reference in New Issue
Block a user