Support Function-level idle timeout setting (#1538)
This PR allows users to specify the idle timeout setting at Function-level. Fix #1050
This commit is contained in:
@@ -35,6 +35,7 @@ func Commands() *cobra.Command {
|
||||
flag.FnEnvName, flag.FnEntryPoint, flag.FnPkgName,
|
||||
flag.FnExecutorType, flag.FnCfgMap, flag.FnSecret,
|
||||
flag.FnSpecializationTimeout, flag.FnExecutionTimeout,
|
||||
flag.FnIdleTimeout,
|
||||
|
||||
// TODO retired pkg & trigger related flags from function cmd
|
||||
flag.PkgCode, flag.PkgSrcArchive, flag.PkgDeployArchive,
|
||||
@@ -85,6 +86,7 @@ func Commands() *cobra.Command {
|
||||
flag.FnEnvName, flag.FnEntryPoint, flag.FnPkgName,
|
||||
flag.FnExecutorType, flag.FnSecret, flag.FnCfgMap,
|
||||
flag.FnSpecializationTimeout, flag.FnExecutionTimeout,
|
||||
flag.FnIdleTimeout,
|
||||
|
||||
flag.PkgCode, flag.PkgSrcArchive, flag.PkgDeployArchive,
|
||||
flag.PkgSrcChecksum, flag.PkgDeployChecksum, flag.PkgInsecure,
|
||||
|
||||
@@ -91,9 +91,11 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
|
||||
fnTimeout := input.Int(flagkey.FnExecutionTimeout)
|
||||
if fnTimeout <= 0 {
|
||||
return errors.New("fntimeout must be greater than 0")
|
||||
return errors.Errorf("--%v must be greater than 0", flagkey.FnExecutionTimeout)
|
||||
}
|
||||
|
||||
fnIdleTimeout := input.Int(flagkey.FnIdleTimeout)
|
||||
|
||||
pkgName := input.String(flagkey.FnPackageName)
|
||||
|
||||
secretNames := input.StringSlice(flagkey.FnSecret)
|
||||
@@ -291,6 +293,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
Resources: *resourceReq,
|
||||
InvokeStrategy: *invokeStrategy,
|
||||
FunctionTimeout: fnTimeout,
|
||||
IdleTimeout: &fnIdleTimeout,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -150,6 +150,11 @@ func (opts *UpdateSubCommand) complete(input cli.Input) error {
|
||||
function.Spec.FunctionTimeout = fnTimeout
|
||||
}
|
||||
|
||||
if input.IsSet(flagkey.FnIdleTimeout) {
|
||||
fnTimeout := input.Int(flagkey.FnIdleTimeout)
|
||||
function.Spec.IdleTimeout = &fnTimeout
|
||||
}
|
||||
|
||||
if len(pkgName) == 0 {
|
||||
pkgName = function.Spec.Package.PackageRef.Name
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user