Skip to content

Commit 897019c

Browse files
authored
Merge pull request serverlessworkflow#1049 from neuroglia-io/feat-container-lifetime
Add a new `lifetime` property to the `container` process
2 parents 8eebe90 + 3829876 commit 897019c

File tree

4 files changed

+74
-3
lines changed

4 files changed

+74
-3
lines changed

dsl-reference.md

+17-2
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@
5555
+ [HTTP Response](#http-response)
5656
+ [HTTP Request](#http-request)
5757
+ [URI Template](#uri-template)
58+
+ [Container Lifetime](#container-lifetime)
5859
+ [Process Result](#process-result)
5960
+ [AsyncAPI Server](#asyncapi-server)
6061
+ [AsyncAPI Message](#asyncapi-message)
6162
+ [AsyncAPI Subscription](#asyncapi-subscription)
6263

63-
6464
## Abstract
6565

6666
This document provides comprehensive definitions and detailed property tables for all the concepts discussed in the Serverless Workflow DSL. It serves as a reference guide, explaining the structure, components, and configurations available within the DSL. By exploring this document, users will gain a thorough understanding of how to define, configure, and manage workflows, including task definitions, flow directives, and state transitions. This foundational knowledge will enable users to effectively utilize the DSL for orchestrating serverless functions and automating processes.
@@ -798,6 +798,7 @@ Enables the execution of external processes encapsulated within a containerized
798798
| ports | `map` | `no` | The container's port mappings, if any |
799799
| volumes | `map` | `no` | The container's volume mappings, if any |
800800
| environment | `map` | `no` | A key/value mapping of the environment variables, if any, to use when running the configured process |
801+
| lifetime | [`containerLifetime`](#container-lifetime) | `no` | An object used to configure the container's lifetime. |
801802

802803
###### Examples
803804

@@ -1915,6 +1916,16 @@ This has the following limitations compared to runtime expressions:
19151916
uri: https://petstore.swagger.io/v2/pet/{petId}
19161917
```
19171918

1919+
### Container Lifetime
1920+
1921+
Configures the lifetime of a container.
1922+
1923+
#### Properties
1924+
1925+
| Property | Type | Required | Description |
1926+
|----------|:----:|:--------:|-------------|
1927+
| cleanup | `string` | `yes` | The cleanup policy to use.<br>*Supported values are:<br>- `always`: the container is deleted immediately after execution.<br>-`never`: the runtime should never delete the container.<br>-`eventually`: the container is deleted after a configured amount of time after its execution.*<br>*Defaults to `never`.* |
1928+
| after | [`duration`](#duration) | `no` | The [`duration`](#duration), if any, after which to delete the container once executed.<br>*Required if `cleanup` has been set to `eventually`, otherwise ignored.* |
19181929
### Process Result
19191930

19201931
Describes the result of a process.
@@ -1933,13 +1944,17 @@ Describes the result of a process.
19331944
document:
19341945
dsl: '1.0.0-alpha5'
19351946
namespace: test
1936-
name: run-example
1947+
name: run-container-example
19371948
version: '0.1.0'
19381949
do:
19391950
- runContainer:
19401951
run:
19411952
container:
19421953
image: fake-image
1954+
lifetime:
1955+
cleanup: eventually
1956+
after:
1957+
minutes: 30
19431958
return: stderr
19441959
19451960
- runScript:
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
document:
2+
dsl: '1.0.0-alpha5'
3+
namespace: test
4+
name: run-container
5+
version: '0.1.0'
6+
do:
7+
- runContainer:
8+
run:
9+
container:
10+
image: hello-world
11+
lifetime:
12+
cleanup: always
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
document:
2+
dsl: '1.0.0-alpha5'
3+
namespace: test
4+
name: run-container
5+
version: '0.1.0'
6+
do:
7+
- runContainer:
8+
run:
9+
container:
10+
image: hello-world
11+
lifetime:
12+
cleanup: eventually
13+
after:
14+
minutes: 30

schema/workflow.yaml

+31-1
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,10 @@ $defs:
630630
type: object
631631
title: ContainerEnvironment
632632
description: A key/value mapping of the environment variables, if any, to use when running the configured process.
633+
lifetime:
634+
$ref: '#/$defs/containerLifetime'
635+
title: ContainerLifetime
636+
description: An object, if any, used to configure the container's lifetime
633637
required: [ image ]
634638
required: [ container ]
635639
- title: RunScript
@@ -1554,6 +1558,32 @@ $defs:
15541558
title: RuntimeExpression
15551559
description: A runtime expression.
15561560
pattern: "^\\s*\\$\\{.+\\}\\s*$"
1561+
containerLifetime:
1562+
type: object
1563+
title: ContainerLifetime
1564+
description: The configuration of a container's lifetime
1565+
unevaluatedProperties: false
1566+
properties:
1567+
cleanup:
1568+
type: string
1569+
title: ContainerCleanupPolicy
1570+
description: The container cleanup policy to use
1571+
enum: [ always, never, eventually ]
1572+
default: never
1573+
after:
1574+
$ref: '#/$defs/duration'
1575+
title: ContainerLifetimeDuration
1576+
description: The duration after which to cleanup the container, in case the cleanup policy has been set to 'eventually'
1577+
required: [ cleanup ]
1578+
if:
1579+
properties:
1580+
cleanup:
1581+
const: eventually
1582+
then:
1583+
required: [ after ]
1584+
else:
1585+
not:
1586+
required: [ after ]
15571587
processResult:
15581588
type: object
15591589
title: ProcessResult
@@ -1658,4 +1688,4 @@ $defs:
16581688
$ref: '#/$defs/runtimeExpression'
16591689
title: AsyncApiMessageConsumptionPolicyUntil
16601690
description: A runtime expression evaluated before each consumed (filtered) message to decide if message consumption should continue.
1661-
required: [ until ]
1691+
required: [ until ]

0 commit comments

Comments
 (0)