Show warning that --yolo, --concurrency and --rpp fields are valid for executortype poolmgr only (#2971)
* yolo, concurrency and rpp are specifically introduced for executortype poolmgr ``` Show warning if these fields are used with other executortype. Update CLI with this information. ``` Signed-off-by: Md Soharab Ansari <soharab.ansari@infracloud.io> * Add warning for fn update too Signed-off-by: Md Soharab Ansari <soharab.ansari@infracloud.io> * Show warning while updating `--yolo`, `--con` and `--rpp` to an already created newdeploy function. Signed-off-by: Md Soharab Ansari <soharab.ansari@infracloud.io> * Fixed a minor bug Signed-off-by: Md Soharab Ansari <soharab.ansari@infracloud.io> * Optmize and increase code readability Signed-off-by: Md Soharab Ansari <soharab.ansari@infracloud.io> * Rename function to checkExecutorPoolManager Signed-off-by: Md Soharab Ansari <soharab.ansari@infracloud.io> --------- Signed-off-by: Md Soharab Ansari <soharab.ansari@infracloud.io>
This commit is contained in:
@@ -98,6 +98,11 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
|
||||
fnIdleTimeout := input.Int(flagkey.FnIdleTimeout)
|
||||
|
||||
err = checkExecutorPoolManager(input, fv1.ExecutorTypePoolmgr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fnConcurrency := DEFAULT_CONCURRENCY
|
||||
if input.IsSet(flagkey.FnConcurrency) {
|
||||
fnConcurrency = input.Int(flagkey.FnConcurrency)
|
||||
@@ -447,6 +452,33 @@ func getInvokeStrategy(input cli.Input, existingInvokeStrategy *fv1.InvokeStrate
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Show warning when --con, --rpp and --yolo flags are used with executortype other than `poolmgr`.
|
||||
// These flags are specifically introduced for executortype `poolmgr`.
|
||||
func checkExecutorPoolManager(input cli.Input, existingExecutorType fv1.ExecutorType) error {
|
||||
var isNotPoolManager bool
|
||||
if input.IsSet(flagkey.EnvExecutorType) {
|
||||
executorType, err := getExecutorType(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
isNotPoolManager = (string(executorType) != string(fv1.ExecutorTypePoolmgr))
|
||||
} else {
|
||||
isNotPoolManager = (string(existingExecutorType) != string(fv1.ExecutorTypePoolmgr))
|
||||
}
|
||||
|
||||
if input.IsSet(flagkey.FnConcurrency) && isNotPoolManager {
|
||||
console.Warn("--concurrency is only valid for executortype; `poolmgr`. Check `fission function create --help`")
|
||||
}
|
||||
if input.IsSet(flagkey.FnRequestsPerPod) && isNotPoolManager {
|
||||
console.Warn("--requestsperpod is only valid for executortype; `poolmgr`. Check `fission function create --help`")
|
||||
}
|
||||
if input.IsSet(flagkey.FnOnceOnly) && isNotPoolManager {
|
||||
console.Warn("--onceonly is only valid for executortype; `poolmgr`. Check `fission function create --help`")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func getExecutorType(input cli.Input) (executorType fv1.ExecutorType, err error) {
|
||||
switch input.String(flagkey.FnExecutorType) {
|
||||
case "":
|
||||
|
||||
@@ -154,6 +154,11 @@ func (opts *UpdateSubCommand) complete(input cli.Input) error {
|
||||
function.Spec.IdleTimeout = &fnTimeout
|
||||
}
|
||||
|
||||
err = checkExecutorPoolManager(input, function.Spec.InvokeStrategy.ExecutionStrategy.ExecutorType)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if input.IsSet(flagkey.FnConcurrency) {
|
||||
function.Spec.Concurrency = input.Int(flagkey.FnConcurrency)
|
||||
}
|
||||
|
||||
@@ -126,9 +126,9 @@ var (
|
||||
FnTestHeader = Flag{Type: StringSlice, Name: flagkey.FnTestHeader, Short: "H", Usage: "Request headers"}
|
||||
FnTestQuery = Flag{Type: StringSlice, Name: flagkey.FnTestQuery, Short: "q", Usage: "Request query parameters: -q key1=value1 -q key2=value2"}
|
||||
FnIdleTimeout = Flag{Type: Int, Name: flagkey.FnIdleTimeout, Usage: "The length of time (in seconds) that a function is idle before pod(s) are eligible for recycling", DefaultValue: 120}
|
||||
FnConcurrency = Flag{Type: Int, Name: flagkey.FnConcurrency, Aliases: []string{"con"}, Usage: "Maximum number of pods specialized concurrently to serve requests", DefaultValue: 500}
|
||||
FnRequestsPerPod = Flag{Type: Int, Name: flagkey.FnRequestsPerPod, Aliases: []string{"rpp"}, Usage: "Maximum number of concurrent requests that can be served by a specialized pod", DefaultValue: 1}
|
||||
FnOnceOnly = Flag{Type: Bool, Name: flagkey.FnOnceOnly, Aliases: []string{"yolo"}, Usage: "Specifies if specialized pod will serve exactly one request in its lifetime"}
|
||||
FnConcurrency = Flag{Type: Int, Name: flagkey.FnConcurrency, Aliases: []string{"con"}, Usage: "Maximum number of pods specialized concurrently to serve requests (Only valid for executortype; `poolmgr`)", DefaultValue: 500}
|
||||
FnRequestsPerPod = Flag{Type: Int, Name: flagkey.FnRequestsPerPod, Aliases: []string{"rpp"}, Usage: "Maximum number of concurrent requests that can be served by a specialized pod (Only valid for executortype; `poolmgr`)", DefaultValue: 1}
|
||||
FnOnceOnly = Flag{Type: Bool, Name: flagkey.FnOnceOnly, Aliases: []string{"yolo"}, Usage: "Specifies if specialized pod will serve exactly one request in its lifetime (Only valid for executortype; `poolmgr`)"}
|
||||
FnSubPath = Flag{Type: String, Name: flagkey.FnSubPath, Usage: "Sub Path to check if function internally supports routing"}
|
||||
FnLogAllPods = Flag{Type: Bool, Name: flagkey.FnLogAllPods, Usage: "Get all pod's logs in the function."}
|
||||
FnRetainPods = Flag{Type: Int, Name: flagkey.FnRetainPods, Usage: "Number of pods to retain after pods specialization.", DefaultValue: 0}
|
||||
|
||||
Reference in New Issue
Block a user