Merge pull request #3560 from dokku/resource-setting-fixes
Resource setting fixes
This commit is contained in:
@@ -311,6 +311,24 @@ verify_app_name "$APP"
|
|||||||
# TODO
|
# TODO
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### `docker-args-process-build`
|
||||||
|
|
||||||
|
- Description: `$PROC_TYPE` may be set to magic `_all_` process type to signify global docker deploy options.
|
||||||
|
- Invoked by: `dokku ps:rebuild`
|
||||||
|
- Arguments: `$APP $IMAGE_TAG $IMAGE_SOURCE_TYPE`
|
||||||
|
- Example:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||||
|
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
||||||
|
APP="$1"; IMAGE_TAG="$2"; IMAGE=$(get_app_image_name $APP $IMAGE_TAG)
|
||||||
|
verify_app_name "$APP"
|
||||||
|
|
||||||
|
# TODO
|
||||||
|
```
|
||||||
|
|
||||||
### `docker-args-process-deploy`
|
### `docker-args-process-deploy`
|
||||||
|
|
||||||
- Description: `$PROC_TYPE` may be set to magic `_all_` process type to signify global docker deploy options.
|
- Description: `$PROC_TYPE` may be set to magic `_all_` process type to signify global docker deploy options.
|
||||||
@@ -333,7 +351,7 @@ verify_app_name "$APP"
|
|||||||
|
|
||||||
- Description: `$PROC_TYPE` may be set to magic `_all_` process type to signify global docker run options.
|
- Description: `$PROC_TYPE` may be set to magic `_all_` process type to signify global docker run options.
|
||||||
- Invoked by: `dokku run`
|
- Invoked by: `dokku run`
|
||||||
- Arguments: `$APP $IMAGE_TAG $IMAGE_SOURCE_TYPE [$PROC_TYPE $CONTAINER_INDEX]`
|
- Arguments: `$APP $IMAGE_TAG $IMAGE_SOURCE_TYPE`
|
||||||
- Example:
|
- Example:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ execute_script() {
|
|||||||
|
|
||||||
local IMAGE_SOURCE_TYPE="dockerfile"
|
local IMAGE_SOURCE_TYPE="dockerfile"
|
||||||
is_image_herokuish_based "$IMAGE" && IMAGE_SOURCE_TYPE="herokuish"
|
is_image_herokuish_based "$IMAGE" && IMAGE_SOURCE_TYPE="herokuish"
|
||||||
DOCKER_ARGS+=$(: | plugn trigger docker-args-process-deploy "$APP" "$IMAGE_TAG" "$IMAGE_SOURCE_TYPE" "$PHASE_SCRIPT_KEY")
|
DOCKER_ARGS+=$(: | plugn trigger docker-args-process-deploy "$APP" "$IMAGE_TAG" "$IMAGE_SOURCE_TYPE")
|
||||||
|
|
||||||
# eval args as array to respect escapes
|
# eval args as array to respect escapes
|
||||||
declare -a ARG_ARRAY
|
declare -a ARG_ARRAY
|
||||||
|
|||||||
@@ -535,7 +535,7 @@ dokku_build() {
|
|||||||
local DOCKER_ARGS=$(: | plugn trigger docker-args-build "$APP" "$IMAGE_SOURCE_TYPE")
|
local DOCKER_ARGS=$(: | plugn trigger docker-args-build "$APP" "$IMAGE_SOURCE_TYPE")
|
||||||
[[ "$DOKKU_TRACE" ]] && DOCKER_ARGS+=" -e TRACE=true "
|
[[ "$DOKKU_TRACE" ]] && DOCKER_ARGS+=" -e TRACE=true "
|
||||||
local IMAGE_SOURCE_TYPE="herokuish"
|
local IMAGE_SOURCE_TYPE="herokuish"
|
||||||
DOCKER_ARGS+=$(: | plugn trigger docker-args-process-run "$APP" "$IMAGE_TAG" "$IMAGE_SOURCE_TYPE" "$PHASE_SCRIPT_KEY")
|
DOCKER_ARGS+=$(: | plugn trigger docker-args-process-build "$APP" "$IMAGE_TAG" "$IMAGE_SOURCE_TYPE")
|
||||||
|
|
||||||
declare -a ARG_ARRAY
|
declare -a ARG_ARRAY
|
||||||
eval "ARG_ARRAY=($DOCKER_ARGS)"
|
eval "ARG_ARRAY=($DOCKER_ARGS)"
|
||||||
@@ -563,7 +563,7 @@ dokku_build() {
|
|||||||
[[ "$DOKKU_DOCKERFILE_CACHE_BUILD" == "false" ]] && DOKKU_DOCKER_BUILD_OPTS="$DOKKU_DOCKER_BUILD_OPTS --no-cache"
|
[[ "$DOKKU_DOCKERFILE_CACHE_BUILD" == "false" ]] && DOKKU_DOCKER_BUILD_OPTS="$DOKKU_DOCKER_BUILD_OPTS --no-cache"
|
||||||
local DOCKER_ARGS=$(: | plugn trigger docker-args-build "$APP" "$IMAGE_SOURCE_TYPE")
|
local DOCKER_ARGS=$(: | plugn trigger docker-args-build "$APP" "$IMAGE_SOURCE_TYPE")
|
||||||
local IMAGE_SOURCE_TYPE="dockerfile"
|
local IMAGE_SOURCE_TYPE="dockerfile"
|
||||||
DOCKER_ARGS+=$(: | plugn trigger docker-args-process-run "$APP" "$IMAGE_TAG" "$IMAGE_SOURCE_TYPE" "$PHASE_SCRIPT_KEY")
|
DOCKER_ARGS+=$(: | plugn trigger docker-args-process-build "$APP" "$IMAGE_TAG" "$IMAGE_SOURCE_TYPE")
|
||||||
|
|
||||||
# strip --volume and -v args from DOCKER_ARGS
|
# strip --volume and -v args from DOCKER_ARGS
|
||||||
local DOCKER_ARGS=$(sed -e "s/--volume=[[:graph:]]\+[[:blank:]]\?//g" -e "s/-v[[:blank:]]\?[[:graph:]]\+[[:blank:]]\?//g" <<<"$DOCKER_ARGS")
|
local DOCKER_ARGS=$(sed -e "s/--volume=[[:graph:]]\+[[:blank:]]\?//g" -e "s/-v[[:blank:]]\?[[:graph:]]\+[[:blank:]]\?//g" <<<"$DOCKER_ARGS")
|
||||||
|
|||||||
@@ -50,6 +50,10 @@ func main() {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if parts[1] == "cpu" {
|
||||||
|
parts[1] = "cpus"
|
||||||
|
}
|
||||||
|
|
||||||
limits[parts[1]] = value
|
limits[parts[1]] = value
|
||||||
}
|
}
|
||||||
if parts[0] == "reserve" {
|
if parts[0] == "reserve" {
|
||||||
|
|||||||
@@ -121,10 +121,11 @@ func setResourceType(appName string, processType string, r Resource, resourceTyp
|
|||||||
common.LogInfo2Quiet(message)
|
common.LogInfo2Quiet(message)
|
||||||
|
|
||||||
for key, value := range resources {
|
for key, value := range resources {
|
||||||
if value != "" {
|
if value == "" {
|
||||||
common.LogVerbose(fmt.Sprintf("%v: %v", key, value))
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
common.LogVerbose(fmt.Sprintf("%v: %v", key, value))
|
||||||
property := propertyKey(processType, resourceType, key)
|
property := propertyKey(processType, resourceType, key)
|
||||||
err := common.PropertyWrite("resource", appName, property, value)
|
err := common.PropertyWrite("resource", appName, property, value)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ scheduler-docker-local-scheduler-run() {
|
|||||||
|
|
||||||
local IMAGE_SOURCE_TYPE="dockerfile"
|
local IMAGE_SOURCE_TYPE="dockerfile"
|
||||||
is_image_herokuish_based "$IMAGE" && IMAGE_SOURCE_TYPE="herokuish"
|
is_image_herokuish_based "$IMAGE" && IMAGE_SOURCE_TYPE="herokuish"
|
||||||
DOCKER_ARGS+=$(: | plugn trigger docker-args-process-run "$APP" "$IMAGE_TAG" "$IMAGE_SOURCE_TYPE" "$PHASE_SCRIPT_KEY")
|
DOCKER_ARGS+=$(: | plugn trigger docker-args-process-run "$APP" "$IMAGE_TAG" "$IMAGE_SOURCE_TYPE")
|
||||||
|
|
||||||
declare -a ARG_ARRAY
|
declare -a ARG_ARRAY
|
||||||
eval "ARG_ARRAY=($DOCKER_ARGS)"
|
eval "ARG_ARRAY=($DOCKER_ARGS)"
|
||||||
|
|||||||
@@ -116,12 +116,21 @@ teardown() {
|
|||||||
echo "status: $status"
|
echo "status: $status"
|
||||||
assert_success
|
assert_success
|
||||||
|
|
||||||
|
run /bin/bash -c "dokku resource:reserve --cpu 0.5 --process-type worker $TEST_APP"
|
||||||
|
echo "output: $output"
|
||||||
|
echo "status: $status"
|
||||||
|
assert_success
|
||||||
|
|
||||||
dokku ps:rebuild "$TEST_APP"
|
dokku ps:rebuild "$TEST_APP"
|
||||||
CID=$(< $DOKKU_ROOT/$TEST_APP/CONTAINER.web.1)
|
CID=$(< $DOKKU_ROOT/$TEST_APP/CONTAINER.web.1)
|
||||||
run /bin/bash -c "docker inspect --format '{{.HostConfig.MemoryReservation}}' $CID"
|
run /bin/bash -c "docker inspect --format '{{.HostConfig.MemoryReservation}}' $CID"
|
||||||
echo "output: $output"
|
echo "output: $output"
|
||||||
echo "status: $status"
|
echo "status: $status"
|
||||||
assert_output "536870912"
|
assert_output "536870912"
|
||||||
|
# run /bin/bash -c "docker inspect --format '{{.HostConfig.NanoCpus}}' $CID"
|
||||||
|
# echo "output: $output"
|
||||||
|
# echo "status: $status"
|
||||||
|
# assert_output "500000000"
|
||||||
|
|
||||||
run /bin/bash -c "dokku resource:reserve-clear --process-type worker $TEST_APP"
|
run /bin/bash -c "dokku resource:reserve-clear --process-type worker $TEST_APP"
|
||||||
echo "output: $output"
|
echo "output: $output"
|
||||||
|
|||||||
Reference in New Issue
Block a user