Merge pull request #4372 from dokku/clear-individual-resource
Add ability to clear an individual resource
This commit is contained in:
@@ -71,6 +71,17 @@ dokku resource:limit --cpu 100 --memory 100 --process-type worker node-js-app
|
||||
memory: 100
|
||||
```
|
||||
|
||||
A resource value can be individually cleared by setting the value to the special value `clear`.
|
||||
|
||||
```shell
|
||||
dokku resource:limit --cpu clear node-js-app
|
||||
```
|
||||
|
||||
```
|
||||
=====> Setting resource limits for node-js-app
|
||||
cpu: cleared
|
||||
```
|
||||
|
||||
#### Displaying Resource Limits
|
||||
|
||||
Running the `resource:limit` command without any flags will display the currently configured default app limits.
|
||||
@@ -169,6 +180,17 @@ dokku resource:reserve --cpu 100 --memory 100 --process-type worker node-js-app
|
||||
memory: 100
|
||||
```
|
||||
|
||||
A resource value can be individually cleared by setting the value to the special value `clear`.
|
||||
|
||||
```shell
|
||||
dokku resource:reserve --cpu clear node-js-app
|
||||
```
|
||||
|
||||
```
|
||||
=====> Setting resource reservation for node-js-app
|
||||
cpu: cleared
|
||||
```
|
||||
|
||||
#### Displaying Resource Reservations
|
||||
|
||||
Running the `resource:reserve` command without any flags will display the currently configured default app reservations.
|
||||
|
||||
@@ -86,10 +86,17 @@ func setResourceType(appName string, processType string, r Resource, resourceTyp
|
||||
continue
|
||||
}
|
||||
|
||||
common.LogVerbose(fmt.Sprintf("%v: %v", key, value))
|
||||
property := propertyKey(processType, resourceType, key)
|
||||
err := common.PropertyWrite("resource", appName, property, value)
|
||||
if err != nil {
|
||||
if value == "clear" {
|
||||
common.LogVerbose(fmt.Sprintf("%v: cleared", key))
|
||||
if err := common.PropertyDelete("resource", appName, property); err != nil {
|
||||
return err
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
common.LogVerbose(fmt.Sprintf("%v: %v", key, value))
|
||||
if err := common.PropertyWrite("resource", appName, property, value); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,3 +111,26 @@ teardown() {
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "(resource) resource:limit clear single" {
|
||||
run /bin/bash -c "dokku resource:limit --memory 512MB $TEST_APP"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "dokku resource:report --resource-_default_.limit.memory $TEST_APP"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output "512MB"
|
||||
|
||||
run /bin/bash -c "dokku resource:limit --memory clear $TEST_APP"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "dokku resource:report --resource-_default_.limit.memory $TEST_APP"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_failure
|
||||
}
|
||||
|
||||
@@ -102,3 +102,26 @@ teardown() {
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "(resource) resource:reserve clear single" {
|
||||
run /bin/bash -c "dokku resource:reserve --memory 512MB $TEST_APP"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "dokku resource:report --resource-_default_.reserve.memory $TEST_APP"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output "512MB"
|
||||
|
||||
run /bin/bash -c "dokku resource:reserve --memory clear $TEST_APP"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "dokku resource:report --resource-_default_.reserve.memory $TEST_APP"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_failure
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user