make graceperiod configurable for container functions (#2337)

This commit is contained in:
Shubham Nazare
2022-01-28 10:18:20 +05:30
committed by GitHub
parent e06aa25245
commit 260de05a63
5 changed files with 14 additions and 1 deletions
@@ -172,6 +172,9 @@ func (cn *Container) getDeploymentSpec(ctx context.Context, fn *fv1.Function, ta
}
gracePeriodSeconds := int64(6 * 60)
if *fn.Spec.PodSpec.TerminationGracePeriodSeconds >= 0 {
gracePeriodSeconds = *fn.Spec.PodSpec.TerminationGracePeriodSeconds
}
podAnnotations := make(map[string]string)
+1
View File
@@ -167,6 +167,7 @@ func Commands() *cobra.Command {
flag.FnCfgMap, flag.FnSecret,
flag.FnExecutionTimeout,
flag.FnIdleTimeout,
flag.FnTerminationGracePeriod,
flag.Labels, flag.Annotation,
// flag for newdeploy to use.
@@ -100,6 +100,11 @@ func (opts *RunContainerSubCommand) complete(input cli.Input) error {
return err
}
fnGracePeriod := input.Int64(flagkey.FnGracePeriod)
if fnGracePeriod < 0 {
console.Warn("grace period must be a non-negative integer, using default value (6 mins)")
}
var imageName string
var port int
var command, args string
@@ -205,7 +210,8 @@ func (opts *RunContainerSubCommand) complete(input cli.Input) error {
}
opts.function.Spec.PodSpec = &apiv1.PodSpec{
Containers: []apiv1.Container{*container},
Containers: []apiv1.Container{*container},
TerminationGracePeriodSeconds: &fnGracePeriod,
}
return nil
+2
View File
@@ -125,6 +125,8 @@ var (
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"}
FnSubPath = Flag{Type: String, Name: flagkey.FnSubPath, Usage: "Sub Path to check if function internally supports routing"}
// Termination Grace Period configurable at function creation/update only for container functions
FnTerminationGracePeriod = Flag{Type: Int64, Name: flagkey.FnGracePeriod, Usage: "Grace time (in seconds) for pod to perform connection draining before termination (default value will be used if negative value is given)", DefaultValue: 360}
HtName = Flag{Type: String, Name: flagkey.HtName, Usage: "HTTP trigger name"}
HtMethod = Flag{Type: StringSlice, Name: flagkey.HtMethod, Usage: "HTTP Methods: GET,POST,PUT,DELETE,HEAD. To mention single method: --method GET and for multiple methods --method GET --method POST. [DEPRECATED for 'fn create', use 'route create' instead]", DefaultValue: []string{http.MethodGet}}
+1
View File
@@ -76,6 +76,7 @@ const (
FnRequestsPerPod = "requestsperpod"
FnOnceOnly = "onceonly"
FnSubPath = "subpath"
FnGracePeriod = "graceperiod"
HtName = resourceName
HtMethod = "method"