diff --git a/dsl-reference.md b/dsl-reference.md index 45fe74b4..9b6b4004 100644 --- a/dsl-reference.md +++ b/dsl-reference.md @@ -55,12 +55,12 @@ + [HTTP Response](#http-response) + [HTTP Request](#http-request) + [URI Template](#uri-template) + + [Container Lifetime](#container-lifetime) + [Process Result](#process-result) + [AsyncAPI Server](#asyncapi-server) + [AsyncAPI Message](#asyncapi-message) + [AsyncAPI Subscription](#asyncapi-subscription) - ## Abstract 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 | ports | `map` | `no` | The container's port mappings, if any | | volumes | `map` | `no` | The container's volume mappings, if any | | environment | `map` | `no` | A key/value mapping of the environment variables, if any, to use when running the configured process | +| lifetime | [`containerLifetime`](#container-lifetime) | `no` | An object used to configure the container's lifetime. | ###### Examples @@ -1915,6 +1916,16 @@ This has the following limitations compared to runtime expressions: uri: https://petstore.swagger.io/v2/pet/{petId} ``` +### Container Lifetime + +Configures the lifetime of a container. + +#### Properties + +| Property | Type | Required | Description | +|----------|:----:|:--------:|-------------| +| cleanup | `string` | `yes` | The cleanup policy to use.
*Supported values are:
- `always`: the container is deleted immediately after execution.
-`never`: the runtime should never delete the container.
-`eventually`: the container is deleted after a configured amount of time after its execution.*
*Defaults to `never`.* | +| after | [`duration`](#duration) | `no` | The [`duration`](#duration), if any, after which to delete the container once executed.
*Required if `cleanup` has been set to `eventually`, otherwise ignored.* | ### Process Result Describes the result of a process. @@ -1933,13 +1944,17 @@ Describes the result of a process. document: dsl: '1.0.0-alpha5' namespace: test - name: run-example + name: run-container-example version: '0.1.0' do: - runContainer: run: container: image: fake-image + lifetime: + cleanup: eventually + after: + minutes: 30 return: stderr - runScript: diff --git a/examples/run-container-cleanup-always.yaml b/examples/run-container-cleanup-always.yaml new file mode 100644 index 00000000..f399d07b --- /dev/null +++ b/examples/run-container-cleanup-always.yaml @@ -0,0 +1,12 @@ +document: + dsl: '1.0.0-alpha5' + namespace: test + name: run-container + version: '0.1.0' +do: + - runContainer: + run: + container: + image: hello-world + lifetime: + cleanup: always \ No newline at end of file diff --git a/examples/run-container-cleanup-eventually.yaml b/examples/run-container-cleanup-eventually.yaml new file mode 100644 index 00000000..58fbfdf3 --- /dev/null +++ b/examples/run-container-cleanup-eventually.yaml @@ -0,0 +1,14 @@ +document: + dsl: '1.0.0-alpha5' + namespace: test + name: run-container + version: '0.1.0' +do: + - runContainer: + run: + container: + image: hello-world + lifetime: + cleanup: eventually + after: + minutes: 30 \ No newline at end of file diff --git a/schema/workflow.yaml b/schema/workflow.yaml index 8fcf0f57..6b44639f 100644 --- a/schema/workflow.yaml +++ b/schema/workflow.yaml @@ -630,6 +630,10 @@ $defs: type: object title: ContainerEnvironment description: A key/value mapping of the environment variables, if any, to use when running the configured process. + lifetime: + $ref: '#/$defs/containerLifetime' + title: ContainerLifetime + description: An object, if any, used to configure the container's lifetime required: [ image ] required: [ container ] - title: RunScript @@ -1554,6 +1558,32 @@ $defs: title: RuntimeExpression description: A runtime expression. pattern: "^\\s*\\$\\{.+\\}\\s*$" + containerLifetime: + type: object + title: ContainerLifetime + description: The configuration of a container's lifetime + unevaluatedProperties: false + properties: + cleanup: + type: string + title: ContainerCleanupPolicy + description: The container cleanup policy to use + enum: [ always, never, eventually ] + default: never + after: + $ref: '#/$defs/duration' + title: ContainerLifetimeDuration + description: The duration after which to cleanup the container, in case the cleanup policy has been set to 'eventually' + required: [ cleanup ] + if: + properties: + cleanup: + const: eventually + then: + required: [ after ] + else: + not: + required: [ after ] processResult: type: object title: ProcessResult @@ -1658,4 +1688,4 @@ $defs: $ref: '#/$defs/runtimeExpression' title: AsyncApiMessageConsumptionPolicyUntil description: A runtime expression evaluated before each consumed (filtered) message to decide if message consumption should continue. - required: [ until ] \ No newline at end of file + required: [ until ]