mirror of
https://github.com/dokku/dokku.git
synced 2025-12-29 00:25:08 +01:00
Merge pull request #5592 from dokku/drop-dokku-scale
Remove support for DOKKU_SCALE file
This commit is contained in:
4
.github/dependabot.yml
vendored
4
.github/dependabot.yml
vendored
@@ -22,7 +22,7 @@ updates:
|
||||
interval: daily
|
||||
open-pull-requests-limit: 10
|
||||
- package-ecosystem: npm
|
||||
directory: "/tests/apps/dockerfile-dokku-scale"
|
||||
directory: "/tests/apps/dockerfile-app-json-formations"
|
||||
schedule:
|
||||
interval: daily
|
||||
open-pull-requests-limit: 10
|
||||
@@ -156,7 +156,7 @@ updates:
|
||||
interval: daily
|
||||
open-pull-requests-limit: 10
|
||||
- package-ecosystem: "docker"
|
||||
directory: "/tests/apps/dockerfile-dokku-scale"
|
||||
directory: "/tests/apps/dockerfile-app-json-formations"
|
||||
schedule:
|
||||
interval: daily
|
||||
open-pull-requests-limit: 10
|
||||
|
||||
@@ -3,3 +3,4 @@
|
||||
## Removals
|
||||
|
||||
- Support for [SPDY](https://en.wikipedia.org/wiki/SPDY) has been removed. No major browser supports it as of 2021. Custom `nginx.conf.sigil` templates referencing spdy-related variables will continue to build until the 1.0.0 release.
|
||||
- Support for the `DOKKU_SCALE` file - deprecated in 0.25.0 - has been removed in favor of the `formations` key in the `app.json` file. Please see the [process management documentation](/docs/processes/process-management.md#manually-managing-process-scaling) for more information on how to use the `formation` key of the `app.json` file.
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@@ -479,10 +478,6 @@ func refreshAppJSON(appName string, image string) error {
|
||||
}
|
||||
|
||||
func setScale(appName string, image string) error {
|
||||
if err := injectDokkuScale(appName, image); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
appJSON, err := getAppJSON(appName)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -507,68 +502,3 @@ func setScale(appName string, image string) error {
|
||||
|
||||
return common.PlugnTrigger("ps-set-scale", args...)
|
||||
}
|
||||
|
||||
func injectDokkuScale(appName string, image string) error {
|
||||
appJSON, err := getAppJSON(appName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
baseDirectory := common.GetDataDirectory("app-json")
|
||||
if !common.DirectoryExists(baseDirectory) {
|
||||
return errors.New("Run 'dokku plugin:install' to ensure the correct directories exist")
|
||||
}
|
||||
|
||||
dokkuScaleFile := filepath.Join(baseDirectory, "DOKKU_SCALE")
|
||||
previouslyExtracted := common.FileExists(dokkuScaleFile)
|
||||
if previouslyExtracted {
|
||||
os.Remove(dokkuScaleFile)
|
||||
}
|
||||
|
||||
common.CopyFromImage(appName, image, "DOKKU_SCALE", dokkuScaleFile)
|
||||
|
||||
if !common.FileExists(dokkuScaleFile) {
|
||||
return nil
|
||||
}
|
||||
|
||||
lines, err := common.FileToSlice(dokkuScaleFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if appJSON.Formation == nil {
|
||||
common.LogWarn("Deprecated: Injecting scale settings from DOKKU_SCALE file. Use the 'formation' key the app.json file to specify scaling instead of 'DOKKU_SCALE'.")
|
||||
appJSON.Formation = make(map[string]Formation)
|
||||
} else {
|
||||
common.LogWarn("Deprecated: DOKKU_SCALE ignored in favor of 'formation' key in the app.json")
|
||||
return nil
|
||||
}
|
||||
|
||||
for _, line := range lines {
|
||||
if line == "" || strings.HasPrefix(line, "#") {
|
||||
continue
|
||||
}
|
||||
|
||||
procParts := strings.SplitN(line, "=", 2)
|
||||
if len(procParts) != 2 {
|
||||
continue
|
||||
}
|
||||
|
||||
processType := procParts[0]
|
||||
quantity, err := strconv.Atoi(procParts[1])
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
appJSON.Formation[processType] = Formation{
|
||||
Quantity: &quantity,
|
||||
}
|
||||
}
|
||||
|
||||
b, err := json.Marshal(appJSON)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return ioutil.WriteFile(GetAppjsonPath(appName), b, 0644)
|
||||
}
|
||||
|
||||
@@ -149,23 +149,11 @@ func TriggerInstall() error {
|
||||
for _, appName := range apps {
|
||||
dokkuScaleFile := filepath.Join(common.AppRoot(appName), "DOKKU_SCALE")
|
||||
if common.FileExists(dokkuScaleFile) {
|
||||
processTuples, err := common.FileToSlice(dokkuScaleFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := scaleSet(appName, true, false, processTuples); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
os.Remove(dokkuScaleFile)
|
||||
}
|
||||
|
||||
dokkuScaleExtracted := filepath.Join(common.AppRoot(appName), "DOKKU_SCALE.extracted")
|
||||
if common.FileExists(dokkuScaleExtracted) {
|
||||
if err := common.PropertyWrite("ps", appName, "can-scale", strconv.FormatBool(false)); err != nil {
|
||||
return err
|
||||
}
|
||||
os.Remove(dokkuScaleExtracted)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
# test comment
|
||||
web=1
|
||||
7
tests/apps/config/app.json
Normal file
7
tests/apps/config/app.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"formation": {
|
||||
"web": {
|
||||
"quantity": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
7
tests/apps/dockerfile-app-json-formations/app.json
Normal file
7
tests/apps/dockerfile-app-json-formations/app.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"formation": {
|
||||
"web": {
|
||||
"quantity": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
web=1
|
||||
@@ -1,2 +0,0 @@
|
||||
web=0
|
||||
worker=1
|
||||
10
tests/apps/nodejs-worker/app.json
Normal file
10
tests/apps/nodejs-worker/app.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"formation": {
|
||||
"web": {
|
||||
"quantity": 0
|
||||
},
|
||||
"worker": {
|
||||
"quantity": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,13 +12,13 @@ teardown() {
|
||||
global_teardown
|
||||
}
|
||||
|
||||
@test "(ps:scale) dockerfile dokku-scale" {
|
||||
@test "(ps:scale) dockerfile app-json formations" {
|
||||
run /bin/bash -c "dokku ps:scale $TEST_APP web=2"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
deploy_app dockerfile-dokku-scale
|
||||
deploy_app dockerfile-app-json-formations
|
||||
CIDS=""
|
||||
for CID_FILE in $DOKKU_ROOT/$TEST_APP/CONTAINER.web.*; do
|
||||
CIDS+=$(<$CID_FILE)
|
||||
|
||||
Reference in New Issue
Block a user