refactor: drop -defaults command in favor of --global flag
This makes usage a bit simpler, at the cost of interface complexity.
This commit is contained in:
@@ -3,10 +3,8 @@
|
||||
> New as of 0.15.0
|
||||
|
||||
```
|
||||
dokku resource:limit [--process-type <process-type,...>] [RESOURCE_OPTS...] <app>
|
||||
dokku resource:reserve [--process-type <process-type,...>] [RESOURCE_OPTS...] <app>
|
||||
dokku resource:limit-defaults [--process-type <process-type,...>] [RESOURCE_OPTS...]
|
||||
dokku resource:reserve-defaults [--process-type <process-type,...>] [RESOURCE_OPTS...]
|
||||
dokku resource:limit [--global] [--process-type <process-type,...>] [RESOURCE_OPTS...] <app>
|
||||
dokku resource:reserve [--global] [--process-type <process-type,...>] [RESOURCE_OPTS...] <app>
|
||||
dokku resource:limit-clear [--process-type <process-type,...>] [<app>]
|
||||
dokku resource:reserve-clear [--process-type <process-type,...>] [<app>]
|
||||
dokku resource:report [<app>]
|
||||
@@ -68,6 +66,8 @@ dokku resource:limit --cpu 100 --memory 100 --process-type worker node-js-app
|
||||
memory: 100
|
||||
```
|
||||
|
||||
#### Displaying Resource Limits
|
||||
|
||||
Running the `resource:limits` command without any flags will display the currently configured app reservation.
|
||||
|
||||
```shell
|
||||
@@ -81,12 +81,12 @@ dokku resource:limits node-js-app
|
||||
network-egress:
|
||||
```
|
||||
|
||||
#### Default Resource Limits
|
||||
#### Global Resource Limits
|
||||
|
||||
By default, Dokku does not limit any resources, though these can be specified at the server level via the `resource:limit-defaults` command. As with the `resource:limit` command, any and all resource request types can be specified.
|
||||
By default, Dokku does not limit any resources, though these can be specified at the server level via the `--global` flag on the `resource:limit` command.
|
||||
|
||||
```shell
|
||||
dokku resource:limit-defaults --memory 200
|
||||
dokku resource:limit --global --memory 200
|
||||
```
|
||||
|
||||
```
|
||||
@@ -94,10 +94,26 @@ dokku resource:limit-defaults --memory 200
|
||||
memory: 200
|
||||
```
|
||||
|
||||
Running the `resource:limit-defaults` command without any flags will display the currently configured default limits.
|
||||
This may also be combined with the `--process-type` flag to set global limits on a process-type level:
|
||||
|
||||
```shell
|
||||
dokku resource:limit-defaults
|
||||
dokku resource:limit --global --memory 150 --process-type web node-js-app
|
||||
```
|
||||
|
||||
```
|
||||
=====> Setting default resource limits (web)
|
||||
memory: 150
|
||||
```
|
||||
|
||||
#### Displaying Global Resource Limits
|
||||
|
||||
Running the `resource:limit` command with only the `--global` flag will display the currently configured default limits.
|
||||
|
||||
```shell
|
||||
dokku resource:limit --global
|
||||
```
|
||||
|
||||
```
|
||||
=====> resource limits default information
|
||||
cpu:
|
||||
memory: 200
|
||||
@@ -107,7 +123,23 @@ dokku resource:limit-defaults
|
||||
network-egress:
|
||||
```
|
||||
|
||||
### Clearing Resource Limits
|
||||
This may also be combined with the `--process-type` flag to see global limits on a process-type level:
|
||||
|
||||
```shell
|
||||
dokku resource:limit --global --process-type web
|
||||
```
|
||||
|
||||
```
|
||||
=====> resource limits default information (web)
|
||||
cpu:
|
||||
memory-swap:
|
||||
memory: 150
|
||||
network-egress:
|
||||
network-ingress:
|
||||
network:
|
||||
```
|
||||
|
||||
#### Clearing Resource Limits
|
||||
|
||||
In cases where the values are incorrect - or there is no desire to limit resources - resource limits may be cleared using the `resource:limit-clear` command.
|
||||
|
||||
@@ -168,6 +200,8 @@ dokku resource:reserve --cpu 100 --memory 100 --process-type worker node-js-app
|
||||
memory: 100
|
||||
```
|
||||
|
||||
#### Displaying Resource Reservations
|
||||
|
||||
Running the `resource:reserve` command without any flags will display the currently configured app reservation.
|
||||
|
||||
```shell
|
||||
@@ -181,12 +215,12 @@ dokku resource:reserve node-js-app
|
||||
network-egress:
|
||||
```
|
||||
|
||||
#### Default Resource Reservations
|
||||
#### Global Resource Reservations
|
||||
|
||||
By default, Dokku does not reserve any resources, though these can be specified at the server level via the `resource:reserve-defaults` command. As with the `resource:reserve` command, any and all resource request types can be specified.
|
||||
By default, Dokku does not reserve any resources, though these can be specified at the server level via the `--global` flag on the `resource:reserve` command.
|
||||
|
||||
```shell
|
||||
dokku resource:reserve-defaults --memory 200
|
||||
dokku resource:reserve --global --memory 200
|
||||
```
|
||||
|
||||
```
|
||||
@@ -194,10 +228,26 @@ dokku resource:reserve-defaults --memory 200
|
||||
memory: 200
|
||||
```
|
||||
|
||||
Running the `resource:reserve-defaults` command without any flags will display the currently configured default reservation.
|
||||
This may also be combined with the `--process-type` flag to set global reservations on a process-type level:
|
||||
|
||||
```shell
|
||||
dokku resource:reserve-defaults
|
||||
dokku resource:reserve --global --memory 150 --process-type web node-js-app
|
||||
```
|
||||
|
||||
```
|
||||
=====> Setting default resource reservation (web)
|
||||
memory: 150
|
||||
```
|
||||
|
||||
#### Displaying Global Resource Reservations
|
||||
|
||||
Running the `resource:reserve` command with only the `--global` flag will display the currently configured default reservation.
|
||||
|
||||
```shell
|
||||
dokku resource:reserve --global
|
||||
```
|
||||
|
||||
```
|
||||
=====> resource reservation default information
|
||||
cpu:
|
||||
memory: 200
|
||||
@@ -207,6 +257,22 @@ dokku resource:reserve-defaults
|
||||
network-egress:
|
||||
```
|
||||
|
||||
This may also be combined with the `--process-type` flag to see global reservations on a process-type level:
|
||||
|
||||
```shell
|
||||
dokku resource:reserve --global --process-type web
|
||||
```
|
||||
|
||||
```
|
||||
=====> resource reservation default information (web)
|
||||
cpu:
|
||||
memory-swap:
|
||||
memory: 150
|
||||
network-egress:
|
||||
network-ingress:
|
||||
network:
|
||||
```
|
||||
|
||||
#### Clearing Resource Reservations
|
||||
|
||||
In cases where the values are incorrect - or there is no desire to reserve resources - resource reservations may be cleared using the `resource:reserve-clear` command.
|
||||
|
||||
@@ -2,7 +2,7 @@ include ../../common.mk
|
||||
|
||||
GO_ARGS ?= -a
|
||||
|
||||
SUBCOMMANDS = subcommands/limit subcommands/limit-clear subcommands/limit-defaults subcommands/reserve subcommands/reserve-clear subcommands/reserve-defaults
|
||||
SUBCOMMANDS = subcommands/limit subcommands/limit-clear subcommands/reserve subcommands/reserve-clear
|
||||
TRIGGERS = triggers/install triggers/post-delete
|
||||
build-in-docker: clean
|
||||
docker run --rm \
|
||||
|
||||
@@ -19,10 +19,8 @@ Manages resource settings for an app
|
||||
Additional commands:`
|
||||
|
||||
helpContent = `
|
||||
resource:limit [--process-type process-type] [RESOURCE_OPTS...] <app>, Limit resources for a given app/process-type combination
|
||||
resource:reserve [--process-type process-type] [RESOURCE_OPTS...] <app>, Reserve resources for a given app/process-type combination
|
||||
resource:limit-defaults [--process-type process-type] [RESOURCE_OPTS...] <app>, Limit resources for a given app/process-type combination
|
||||
resource:reserve-defaults [--process-type process-type] [RESOURCE_OPTS...] <app>, Reserve resources for a given app/process-type combination
|
||||
resource:limit [--global] [--process-type process-type] [RESOURCE_OPTS...] <app>, Limit resources for a given app/process-type combination
|
||||
resource:reserve [--global] [--process-type process-type] [RESOURCE_OPTS...] <app>, Reserve resources for a given app/process-type combination
|
||||
`
|
||||
)
|
||||
|
||||
|
||||
@@ -11,9 +11,10 @@ import (
|
||||
func main() {
|
||||
args := flag.NewFlagSet("resource:limit-clear", flag.ExitOnError)
|
||||
processType := args.String("process-type", "", "process-type: A process type to clear")
|
||||
global := args.Bool("global", false, "global: Whether to clear global settings or not")
|
||||
args.Parse(os.Args[2:])
|
||||
|
||||
err := resource.CommandLimitClear(args.Args(), *processType)
|
||||
err := resource.CommandLimitClear(args.Args(), *processType, *global)
|
||||
if err != nil {
|
||||
common.LogFail(err.Error())
|
||||
}
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"os"
|
||||
|
||||
"github.com/dokku/dokku/plugins/common"
|
||||
"github.com/dokku/dokku/plugins/resource"
|
||||
)
|
||||
|
||||
func main() {
|
||||
args := flag.NewFlagSet("resource:limit-defaults", flag.ExitOnError)
|
||||
processType := args.String("process-type", "", "process-type: A process type to manage")
|
||||
cpu := args.String("cpu", "", "cpu: The amount of cpu to limit processes by")
|
||||
memory := args.String("memory", "", "memory: The amount of memory to limit processes by")
|
||||
memorySwap := args.String("memory-swap", "", "memory-swap: The amount of swap memory to limit processes by")
|
||||
network := args.String("network", "", "network: The amount of network bandwidth to limit processes by")
|
||||
networkIngress := args.String("network-ingress", "", "network-ingress: The amount of ingress network bandwidth to limit processes by")
|
||||
networkEgress := args.String("network-egress", "", "network-egress: The amount of egress network bandwidth to limit processes by")
|
||||
args.Parse(os.Args[2:])
|
||||
|
||||
resources := resource.Resource{
|
||||
CPU: *cpu,
|
||||
Memory: *memory,
|
||||
MemorySwap: *memorySwap,
|
||||
Network: *network,
|
||||
NetworkIngress: *networkIngress,
|
||||
NetworkEgress: *networkEgress,
|
||||
}
|
||||
|
||||
err := resource.CommandLimitDefaults(args.Args(), *processType, resources)
|
||||
if err != nil {
|
||||
common.LogFail(err.Error())
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
func main() {
|
||||
args := flag.NewFlagSet("resource:limit", flag.ExitOnError)
|
||||
processType := args.String("process-type", "", "process-type: A process type to manage")
|
||||
global := args.Bool("global", false, "global: Whether to clear global settings or not")
|
||||
cpu := args.String("cpu", "", "cpu: The amount of cpu to limit processes by")
|
||||
memory := args.String("memory", "", "memory: The amount of memory to limit processes by")
|
||||
memorySwap := args.String("memory-swap", "", "memory-swap: The amount of swap memory to limit processes by")
|
||||
@@ -28,7 +29,7 @@ func main() {
|
||||
NetworkEgress: *networkEgress,
|
||||
}
|
||||
|
||||
err := resource.CommandLimit(args.Args(), *processType, resources)
|
||||
err := resource.CommandLimit(args.Args(), *processType, resources, *global)
|
||||
if err != nil {
|
||||
common.LogFail(err.Error())
|
||||
}
|
||||
|
||||
@@ -11,9 +11,10 @@ import (
|
||||
func main() {
|
||||
args := flag.NewFlagSet("resource:reserve-clear", flag.ExitOnError)
|
||||
processType := args.String("process-type", "", "process-type: A process type to clear")
|
||||
global := args.Bool("global", false, "global: Whether to clear global settings or not")
|
||||
args.Parse(os.Args[2:])
|
||||
|
||||
err := resource.CommandReserveClear(args.Args(), *processType)
|
||||
err := resource.CommandReserveClear(args.Args(), *processType, *global)
|
||||
if err != nil {
|
||||
common.LogFail(err.Error())
|
||||
}
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"os"
|
||||
|
||||
"github.com/dokku/dokku/plugins/common"
|
||||
"github.com/dokku/dokku/plugins/resource"
|
||||
)
|
||||
|
||||
func main() {
|
||||
args := flag.NewFlagSet("resource:reserve-defaults", flag.ExitOnError)
|
||||
processType := args.String("process-type", "", "process-type: A process type to manage")
|
||||
cpu := args.String("cpu", "", "cpu: The amount of cpu to reserve for processes")
|
||||
memory := args.String("memory", "", "memory: The amount of memory to reserve for processes")
|
||||
memorySwap := args.String("memory-swap", "", "memory-swap: The amount of swap memory to reserve for processes")
|
||||
network := args.String("network", "", "network: The amount of network bandwidth to reserve for processes")
|
||||
networkIngress := args.String("network-ingress", "", "network-ingress: The amount of ingress network bandwidth to reserve for processes")
|
||||
networkEgress := args.String("network-egress", "", "network-egress: The amount of egress network bandwidth to reserve for processes")
|
||||
args.Parse(os.Args[2:])
|
||||
|
||||
resources := resource.Resource{
|
||||
CPU: *cpu,
|
||||
Memory: *memory,
|
||||
MemorySwap: *memorySwap,
|
||||
Network: *network,
|
||||
NetworkIngress: *networkIngress,
|
||||
NetworkEgress: *networkEgress,
|
||||
}
|
||||
|
||||
err := resource.CommandReserveDefaults(args.Args(), *processType, resources)
|
||||
if err != nil {
|
||||
common.LogFail(err.Error())
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
func main() {
|
||||
args := flag.NewFlagSet("resource:reserve", flag.ExitOnError)
|
||||
processType := args.String("process-type", "", "process-type: A process type to manage")
|
||||
global := args.Bool("global", false, "global: Whether to clear global settings or not")
|
||||
cpu := args.String("cpu", "", "cpu: The amount of cpu to reserve for processes")
|
||||
memory := args.String("memory", "", "memory: The amount of memory to reserve for processes")
|
||||
memorySwap := args.String("memory-swap", "", "memory-swap: The amount of swap memory to reserve for processes")
|
||||
@@ -28,7 +29,7 @@ func main() {
|
||||
NetworkEgress: *networkEgress,
|
||||
}
|
||||
|
||||
err := resource.CommandReserve(args.Args(), *processType, resources)
|
||||
err := resource.CommandReserve(args.Args(), *processType, resources, *global)
|
||||
if err != nil {
|
||||
common.LogFail(err.Error())
|
||||
}
|
||||
|
||||
@@ -7,55 +7,49 @@ import (
|
||||
)
|
||||
|
||||
// CommandLimit implements resource:limit
|
||||
func CommandLimit(args []string, processType string, r Resource) (err error) {
|
||||
var appName string
|
||||
appName, err = getAppName(args)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
func CommandLimit(args []string, processType string, r Resource, global bool) (err error) {
|
||||
appName := "_all_"
|
||||
if !global {
|
||||
appName, err = getAppName(args)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if err = common.VerifyAppName(appName); err != nil {
|
||||
common.LogFail(err.Error())
|
||||
if err = common.VerifyAppName(appName); err != nil {
|
||||
common.LogFail(err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
return setRequestType(appName, processType, r, "limit")
|
||||
}
|
||||
|
||||
// CommandLimitClear implements resource:limit-clear
|
||||
func CommandLimitClear(args []string, processType string) (err error) {
|
||||
func CommandLimitClear(args []string, processType string, global bool) (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
// CommandLimitDefaults implements resource:limit-defaults
|
||||
func CommandLimitDefaults(args []string, processType string, r Resource) (err error) {
|
||||
return setRequestType("_all_", "", r, "limit")
|
||||
}
|
||||
|
||||
// CommandReserve implements resource:reserve
|
||||
func CommandReserve(args []string, processType string, r Resource) (err error) {
|
||||
var appName string
|
||||
appName, err = getAppName(args)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
func CommandReserve(args []string, processType string, r Resource, global bool) (err error) {
|
||||
appName := "_all_"
|
||||
if !global {
|
||||
appName, err = getAppName(args)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if err = common.VerifyAppName(appName); err != nil {
|
||||
common.LogFail(err.Error())
|
||||
if err = common.VerifyAppName(appName); err != nil {
|
||||
common.LogFail(err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
return setRequestType(appName, processType, r, "reserve")
|
||||
}
|
||||
|
||||
// CommandReserveClear implements resource:reserve-clear
|
||||
func CommandReserveClear(args []string, processType string) (err error) {
|
||||
func CommandReserveClear(args []string, processType string, global bool) (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
// CommandReserveDefaults implements resource:reserve-defaults
|
||||
func CommandReserveDefaults(args []string, processType string, r Resource) (err error) {
|
||||
return setRequestType("_all_", "", r, "reserve")
|
||||
}
|
||||
|
||||
func setRequestType(appName string, processType string, r Resource, requestType string) (err error) {
|
||||
if len(processType) == 0 {
|
||||
processType = "_all_"
|
||||
|
||||
Reference in New Issue
Block a user