Skip to content

Commit

Permalink
Merge pull request #1049 from neuroglia-io/feat-container-lifetime
Browse files Browse the repository at this point in the history
Add a new `lifetime` property to the `container` process
  • Loading branch information
cdavernas authored Jan 9, 2025
2 parents 8eebe90 + 3829876 commit 897019c
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 3 deletions.
19 changes: 17 additions & 2 deletions dsl-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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.<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`.* |
| 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.* |
### Process Result

Describes the result of a process.
Expand All @@ -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:
Expand Down
12 changes: 12 additions & 0 deletions examples/run-container-cleanup-always.yaml
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions examples/run-container-cleanup-eventually.yaml
Original file line number Diff line number Diff line change
@@ -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
32 changes: 31 additions & 1 deletion schema/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 ]
required: [ until ]

0 comments on commit 897019c

Please sign in to comment.