mirror of
https://github.com/dokku/dokku.git
synced 2026-02-24 04:00:36 +01:00
Merge pull request #6582 from dokku/ps-cleanup
Correctly handle extra whitespace in scale file contents
This commit is contained in:
@@ -1,107 +1,107 @@
|
||||
{
|
||||
"dependencies": [
|
||||
{
|
||||
"name": "docker-image-labeler",
|
||||
"version": "0.6.1",
|
||||
"urls": {
|
||||
"amd64": "https://github.com/dokku/docker-image-labeler/releases/download/v0.6.1/docker-image-labeler_0.6.1_linux_amd64.tgz",
|
||||
"arm64": "https://github.com/dokku/docker-image-labeler/releases/download/v0.6.1/docker-image-labeler_0.6.1_linux_arm64.tgz",
|
||||
"arm": "https://github.com/dokku/docker-image-labeler/releases/download/v0.6.1/docker-image-labeler_0.6.1_linux_armhf.tgz"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "docker-container-healthchecker",
|
||||
"version": "0.7.2",
|
||||
"urls": {
|
||||
"amd64": "https://github.com/dokku/docker-container-healthchecker/releases/download/v0.7.2/docker-container-healthchecker_0.7.2_linux_amd64.tgz",
|
||||
"arm64": "https://github.com/dokku/docker-container-healthchecker/releases/download/v0.7.2/docker-container-healthchecker_0.7.2_linux_arm64.tgz",
|
||||
"arm": "https://github.com/dokku/docker-container-healthchecker/releases/download/v0.7.2/docker-container-healthchecker_0.7.2_linux_armhf.tgz"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "lambda-builder",
|
||||
"version": "0.5.0",
|
||||
"urls": {
|
||||
"amd64": "https://github.com/dokku/lambda-builder/releases/download/v0.5.0/lambda-builder_0.5.0_linux_amd64.tgz",
|
||||
"arm64": "https://github.com/dokku/lambda-builder/releases/download/v0.5.0/lambda-builder_0.5.0_linux_arm64.tgz",
|
||||
"arm": "https://github.com/dokku/lambda-builder/releases/download/v0.5.0/lambda-builder_0.5.0_linux_armhf.tgz"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "netrc",
|
||||
"version": "0.7.1",
|
||||
"urls": {
|
||||
"amd64": "https://github.com/dokku/netrc/releases/download/v0.7.1/netrc_0.7.1_linux_amd64.tgz",
|
||||
"arm64": "https://github.com/dokku/netrc/releases/download/v0.7.1/netrc_0.7.1_linux_arm64.tgz",
|
||||
"arm": "https://github.com/dokku/netrc/releases/download/v0.7.1/netrc_0.7.1_linux_armhf.tgz"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "procfile-util",
|
||||
"version": "0.16.0",
|
||||
"urls": {
|
||||
"amd64": "https://github.com/dokku/procfile-util/releases/download/v0.16.0/procfile-util_0.16.0_linux_amd64.tgz",
|
||||
"arm64": "https://github.com/dokku/procfile-util/releases/download/v0.16.0/procfile-util_0.16.0_linux_arm64.tgz",
|
||||
"arm": "https://github.com/dokku/procfile-util/releases/download/v0.16.0/procfile-util_0.16.0_linux_armhf.tgz"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "sshcommand",
|
||||
"version": "0.17.1",
|
||||
"urls": {
|
||||
"amd64": "https://github.com/dokku/sshcommand/releases/download/v0.17.1/sshcommand_0.17.1_linux_x86_64.tgz",
|
||||
"arm64": "https://github.com/dokku/sshcommand/releases/download/v0.17.1/sshcommand_0.17.1_linux_x86_64.tgz",
|
||||
"arm": "https://github.com/dokku/sshcommand/releases/download/v0.17.1/sshcommand_0.17.1_linux_x86_64.tgz"
|
||||
}
|
||||
}
|
||||
],
|
||||
"predependencies": [
|
||||
{
|
||||
"name": "gliderlabs-sigil",
|
||||
"version": "0.10.1",
|
||||
"urls": {
|
||||
"amd64": "https://github.com/gliderlabs/sigil/releases/download/v0.10.1/gliderlabs-sigil_0.10.1_linux_amd64.tgz",
|
||||
"arm64": "https://github.com/gliderlabs/sigil/releases/download/v0.10.1/gliderlabs-sigil_0.10.1_linux_arm64.tgz",
|
||||
"arm": "https://github.com/gliderlabs/sigil/releases/download/v0.10.1/gliderlabs-sigil_0.10.1_linux_armhf.tgz"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "plugn",
|
||||
"version": "0.12.0",
|
||||
"urls": {
|
||||
"amd64": "https://github.com/dokku/plugn/releases/download/v0.12.0/plugn_0.12.0_linux_amd64.tgz",
|
||||
"arm64": "https://github.com/dokku/plugn/releases/download/v0.12.0/plugn_0.12.0_linux_arm64.tgz",
|
||||
"arm": "https://github.com/dokku/plugn/releases/download/v0.12.0/plugn_0.12.0_linux_armhf.tgz"
|
||||
}
|
||||
}
|
||||
],
|
||||
"recommendations": [
|
||||
{
|
||||
"name": "dokku-event-listener",
|
||||
"version": "0.15.0",
|
||||
"urls": {
|
||||
"amd64": "https://github.com/dokku/dokku-event-listener/releases/download/v0.15.0/dokku-event-listener_0.15.0_linux_amd64.tgz",
|
||||
"arm64": "https://github.com/dokku/dokku-event-listener/releases/download/v0.15.0/dokku-event-listener_0.15.0_linux_arm64.tgz",
|
||||
"arm": "https://github.com/dokku/dokku-event-listener/releases/download/v0.15.0/dokku-event-listener_0.15.0_linux_armhf.tgz"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dokku-update",
|
||||
"version": "0.7.2",
|
||||
"urls": {
|
||||
"amd64": "https://github.com/dokku/dokku-update/releases/download/v0.7.2/dokku-update_0.7.2_linux_x86_64.tgz",
|
||||
"arm64": "https://github.com/dokku/dokku-update/releases/download/v0.7.2/dokku-update_0.7.2_linux_x86_64.tgz",
|
||||
"arm": "https://github.com/dokku/dokku-update/releases/download/v0.7.2/dokku-update_0.7.2_linux_x86_64.tgz"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "herokuish",
|
||||
"version": "0.7.1",
|
||||
"urls": {
|
||||
"amd64": "https://github.com/gliderlabs/herokuish/releases/download/v0.7.1/herokuish_0.7.1_linux_x86_64.tgz",
|
||||
"arm64": "https://github.com/gliderlabs/herokuish/releases/download/v0.7.1/herokuish_0.7.1_linux_x86_64.tgz",
|
||||
"arm": "https://github.com/gliderlabs/herokuish/releases/download/v0.7.1/herokuish_0.7.1_linux_x86_64.tgz"
|
||||
}
|
||||
}
|
||||
]
|
||||
"dependencies": [
|
||||
{
|
||||
"name": "docker-image-labeler",
|
||||
"version": "0.6.1",
|
||||
"urls": {
|
||||
"amd64": "https://github.com/dokku/docker-image-labeler/releases/download/v0.6.1/docker-image-labeler_0.6.1_linux_amd64.tgz",
|
||||
"arm64": "https://github.com/dokku/docker-image-labeler/releases/download/v0.6.1/docker-image-labeler_0.6.1_linux_arm64.tgz",
|
||||
"arm": "https://github.com/dokku/docker-image-labeler/releases/download/v0.6.1/docker-image-labeler_0.6.1_linux_armhf.tgz"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "docker-container-healthchecker",
|
||||
"version": "0.7.2",
|
||||
"urls": {
|
||||
"amd64": "https://github.com/dokku/docker-container-healthchecker/releases/download/v0.7.2/docker-container-healthchecker_0.7.2_linux_amd64.tgz",
|
||||
"arm64": "https://github.com/dokku/docker-container-healthchecker/releases/download/v0.7.2/docker-container-healthchecker_0.7.2_linux_arm64.tgz",
|
||||
"arm": "https://github.com/dokku/docker-container-healthchecker/releases/download/v0.7.2/docker-container-healthchecker_0.7.2_linux_armhf.tgz"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "lambda-builder",
|
||||
"version": "0.5.0",
|
||||
"urls": {
|
||||
"amd64": "https://github.com/dokku/lambda-builder/releases/download/v0.5.0/lambda-builder_0.5.0_linux_amd64.tgz",
|
||||
"arm64": "https://github.com/dokku/lambda-builder/releases/download/v0.5.0/lambda-builder_0.5.0_linux_arm64.tgz",
|
||||
"arm": "https://github.com/dokku/lambda-builder/releases/download/v0.5.0/lambda-builder_0.5.0_linux_armhf.tgz"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "netrc",
|
||||
"version": "0.7.1",
|
||||
"urls": {
|
||||
"amd64": "https://github.com/dokku/netrc/releases/download/v0.7.1/netrc_0.7.1_linux_amd64.tgz",
|
||||
"arm64": "https://github.com/dokku/netrc/releases/download/v0.7.1/netrc_0.7.1_linux_arm64.tgz",
|
||||
"arm": "https://github.com/dokku/netrc/releases/download/v0.7.1/netrc_0.7.1_linux_armhf.tgz"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "procfile-util",
|
||||
"version": "0.17.1",
|
||||
"urls": {
|
||||
"amd64": "https://github.com/dokku/procfile-util/releases/download/v0.17.1/procfile-util_0.17.1_linux_amd64.tgz",
|
||||
"arm64": "https://github.com/dokku/procfile-util/releases/download/v0.17.1/procfile-util_0.17.1_linux_arm64.tgz",
|
||||
"arm": "https://github.com/dokku/procfile-util/releases/download/v0.17.1/procfile-util_0.17.1_linux_armhf.tgz"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "sshcommand",
|
||||
"version": "0.17.1",
|
||||
"urls": {
|
||||
"amd64": "https://github.com/dokku/sshcommand/releases/download/v0.17.1/sshcommand_0.17.1_linux_x86_64.tgz",
|
||||
"arm64": "https://github.com/dokku/sshcommand/releases/download/v0.17.1/sshcommand_0.17.1_linux_x86_64.tgz",
|
||||
"arm": "https://github.com/dokku/sshcommand/releases/download/v0.17.1/sshcommand_0.17.1_linux_x86_64.tgz"
|
||||
}
|
||||
}
|
||||
],
|
||||
"predependencies": [
|
||||
{
|
||||
"name": "gliderlabs-sigil",
|
||||
"version": "0.10.1",
|
||||
"urls": {
|
||||
"amd64": "https://github.com/gliderlabs/sigil/releases/download/v0.10.1/gliderlabs-sigil_0.10.1_linux_amd64.tgz",
|
||||
"arm64": "https://github.com/gliderlabs/sigil/releases/download/v0.10.1/gliderlabs-sigil_0.10.1_linux_arm64.tgz",
|
||||
"arm": "https://github.com/gliderlabs/sigil/releases/download/v0.10.1/gliderlabs-sigil_0.10.1_linux_armhf.tgz"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "plugn",
|
||||
"version": "0.12.0",
|
||||
"urls": {
|
||||
"amd64": "https://github.com/dokku/plugn/releases/download/v0.12.0/plugn_0.12.0_linux_amd64.tgz",
|
||||
"arm64": "https://github.com/dokku/plugn/releases/download/v0.12.0/plugn_0.12.0_linux_arm64.tgz",
|
||||
"arm": "https://github.com/dokku/plugn/releases/download/v0.12.0/plugn_0.12.0_linux_armhf.tgz"
|
||||
}
|
||||
}
|
||||
],
|
||||
"recommendations": [
|
||||
{
|
||||
"name": "dokku-event-listener",
|
||||
"version": "0.15.0",
|
||||
"urls": {
|
||||
"amd64": "https://github.com/dokku/dokku-event-listener/releases/download/v0.15.0/dokku-event-listener_0.15.0_linux_amd64.tgz",
|
||||
"arm64": "https://github.com/dokku/dokku-event-listener/releases/download/v0.15.0/dokku-event-listener_0.15.0_linux_arm64.tgz",
|
||||
"arm": "https://github.com/dokku/dokku-event-listener/releases/download/v0.15.0/dokku-event-listener_0.15.0_linux_armhf.tgz"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "dokku-update",
|
||||
"version": "0.7.2",
|
||||
"urls": {
|
||||
"amd64": "https://github.com/dokku/dokku-update/releases/download/v0.7.2/dokku-update_0.7.2_linux_x86_64.tgz",
|
||||
"arm64": "https://github.com/dokku/dokku-update/releases/download/v0.7.2/dokku-update_0.7.2_linux_x86_64.tgz",
|
||||
"arm": "https://github.com/dokku/dokku-update/releases/download/v0.7.2/dokku-update_0.7.2_linux_x86_64.tgz"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "herokuish",
|
||||
"version": "0.7.1",
|
||||
"urls": {
|
||||
"amd64": "https://github.com/gliderlabs/herokuish/releases/download/v0.7.1/herokuish_0.7.1_linux_x86_64.tgz",
|
||||
"arm64": "https://github.com/gliderlabs/herokuish/releases/download/v0.7.1/herokuish_0.7.1_linux_x86_64.tgz",
|
||||
"arm": "https://github.com/gliderlabs/herokuish/releases/download/v0.7.1/herokuish_0.7.1_linux_x86_64.tgz"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ import (
|
||||
|
||||
"github.com/dokku/dokku/plugins/common"
|
||||
dockeroptions "github.com/dokku/dokku/plugins/docker-options"
|
||||
"github.com/ryanuber/columnize"
|
||||
)
|
||||
|
||||
func canScaleApp(appName string) bool {
|
||||
@@ -20,24 +19,6 @@ func canScaleApp(appName string) bool {
|
||||
return common.ToBool(canScale)
|
||||
}
|
||||
|
||||
func getProcessStatus(appName string) map[string]string {
|
||||
statuses := make(map[string]string)
|
||||
containerFiles := common.ListFilesWithPrefix(common.AppRoot(appName), "CONTAINER.")
|
||||
for _, filename := range containerFiles {
|
||||
containerID := common.ReadFirstLine(filename)
|
||||
containerStatus, _ := common.DockerInspect(containerID, "{{ .State.Status }}")
|
||||
process := strings.TrimPrefix(filename, fmt.Sprintf("%s/CONTAINER.", common.AppRoot(appName)))
|
||||
|
||||
if containerStatus == "" {
|
||||
containerStatus = "missing"
|
||||
}
|
||||
|
||||
statuses[process] = fmt.Sprintf("%s (CID: %s)", containerStatus, containerID[0:11])
|
||||
}
|
||||
|
||||
return statuses
|
||||
}
|
||||
|
||||
func getProcfileCommand(procfilePath string, processType string, port int) (string, error) {
|
||||
if !common.FileExists(procfilePath) {
|
||||
return "", errors.New("No procfile found")
|
||||
@@ -143,18 +124,24 @@ func isValidRestartPolicy(policy string) bool {
|
||||
func parseProcessTuples(processTuples []string) (FormationSlice, error) {
|
||||
formations := FormationSlice{}
|
||||
|
||||
foundFormations := map[string]bool{}
|
||||
for _, processTuple := range processTuples {
|
||||
s := strings.Split(processTuple, "=")
|
||||
s := strings.SplitN(processTuple, "=", 2)
|
||||
if len(s) == 1 {
|
||||
return formations, fmt.Errorf("Missing count for process type %s", processTuple)
|
||||
}
|
||||
|
||||
processType := s[0]
|
||||
quantity, err := strconv.Atoi(s[1])
|
||||
processType := strings.TrimSpace(s[0])
|
||||
quantity, err := strconv.Atoi(strings.TrimSpace(s[1]))
|
||||
if err != nil {
|
||||
return formations, fmt.Errorf("Invalid count for process type %s", s[0])
|
||||
}
|
||||
|
||||
if foundFormations[processType] {
|
||||
continue
|
||||
}
|
||||
|
||||
foundFormations[processType] = true
|
||||
formations = append(formations, &Formation{
|
||||
ProcessType: processType,
|
||||
Quantity: quantity,
|
||||
@@ -211,7 +198,22 @@ func getFormations(appName string) (FormationSlice, error) {
|
||||
return formations, err
|
||||
}
|
||||
|
||||
return append(formations, oldFormations...), nil
|
||||
foundProcessTypes := map[string]bool{}
|
||||
for _, formation := range formations {
|
||||
foundProcessTypes[formation.ProcessType] = true
|
||||
}
|
||||
|
||||
for _, formation := range oldFormations {
|
||||
if foundProcessTypes[formation.ProcessType] {
|
||||
continue
|
||||
}
|
||||
|
||||
foundProcessTypes[formation.ProcessType] = true
|
||||
formations = append(formations, formation)
|
||||
}
|
||||
|
||||
sort.Sort(formations)
|
||||
return formations, nil
|
||||
}
|
||||
|
||||
func restorePrep() error {
|
||||
@@ -229,18 +231,12 @@ func scaleReport(appName string) error {
|
||||
}
|
||||
|
||||
common.LogInfo1Quiet(fmt.Sprintf("Scaling for %s", appName))
|
||||
config := columnize.DefaultConfig()
|
||||
config.Delim = "="
|
||||
config.Glue = ": "
|
||||
config.Prefix = " "
|
||||
config.Empty = ""
|
||||
|
||||
content := []string{}
|
||||
if os.Getenv("DOKKU_QUIET_OUTPUT") == "" {
|
||||
content = append(content, "proctype=qty", "--------=---")
|
||||
}
|
||||
|
||||
sort.Sort(formations)
|
||||
for _, formation := range formations {
|
||||
content = append(content, fmt.Sprintf("%s=%d", formation.ProcessType, formation.Quantity))
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ require (
|
||||
github.com/dokku/dokku/plugins/config v0.0.0-00010101000000-000000000000
|
||||
github.com/dokku/dokku/plugins/docker-options v0.0.0-00010101000000-000000000000
|
||||
github.com/gofrs/flock v0.8.1
|
||||
github.com/ryanuber/columnize v2.1.2+incompatible
|
||||
github.com/spf13/pflag v1.0.5
|
||||
)
|
||||
|
||||
@@ -26,6 +25,7 @@ require (
|
||||
github.com/otiai10/copy v1.14.0 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/pkg/sftp v1.13.5 // indirect
|
||||
github.com/ryanuber/columnize v2.1.2+incompatible // indirect
|
||||
golang.org/x/crypto v0.19.0 // indirect
|
||||
golang.org/x/sync v0.6.0 // indirect
|
||||
golang.org/x/sys v0.17.0 // indirect
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@@ -298,7 +297,6 @@ func TriggerPsCurrentScale(appName string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
sort.Sort(formations)
|
||||
lines := []string{}
|
||||
for _, formation := range formations {
|
||||
lines = append(lines, fmt.Sprintf("%s=%d", formation.ProcessType, formation.Quantity))
|
||||
|
||||
@@ -71,6 +71,7 @@ EOF
|
||||
run /bin/bash -c "dokku --quiet ps:scale $TEST_APP"
|
||||
output=$(echo "$output" | tr -s " ")
|
||||
echo "output: ($output)"
|
||||
echo "status: $status"
|
||||
assert_output $'cron: 0\ncustom: 0\nrelease: 0\nweb: 1\nworker: 0'
|
||||
|
||||
pushd $TMP
|
||||
@@ -81,12 +82,25 @@ EOF
|
||||
run /bin/bash -c "dokku --quiet ps:scale $TEST_APP"
|
||||
output=$(echo "$output" | tr -s " ")
|
||||
echo "output: ($output)"
|
||||
echo "status: $status"
|
||||
assert_output $'cron: 0\ncustom: 0\nrelease: 0\nscaletest: 0\nweb: 1\nworker: 0'
|
||||
|
||||
popd
|
||||
rm -rf "$TMP"
|
||||
}
|
||||
|
||||
@test "(ps:scale) ps:scale formatting" {
|
||||
echo "web=4
|
||||
worker=1
|
||||
beat =0
|
||||
web =0" >/var/lib/dokku/config/ps/$TEST_APP/scale
|
||||
|
||||
run /bin/bash -c "dokku --quiet ps:scale $TEST_APP"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_output $'beat: 0\nweb: 4\nworker: 1'
|
||||
}
|
||||
|
||||
@test "(ps) handle windows newlines in procfile" {
|
||||
run deploy_app python dokku@$DOKKU_DOMAIN:$TEST_APP procfile_line_endings_to_windows
|
||||
echo "output: $output"
|
||||
|
||||
Reference in New Issue
Block a user