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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user