Merge pull request #5592 from dokku/drop-dokku-scale

Remove support for DOKKU_SCALE file
This commit is contained in:
josegonzalez
2023-01-16 01:13:33 -05:00
committed by GitHub
18 changed files with 29 additions and 91 deletions

View File

@@ -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

View File

@@ -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.

View 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)
}

View File

@@ -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)
}
}

View File

@@ -1,2 +0,0 @@
# test comment
web=1

View File

@@ -0,0 +1,7 @@
{
"formation": {
"web": {
"quantity": 1
}
}
}

View File

@@ -0,0 +1,7 @@
{
"formation": {
"web": {
"quantity": 1
}
}
}

View File

@@ -1 +0,0 @@
web=1

View File

@@ -1,2 +0,0 @@
web=0
worker=1

View File

@@ -0,0 +1,10 @@
{
"formation": {
"web": {
"quantity": 0
},
"worker": {
"quantity": 1
}
}
}

View File

@@ -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)