diff --git a/pkg/fission-cli/cmd/function/create.go b/pkg/fission-cli/cmd/function/create.go index fc488d1d..c9aca0d3 100644 --- a/pkg/fission-cli/cmd/function/create.go +++ b/pkg/fission-cli/cmd/function/create.go @@ -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 "": diff --git a/pkg/fission-cli/cmd/function/update.go b/pkg/fission-cli/cmd/function/update.go index 431658d8..d3759f5a 100644 --- a/pkg/fission-cli/cmd/function/update.go +++ b/pkg/fission-cli/cmd/function/update.go @@ -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) } diff --git a/pkg/fission-cli/flag/flag.go b/pkg/fission-cli/flag/flag.go index 43b4a7f6..c1424fd8 100644 --- a/pkg/fission-cli/flag/flag.go +++ b/pkg/fission-cli/flag/flag.go @@ -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}