Recoverable tasks [version 1]

Signed-off-by: Bogdan Nechyporenko <bnechyporenko@bol.com>
Signed-off-by: bnechyporenko <bnechyporenko@bol.com>
This commit is contained in:
bnechyporenko
2024-01-14 16:18:42 +01:00
parent 56d3373c82
commit 11b9a08e92
31 changed files with 473 additions and 62 deletions
+15
View File
@@ -16,12 +16,21 @@ export const isTemplateEntityV1beta3: (
entity: Entity,
) => entity is TemplateEntityV1beta3;
// @public
export type TaskRecoverStrategy = 'none' | 'startOver';
// @public
export interface TaskRecovery {
EXPERIMENTAL_strategy?: TaskRecoverStrategy;
}
// @public
export type TaskSpec = TaskSpecV1beta3;
// @public
export interface TaskSpecV1beta3 {
apiVersion: 'scaffolder.backstage.io/v1beta3';
EXPERIMENTAL_recovery?: TaskRecovery;
output: {
[name: string]: JsonValue;
};
@@ -67,6 +76,7 @@ export interface TemplateEntityV1beta3 extends Entity {
spec: {
type: string;
presentation?: TemplatePresentationV1beta3;
EXPERIMENTAL_recovery?: TemplateRecoveryV1beta3;
parameters?: TemplateParametersV1beta3 | TemplateParametersV1beta3[];
steps: Array<TemplateEntityStepV1beta3>;
output?: {
@@ -108,4 +118,9 @@ export interface TemplatePresentationV1beta3 extends JsonObject {
reviewButtonText?: string;
};
}
// @public
export interface TemplateRecoveryV1beta3 extends JsonObject {
EXPERIMENTAL_strategy?: 'none' | 'startOver';
}
```
+28
View File
@@ -44,6 +44,30 @@ export type TemplateInfo = {
};
};
/**
*
* none - not recover, let the task be marked as failed
* startOver - do recover, start the execution of the task from the first step.
*
* @public
*/
export type TaskRecoverStrategy = 'none' | 'startOver';
/**
* When task didn't have a chance to complete due to system restart you can define the strategy what to do with such tasks,
* by defining a strategy.
*
* By default, it is none, what means to not recover but updating the status from 'processing' to 'failed'.
*
* @public
*/
export interface TaskRecovery {
/**
* Depends on how you designed your task you might tailor the behaviour for each of them.
*/
EXPERIMENTAL_strategy?: TaskRecoverStrategy;
}
/**
* An individual step of a scaffolder task, as stored in the database.
*
@@ -119,6 +143,10 @@ export interface TaskSpecV1beta3 {
*/
ref?: string;
};
/**
* How to recover the task after system restart or system crash.
*/
EXPERIMENTAL_recovery?: TaskRecovery;
}
/**
@@ -139,6 +139,16 @@
}
]
},
"EXPERIMENTAL_recovery": {
"type": "object",
"description": "A task recovery section.",
"properties": {
"EXPERIMENTAL_strategy": {
"type": "string",
"description": "Recovery strategy for your task (none or startOver). By default none"
}
}
},
"steps": {
"type": "array",
"description": "A list of steps to execute.",
@@ -51,6 +51,11 @@ export interface TemplateEntityV1beta3 extends Entity {
*/
presentation?: TemplatePresentationV1beta3;
/**
* Recovery strategy for the template
*/
EXPERIMENTAL_recovery?: TemplateRecoveryV1beta3;
/**
* This is a JSONSchema or an array of JSONSchema's which is used to render a form in the frontend
* to collect user input and validate it against that schema. This can then be used in the `steps` part below to template
@@ -73,6 +78,22 @@ export interface TemplateEntityV1beta3 extends Entity {
};
}
/**
* Depends on how you designed your task you might tailor the behaviour for each of them.
*
* @public
*/
export interface TemplateRecoveryV1beta3 extends JsonObject {
/**
*
* none - not recover, let the task be marked as failed
* startOver - do recover, start the execution of the task from the first step.
*
* @public
*/
EXPERIMENTAL_strategy?: 'none' | 'startOver';
}
/**
* The presentation of the template.
*
+1
View File
@@ -32,4 +32,5 @@ export type {
TemplateEntityStepV1beta3,
TemplateParametersV1beta3,
TemplatePermissionsV1beta3,
TemplateRecoveryV1beta3,
} from './TemplateEntityV1beta3';