Skip to content

Commit

Permalink
Add runfn implementation with timeout support
Browse files Browse the repository at this point in the history
Allows to limit execution time of KRM function.

Change-Id: I7fd8d97492512c6c5033375429906a1268f3818e
Signed-off-by: Ruslan Aliev <[email protected]>
Closes: #544
Closes: #545
Closes: #597
  • Loading branch information
raliev12 committed Nov 17, 2021
1 parent 1aab57a commit d0e2f6d
Show file tree
Hide file tree
Showing 8 changed files with 1,873 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,12 @@ spec:
parameter is specified. Else it will write output to STDOUT. This
path relative to current site root.
type: string
timeout:
description: Timeout is the maximum amount of time (in seconds) for
container execution if not specified (0) no timeout will be set
and container could run indefinitely
format: int64
type: integer
type:
description: Supported types are "airship" and "krm"
type: string
Expand Down
4 changes: 4 additions & 0 deletions pkg/api/v1alpha1/genericcontainer_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ type GenericContainerSpec struct {

// Mounts are the storage or directories to mount into the container
StorageMounts []StorageMount `json:"mounts,omitempty" yaml:"mounts,omitempty"`

// Timeout is the maximum amount of time (in seconds) for container execution
// if not specified (0) no timeout will be set and container could run indefinitely
Timeout uint64 `json:"timeout,omitempty"`
}

// AirshipContainerSpec airship container settings
Expand Down
3 changes: 2 additions & 1 deletion pkg/container/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ import (
"github.com/ahmetb/dlog"
"sigs.k8s.io/kustomize/kyaml/fn/runtime/runtimeutil"
"sigs.k8s.io/kustomize/kyaml/kio"
"sigs.k8s.io/kustomize/kyaml/runfn"
kyaml "sigs.k8s.io/kustomize/kyaml/yaml"
"sigs.k8s.io/yaml"

"opendev.org/airship/airshipctl/pkg/api/v1alpha1"
"opendev.org/airship/airshipctl/pkg/container/runfn"
"opendev.org/airship/airshipctl/pkg/log"
"opendev.org/airship/airshipctl/pkg/util"
)
Expand Down Expand Up @@ -228,6 +228,7 @@ func (c *V1Alpha1) runKRM() error {
Output: c.output,
StorageMounts: mounts,
ContinueOnEmptyResult: true,
Timeout: c.conf.Spec.Timeout,
}
function, err := kyaml.Parse(c.conf.Config)
if err != nil {
Expand Down
Loading

0 comments on commit d0e2f6d

Please sign in to comment.