feat: add ability to clear an individual resource

This commit is contained in:
Jose Diaz-Gonzalez committed 2021-02-07 20:32:43 -05:00
1 parent e7d9d6b19e
commit e556be1a0d
4 files changed
+78 -3

No files matched your search

@@ -71,6 +71,17 @@ dokku resource:limit --cpu 100 --memory 100 --process-type worker node-js-app
memory: 100 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 #### Displaying Resource Limits
Running the `resource:limit` command without any flags will display the currently configured default app 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 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 #### Displaying Resource Reservations
Running the `resource:reserve` command without any flags will display the currently configured default app reservations. Running the `resource:reserve` command without any flags will display the currently configured default app reservations.
+10 -3
View File
@@ -86,10 +86,17 @@ func setResourceType(appName string, processType string, r Resource, resourceTyp
continue 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) if value == "clear" {
if err != nil { 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 return err
} }
} }
+23
View File
@@ -111,3 +111,26 @@ teardown() {
echo "status: $status" echo "status: $status"
assert_success 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
}
+23
View File
@@ -102,3 +102,26 @@ teardown() {
echo "status: $status" echo "status: $status"
assert_success 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
}