instance_id
stringlengths
17
39
repo
stringclasses
8 values
issue_id
stringlengths
14
34
pr_id
stringlengths
14
34
linking_methods
sequencelengths
1
3
base_commit
stringlengths
40
40
merge_commit
stringlengths
0
40
hints_text
sequencelengths
0
106
resolved_comments
sequencelengths
0
119
created_at
unknown
labeled_as
sequencelengths
0
7
problem_title
stringlengths
7
174
problem_statement
stringlengths
0
55.4k
gold_files
sequencelengths
0
10
gold_files_postpatch
sequencelengths
1
10
test_files
sequencelengths
0
60
gold_patch
stringlengths
220
5.83M
test_patch
stringlengths
386
194k
split_random
stringclasses
3 values
split_time
stringclasses
3 values
issue_start_time
timestamp[ns]
issue_created_at
unknown
issue_by_user
stringlengths
3
21
split_repo
stringclasses
3 values
kestra-io/kestra/1578_1651
kestra-io/kestra
kestra-io/kestra/1578
kestra-io/kestra/1651
[ "keyword_pr_to_issue" ]
b5277ecd1d8817ed246754150b5cb7d424fe1840
16fe7a2f07c2500c6e66cb6559089128f5fec9ea
[ "Can't reproduce, if anyone else manage to feel free to take it", "nvm" ]
[]
"2023-06-28T02:53:34Z"
[ "bug" ]
Unsaved popup even If I just save the content
ERROR: type should be string, got "\r\nhttps://github.com/kestra-io/kestra/assets/2064609/6f94a6ce-1c65-4381-83bf-6eaf13409ae4\r\n\r\n- type somethings\r\n- hit ctrl + s\r\n- hit f5 \r\n- say the unsaved popup "
[ "ui/src/components/inputs/EditorView.vue" ]
[ "ui/src/components/inputs/EditorView.vue" ]
[]
diff --git a/ui/src/components/inputs/EditorView.vue b/ui/src/components/inputs/EditorView.vue index 154d512425..8e02695b55 100644 --- a/ui/src/components/inputs/EditorView.vue +++ b/ui/src/components/inputs/EditorView.vue @@ -341,6 +341,7 @@ flowYaml.value = event; haveChange.value = true; store.dispatch("core/isUnsaved", true); + clearTimeout(timer.value) return store.dispatch("flow/validateFlow", {flow: event}) .then(value => { if (flowHaveTasks() && ["topology", "source-topology"].includes(viewType.value)) { @@ -412,7 +413,6 @@ onEdit(YamlUtils.insertError(source, newError.value)); newError.value = null; isNewErrorOpen.value = false; - haveChange.value = true; } const getFlowMetadata = () => {
null
val
train
2023-06-28T12:23:08
"2023-06-21T15:42:49Z"
tchiotludo
train
kestra-io/kestra/1645_1653
kestra-io/kestra
kestra-io/kestra/1645
kestra-io/kestra/1653
[ "keyword_pr_to_issue" ]
0d4ce281f8372abe5727a40ad52d87e2fb3736ba
6132c8a19ac2b55cc9a8d7a2484534ebc58242a0
[]
[]
"2023-06-28T09:16:50Z"
[ "bug", "enhancement" ]
Documentation in editor view doesn't show up if no line below cursor position
### Expected Behavior When there is no new line below the cursor position, the task documentation doesn't show up as it should ### Actual Behaviour ![image](https://github.com/kestra-io/kestra/assets/46634684/07ce1957-4a9c-42df-a6d7-6db8800a9f6b) ### Steps To Reproduce _No response_ ### Environment Information - Kestra Version: - Operating System (OS / Docker / Kubernetes): - Java Version (If not docker): ### Example flow _No response_
[ "ui/src/utils/yamlUtils.js" ]
[ "ui/src/utils/yamlUtils.js" ]
[]
diff --git a/ui/src/utils/yamlUtils.js b/ui/src/utils/yamlUtils.js index cfc91337d7..67d6cbdbce 100644 --- a/ui/src/utils/yamlUtils.js +++ b/ui/src/utils/yamlUtils.js @@ -161,41 +161,42 @@ export default class YamlUtils { return index === -1 ? Number.MAX_SAFE_INTEGER : index; } - static getTaskType(source, position) { - const lineCounter = new LineCounter(); - const yamlDoc = yaml.parseDocument(source, {lineCounter}); + static extractAllTypes(source) { + const yamlDoc = yaml.parseDocument(source); + const types = []; if (yamlDoc.contents && yamlDoc.contents.items && yamlDoc.contents.items.find(e => ["tasks", "triggers", "errors"].includes(e.key.value))) { - const cursorIndex = lineCounter.lineStarts[position.lineNumber - 1] + position.column; - if (yamlDoc.contents) { - for (const item of yamlDoc.contents.items) { - if (item.value instanceof YAMLSeq && item.key.range[0] <= cursorIndex && item.value.range[1] >= cursorIndex) { - return YamlUtils._getTaskType(item.value, cursorIndex, null) + yaml.visit(yamlDoc, { + Map(_, map) { + if (map.items) { + for (const item of map.items) { + if (item.key.value === "type") { + const type = item.value?.value; + types.push({type, range: map.range}); + } + } } } - } + }) } - return null; + return types; } - static _getTaskType(element, cursorIndex, previousTaskType) { - let taskType = previousTaskType - for (const item of element.items) { - // Every -1 & +1 allows catching cursor - // that is just behind or just after a task - if (item instanceof Pair) { - if (item.key.value === "type" && element.range[0]-1 <= cursorIndex && element.range[1]+1 >= cursorIndex) { - taskType = item.value.value - } - if ((item.value instanceof YAMLSeq || item.value instanceof YAMLMap) && item.value.range[0]-1 <= cursorIndex && item.value.range[1]+1 >= cursorIndex) { - taskType = this._getTaskType(item.value, cursorIndex, taskType) - } - } else if (item.range[0]-1 <= cursorIndex && item.range[1]+1 >= cursorIndex) { - if (item.items instanceof Array) { - taskType = this._getTaskType(item, cursorIndex) - } + static getTaskType(source, position) { + const types = this.extractAllTypes(source) + + const lineCounter = new LineCounter(); + yaml.parseDocument(source, {lineCounter}); + const cursorIndex = lineCounter.lineStarts[position.lineNumber - 1] + position.column; + + for(const type of types.reverse()) { + if (cursorIndex > type.range[1]) { + return type.type; + } + if (cursorIndex >= type.range[0] && cursorIndex <= type.range[1]) { + return type.type; } } - return taskType + return null; } static swapTasks(source, taskId1, taskId2) {
null
train
train
2023-06-28T16:22:30
"2023-06-27T15:36:51Z"
Ben8t
train
kestra-io/kestra/1310_1655
kestra-io/kestra
kestra-io/kestra/1310
kestra-io/kestra/1655
[ "keyword_pr_to_issue" ]
ba1eaa309ce37fd91cd53b17a60d9639d16f148d
0d4ce281f8372abe5727a40ad52d87e2fb3736ba
[ "What do you expect ? @Skraye ", "Does not looks natural to me.\r\nWhat do you think @Nico-Kestra ?", "https://www.figma.com/file/4tLhsoCsh9yVzYRY1N70kS/App-Kestra?type=design&node-id=1100%3A7303&t=oTbZMn2N0k2MDyDk-1\r\n\r\nI think it's important to provide context for why Kestra triggers this pop-up. This text needs to be revised @Ben8t an idea?\r\n\r\nAlso, having checkboxes under the label with nothing next to them looks really ugly, so I suggest placing them next to the label.\r\n", "\"Complete the following inputs to run the flow:\" 🤔 \r\n@anna-geller for a better english formulation ?" ]
[]
"2023-06-28T14:02:09Z"
[ "bug" ]
Boolean inputs not displayed correctly
### Expected Behavior _No response_ ### Actual Behaviour ![image](https://github.com/kestra-io/kestra/assets/37600690/3013e7f4-5467-4deb-8f2a-88ce1e696070) ### Steps To Reproduce _No response_ ### Environment Information - Kestra Version: 0.8.1 ### Example flow _No response_
[ "ui/src/components/flows/FlowRun.vue" ]
[ "ui/src/components/flows/FlowRun.vue" ]
[]
diff --git a/ui/src/components/flows/FlowRun.vue b/ui/src/components/flows/FlowRun.vue index ff230ed36a..726a8fa656 100644 --- a/ui/src/components/flows/FlowRun.vue +++ b/ui/src/components/flows/FlowRun.vue @@ -9,7 +9,7 @@ <el-form-item v-for="input in flow.inputs || []" :key="input.id" - :label="input.name" + :label="input.type === 'BOOLEAN' ? undefined : input.name" :required="input.required !== false" :prop="input.name" > @@ -30,11 +30,12 @@ v-model="inputs[input.name]" :step="0.001" /> - <el-checkbox + <el-switch v-if="input.type === 'BOOLEAN'" v-model="inputs[input.name]" - value="true" - unchecked-value="false" + active-value="true" + :active-text="input.name" + inactive-value="false" /> <el-date-picker v-if="input.type === 'DATETIME'" @@ -300,25 +301,28 @@ </script> <style scoped lang="scss"> -.bottom-buttons { - margin-top: 36px; - display: flex; + .bottom-buttons { + margin-top: 36px; + display: flex; - > * { - flex: 1; + > * { + flex: 1; - * { - margin: 0; + * { + margin: 0; + } } - } - .left-align :deep(div) { - flex-direction: row - } + .left-align :deep(div) { + flex-direction: row + } - .right-align :deep(div) { - flex-direction: row-reverse; + .right-align :deep(div) { + flex-direction: row-reverse; + } } -} + :deep(.el-switch__label) { + color: var(--el-text-color-regular); + } </style> \ No newline at end of file
null
train
train
2023-06-28T15:29:43
"2023-05-16T08:09:57Z"
Skraye
train
kestra-io/kestra/1405_1662
kestra-io/kestra
kestra-io/kestra/1405
kestra-io/kestra/1662
[ "keyword_pr_to_issue" ]
ce87fcedad47f4f4807381ba8bfed56e3e977bdb
97fbc93655fc333232b2c9b1947b97c431cf84f9
[ "Another suggestion would be to have a more explicit \"with-text\" button either fixed at top or bottom (without it taking too much space) because this functionnality is way too hidden imo. Also, it shouldn't appear as a button ?", "Proper design/solution in Figma\n\nhttps://www.figma.com/file/4tLhsoCsh9yVzYRY1N70kS/App-Kestra?type=design&node-id=147%3A784&t=zy4kqMTgQpMqckZe-1" ]
[ "```suggestion\r\n <el-header>\r\n <AlertCircle class=\"align-middle text-danger\" />\r\n <span class=\"align-middle\">\r\n {{ $t(\"error detected\") }}\r\n </span>\r\n </el-header>\r\n```" ]
"2023-06-29T09:19:43Z"
[ "enhancement", "frontend" ]
Highlight/Move Flow syntax error/validation icon
### Feature description The icon indicating flow syntax error/validation is a bit hided and could be closer to the actual editor or highlight messages in a better way. One idea is to move this icon to the left side (close to the unfold/fold arrows) but then it won't appear in full topology view ![image](https://github.com/kestra-io/kestra/assets/46634684/0449f660-b37d-4266-8acb-d6225ff8634f)
[ "ui/src/components/flows/ValidationError.vue", "ui/src/components/inputs/Editor.vue", "ui/src/components/inputs/EditorView.vue", "ui/src/components/inputs/LowCodeEditor.vue", "ui/src/components/inputs/SwitchView.vue", "ui/src/styles/layout/element-plus-overload.scss", "ui/src/translations.json" ]
[ "ui/src/components/flows/ValidationError.vue", "ui/src/components/inputs/Editor.vue", "ui/src/components/inputs/EditorView.vue", "ui/src/components/inputs/LowCodeEditor.vue", "ui/src/components/inputs/SwitchView.vue", "ui/src/styles/layout/element-plus-overload.scss", "ui/src/translations.json" ]
[]
diff --git a/ui/src/components/flows/ValidationError.vue b/ui/src/components/flows/ValidationError.vue index 91efd35cfc..6073d6c1d2 100644 --- a/ui/src/components/flows/ValidationError.vue +++ b/ui/src/components/flows/ValidationError.vue @@ -1,21 +1,31 @@ <template> - <el-tooltip :disabled="!error" raw-content transition="" :hide-after="0" :persistent="false"> + <el-tooltip popper-class="p-0 bg-transparent" :placement="tooltipPlacement" :show-arrow="false" :disabled="!error" raw-content transition="" :persistent="false"> <template #content> - <pre>{{ error }}</pre> + <el-container class="error-tooltip"> + <el-header> + <AlertCircle class="align-middle text-danger" /> + <span class="align-middle"> + {{ $t("error detected") }} + </span> + </el-header> + <el-main>{{ error }}</el-main> + </el-container> </template> - <el-button :link="link" type="default"> - <component :class="'text-' + (error ? 'danger' : 'success')" :is="error ? CloseCircleOutline : CheckCircleOutline" /> + <el-button v-bind="$attrs" :link="link" :size="size" type="default"> + <component :class="'text-' + (error ? 'danger' : 'success')" :is="error ? AlertCircle : CheckCircle" /> + <span v-if="error" class="text-danger">{{ $t("error detected") }}</span> </el-button> </el-tooltip> </template> <script setup> - import CheckCircleOutline from "vue-material-design-icons/CheckCircleOutline.vue"; - import CloseCircleOutline from "vue-material-design-icons/CloseCircleOutline.vue"; + import CheckCircle from "vue-material-design-icons/CheckCircle.vue"; + import AlertCircle from "vue-material-design-icons/AlertCircle.vue"; </script> <script> export default { + inheritAttrs: false, props: { error: { type: String, @@ -25,26 +35,94 @@ type: Boolean, default: false }, + size: { + type: String, + default: "default" + }, + tooltipPlacement: { + type: String, + default: undefined + } }, }; </script> -<style lang="scss" scoped> - pre { - margin-bottom: 0; - max-width: 40vw; - white-space: pre-wrap; - background: transparent; - color: var(--bs-gray-100); - html.dark & { - color: var(--bs-gray-900); +<style scoped lang="scss"> + @import "../../styles/variable"; + + .el-button.el-button--default { + transition: none; + + &.el-button--small { + padding: 5px; + height: fit-content; + } + + &:hover, &:focus { + background-color: var(--el-button-bg-color); + } + + &:has(.material-design-icon.text-success) { + border-color: rgb(var(--bs-success-rgb)); + } + &:has(.material-design-icon.text-danger) { + border-color: rgb(var(--bs-danger-rgb)); + + span.text-danger:not(.material-design-icon) { + margin-left: calc(var(--spacer) / 2); + font-size: $font-size-sm; + } } - padding: 0; } - .el-button.el-button--default { - background-color: var(--bs-body-bg); + .error-tooltip { + padding: 0; + width: fit-content; + min-width: 20vw; + max-width: 50vw; + border-radius: $border-radius-lg; + color: $black; + + html.dark & { + color: white; + } + + > * { + height: fit-content; + margin: 0; + } + + .el-header { + padding: $spacer; + background-color: var(--bs-gray-200); + border-bottom: 1px solid var(--bs-gray-300); + border-radius: $border-radius-lg $border-radius-lg 0 0; + font-size: $font-size-sm; + font-weight: $font-weight-bold; + + html.dark & { + background-color: var(--bs-gray-500); + border-bottom: 1px solid var(--bs-gray-600); + } + + .material-design-icon { + font-size: 1.5rem; + margin-right: calc(var(--spacer) / 2); + } + } + + .el-main { + padding: calc(2 * var(--spacer)) $spacer !important; + border-radius: 0 0 $border-radius-lg $border-radius-lg; + font-family: $font-family-monospace; + background-color: white; + + html.dark & { + color: white; + background-color: var(--bs-gray-400); + } + } } </style> \ No newline at end of file diff --git a/ui/src/components/inputs/Editor.vue b/ui/src/components/inputs/Editor.vue index f5047edd5c..d16d6cc50d 100644 --- a/ui/src/components/inputs/Editor.vue +++ b/ui/src/components/inputs/Editor.vue @@ -20,6 +20,7 @@ <el-button :icon="icon.Help" @click="restartGuidedTour" size="small" /> </el-tooltip> </el-button-group> + <slot name="extends-navbar"/> </div> </slot> </nav> diff --git a/ui/src/components/inputs/EditorView.vue b/ui/src/components/inputs/EditorView.vue index 154d512425..d113955b43 100644 --- a/ui/src/components/inputs/EditorView.vue +++ b/ui/src/components/inputs/EditorView.vue @@ -619,7 +619,11 @@ @cursor="updatePluginDocumentation($event)" :creating="isCreating" @restartGuidedTour="() => persistViewType('source')" - /> + > + <template #extends-navbar> + <ValidationError tooltip-placement="bottom-start" size="small" class="ms-2" :error="flowError" /> + </template> + </editor> <div class="slider" @mousedown="dragEditor" v-if="combinedEditor" /> <Blueprints :class="{'d-none': viewType !== 'source-blueprints'}" embed class="combined-right-view enhance-readability" :top-navbar="false" prevent-route-info /> <div @@ -639,7 +643,11 @@ :source="flowYaml" :is-allowed-edit="isAllowedEdit()" :view-type="viewType" - /> + > + <template #top-bar v-if="viewType === 'topology'"> + <ValidationError tooltip-placement="bottom-start" size="small" class="ms-2" :error="flowError" /> + </template> + </LowCodeEditor> </div> <PluginDocumentation v-if="viewType === 'source-doc'" diff --git a/ui/src/components/inputs/LowCodeEditor.vue b/ui/src/components/inputs/LowCodeEditor.vue index c54b03ebd5..8d0a33cb95 100644 --- a/ui/src/components/inputs/LowCodeEditor.vue +++ b/ui/src/components/inputs/LowCodeEditor.vue @@ -540,6 +540,7 @@ <template> <div ref="vueFlow" class="vueflow"> + <slot name="top-bar"/> <VueFlow v-model="elements" :default-marker-color="cssVariable('--bs-cyan')" diff --git a/ui/src/components/inputs/SwitchView.vue b/ui/src/components/inputs/SwitchView.vue index 67635946b4..6ec5b5c18a 100644 --- a/ui/src/components/inputs/SwitchView.vue +++ b/ui/src/components/inputs/SwitchView.vue @@ -1,6 +1,5 @@ <template> <el-button-group size="small"> - <ValidationError :error="flowError" /> <el-tooltip :content="$t('source')" transition="" :hide-after="0" :persistent="false"> <el-button :type="buttonType('source')" @click="switchView('source')" :icon="FileDocumentEdit" /> </el-tooltip> @@ -28,7 +27,6 @@ </script> <script> - import {mapGetters} from "vuex"; import ValidationError from "../flows/ValidationError.vue"; export default { @@ -39,9 +37,6 @@ type: String } }, - computed: { - ...mapGetters("flow", ["flowError"]), - }, methods: { switchView(view) { this.$emit("switch-view", view) diff --git a/ui/src/styles/layout/element-plus-overload.scss b/ui/src/styles/layout/element-plus-overload.scss index 9f2e570e2d..ccffe73f9f 100644 --- a/ui/src/styles/layout/element-plus-overload.scss +++ b/ui/src/styles/layout/element-plus-overload.scss @@ -393,6 +393,8 @@ form.ks-horizontal { // popper .el-popper { + border-radius: $border-radius-lg; + &.is-light { border: 1px solid var(--bs-border-color); diff --git a/ui/src/translations.json b/ui/src/translations.json index dcf29e2661..5e08e2fe1a 100644 --- a/ui/src/translations.json +++ b/ui/src/translations.json @@ -454,7 +454,8 @@ "expand all": "Expand all", "collapse all": "Collapse all", "log expand setting": "Log default display", - "slack support": "Ask help on our Slack" + "slack support": "Ask help on our Slack", + "error detected": "Error detected" }, "fr": { "id": "Identifiant", @@ -913,6 +914,7 @@ "expand all": "Afficher tout", "collapse all": "Masquer tout", "log expand setting": "Affichage par défaut des journaux", - "slack support": "Demandez de l'aide sur notre Slack" + "slack support": "Demandez de l'aide sur notre Slack", + "error detected": "Erreur détectée" } }
null
val
train
2023-06-29T14:38:48
"2023-05-25T09:59:40Z"
Ben8t
train
kestra-io/kestra/1462_1666
kestra-io/kestra
kestra-io/kestra/1462
kestra-io/kestra/1666
[ "keyword_pr_to_issue" ]
aeab342363e880f7b3f6455fed4497214376abb1
6a006efb34124c5310d1ce01eb0cb28a4315149d
[]
[]
"2023-06-29T12:49:09Z"
[]
Set delete to false for the deploy action and `flow namespace update` CLI
### Feature description Deleting flows by default is too dangerous, it should be set to false by default I could submit a PR to just set this to true by default here: https://github.com/kestra-io/kestra/blob/c2822aeea118473ddbeace8919f50e4fbbc802f7/cli/src/main/java/io/kestra/cli/commands/AbstractServiceNamespaceUpdateCommand.java#L16 but @tchiotludo mentioned it's cleaner to rewrite this to have "delete=false" (I agree) the action needs to be adjusted as well https://github.com/kestra-io/deploy-action
[ "cli/src/main/java/io/kestra/cli/commands/AbstractServiceNamespaceUpdateCommand.java", "cli/src/main/java/io/kestra/cli/commands/flows/namespaces/FlowNamespaceUpdateCommand.java", "cli/src/main/java/io/kestra/cli/commands/templates/namespaces/TemplateNamespaceUpdateCommand.java" ]
[ "cli/src/main/java/io/kestra/cli/commands/AbstractServiceNamespaceUpdateCommand.java", "cli/src/main/java/io/kestra/cli/commands/flows/namespaces/FlowNamespaceUpdateCommand.java", "cli/src/main/java/io/kestra/cli/commands/templates/namespaces/TemplateNamespaceUpdateCommand.java" ]
[ "cli/src/test/java/io/kestra/cli/commands/flows/namespaces/FlowNamespaceUpdateCommandTest.java" ]
diff --git a/cli/src/main/java/io/kestra/cli/commands/AbstractServiceNamespaceUpdateCommand.java b/cli/src/main/java/io/kestra/cli/commands/AbstractServiceNamespaceUpdateCommand.java index 3964e7efec..4337888f76 100644 --- a/cli/src/main/java/io/kestra/cli/commands/AbstractServiceNamespaceUpdateCommand.java +++ b/cli/src/main/java/io/kestra/cli/commands/AbstractServiceNamespaceUpdateCommand.java @@ -14,8 +14,8 @@ public abstract class AbstractServiceNamespaceUpdateCommand extends AbstractApiC @CommandLine.Parameters(index = "1", description = "the directory containing files for current namespace") public Path directory; - @CommandLine.Option(names = {"--no-delete"}, description = "if missing should not be deleted") - public boolean noDelete = false ; + @CommandLine.Option(names = {"--delete"}, negatable = true, description = "if missing should be deleted") + public boolean delete = false; @Builder @Value diff --git a/cli/src/main/java/io/kestra/cli/commands/flows/namespaces/FlowNamespaceUpdateCommand.java b/cli/src/main/java/io/kestra/cli/commands/flows/namespaces/FlowNamespaceUpdateCommand.java index 410c3f19cb..a8dfd0a5fe 100644 --- a/cli/src/main/java/io/kestra/cli/commands/flows/namespaces/FlowNamespaceUpdateCommand.java +++ b/cli/src/main/java/io/kestra/cli/commands/flows/namespaces/FlowNamespaceUpdateCommand.java @@ -57,7 +57,7 @@ public Integer call() throws Exception { } try(DefaultHttpClient client = client()) { MutableHttpRequest<String> request = HttpRequest - .POST("/api/v1/flows/" + namespace + "?delete=" + !noDelete, body).contentType(MediaType.APPLICATION_YAML); + .POST("/api/v1/flows/" + namespace + "?delete=" + delete, body).contentType(MediaType.APPLICATION_YAML); List<UpdateResult> updated = client.toBlocking().retrieve( this.requestOptions(request), diff --git a/cli/src/main/java/io/kestra/cli/commands/templates/namespaces/TemplateNamespaceUpdateCommand.java b/cli/src/main/java/io/kestra/cli/commands/templates/namespaces/TemplateNamespaceUpdateCommand.java index 19e4777b50..a5c9126323 100644 --- a/cli/src/main/java/io/kestra/cli/commands/templates/namespaces/TemplateNamespaceUpdateCommand.java +++ b/cli/src/main/java/io/kestra/cli/commands/templates/namespaces/TemplateNamespaceUpdateCommand.java @@ -45,7 +45,7 @@ public Integer call() throws Exception { try (DefaultHttpClient client = client()) { MutableHttpRequest<List<Template>> request = HttpRequest - .POST("/api/v1/templates/" + namespace + "?delete=" + !noDelete, templates); + .POST("/api/v1/templates/" + namespace + "?delete=" + delete, templates); List<UpdateResult> updated = client.toBlocking().retrieve( this.requestOptions(request),
diff --git a/cli/src/test/java/io/kestra/cli/commands/flows/namespaces/FlowNamespaceUpdateCommandTest.java b/cli/src/test/java/io/kestra/cli/commands/flows/namespaces/FlowNamespaceUpdateCommandTest.java index 24f9327192..3437a90dc1 100644 --- a/cli/src/test/java/io/kestra/cli/commands/flows/namespaces/FlowNamespaceUpdateCommandTest.java +++ b/cli/src/test/java/io/kestra/cli/commands/flows/namespaces/FlowNamespaceUpdateCommandTest.java @@ -16,10 +16,11 @@ class FlowNamespaceUpdateCommandTest { @Test - void run() { + void runWithDelete() { URL directory = FlowNamespaceUpdateCommandTest.class.getClassLoader().getResource("flows"); ByteArrayOutputStream out = new ByteArrayOutputStream(); System.setOut(new PrintStream(out)); + URL subDirectory = FlowNamespaceUpdateCommandTest.class.getClassLoader().getResource("flows/flowsSubFolder"); try (ApplicationContext ctx = ApplicationContext.run(Environment.CLI, Environment.TEST)) { @@ -31,12 +32,28 @@ void run() { embeddedServer.getURL().toString(), "--user", "myuser:pass:word", + "--delete", "io.kestra.cli", directory.getPath(), + }; + PicocliRunner.call(FlowNamespaceUpdateCommand.class, ctx, args); + + assertThat(out.toString(), containsString("3 flow(s)")); + out.reset(); + + args = new String[]{ + "--server", + embeddedServer.getURL().toString(), + "--user", + "myuser:pass:word", + "--delete", + "io.kestra.cli", + subDirectory.getPath(), }; PicocliRunner.call(FlowNamespaceUpdateCommand.class, ctx, args); + // 2 delete + 1 update assertThat(out.toString(), containsString("3 flow(s)")); } } @@ -94,17 +111,32 @@ void runNoDelete() { PicocliRunner.call(FlowNamespaceUpdateCommand.class, ctx, args); assertThat(out.toString(), containsString("3 flow(s)")); + out.reset(); - String[] newArgs = { + // no "delete" arg should behave as no-delete + args = new String[]{ "--server", embeddedServer.getURL().toString(), "--user", "myuser:pass:word", "io.kestra.cli", - subDirectory.getPath(), - "--no-delete" + subDirectory.getPath() + }; + PicocliRunner.call(FlowNamespaceUpdateCommand.class, ctx, args); + + assertThat(out.toString(), containsString("1 flow(s)")); + out.reset(); + + args = new String[]{ + "--server", + embeddedServer.getURL().toString(), + "--user", + "myuser:pass:word", + "--no-delete", + "io.kestra.cli", + subDirectory.getPath() }; - PicocliRunner.call(FlowNamespaceUpdateCommand.class, ctx, newArgs); + PicocliRunner.call(FlowNamespaceUpdateCommand.class, ctx, args); assertThat(out.toString(), containsString("1 flow(s)")); }
train
train
2023-06-30T09:51:58
"2023-06-06T11:05:29Z"
anna-geller
train
kestra-io/kestra/1636_1667
kestra-io/kestra
kestra-io/kestra/1636
kestra-io/kestra/1667
[ "keyword_pr_to_issue" ]
87b7912607857c15b22b707a582bed25c0566dea
9367ef374dad02ee894aeeaa601ce475c9056927
[]
[]
"2023-06-29T17:18:25Z"
[ "bug" ]
Blueprint filter
### Expected Behavior Displaying filters/tags : - A tag should not be displayed if it has no blueprints. - When you do a search, you need to refresh the filter display. <img width="1782" alt="Capture d’écran 2023-06-27 à 12 42 44" src="https://github.com/kestra-io/kestra/assets/125994028/c9bb39a2-8da1-4030-9689-a96c6856b73a"> Thanks ### Actual Behaviour _No response_ ### Steps To Reproduce _No response_ ### Environment Information - Kestra Version: - Operating System (OS / Docker / Kubernetes): - Java Version (If not docker): ### Example flow _No response_
[ "ui/src/override/components/flows/blueprints/BlueprintsBrowser.vue", "webserver/src/main/java/io/kestra/webserver/controllers/BlueprintController.java" ]
[ "ui/src/override/components/flows/blueprints/BlueprintsBrowser.vue", "webserver/src/main/java/io/kestra/webserver/controllers/BlueprintController.java" ]
[ "webserver/src/test/java/io/kestra/webserver/controllers/BlueprintControllerTest.java" ]
diff --git a/ui/src/override/components/flows/blueprints/BlueprintsBrowser.vue b/ui/src/override/components/flows/blueprints/BlueprintsBrowser.vue index 5be2060bdd..a5b0caaa9d 100644 --- a/ui/src/override/components/flows/blueprints/BlueprintsBrowser.vue +++ b/ui/src/override/components/flows/blueprints/BlueprintsBrowser.vue @@ -122,8 +122,15 @@ } }, loadTags(beforeLoadBlueprintBaseUri) { + const query = {} + if (this.$route.query.q || this.q) { + query.q = this.$route.query.q || this.q; + } + return this.$http - .get(beforeLoadBlueprintBaseUri + "/tags") + .get(beforeLoadBlueprintBaseUri + "/tags", { + params: query + }) .then(response => { // Handle switch tab while fetching data if (this.blueprintBaseUri === beforeLoadBlueprintBaseUri) { @@ -169,12 +176,7 @@ const beforeLoadBlueprintBaseUri = this.blueprintBaseUri; Promise.all([ - new Promise(async (resolve) => { - if (this.tags === undefined) { - await this.loadTags(beforeLoadBlueprintBaseUri); - } - resolve(); - }), + this.loadTags(beforeLoadBlueprintBaseUri), this.loadBlueprints(beforeLoadBlueprintBaseUri) ]).finally(() => { // Handle switch tab while fetching data @@ -186,7 +188,6 @@ hardReload() { this.ready = false; this.selectedTag = 0; - this.tags = undefined; this.load(this.onDataLoaded); } }, @@ -223,6 +224,11 @@ }, blueprintBaseUri() { this.hardReload(); + }, + tags() { + if(!this.tags.hasOwnProperty(this.selectedTag)) { + this.selectedTag = 0; + } } } }; diff --git a/webserver/src/main/java/io/kestra/webserver/controllers/BlueprintController.java b/webserver/src/main/java/io/kestra/webserver/controllers/BlueprintController.java index b4bb57b6c3..fc925e8839 100644 --- a/webserver/src/main/java/io/kestra/webserver/controllers/BlueprintController.java +++ b/webserver/src/main/java/io/kestra/webserver/controllers/BlueprintController.java @@ -1,7 +1,6 @@ package io.kestra.webserver.controllers; import com.fasterxml.jackson.annotation.JsonInclude; -import io.kestra.core.models.hierarchies.FlowGraph; import io.kestra.webserver.responses.PagedResults; import io.micronaut.core.annotation.Introspected; import io.micronaut.core.annotation.Nullable; @@ -85,8 +84,9 @@ public BlueprintItemWithFlow blueprint( @SuppressWarnings("unchecked") @ExecuteOn(TaskExecutors.IO) @Get("tags") - @Operation(tags = {"Blueprint Tags"}, summary = "List all blueprint tags") + @Operation(tags = {"Blueprint Tags"}, summary = "List blueprint tags matching the filter") public List<BlueprintTagItem> blueprintTags( + @Parameter(description = "A string filter to get tags with matching blueprints only") @Nullable @QueryValue(value = "q") Optional<String> q, HttpRequest<?> httpRequest ) throws URISyntaxException { return fastForwardToKestraApi(httpRequest, "/v1/blueprints/tags", Argument.of(List.class, BlueprintTagItem.class));
diff --git a/webserver/src/test/java/io/kestra/webserver/controllers/BlueprintControllerTest.java b/webserver/src/test/java/io/kestra/webserver/controllers/BlueprintControllerTest.java index d772420214..15740e77eb 100644 --- a/webserver/src/test/java/io/kestra/webserver/controllers/BlueprintControllerTest.java +++ b/webserver/src/test/java/io/kestra/webserver/controllers/BlueprintControllerTest.java @@ -137,7 +137,7 @@ void blueprintTags(WireMockRuntimeInfo wmRuntimeInfo) { ); List<BlueprintController.BlueprintTagItem> blueprintTags = client.toBlocking().retrieve( - HttpRequest.GET("/api/v1/blueprints/community/tags"), + HttpRequest.GET("/api/v1/blueprints/community/tags?q=someQuery"), Argument.of(List.class, BlueprintController.BlueprintTagItem.class) ); @@ -147,6 +147,6 @@ void blueprintTags(WireMockRuntimeInfo wmRuntimeInfo) { assertThat(blueprintTags.get(0).getPublishedAt(), is(Instant.parse("2023-06-01T08:37:10.171Z"))); WireMock wireMock = wmRuntimeInfo.getWireMock(); - wireMock.verifyThat(getRequestedFor(urlEqualTo("/v1/blueprints/tags"))); + wireMock.verifyThat(getRequestedFor(urlEqualTo("/v1/blueprints/tags?q=someQuery"))); } }
train
train
2023-06-30T14:48:36
"2023-06-27T10:45:51Z"
Nico-Kestra
train
kestra-io/kestra/1664_1673
kestra-io/kestra
kestra-io/kestra/1664
kestra-io/kestra/1673
[ "keyword_pr_to_issue" ]
97fbc93655fc333232b2c9b1947b97c431cf84f9
2165f24d9a1314fa3edd51ece1d89304aecf093f
[ "Hello @anna-geller,\r\nWe can use [this icon](https://www.figma.com/file/uUvt0RQ9DWiBTweX6oT4Qp/Library-Icons-Plugins?type=design&node-id=104%3A524&mode=design&t=Cgr0elzcgnzWmL8C-1) for all conditions" ]
[]
"2023-06-30T19:41:13Z"
[ "plugin", "frontend" ]
Add logos to `models.conditions` tasks
### Feature description Blueprints make it more visible that some logos are missing on core tasks such as Conditions: ![image](https://github.com/kestra-io/kestra/assets/86264395/2cc23f31-3c88-4857-8ce6-2bd11986daa1) It would be great to add those. @Nico-Kestra do you have some logo examples in mind that could be used? https://kestra.io/plugins/core/conditions/io.kestra.core.models.conditions.types.executionnamespacecondition
[]
[ "core/src/main/resources/icons/io.kestra.core.models.conditions.types.svg" ]
[]
diff --git a/core/src/main/resources/icons/io.kestra.core.models.conditions.types.svg b/core/src/main/resources/icons/io.kestra.core.models.conditions.types.svg new file mode 100644 index 0000000000..6ce949f35d --- /dev/null +++ b/core/src/main/resources/icons/io.kestra.core.models.conditions.types.svg @@ -0,0 +1,7 @@ +<svg width="81" height="80" viewBox="0 0 81 80" fill="none" xmlns="http://www.w3.org/2000/svg"> +<path fill-rule="evenodd" clip-rule="evenodd" d="M14.4367 13.2937C15.9061 11.8722 17.709 11.4243 19.1061 11.5108H22.1744C23.6741 11.5108 24.8899 12.7265 24.8899 14.2263C24.8899 15.726 23.6741 16.9418 22.1744 16.9418H18.885L18.7632 16.9312C18.7495 16.9317 18.6815 16.9339 18.583 16.9664C18.4757 17.0018 18.3459 17.0684 18.2128 17.1972C17.988 17.4146 17.431 18.1358 17.431 20.1419V59.8581C17.431 61.8641 17.988 62.5853 18.2128 62.8028C18.3459 62.9316 18.4757 62.9982 18.583 63.0335C18.6815 63.066 18.7495 63.0683 18.7632 63.0687L18.885 63.0582H22.1744C23.6741 63.0582 24.8899 64.274 24.8899 65.7737C24.8899 67.2734 23.6741 68.4892 22.1744 68.4892H19.1061C17.709 68.5756 15.9061 68.1277 14.4367 66.7063C12.8735 65.1941 12 62.8932 12 59.8581V20.1419C12 17.1068 12.8735 14.8059 14.4367 13.2937Z" fill="#26282D"/> +<path fill-rule="evenodd" clip-rule="evenodd" d="M66.5633 13.2937C65.0939 11.8722 63.291 11.4243 61.8939 11.5108H58.8256C57.3259 11.5108 56.1101 12.7265 56.1101 14.2263C56.1101 15.726 57.3259 16.9418 58.8256 16.9418H62.115L62.2368 16.9312C62.2505 16.9317 62.3185 16.9339 62.417 16.9664C62.5243 17.0018 62.6541 17.0684 62.7872 17.1972C63.012 17.4146 63.569 18.1358 63.569 20.1419V59.8581C63.569 61.8641 63.012 62.5853 62.7872 62.8028C62.6541 62.9316 62.5243 62.9982 62.417 63.0335C62.3185 63.066 62.2505 63.0683 62.2368 63.0687L62.115 63.0582H58.8256C57.3259 63.0582 56.1101 64.274 56.1101 65.7737C56.1101 67.2734 57.3259 68.4892 58.8256 68.4892H61.8939C63.291 68.5756 65.0939 68.1277 66.5633 66.7063C68.1265 65.1941 69 62.8932 69 59.8581V20.1419C69 17.1068 68.1265 14.8059 66.5633 13.2937Z" fill="#26282D"/> +<path fill-rule="evenodd" clip-rule="evenodd" d="M23.3952 29.0209C23.3952 27.5211 24.611 26.3054 26.1107 26.3054H55.2862C56.786 26.3054 58.0017 27.5211 58.0017 29.0209C58.0017 30.5206 56.786 31.7364 55.2862 31.7364H26.1107C24.611 31.7364 23.3952 30.5206 23.3952 29.0209Z" fill="#26282D"/> +<path fill-rule="evenodd" clip-rule="evenodd" d="M23.3952 40.5151C23.3952 39.0154 24.611 37.7996 26.1107 37.7996H44.9042C46.4039 37.7996 47.6197 39.0154 47.6197 40.5151C47.6197 42.0149 46.4039 43.2306 44.9042 43.2306H26.1107C24.611 43.2306 23.3952 42.0149 23.3952 40.5151Z" fill="#26282D"/> +<path fill-rule="evenodd" clip-rule="evenodd" d="M23.3952 52.133C23.3952 50.6333 24.611 49.4175 26.1107 49.4175H51.8255C53.3253 49.4175 54.541 50.6333 54.541 52.133C54.541 53.6328 53.3253 54.8485 51.8255 54.8485H26.1107C24.611 54.8485 23.3952 53.6328 23.3952 52.133Z" fill="#26282D"/> +</svg>
null
train
train
2023-06-30T20:59:49
"2023-06-29T11:32:20Z"
anna-geller
train
kestra-io/kestra/1587_1674
kestra-io/kestra
kestra-io/kestra/1587
kestra-io/kestra/1674
[ "keyword_pr_to_issue" ]
97fbc93655fc333232b2c9b1947b97c431cf84f9
09c8261eaeae858d1bc4ab06d8ab55e6097c0031
[ "From my POV, I would make declared variable null, because in this example :\r\n* inputs.givenName > Is defined but has no value > `null`\r\n* inputs.notDefined > Is not defined> `undefined`", "as a user, I'd expect that input is set to `null` when `defaults` is not provided ", "relate to #1515, we removed null values in the serialization process, that is, i must admit, one of the worst choice I've made so far :cry: ", "@tchiotludo I think for inputs we can do something as it's an object with name/type/value so we can still serialize the object even when the value is null. There should be null check somewhere that remove inputs with null value.\r\n\r\nInputs with null values are filtered here for ex (there can be multiple places to update): https://github.com/kestra-io/kestra/blob/develop/core/src/main/java/io/kestra/core/runners/RunnerUtils.java#L120" ]
[]
"2023-06-30T21:09:38Z"
[ "backend" ]
Empty inputs are not added to the list of inputs
### Issue description As example, see the followning flow: ```yaml id: trial namespace: iss.trial inputs: - name: givenName type: STRING required: false tasks: - id: if type: io.kestra.core.tasks.flows.If condition: "{{inputs.givenName}}" then: - id: when-true type: io.kestra.core.tasks.log.Log message: 'Condition was true' else: - id: when-false type: io.kestra.core.tasks.log.Log message: 'Condition was false' ``` It didn't work as if the `givenName` input is not set, it will not be added to the list of inputs so the `inputs` variable will be missing (or if other inputs exist, the `inputs.givenName` variable will be missing). To make it work we must use the coalescing operator so the condition becomes: ```yaml condition: "{{inputs.givenName ?? false}}" ``` This can be surprising and more complex than needed. Maybe we can add non-set inputs in the list of inputs with a null value.
[ "core/src/main/java/io/kestra/core/models/executions/Execution.java", "core/src/main/java/io/kestra/core/runners/RunnerUtils.java" ]
[ "core/src/main/java/io/kestra/core/models/executions/Execution.java", "core/src/main/java/io/kestra/core/runners/RunnerUtils.java" ]
[ "core/src/test/java/io/kestra/core/runners/InputsTest.java", "webserver/src/test/java/io/kestra/webserver/controllers/ExecutionControllerTest.java" ]
diff --git a/core/src/main/java/io/kestra/core/models/executions/Execution.java b/core/src/main/java/io/kestra/core/models/executions/Execution.java index fecb1ba777..f1a933a55c 100644 --- a/core/src/main/java/io/kestra/core/models/executions/Execution.java +++ b/core/src/main/java/io/kestra/core/models/executions/Execution.java @@ -4,6 +4,7 @@ import ch.qos.logback.classic.spi.LoggingEvent; import ch.qos.logback.classic.spi.ThrowableProxy; import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Streams; import lombok.Builder; @@ -48,6 +49,7 @@ public class Execution implements DeletedInterface { List<TaskRun> taskRunList; @With + @JsonInclude(JsonInclude.Include.NON_EMPTY) Map<String, Object> inputs; @With diff --git a/core/src/main/java/io/kestra/core/runners/RunnerUtils.java b/core/src/main/java/io/kestra/core/runners/RunnerUtils.java index 521e857edb..1aa9ba91b0 100644 --- a/core/src/main/java/io/kestra/core/runners/RunnerUtils.java +++ b/core/src/main/java/io/kestra/core/runners/RunnerUtils.java @@ -117,7 +117,10 @@ public Map<String, Object> typedInputs(Flow flow, Execution execution, Map<Strin } if (!input.getRequired() && current == null) { - return Optional.empty(); + return Optional.of(new AbstractMap.SimpleEntry<>( + input.getName(), + null + )); } var parsedInput = parseInput(flow, execution, input, current); @@ -126,7 +129,7 @@ public Map<String, Object> typedInputs(Flow flow, Execution execution, Map<Strin }) .filter(Optional::isPresent) .map(Optional::get) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + .collect(HashMap::new, (map, entry) -> map.put(entry.getKey(), entry.getValue()), Map::putAll); return handleNestedInputs(results); }
diff --git a/core/src/test/java/io/kestra/core/runners/InputsTest.java b/core/src/test/java/io/kestra/core/runners/InputsTest.java index c1fa9ac5b4..d194f7a61e 100644 --- a/core/src/test/java/io/kestra/core/runners/InputsTest.java +++ b/core/src/test/java/io/kestra/core/runners/InputsTest.java @@ -85,6 +85,15 @@ void missingRequired() { }); } + @Test + void nonRequiredNoDefaultNoValueIsNull() { + HashMap<String, String> inputsWithMissingOptionalInput = new HashMap<>(inputs); + inputsWithMissingOptionalInput.remove("bool"); + + assertThat(typedInputs(inputsWithMissingOptionalInput).containsKey("bool"), is(true)); + assertThat(typedInputs(inputsWithMissingOptionalInput).get("bool"), nullValue()); + } + @SuppressWarnings("unchecked") @Test void allValidInputs() throws URISyntaxException, IOException { diff --git a/webserver/src/test/java/io/kestra/webserver/controllers/ExecutionControllerTest.java b/webserver/src/test/java/io/kestra/webserver/controllers/ExecutionControllerTest.java index ef3169eaf4..4cd172d702 100644 --- a/webserver/src/test/java/io/kestra/webserver/controllers/ExecutionControllerTest.java +++ b/webserver/src/test/java/io/kestra/webserver/controllers/ExecutionControllerTest.java @@ -129,6 +129,8 @@ void trigger() { assertThat(result.getInputs().get("float"), is(42.42)); assertThat(result.getInputs().get("file").toString(), startsWith("kestra:///io/kestra/tests/inputs/executions/")); assertThat(result.getInputs().get("file").toString(), startsWith("kestra:///io/kestra/tests/inputs/executions/")); + assertThat(result.getInputs().containsKey("bool"), is(true)); + assertThat(result.getInputs().get("bool"), nullValue()); assertThat(result.getLabels().get("a"), is("label-1")); assertThat(result.getLabels().get("b"), is("label-2")); assertThat(result.getLabels().get("flow-label-1"), is("flow-label-1"));
train
train
2023-06-30T20:59:49
"2023-06-22T10:04:42Z"
loicmathieu
train
kestra-io/kestra/1641_1677
kestra-io/kestra
kestra-io/kestra/1641
kestra-io/kestra/1677
[ "keyword_pr_to_issue" ]
97fbc93655fc333232b2c9b1947b97c431cf84f9
852dff110f3f348294ec50f0b1459a4ea438805e
[]
[]
"2023-07-03T07:49:09Z"
[ "bug" ]
Regression error: the button to switch between vertical and horizontal topology alignment is gone
### Expected Behavior ![image](https://github.com/kestra-io/kestra/assets/86264395/f0bfbd61-b093-489e-a61c-11b5919c507f) there is o way to change it to the top to bottom ### Actual Behaviour _No response_ ### Steps To Reproduce _No response_ ### Environment Information - Kestra Version: develop full - Operating System (OS / Docker / Kubernetes): - Java Version (If not docker): ### Example flow _No response_
[ "ui/src/components/executions/Topology.vue", "ui/src/components/flows/Topology.vue" ]
[ "ui/src/components/executions/Topology.vue", "ui/src/components/flows/Topology.vue" ]
[]
diff --git a/ui/src/components/executions/Topology.vue b/ui/src/components/executions/Topology.vue index 9bc3149d9b..85f3e06cbf 100644 --- a/ui/src/components/executions/Topology.vue +++ b/ui/src/components/executions/Topology.vue @@ -10,6 +10,7 @@ :source="flow.source" :execution="execution" @follow="forwardEvent('follow', $event)" + view-type="topology" /> </div> </el-card> diff --git a/ui/src/components/flows/Topology.vue b/ui/src/components/flows/Topology.vue index f6b05a1b43..7df13c851f 100644 --- a/ui/src/components/flows/Topology.vue +++ b/ui/src/components/flows/Topology.vue @@ -8,6 +8,7 @@ :flow-graph="flowGraph" :source="flow.source" :is-read-only="isReadOnly" + view-type="topology" /> </div> </el-card>
null
train
train
2023-06-30T20:59:49
"2023-06-27T13:09:23Z"
anna-geller
train
kestra-io/kestra/1679_1685
kestra-io/kestra
kestra-io/kestra/1679
kestra-io/kestra/1685
[ "keyword_pr_to_issue" ]
7eb27e02cad90cd8d4df42459d64cfd3c3f822b0
8387a7590cee897e3adcd91260c3301a3174aa66
[]
[ "You should get all env var at bean creation time and prepare a map of key/value, this would be more performant than calling System.getenv at each function call.", ":+1: ", "`SECRETS_` should be defined as a constant.", "Should be toLowerCase I think, and you can use the length of the prefix constant instead of hardcoding 8 ;) ", "I get them as uppercase because env var will probably be as uppercase when set up. Whatever I enforce both the map input and the get as uppercase for now, is it ok ?" ]
"2023-07-03T14:06:00Z"
[ "backend" ]
Add Secret environment variable
### Feature description Add a `SECRET` environment variable with base64 encodage letting user add simple secret variables in configuration
[ "build.gradle", "core/src/main/java/io/kestra/core/runners/pebble/Extension.java" ]
[ "build.gradle", "core/src/main/java/io/kestra/core/runners/pebble/Extension.java", "core/src/main/java/io/kestra/core/runners/pebble/functions/SecretFunction.java", "core/src/main/java/io/kestra/core/secret/SecretService.java" ]
[ "core/src/test/java/io/kestra/core/secret/SecretFunctionTest.java", "core/src/test/resources/flows/valids/secrets.yaml" ]
diff --git a/build.gradle b/build.gradle index c37ecf0c06..6387373985 100644 --- a/build.gradle +++ b/build.gradle @@ -168,6 +168,8 @@ subprojects { // configure en_US default locale for tests systemProperty 'user.language', 'en' systemProperty 'user.country', 'US' + + environment 'SECRETS_MY_SECRET', "{\"secretKey\":\"secretValue\"}".bytes.encodeBase64().toString() } testlogger { diff --git a/core/src/main/java/io/kestra/core/runners/pebble/Extension.java b/core/src/main/java/io/kestra/core/runners/pebble/Extension.java index 52ab79452c..d06d8956d3 100644 --- a/core/src/main/java/io/kestra/core/runners/pebble/Extension.java +++ b/core/src/main/java/io/kestra/core/runners/pebble/Extension.java @@ -1,5 +1,6 @@ package io.kestra.core.runners.pebble; +import io.kestra.core.runners.pebble.functions.SecretFunction; import io.pebbletemplates.pebble.extension.*; import io.pebbletemplates.pebble.operator.Associativity; import io.pebbletemplates.pebble.operator.BinaryOperator; @@ -17,12 +18,17 @@ import java.util.HashMap; import java.util.List; import java.util.Map; + +import jakarta.inject.Inject; import jakarta.inject.Singleton; import static io.pebbletemplates.pebble.operator.BinaryOperatorType.NORMAL; @Singleton public class Extension extends AbstractExtension { + @Inject + private SecretFunction secretFunction; + @Override public List<TokenParser> getTokenParsers() { return null; @@ -82,6 +88,7 @@ public Map<String, Function> getFunctions() { tests.put("now", new NowFunction()); tests.put("json", new JsonFunction()); tests.put("currentEachOutput", new CurrentEachOutputFunction()); + tests.put("secret", secretFunction); return tests; } diff --git a/core/src/main/java/io/kestra/core/runners/pebble/functions/SecretFunction.java b/core/src/main/java/io/kestra/core/runners/pebble/functions/SecretFunction.java new file mode 100644 index 0000000000..19c4c6c836 --- /dev/null +++ b/core/src/main/java/io/kestra/core/runners/pebble/functions/SecretFunction.java @@ -0,0 +1,46 @@ +package io.kestra.core.runners.pebble.functions; + +import io.kestra.core.exceptions.IllegalVariableEvaluationException; +import io.kestra.core.secret.SecretService; +import io.pebbletemplates.pebble.error.PebbleException; +import io.pebbletemplates.pebble.extension.Function; +import io.pebbletemplates.pebble.template.EvaluationContext; +import io.pebbletemplates.pebble.template.PebbleTemplate; +import jakarta.inject.Inject; +import jakarta.inject.Singleton; + +import java.io.IOException; +import java.util.List; +import java.util.Map; + +@Singleton +public class SecretFunction implements Function { + @Inject + private SecretService secretService; + + @Override + public List<String> getArgumentNames() { + return List.of("key"); + } + + @SuppressWarnings("unchecked") + @Override + public Object execute(Map<String, Object> args, PebbleTemplate self, EvaluationContext context, int lineNumber) { + String key = getSecretKey(args, self, lineNumber); + Map<String, String> flow = (Map<String, String>) context.getVariable("flow"); + + try { + return secretService.findSecret(flow.get("namespace"), key); + } catch (IllegalVariableEvaluationException | IOException e) { + throw new PebbleException(e, e.getMessage(), lineNumber, self.getName()); + } + } + + protected String getSecretKey(Map<String, Object> args, PebbleTemplate self, int lineNumber) { + if (!args.containsKey("key")) { + throw new PebbleException(null, "The 'secret' function expects an argument 'key'.", lineNumber, self.getName()); + } + + return (String) args.get("key"); + } +} \ No newline at end of file diff --git a/core/src/main/java/io/kestra/core/secret/SecretService.java b/core/src/main/java/io/kestra/core/secret/SecretService.java new file mode 100644 index 0000000000..13ba7f97aa --- /dev/null +++ b/core/src/main/java/io/kestra/core/secret/SecretService.java @@ -0,0 +1,34 @@ +package io.kestra.core.secret; + +import io.kestra.core.exceptions.IllegalVariableEvaluationException; +import jakarta.inject.Singleton; + +import javax.annotation.PostConstruct; +import java.io.IOException; +import java.util.Base64; +import java.util.Map; +import java.util.Optional; +import java.util.stream.Collectors; + +@Singleton +public class SecretService { + private static final String SECRET_PREFIX = "SECRETS_"; + private Map<String, String> decodedSecrets; + + @PostConstruct + private void postConstruct() { + decodedSecrets = System.getenv().entrySet().stream().filter(entry -> entry.getKey().startsWith(SECRET_PREFIX)).collect(Collectors.toMap( + entry -> entry.getKey().substring(SECRET_PREFIX.length()).toUpperCase(), + entry -> new String(Base64.getDecoder().decode(entry.getValue())) + )); + } + + public String findSecret(String namespace, String key) throws IOException, IllegalVariableEvaluationException { + return Optional + .ofNullable(decodedSecrets.get(key.toUpperCase())) + .orElseThrow(() -> new IllegalVariableEvaluationException("Unable to find secret '" + key + "'. " + + "You should add it in your environment variables as 'SECRETS_" + key.toUpperCase() + + "' with base64-encoded value." + )); + } +}
diff --git a/core/src/test/java/io/kestra/core/secret/SecretFunctionTest.java b/core/src/test/java/io/kestra/core/secret/SecretFunctionTest.java new file mode 100644 index 0000000000..9e30fd8329 --- /dev/null +++ b/core/src/test/java/io/kestra/core/secret/SecretFunctionTest.java @@ -0,0 +1,39 @@ +package io.kestra.core.secret; + +import io.kestra.core.exceptions.IllegalVariableEvaluationException; +import io.kestra.core.models.executions.Execution; +import io.kestra.core.runners.AbstractMemoryRunnerTest; +import io.kestra.core.runners.RunnerUtils; +import io.micronaut.test.extensions.junit5.annotation.MicronautTest; +import jakarta.inject.Inject; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import java.util.concurrent.TimeoutException; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; + +@MicronautTest +public class SecretFunctionTest extends AbstractMemoryRunnerTest { + @Inject + private RunnerUtils runnerUtils; + + @Inject + private SecretService secretService; + + @Test + void getSecret() throws TimeoutException { + Execution execution = runnerUtils.runOne("io.kestra.tests", "secrets"); + assertThat(execution.getTaskRunList().get(0).getOutputs().get("value"), is("secretValue")); + } + + @Test + void getUnknownSecret() { + IllegalVariableEvaluationException exception = Assertions.assertThrows(IllegalVariableEvaluationException.class, () -> + secretService.findSecret(null, "unknown_secret_key") + ); + + assertThat(exception.getMessage(), is("Unable to find secret 'unknown_secret_key'")); + } +} diff --git a/core/src/test/resources/flows/valids/secrets.yaml b/core/src/test/resources/flows/valids/secrets.yaml new file mode 100644 index 0000000000..2f5108bd35 --- /dev/null +++ b/core/src/test/resources/flows/valids/secrets.yaml @@ -0,0 +1,7 @@ +id: secrets +namespace: io.kestra.tests + +tasks: + - id: get-secret + type: io.kestra.core.tasks.debugs.Return + format: "{{json(secret('my_secret')).secretKey}}" \ No newline at end of file
test
train
2023-07-03T16:47:51
"2023-07-03T09:16:05Z"
Ben8t
train
kestra-io/kestra/1682_1690
kestra-io/kestra
kestra-io/kestra/1682
kestra-io/kestra/1690
[ "keyword_pr_to_issue" ]
8df54c40fb4d59dc66189ecbea1aaf812ae8756e
1983530419a76e28feba0993ea939f736b717220
[ "Hi,\r\nWe totally revamped our website a few weeks ago and it's possible that some links changed.\r\nThe README should be updated, if you would like to make a pull request it would be great!" ]
[]
"2023-07-04T05:13:08Z"
[ "documentation" ]
Typos on links to Plugins' documentation.
### Issue description I found two types of typos on the links in README which redirect the user to the respective plugin's documentation on https://kestra.io/plugins/ . 1) Type 1 - Affected Plugins: Bash, Node and Python. The README file has the type name starting with an uppercase character i.e. `https://kestra.io/plugins/core/tasks/scripts/io.kestra.core.tasks.scripts.Python` but the actual link has the type name in lower case i.e. `https://kestra.io/plugins/core/tasks/scripts/io.kestra.core.tasks.scripts.python` Following are the lines where the issue is present: https://github.com/kestra-io/kestra/blob/97fbc93655fc333232b2c9b1947b97c431cf84f9/README.md?plain=1#L221 https://github.com/kestra-io/kestra/blob/97fbc93655fc333232b2c9b1947b97c431cf84f9/README.md?plain=1#L270 https://github.com/kestra-io/kestra/blob/97fbc93655fc333232b2c9b1947b97c431cf84f9/README.md?plain=1#L282 2) Type 2: Affected Plugins: Groovy, Jython and Nashorn. The links on the README file is of the pattern `https://kestra.io/plugins/plugin-scripts-xxx`, where xxx is the plugin name in lower case, but the actual links are of the pattern `https://kestra.io/plugins/plugin-script-xxx` where the word script is singular. Following are the lines where the issue is present: https://github.com/kestra-io/kestra/blob/97fbc93655fc333232b2c9b1947b97c431cf84f9/README.md?plain=1#L251 https://github.com/kestra-io/kestra/blob/97fbc93655fc333232b2c9b1947b97c431cf84f9/README.md?plain=1#L256 https://github.com/kestra-io/kestra/blob/97fbc93655fc333232b2c9b1947b97c431cf84f9/README.md?plain=1#L267 I am not sure they are really typos, perhaps you would actually want the documentation to be available on `https://kestra.io/plugins/core/tasks/scripts/io.kestra.core.tasks.scripts.python` instead of `https://kestra.io/plugins/core/tasks/scripts/io.kestra.core.tasks.scripts.Python` etc. So I just wanted to raise the issue before attempting to make any pull request. Let me know if I have to make a pull request after correcting the changes.
[ "README.md" ]
[ "README.md" ]
[]
diff --git a/README.md b/README.md index c917c65c65..a203bb5b3f 100644 --- a/README.md +++ b/README.md @@ -218,7 +218,7 @@ Here are some examples of the available plugins: </tr> <tr> <td><a href="https://kestra.io/plugins/plugin-azure/#storage-blob">Azure Blob Storage</a></td> - <td><a href="https://kestra.io/plugins/core/tasks/scripts/io.kestra.core.tasks.scripts.Bash">Bash</a></td> + <td><a href="https://kestra.io/plugins/core/tasks/scripts/io.kestra.core.tasks.scripts.bash">Bash</a></td> <td><a href="https://kestra.io/plugins/plugin-gcp#bigquery">Big Query</a></td> </tr> <tr> @@ -248,12 +248,12 @@ Here are some examples of the available plugins: </tr> <tr> <td><a href="https://kestra.io/plugins/plugin-googleworkspace#sheets">Google Sheets</a></td> - <td><a href="https://kestra.io/plugins/plugin-scripts-groovy">Groovy</a></td> + <td><a href="https://kestra.io/plugins/plugin-script-groovy">Groovy</a></td> <td><a href="https://kestra.io/plugins/plugin-fs#http">Http</a></td> </tr> <tr> <td><a href="https://kestra.io/plugins/plugin-serdes#json">JSON</a></td> - <td><a href="https://kestra.io/plugins/plugin-scripts-jython">Jython</a></td> + <td><a href="https://kestra.io/plugins/plugin-script-jython">Jython</a></td> <td><a href="https://kestra.io/plugins/plugin-kafka">Kafka</a></td> </tr> <tr> @@ -264,10 +264,10 @@ Here are some examples of the available plugins: <tr> <td><a href="https://kestra.io/plugins/plugin-mongodb">MongoDb</a></td> <td><a href="https://kestra.io/plugins/plugin-jdbc-mysql">MySQL</a></td> - <td><a href="https://kestra.io/plugins/plugin-scripts-nashorn">Nashorn</a></td> + <td><a href="https://kestra.io/plugins/plugin-script-nashorn">Nashorn</a></td> </tr> <tr> - <td><a href="https://kestra.io/plugins/core/tasks/scripts/io.kestra.core.tasks.scripts.Node">Node</a></td> + <td><a href="https://kestra.io/plugins/core/tasks/scripts/io.kestra.core.tasks.scripts.node">Node</a></td> <td><a href="https://kestra.io/plugins/plugin-crypto#openpgp">Open PGP</a></td> <td><a href="https://kestra.io/plugins/plugin-jdbc-oracle">Oracle</a></td> </tr> @@ -279,7 +279,7 @@ Here are some examples of the available plugins: <tr> <td><a href="https://kestra.io/plugins/plugin-powerbi">Power BI</a></td> <td><a href="https://kestra.io/plugins/plugin-pulsar">Apache Pulsar</a></td> - <td><a href="https://kestra.io/plugins/core/tasks/scripts/io.kestra.core.tasks.scripts.Python">Python</a></td> + <td><a href="https://kestra.io/plugins/core/tasks/scripts/io.kestra.core.tasks.scripts.python">Python</a></td> </tr> <tr> <td><a href="https://kestra.io/plugins/plugin-jdbc-redshift">Redshift</a></td>
null
train
train
2023-07-03T22:30:13
"2023-07-03T11:48:13Z"
npranav10
train
kestra-io/kestra/1691_1692
kestra-io/kestra
kestra-io/kestra/1691
kestra-io/kestra/1692
[ "keyword_pr_to_issue" ]
18531555353d516abfaa84ffad8c88ab9e85f146
405a82c18562d058303db2c310fb1b4168ba21fe
[]
[]
"2023-07-04T12:26:21Z"
[ "bug", "enhancement", "frontend" ]
Subflows logs are not displayed in parent gantt & logs
### Expected Behavior _No response_ ### Actual Behaviour _No response_ ### Steps To Reproduce _No response_ ### Environment Information - Kestra Version: 0.10.0-SNAPSHOT - Operating System (OS / Docker / Kubernetes): - Java Version (If not docker): ### Example flow _No response_
[ "ui/src/components/executions/Logs.vue", "ui/src/components/logs/LogList.vue" ]
[ "ui/src/components/executions/Logs.vue", "ui/src/components/logs/LogList.vue" ]
[]
diff --git a/ui/src/components/executions/Logs.vue b/ui/src/components/executions/Logs.vue index 403b9aaa9a..1597cc6222 100644 --- a/ui/src/components/executions/Logs.vue +++ b/ui/src/components/executions/Logs.vue @@ -101,7 +101,7 @@ taskRunList() { const fullList = []; for (const taskRun of (this.execution.taskRunList || [])) { - for (const attempt in taskRun.attempts) { + for (const attempt in (taskRun.attempts ?? [{}])) { fullList.push({ ...taskRun, attempt: parseInt(attempt), diff --git a/ui/src/components/logs/LogList.vue b/ui/src/components/logs/LogList.vue index b9f7d68074..3a28a6ca38 100644 --- a/ui/src/components/logs/LogList.vue +++ b/ui/src/components/logs/LogList.vue @@ -459,7 +459,11 @@ } }, attempts(taskRun) { - return this.execution.state.current === State.RUNNING || !this.attemptNumber ? taskRun.attempts : [taskRun.attempts[this.attemptNumber]] ; + if (this.execution.state.current === State.RUNNING || !this.attemptNumber) { + return taskRun.attempts ?? [{state: taskRun.state}]; + } + + return [taskRun.attempts[this.attemptNumber]]; }, onTaskSelect(dropdownVisible, task) { if (dropdownVisible && this.taskRun?.id !== task.id) {
null
train
train
2023-07-04T13:32:20
"2023-07-04T12:22:45Z"
brian-mulier-p
train
kestra-io/kestra/1693_1696
kestra-io/kestra
kestra-io/kestra/1693
kestra-io/kestra/1696
[ "keyword_pr_to_issue" ]
708997cffe922750afa4d5b58de378324f3f35db
c48ccb3c0e786481331daa37775cce16b13a784c
[]
[]
"2023-07-04T14:26:14Z"
[ "bug", "enhancement", "frontend" ]
Copy Flow button is not working anymore
### Expected Behavior When I hit the Copy button on the flow page, a new flow with the same content should be created ### Actual Behaviour The "default" flow is created with the following content: ``` id: hello-world namespace: dev tasks: - id: hello type: io.kestra.core.tasks.log.Log message: Kestra team wishes you a great day! 👋 ``` ### Steps To Reproduce 1. Go to the editor of an existing flow 2. Click on Actions -> Copy ### Environment Information - Kestra Version: 0.10.0 - Operating System (OS / Docker / Kubernetes): - Java Version (If not docker): ### Example flow _No response_
[ "ui/src/components/flows/FlowCreate.vue", "ui/src/components/inputs/EditorView.vue" ]
[ "ui/src/components/flows/FlowCreate.vue", "ui/src/components/inputs/EditorView.vue" ]
[]
diff --git a/ui/src/components/flows/FlowCreate.vue b/ui/src/components/flows/FlowCreate.vue index a12306fc95..c1883446af 100644 --- a/ui/src/components/flows/FlowCreate.vue +++ b/ui/src/components/flows/FlowCreate.vue @@ -9,7 +9,7 @@ :total="total" :guided-properties="guidedProperties" :flow-error="flowError" - :flow="flowWithSource" + :flow="sourceWrapper" /> </div> <div id="guided-right" /> @@ -19,38 +19,36 @@ import EditorView from "../inputs/EditorView.vue"; import {mapGetters, mapState} from "vuex"; import RouteContext from "../../mixins/routeContext"; - import YamlUtils from "../../utils/yamlUtils"; export default { mixins: [RouteContext], components: { EditorView }, - data() { - return { - defaultFlowTemplate: { - id: "hello-world", - namespace: "dev", - tasks: [{ - id: "hello", - type: "io.kestra.core.tasks.log.Log", - message: "Kestra team wishes you a great day! 👋" - }] - } - } - }, beforeUnmount() { this.$store.commit("flow/setFlowError", undefined); }, computed: { - flowWithSource() { - return {source: YamlUtils.stringify(this.defaultFlowTemplate)}; + sourceWrapper() { + return {source: this.defaultFlowTemplate}; + }, + defaultFlowTemplate() { + if(this.$route.query.copy && this.flow){ + return this.flow.source; + } + + return `id: hello-world +namespace: dev +tasks: + - id: hello + type: io.kestra.core.tasks.log.Log + message: Kestra team wishes you a great day! 👋`; }, ...mapState("flow", ["flowGraph", "total"]), ...mapState("auth", ["user"]), ...mapState("plugin", ["pluginSingleList", "pluginsDocumentation"]), ...mapGetters("core", ["guidedProperties"]), - ...mapGetters("flow", ["flowError"]), + ...mapGetters("flow", ["flow", "flowError"]), routeInfo() { return { title: this.$t("flows") diff --git a/ui/src/components/inputs/EditorView.vue b/ui/src/components/inputs/EditorView.vue index b9a51e9955..90db63297b 100644 --- a/ui/src/components/inputs/EditorView.vue +++ b/ui/src/components/inputs/EditorView.vue @@ -74,10 +74,6 @@ type: Boolean, default: false }, - sourceCopy: { - type: String, - default: null - }, total: { type: Number, default: null
null
train
train
2023-07-04T16:09:40
"2023-07-04T12:40:12Z"
loicmathieu
train
kestra-io/kestra/1699_1700
kestra-io/kestra
kestra-io/kestra/1699
kestra-io/kestra/1700
[ "keyword_pr_to_issue" ]
c48ccb3c0e786481331daa37775cce16b13a784c
6ded19ec285f96789e10951978b73645d8b3ccc0
[]
[]
"2023-07-04T15:11:08Z"
[ "bug", "enhancement", "frontend" ]
Do not display 'Triggers' tab in Flow when there is none
### Expected Behavior _No response_ ### Actual Behaviour _No response_ ### Steps To Reproduce _No response_ ### Environment Information - Kestra Version: - Operating System (OS / Docker / Kubernetes): - Java Version (If not docker): ### Example flow _No response_
[ "ui/src/components/flows/FlowRoot.vue" ]
[ "ui/src/components/flows/FlowRoot.vue" ]
[]
diff --git a/ui/src/components/flows/FlowRoot.vue b/ui/src/components/flows/FlowRoot.vue index 1a9f0604d2..8454594916 100644 --- a/ui/src/components/flows/FlowRoot.vue +++ b/ui/src/components/flows/FlowRoot.vue @@ -138,7 +138,8 @@ tabs.push({ name: "triggers", component: FlowTriggers, - title: this.$t("triggers") + title: this.$t("triggers"), + disabled: !this.flow.triggers }); }
null
train
train
2023-07-04T16:33:55
"2023-07-04T15:02:03Z"
brian-mulier-p
train
kestra-io/kestra/1706_1711
kestra-io/kestra
kestra-io/kestra/1706
kestra-io/kestra/1711
[ "keyword_pr_to_issue" ]
f58d857a8dab338c13490b55e26283c9da72ac94
ed80eb5c06244f00736daf3e01ad07004d321bfc
[]
[ "We usually use `@Slf4j` at the class level.\r\nAt least add it as a constant it's a best practice even if only used there." ]
"2023-07-05T10:00:54Z"
[ "bug" ]
Secret not in base64 exit the instance
### Expected Behavior _No response_ ### Actual Behaviour When putting a SECRET not in base64 the Kestra instance exit with this error : ``` 2023-07-05 07:59:30,436 INFO standalone io.kestra.cli.AbstractCommand Starting Kestra with environments [cli] 2023-07-05 07:59:30,618 INFO standalone io.kestra.cli.AbstractCommand Server Running: http://d55ea905c356:8080, Management server on port http://d55ea905c356:8081/health 2023-07-05 07:59:31,326 ERROR standalone-runner_2 .c.u.ThreadUncaughtExceptionHandlers Caught an exception in Thread[standalone-runner_2,5,main]. Shutting down. io.micronaut.context.exceptions.DependencyInjectionException: Error instantiating bean of type [io.kestra.core.runners.pebble.functions.SecretFunction] Message: Error invoking method: postConstruct Path Taken: new Extension() --> Extension.secretFunction --> SecretFunction.secretService at io.micronaut.context.AbstractInitializableBeanDefinition.invokeMethodWithReflection(AbstractInitializableBeanDefinition.java:957) at io.kestra.core.secret.$SecretService$Definition.initialize(Unknown Source) at io.kestra.core.secret.$SecretService$Definition.build(Unknown Source) at io.micronaut.context.DefaultBeanContext.resolveByBeanFactory(DefaultBeanContext.java:2354) at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:2305) at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:2251) at io.micronaut.context.DefaultBeanContext.createRegistration(DefaultBeanContext.java:3016) at io.micronaut.context.SingletonScope.getOrCreate(SingletonScope.java:80) at io.micronaut.context.DefaultBeanContext.findOrCreateSingletonBeanRegistration(DefaultBeanContext.java:2918) at io.micronaut.context.DefaultBeanContext.resolveBeanRegistration(DefaultBeanContext.java:2879) at io.micronaut.context.DefaultBeanContext.resolveBeanRegistration(DefaultBeanContext.java:2800) at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:1617) at io.micronaut.context.AbstractBeanResolutionContext.getBean(AbstractBeanResolutionContext.java:66) at io.micronaut.context.AbstractInitializableBeanDefinition.resolveBean(AbstractInitializableBeanDefinition.java:2065) at io.micronaut.context.AbstractInitializableBeanDefinition.getBeanForField(AbstractInitializableBeanDefinition.java:1603) at io.kestra.core.runners.pebble.functions.$SecretFunction$Definition.injectBean(Unknown Source) at io.kestra.core.runners.pebble.functions.$SecretFunction$Definition.build(Unknown Source) at io.micronaut.context.DefaultBeanContext.resolveByBeanFactory(DefaultBeanContext.java:2354) at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:2305) at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:2251) at io.micronaut.context.DefaultBeanContext.createRegistration(DefaultBeanContext.java:3016) at io.micronaut.context.SingletonScope.getOrCreate(SingletonScope.java:80) at io.micronaut.context.DefaultBeanContext.findOrCreateSingletonBeanRegistration(DefaultBeanContext.java:2918) at io.micronaut.context.DefaultBeanContext.resolveBeanRegistration(DefaultBeanContext.java:2879) at io.micronaut.context.DefaultBeanContext.resolveBeanRegistration(DefaultBeanContext.java:2800) at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:1617) at io.micronaut.context.AbstractBeanResolutionContext.getBean(AbstractBeanResolutionContext.java:66) at io.micronaut.context.AbstractInitializableBeanDefinition.resolveBean(AbstractInitializableBeanDefinition.java:2065) at io.micronaut.context.AbstractInitializableBeanDefinition.getBeanForField(AbstractInitializableBeanDefinition.java:1603) at io.kestra.core.runners.pebble.$Extension$Definition.injectBean(Unknown Source) at io.kestra.core.runners.pebble.$Extension$Definition.build(Unknown Source) at io.micronaut.context.DefaultBeanContext.resolveByBeanFactory(DefaultBeanContext.java:2354) at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:2305) at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:2251) at io.micronaut.context.DefaultBeanContext.createRegistration(DefaultBeanContext.java:3016) at io.micronaut.context.SingletonScope.getOrCreate(SingletonScope.java:80) at io.micronaut.context.DefaultBeanContext.findOrCreateSingletonBeanRegistration(DefaultBeanContext.java:2918) at io.micronaut.context.DefaultBeanContext.resolveBeanRegistration(DefaultBeanContext.java:2879) at io.micronaut.context.DefaultBeanContext.resolveBeanRegistration(DefaultBeanContext.java:2853) at io.micronaut.context.DefaultBeanContext.addCandidateToList(DefaultBeanContext.java:3511) at io.micronaut.context.DefaultBeanContext.resolveBeanRegistrations(DefaultBeanContext.java:3457) at io.micronaut.context.DefaultBeanContext.getBeanRegistrations(DefaultBeanContext.java:3427) at io.micronaut.context.DefaultBeanContext.getBeansOfType(DefaultBeanContext.java:1381) at io.micronaut.context.DefaultBeanContext.getBeansOfType(DefaultBeanContext.java:1364) at io.micronaut.context.DefaultBeanContext.getBeansOfType(DefaultBeanContext.java:888) at io.kestra.core.runners.VariableRenderer.<init>(VariableRenderer.java:85) at io.kestra.core.runners.$VariableRenderer$Definition.build(Unknown Source) at io.micronaut.context.DefaultBeanContext.resolveByBeanFactory(DefaultBeanContext.java:2354) at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:2305) at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:2251) at io.micronaut.context.DefaultBeanContext.createRegistration(DefaultBeanContext.java:3016) at io.micronaut.context.SingletonScope.getOrCreate(SingletonScope.java:80) at io.micronaut.context.DefaultBeanContext.findOrCreateSingletonBeanRegistration(DefaultBeanContext.java:2918) at io.micronaut.context.DefaultBeanContext.resolveBeanRegistration(DefaultBeanContext.java:2879) at io.micronaut.context.DefaultBeanContext.resolveBeanRegistration(DefaultBeanContext.java:2800) at io.micronaut.context.DefaultBeanContext.findBean(DefaultBeanContext.java:1680) at io.micronaut.context.DefaultBeanContext.findBean(DefaultBeanContext.java:1655) at io.micronaut.context.DefaultBeanContext.findBean(DefaultBeanContext.java:878) at io.micronaut.context.BeanLocator.findBean(BeanLocator.java:291) at io.kestra.core.runners.RunContext.initBean(RunContext.java:117) at io.kestra.core.runners.RunContext.<init>(RunContext.java:91) at io.kestra.core.runners.RunContextFactory.of(RunContextFactory.java:30) at io.kestra.core.schedulers.AbstractScheduler.lambda$computeSchedulable$8(AbstractScheduler.java:192) at java.base/java.util.stream.ReferencePipeline$3$1.accept(Unknown Source) at java.base/java.util.stream.ReferencePipeline$2$1.accept(Unknown Source) at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(Unknown Source) at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source) at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(Unknown Source) at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(Unknown Source) at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source) at java.base/java.util.stream.ReferencePipeline.forEach(Unknown Source) at java.base/java.util.stream.ReferencePipeline$7$1.accept(Unknown Source) at java.base/java.util.stream.ReferencePipeline$2$1.accept(Unknown Source) at java.base/java.util.stream.ReferencePipeline$2$1.accept(Unknown Source) at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(Unknown Source) at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source) at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source) at java.base/java.util.stream.AbstractPipeline.evaluateToArrayNode(Unknown Source) at java.base/java.util.stream.ReferencePipeline.toArray(Unknown Source) at java.base/java.util.stream.ReferencePipeline.toArray(Unknown Source) at java.base/java.util.stream.ReferencePipeline.toList(Unknown Source) at io.kestra.core.schedulers.AbstractScheduler.computeSchedulable(AbstractScheduler.java:202) at io.kestra.core.runners.FlowListeners.listen(FlowListeners.java:132) at io.kestra.core.schedulers.AbstractScheduler.run(AbstractScheduler.java:108) at io.kestra.jdbc.runner.JdbcScheduler.run(JdbcScheduler.java:52) at io.micrometer.core.instrument.internal.TimedRunnable.run(TimedRunnable.java:49) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.base/java.lang.Thread.run(Unknown Source) Caused by: io.micronaut.core.reflect.exception.InvocationException: Exception occurred invoking method [private void io.kestra.core.secret.SecretService.postConstruct()]: null at io.micronaut.core.reflect.ReflectionUtils.invokeMethod(ReflectionUtils.java:198) at io.micronaut.context.AbstractInitializableBeanDefinition.invokeMethodWithReflection(AbstractInitializableBeanDefinition.java:952) ... 90 common frames omitted Caused by: java.lang.reflect.InvocationTargetException: null at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at io.micronaut.core.reflect.ReflectionUtils.invokeMethod(ReflectionUtils.java:194) ... 91 common frames omitted Caused by: java.lang.IllegalArgumentException: Last unit does not have enough valid bits at java.base/java.util.Base64$Decoder.decode0(Unknown Source) at java.base/java.util.Base64$Decoder.decode(Unknown Source) at java.base/java.util.Base64$Decoder.decode(Unknown Source) at io.kestra.core.secret.SecretService.lambda$postConstruct$2(SecretService.java:22) at java.base/java.util.stream.Collectors.lambda$uniqKeysMapAccumulator$1(Unknown Source) at java.base/java.util.stream.ReduceOps$3ReducingSink.accept(Unknown Source) at java.base/java.util.stream.ReferencePipeline$2$1.accept(Unknown Source) at java.base/java.util.Collections$UnmodifiableMap$UnmodifiableEntrySet.lambda$entryConsumer$0(Unknown Source) at java.base/java.util.Iterator.forEachRemaining(Unknown Source) at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Unknown Source) at java.base/java.util.Collections$UnmodifiableMap$UnmodifiableEntrySet$UnmodifiableEntrySetSpliterator.forEachRemaining(Unknown Source) at java.base/java.util.stream.AbstractPipeline.copyInto(Unknown Source) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source) at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(Unknown Source) at java.base/java.util.stream.AbstractPipeline.evaluate(Unknown Source) at java.base/java.util.stream.ReferencePipeline.collect(Unknown Source) at io.kestra.core.secret.SecretService.postConstruct(SecretService.java:20) ``` ### Steps To Reproduce _No response_ ### Environment Information - Kestra Version: - Operating System (OS / Docker / Kubernetes): - Java Version (If not docker): ### Example flow _No response_
[ "build.gradle", "core/src/main/java/io/kestra/core/secret/SecretService.java" ]
[ "build.gradle", "core/src/main/java/io/kestra/core/secret/SecretService.java" ]
[]
diff --git a/build.gradle b/build.gradle index 6387373985..cfe5455df3 100644 --- a/build.gradle +++ b/build.gradle @@ -170,6 +170,7 @@ subprojects { systemProperty 'user.country', 'US' environment 'SECRETS_MY_SECRET', "{\"secretKey\":\"secretValue\"}".bytes.encodeBase64().toString() + environment 'SECRETS_NON_B64_SECRET', "some secret value" } testlogger { diff --git a/core/src/main/java/io/kestra/core/secret/SecretService.java b/core/src/main/java/io/kestra/core/secret/SecretService.java index 13ba7f97aa..05b9e859e8 100644 --- a/core/src/main/java/io/kestra/core/secret/SecretService.java +++ b/core/src/main/java/io/kestra/core/secret/SecretService.java @@ -2,6 +2,9 @@ import io.kestra.core.exceptions.IllegalVariableEvaluationException; import jakarta.inject.Singleton; +import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import javax.annotation.PostConstruct; import java.io.IOException; @@ -11,16 +14,26 @@ import java.util.stream.Collectors; @Singleton +@Slf4j public class SecretService { private static final String SECRET_PREFIX = "SECRETS_"; private Map<String, String> decodedSecrets; @PostConstruct private void postConstruct() { - decodedSecrets = System.getenv().entrySet().stream().filter(entry -> entry.getKey().startsWith(SECRET_PREFIX)).collect(Collectors.toMap( - entry -> entry.getKey().substring(SECRET_PREFIX.length()).toUpperCase(), - entry -> new String(Base64.getDecoder().decode(entry.getValue())) - )); + decodedSecrets = System.getenv().entrySet().stream() + .filter(entry -> entry.getKey().startsWith(SECRET_PREFIX)) + .<Map.Entry<String, String>>mapMulti((entry, consumer) -> { + try { + consumer.accept(Map.entry(entry.getKey(), new String(Base64.getDecoder().decode(entry.getValue())))); + } catch (Exception e) { + log.error("Could not decode secret '{}', make sure it is Base64-encoded", entry.getKey(), e); + } + }) + .collect(Collectors.toMap( + entry -> entry.getKey().substring(SECRET_PREFIX.length()).toUpperCase(), + Map.Entry::getValue + )); } public String findSecret(String namespace, String key) throws IOException, IllegalVariableEvaluationException {
null
test
train
2023-07-04T22:48:42
"2023-07-05T08:28:30Z"
Ben8t
train
kestra-io/kestra/1695_1712
kestra-io/kestra
kestra-io/kestra/1695
kestra-io/kestra/1712
[ "keyword_pr_to_issue" ]
352d71870bc5be8d3fc13163b48f96e2ebacd724
faaeebb8eee61fc4dd8e123b55f0e9678b178c4d
[]
[]
"2023-07-05T10:18:49Z"
[ "bug", "enhancement", "frontend" ]
Topology view let us put one task on another
### Expected Behavior _No response_ ### Actual Behaviour It then scopes the moved task to the bound of the dropped-on task. Strange behaviour which has no impact functionally but let us move things around on something which should be non-editable ![image](https://github.com/kestra-io/kestra/assets/37618489/74c585f5-6314-408e-9d86-46b697e75b05) Wondering if it has something related to https://github.com/kestra-io/kestra/issues/1458 NOTE: It happens only on Execution topology tab ### Steps To Reproduce Go to topology Drag one task on another -> You can move the task within the dropped-on task but you can no longer move it out unless you refresh the page ### Environment Information - Kestra Version: 0.10.0 - Operating System (OS / Docker / Kubernetes): - Java Version (If not docker): ### Example flow _No response_
[ "ui/src/components/executions/Topology.vue" ]
[ "ui/src/components/executions/Topology.vue" ]
[]
diff --git a/ui/src/components/executions/Topology.vue b/ui/src/components/executions/Topology.vue index 85f3e06cbf..d3d19ddcfc 100644 --- a/ui/src/components/executions/Topology.vue +++ b/ui/src/components/executions/Topology.vue @@ -9,6 +9,7 @@ :flow-graph="flowGraph" :source="flow.source" :execution="execution" + is-read-only @follow="forwardEvent('follow', $event)" view-type="topology" />
null
train
train
2023-07-05T12:13:48
"2023-07-04T13:01:31Z"
brian-mulier-p
train
kestra-io/kestra/1694_1714
kestra-io/kestra
kestra-io/kestra/1694
kestra-io/kestra/1714
[ "keyword_pr_to_issue" ]
ed80eb5c06244f00736daf3e01ad07004d321bfc
9e64c837b7502f8a1c292f754af02abbbaba6fcd
[ "I think a simple fix would be to show Collapse all if there is any taskRun expanded and Expand all in any other case" ]
[]
"2023-07-05T11:39:27Z"
[ "bug", "enhancement", "frontend" ]
Collapse all is displayed on logs while there is no logs open
### Expected Behavior _No response_ ### Actual Behaviour If settings -> failed task logs open only and there is no failed task, nothing is opened and still the button is "Collapse all" while it should be expand all (only if no failed task). For now we have to click on "Collapse all" which does nothing then the button goes to "Expand all" which then works ### Steps To Reproduce _No response_ ### Environment Information - Kestra Version: - Operating System (OS / Docker / Kubernetes): - Java Version (If not docker): ### Example flow _No response_
[ "ui/src/components/executions/Logs.vue", "ui/src/components/logs/LogList.vue" ]
[ "ui/src/components/executions/Logs.vue", "ui/src/components/logs/LogList.vue" ]
[]
diff --git a/ui/src/components/executions/Logs.vue b/ui/src/components/executions/Logs.vue index 1597cc6222..70fb3bcfc6 100644 --- a/ui/src/components/executions/Logs.vue +++ b/ui/src/components/executions/Logs.vue @@ -40,6 +40,7 @@ :exclude-metas="['namespace', 'flowId', 'taskId', 'executionId']" :filter="filter" @follow="forwardEvent('follow', $event)" + @opened-taskruns-count="openedTaskrunsCounts[taskRun.id] = $event" :logs-to-open-parent="logsToOpen" /> <div v-else-if="execution.state.current !== State.RUNNING"> @@ -52,6 +53,7 @@ :exclude-metas="['namespace', 'flowId', 'taskId', 'executionId']" :filter="filter" @follow="forwardEvent('follow', $event)" + @opened-taskruns-count="openedTaskrunsCounts[taskRun.id] = $event" :logs-to-open-parent="logsToOpen" /> </div> @@ -67,7 +69,6 @@ import LogLevelSelector from "../logs/LogLevelSelector.vue"; import Collapse from "../layout/Collapse.vue"; import State from "../../utils/state"; - import {logDisplayTypes} from "../../utils/constants"; export default { components: { @@ -83,7 +84,8 @@ fullscreen: false, level: undefined, filter: undefined, - logsToOpen: undefined + logsToOpen: undefined, + openedTaskrunsCounts: {} }; }, created() { @@ -110,14 +112,12 @@ } return fullList }, - logDisplayButtonText() { - if (this.logsToOpen) { - return this.logsToOpen.length !== 0 ? this.$t("collapse all") : this.$t("expand all") - } else { - const logDisplay = localStorage.getItem("logDisplay") || logDisplayTypes.DEFAULT; - return logDisplay === logDisplayTypes.HIDDEN ? this.$t("expand all") : this.$t("collapse all") - } + openedTaskrunsTotal() { + return Object.values(this.openedTaskrunsCounts).reduce((prev, count) => prev + count, 0); }, + logDisplayButtonText() { + return this.openedTaskrunsTotal === 0 ? this.$t("expand all") : this.$t("collapse all") + } }, methods: { downloadContent() { @@ -145,12 +145,7 @@ this.$router.push({query: {...this.$route.query, q: this.filter, level: this.level, page: 1}}); }, handleLogDisplay() { - const logDisplay = localStorage.getItem("logDisplay") || logDisplayTypes.DEFAULT; - if (this.logsToOpen) { - this.logsToOpen.length === 0 ? this.logsToOpen = State.arrayAllStates().map(s => s.name) : this.logsToOpen = [] - return; - } - if (logDisplay === logDisplayTypes.HIDDEN ) { + if(this.openedTaskrunsTotal === 0) { this.logsToOpen = State.arrayAllStates().map(s => s.name) } else { this.logsToOpen = [] diff --git a/ui/src/components/logs/LogList.vue b/ui/src/components/logs/LogList.vue index 3a28a6ca38..5e741d4c86 100644 --- a/ui/src/components/logs/LogList.vue +++ b/ui/src/components/logs/LogList.vue @@ -197,6 +197,7 @@ Duration, TaskIcon, }, + emits: ["opened-taskruns-count"], props: { level: { type: String, @@ -254,6 +255,9 @@ }; }, watch: { + "showLogs.length": function(openedTaskrunsCount) { + this.$emit("opened-taskruns-count", openedTaskrunsCount); + }, level: function () { this.page = 1; this.logsList = [];
null
test
train
2023-07-05T12:33:30
"2023-07-04T12:55:55Z"
brian-mulier-p
train
kestra-io/kestra/1715_1717
kestra-io/kestra
kestra-io/kestra/1715
kestra-io/kestra/1717
[ "keyword_pr_to_issue" ]
64c9b22489ac91d38be84d0ce1448f5f388e8fc7
988beefabccc07de412e5314a19b174a16232a4d
[]
[]
"2023-07-05T13:36:34Z"
[]
Change prefix from SECRETS_ to SECRET_ for consistency with the `secret()` function
### Feature description Given that this prefix is added for each (singular) secret, SECRET_ prefix seems more natural and easier to understand/remember. Also, the `secret()` function currently can only retrieve one secret at a time so plural SECRETS_ can be misleading. cc @brian-mulier-p 🙏
[ "build.gradle", "core/src/main/java/io/kestra/core/secret/SecretService.java" ]
[ "build.gradle", "core/src/main/java/io/kestra/core/secret/SecretService.java" ]
[]
diff --git a/build.gradle b/build.gradle index cfe5455df3..3e4832e055 100644 --- a/build.gradle +++ b/build.gradle @@ -169,8 +169,8 @@ subprojects { systemProperty 'user.language', 'en' systemProperty 'user.country', 'US' - environment 'SECRETS_MY_SECRET', "{\"secretKey\":\"secretValue\"}".bytes.encodeBase64().toString() - environment 'SECRETS_NON_B64_SECRET', "some secret value" + environment 'SECRET_MY_SECRET', "{\"secretKey\":\"secretValue\"}".bytes.encodeBase64().toString() + environment 'SECRET_NON_B64_SECRET', "some secret value" } testlogger { diff --git a/core/src/main/java/io/kestra/core/secret/SecretService.java b/core/src/main/java/io/kestra/core/secret/SecretService.java index 05b9e859e8..5cb9bbd98a 100644 --- a/core/src/main/java/io/kestra/core/secret/SecretService.java +++ b/core/src/main/java/io/kestra/core/secret/SecretService.java @@ -16,7 +16,7 @@ @Singleton @Slf4j public class SecretService { - private static final String SECRET_PREFIX = "SECRETS_"; + private static final String SECRET_PREFIX = "SECRET_"; private Map<String, String> decodedSecrets; @PostConstruct @@ -40,7 +40,7 @@ public String findSecret(String namespace, String key) throws IOException, Illeg return Optional .ofNullable(decodedSecrets.get(key.toUpperCase())) .orElseThrow(() -> new IllegalVariableEvaluationException("Unable to find secret '" + key + "'. " + - "You should add it in your environment variables as 'SECRETS_" + key.toUpperCase() + + "You should add it in your environment variables as '" + SECRET_PREFIX + key.toUpperCase() + "' with base64-encoded value." )); }
null
val
train
2023-07-05T14:48:55
"2023-07-05T12:51:18Z"
anna-geller
train
kestra-io/kestra/1697_1718
kestra-io/kestra
kestra-io/kestra/1697
kestra-io/kestra/1718
[ "keyword_pr_to_issue" ]
ef8669f91112c38bb03f8e0fb8723c7f51f62a81
9a21fd5f1e5abc6b5f2ea8b2e383056324f9e3f6
[]
[]
"2023-07-05T14:45:02Z"
[ "bug", "enhancement", "frontend" ]
Moving outside task in place of a Dag subtask which others depend on break everything
### Expected Behavior _No response_ ### Actual Behaviour Here I moved "hello" task which was outside, in place of the "b" task which is a dependance of "a" task. It breaks everything -> yaml editor was properly updated (although incorrect due to missing dependency) while the topology looks buggy and can't move my "hello" task except by drag&dropping on the underneath "b" task which moves back the "hello" task outside and "b" task inside due to flow becoming valid again ![image](https://github.com/kestra-io/kestra/assets/37618489/f9c5309f-d5b8-40c1-aac4-ff4fe8a4bea0) ### Steps To Reproduce Create a Dag task with two task, including one which is dependant of the other Create a task outside of the Dag Move the outside task in place of the dependance task -> If you move the outside task on a dag task which has no dependency it works properly ### Environment Information - Kestra Version: 0.10.0-SNAPSHOT - Operating System (OS / Docker / Kubernetes): - Java Version (If not docker): ### Example flow ``` id: hello-worldf namespace: dev labels: some: flowLabel tasks: - id: dag type: io.kestra.core.tasks.flows.Dag tasks: - task: id: a type: io.kestra.core.tasks.flows.Flow namespace: dev flowId: hello-world dependsOn: - b - task: id: b type: io.kestra.core.tasks.scripts.Bash commands: - "sleep 5" - task: id: c type: io.kestra.core.tasks.log.Log message: Ended all dependsOn: - a - id: hello type: io.kestra.core.tasks.log.Log message: Kestra team wishes you a great day! 👋 ```
[ "ui/src/components/inputs/LowCodeEditor.vue", "ui/src/translations.json", "ui/src/utils/yamlUtils.js" ]
[ "ui/src/components/inputs/LowCodeEditor.vue", "ui/src/translations.json", "ui/src/utils/yamlUtils.js" ]
[]
diff --git a/ui/src/components/inputs/LowCodeEditor.vue b/ui/src/components/inputs/LowCodeEditor.vue index 8d0a33cb95..8923583025 100644 --- a/ui/src/components/inputs/LowCodeEditor.vue +++ b/ui/src/components/inputs/LowCodeEditor.vue @@ -208,12 +208,21 @@ // check multiple intersection with task const taskNode2 = e.intersections.find(n => n.type === "task"); if (taskNode2) { - emit("on-edit", YamlUtils.swapTasks(props.source, taskNode1.id, taskNode2.id)) + try { + emit("on-edit", YamlUtils.swapTasks(props.source, taskNode1.id, taskNode2.id)) + } catch (e) { + store.dispatch("core/showMessage", { + variant: "error", + title: t("cannot swap tasks"), + message: t(e.message, e.messageOptions) + }); + taskNode1.position = lastPosition.value; + } } else { - getNodes.value.find(n => n.id === e.node.id).position = lastPosition.value; + taskNode1.position = lastPosition.value; } } else { - getNodes.value.find(n => n.id === e.node.id).position = lastPosition.value; + e.node.position = lastPosition.value; } resetNodesStyle(); e.node.style = {...e.node.style, zIndex: 1} diff --git a/ui/src/translations.json b/ui/src/translations.json index d986793b6d..ff07889c0e 100644 --- a/ui/src/translations.json +++ b/ui/src/translations.json @@ -457,7 +457,9 @@ "collapse all": "Collapse all", "log expand setting": "Log default display", "slack support": "Ask help on our Slack", - "error detected": "Error detected" + "error detected": "Error detected", + "cannot swap tasks": "Can't swap the tasks", + "dependency task": "Task {taskId} is a dependency of another task" }, "fr": { "id": "Identifiant", @@ -919,6 +921,8 @@ "collapse all": "Masquer tout", "log expand setting": "Affichage par défaut des journaux", "slack support": "Demandez de l'aide sur notre Slack", - "error detected": "Erreur détectée" + "error detected": "Erreur détectée", + "cannot swap tasks": "Impossible de permuter les tâches", + "dependency task": "La tâche {taskId} est une dépendance d'une autre tâche" } } diff --git a/ui/src/utils/yamlUtils.js b/ui/src/utils/yamlUtils.js index 67d6cbdbce..45dfbbfb79 100644 --- a/ui/src/utils/yamlUtils.js +++ b/ui/src/utils/yamlUtils.js @@ -205,6 +205,17 @@ export default class YamlUtils { const task1 = YamlUtils._extractTask(yamlDoc, taskId1); const task2 = YamlUtils._extractTask(yamlDoc, taskId2); + yaml.visit(yamlDoc, { + Pair(_, pair) { + if (pair.key.value === 'dependsOn' && pair.value.items.map(e => e.value).includes(taskId2)) { + throw { + message: 'dependency task', + messageOptions: { taskId: taskId2 } + }; + } + } + }); + YamlUtils._extractTask(yamlDoc, taskId1, () => task2); YamlUtils._extractTask(yamlDoc, taskId2, () => task1);
null
train
train
2023-07-05T15:55:51
"2023-07-04T14:49:30Z"
brian-mulier-p
train
kestra-io/kestra/1321_1741
kestra-io/kestra
kestra-io/kestra/1321
kestra-io/kestra/1741
[ "keyword_pr_to_issue" ]
226e971496407e7e3a40890a0be97014bcd63c98
d1194e919c985cb4e56a5b3568172f4a257153fa
[]
[ "```suggestion\r\n testImplementation project(':runner-memory')\r\n```\r\n\r\nThis should be removed to prove it's working ;)", "You should only need H2", "Well, I prefere to keep those warnings but ... OK-ish", "We've used them over 100 times in the application, so I don't see the need for spam to tell us that we're doing unchecked cast unless we plan to correct it in the short term.", "No, because there are utils I need in them", "Is it really needed ?\r\nWe shouldn't normally have two implementations on the same application context." ]
"2023-07-12T09:30:21Z"
[]
Migrate webserver test from memory to H2
### Issue description Since many endpoints are not implemented in the memory repositories, they cannot be tested. We need to rewrite the test to work with a H2 database and add the missing tests
[ "jdbc-h2/src/main/java/io/kestra/repository/h2/H2SettingRepository.java", "webserver/build.gradle" ]
[ "jdbc-h2/src/main/java/io/kestra/repository/h2/H2SettingRepository.java", "webserver/build.gradle" ]
[ "webserver/src/test/java/io/kestra/webserver/controllers/BlueprintControllerTest.java", "webserver/src/test/java/io/kestra/webserver/controllers/ExecutionControllerTest.java", "webserver/src/test/java/io/kestra/webserver/controllers/FlowControllerTest.java", "webserver/src/test/java/io/kestra/webserver/controllers/MetricControllerTest.java", "webserver/src/test/java/io/kestra/webserver/controllers/MiscControllerTest.java", "webserver/src/test/java/io/kestra/webserver/controllers/TemplateControllerTest.java", "webserver/src/test/java/io/kestra/webserver/controllers/h2/JdbcH2ControllerTest.java", "webserver/src/test/java/io/kestra/webserver/filter/AuthenticationFilterTest.java", "webserver/src/test/resources/application.yml" ]
diff --git a/jdbc-h2/src/main/java/io/kestra/repository/h2/H2SettingRepository.java b/jdbc-h2/src/main/java/io/kestra/repository/h2/H2SettingRepository.java index 27170a4a27..4cb1c17b24 100644 --- a/jdbc-h2/src/main/java/io/kestra/repository/h2/H2SettingRepository.java +++ b/jdbc-h2/src/main/java/io/kestra/repository/h2/H2SettingRepository.java @@ -1,9 +1,7 @@ package io.kestra.repository.h2; import io.kestra.core.models.Setting; -import io.kestra.core.models.triggers.Trigger; import io.kestra.jdbc.repository.AbstractJdbcSettingRepository; -import io.kestra.jdbc.repository.AbstractJdbcTriggerRepository; import io.micronaut.context.ApplicationContext; import jakarta.inject.Inject; import jakarta.inject.Singleton; diff --git a/webserver/build.gradle b/webserver/build.gradle index 47b399d581..d0f2c204b9 100644 --- a/webserver/build.gradle +++ b/webserver/build.gradle @@ -22,9 +22,12 @@ dependencies { // test testImplementation project(':core').sourceSets.test.output - testImplementation project(':repository-memory') - testImplementation project(':runner-memory') testImplementation project(':storage-local') testImplementation("com.github.tomakehurst:wiremock-jre8:2.35.0") + + testImplementation project(':jdbc') + testImplementation project(':jdbc').sourceSets.test.output + testImplementation project(':jdbc-h2') + testImplementation("io.micronaut.sql:micronaut-jooq") }
diff --git a/webserver/src/test/java/io/kestra/webserver/controllers/BlueprintControllerTest.java b/webserver/src/test/java/io/kestra/webserver/controllers/BlueprintControllerTest.java index 15740e77eb..7c496b03a9 100644 --- a/webserver/src/test/java/io/kestra/webserver/controllers/BlueprintControllerTest.java +++ b/webserver/src/test/java/io/kestra/webserver/controllers/BlueprintControllerTest.java @@ -3,7 +3,6 @@ import com.github.tomakehurst.wiremock.client.WireMock; import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo; import com.github.tomakehurst.wiremock.junit5.WireMockTest; -import io.kestra.core.models.hierarchies.FlowGraph; import io.kestra.core.repositories.ArrayListTotal; import io.kestra.webserver.responses.PagedResults; import io.micronaut.core.type.Argument; @@ -77,6 +76,7 @@ void blueprintFlow(WireMockRuntimeInfo wmRuntimeInfo) { wireMock.verifyThat(getRequestedFor(urlEqualTo("/v1/blueprints/id_1/flow"))); } + @SuppressWarnings("unchecked") @Test void blueprintGraph(WireMockRuntimeInfo wmRuntimeInfo) { stubFor(get(urlMatching("/v1/blueprints/id_1/graph.*")) diff --git a/webserver/src/test/java/io/kestra/webserver/controllers/ExecutionControllerTest.java b/webserver/src/test/java/io/kestra/webserver/controllers/ExecutionControllerTest.java index cb1b41c280..7a5b5ff868 100644 --- a/webserver/src/test/java/io/kestra/webserver/controllers/ExecutionControllerTest.java +++ b/webserver/src/test/java/io/kestra/webserver/controllers/ExecutionControllerTest.java @@ -3,19 +3,19 @@ import com.google.common.collect.ImmutableMap; import io.kestra.core.models.Label; import io.kestra.core.models.executions.Execution; -import io.kestra.core.models.executions.TaskRun; import io.kestra.core.models.flows.Flow; import io.kestra.core.models.flows.State; import io.kestra.core.models.storage.FileMetas; import io.kestra.core.models.triggers.types.Webhook; +import io.kestra.core.models.executions.TaskRun; import io.kestra.core.queues.QueueFactoryInterface; import io.kestra.core.queues.QueueInterface; import io.kestra.core.repositories.ExecutionRepositoryInterface; import io.kestra.core.repositories.FlowRepositoryInterface; -import io.kestra.core.runners.AbstractMemoryRunnerTest; import io.kestra.core.runners.InputsTest; import io.kestra.core.utils.Await; import io.kestra.core.utils.IdUtils; +import io.kestra.webserver.controllers.h2.JdbcH2ControllerTest; import io.kestra.webserver.responses.PagedResults; import io.micronaut.core.type.Argument; import io.micronaut.data.model.Pageable; @@ -45,7 +45,7 @@ import static org.hamcrest.Matchers.*; import static org.junit.jupiter.api.Assertions.assertThrows; -class ExecutionControllerTest extends AbstractMemoryRunnerTest { +class ExecutionControllerTest extends JdbcH2ControllerTest { @Inject EmbeddedServer embeddedServer; @@ -92,8 +92,6 @@ private Execution triggerExecution(String namespace, String flowId, MultipartBod Execution.class ); } - - private MultipartBody createInputsFlowBody() { // Trigger execution File applicationFile = new File(Objects.requireNonNull( @@ -434,7 +432,7 @@ void downloadFile() throws TimeoutException { FileMetas.class ).blockingFirst(); - assertThat(metas.getSize(), equalTo(648L)); + assertThat(metas.getSize(), equalTo(2193L)); String newExecutionId = IdUtils.create(); @@ -551,4 +549,14 @@ void killPaused() throws TimeoutException, InterruptedException { Execution.class); assertThat(execution.getState().isPaused(), is(false)); } + + @Test + void find() throws TimeoutException, InterruptedException { + PagedResults<?> executions = client.toBlocking().retrieve( + HttpRequest.GET("/api/v1/executions/search"), PagedResults.class + ); + + assertThat(executions.getTotal(), is(0L)); + + } } diff --git a/webserver/src/test/java/io/kestra/webserver/controllers/FlowControllerTest.java b/webserver/src/test/java/io/kestra/webserver/controllers/FlowControllerTest.java index 596630f4b4..f0620cd518 100644 --- a/webserver/src/test/java/io/kestra/webserver/controllers/FlowControllerTest.java +++ b/webserver/src/test/java/io/kestra/webserver/controllers/FlowControllerTest.java @@ -10,14 +10,14 @@ import io.kestra.core.models.hierarchies.FlowGraph; import io.kestra.core.models.tasks.Task; import io.kestra.core.models.validations.ValidateConstraintViolation; -import io.kestra.core.runners.AbstractMemoryRunnerTest; import io.kestra.core.serializers.YamlFlowParser; import io.kestra.core.tasks.debugs.Return; import io.kestra.core.tasks.flows.Sequential; import io.kestra.core.utils.IdUtils; import io.kestra.core.utils.TestsUtils; -import io.kestra.repository.memory.MemoryFlowRepository; +import io.kestra.jdbc.repository.AbstractJdbcFlowRepository; import io.kestra.webserver.controllers.domain.IdWithNamespace; +import io.kestra.webserver.controllers.h2.JdbcH2ControllerTest; import io.kestra.webserver.responses.BulkResponse; import io.kestra.webserver.responses.PagedResults; import io.micronaut.core.type.Argument; @@ -37,7 +37,6 @@ import java.io.File; import java.io.IOException; -import java.net.URISyntaxException; import java.net.URL; import java.nio.charset.Charset; import java.nio.file.Files; @@ -51,22 +50,20 @@ import static org.hamcrest.Matchers.*; import static org.junit.jupiter.api.Assertions.assertThrows; -class FlowControllerTest extends AbstractMemoryRunnerTest { +class FlowControllerTest extends JdbcH2ControllerTest { @Inject @Client("/") RxHttpClient client; @Inject - MemoryFlowRepository memoryFlowRepository; + AbstractJdbcFlowRepository jdbcFlowRepository; @BeforeEach - protected void init() throws IOException, URISyntaxException { - memoryFlowRepository.findAll() - .forEach(memoryFlowRepository::delete); + protected void init() { + jdbcFlowRepository.findAll() + .forEach(jdbcFlowRepository::delete); - super.init(); - - TestsUtils.loads(repositoryLoader); + super.setup(); } @Test @@ -154,8 +151,8 @@ void updateNamespace() { // f3 & f4 must be updated updated = client.toBlocking().retrieve(HttpRequest.POST("/api/v1/flows/io.kestra.updatenamespace", flows), Argument.listOf(Flow.class)); assertThat(updated.size(), is(4)); - assertThat(updated.get(0).getInputs().get(0).getName(), is("2")); - assertThat(updated.get(1).getInputs().get(0).getName(), is("1")); + assertThat(updated.get(2).getInputs().get(0).getName(), is("3-3")); + assertThat(updated.get(3).getInputs().get(0).getName(), is("4")); // f1 & f2 must be deleted assertThrows(HttpClientResponseException.class, () -> { diff --git a/webserver/src/test/java/io/kestra/webserver/controllers/MetricControllerTest.java b/webserver/src/test/java/io/kestra/webserver/controllers/MetricControllerTest.java index 789ea894de..15081d193d 100644 --- a/webserver/src/test/java/io/kestra/webserver/controllers/MetricControllerTest.java +++ b/webserver/src/test/java/io/kestra/webserver/controllers/MetricControllerTest.java @@ -2,9 +2,8 @@ import io.kestra.core.models.executions.Execution; import io.kestra.core.models.executions.MetricEntry; -import io.kestra.core.repositories.ArrayListTotal; -import io.kestra.core.runners.AbstractMemoryRunnerTest; -import io.kestra.repository.memory.MemoryMetricRepository; +import io.kestra.jdbc.repository.AbstractJdbcMetricRepository; +import io.kestra.webserver.controllers.h2.JdbcH2ControllerTest; import io.kestra.webserver.responses.PagedResults; import io.micronaut.core.type.Argument; import io.micronaut.http.HttpRequest; @@ -15,12 +14,11 @@ import jakarta.inject.Inject; import org.junit.jupiter.api.Test; -import java.util.List; - -import static org.hamcrest.Matchers.*; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.notNullValue; -class MetricControllerTest extends AbstractMemoryRunnerTest { +class MetricControllerTest extends JdbcH2ControllerTest { private static final String TESTS_FLOW_NS = "io.kestra.tests"; @Inject @@ -28,7 +26,7 @@ class MetricControllerTest extends AbstractMemoryRunnerTest { RxHttpClient client; @Inject - MemoryMetricRepository memoryMetricRepository; + AbstractJdbcMetricRepository jdbcMetricRepository; @SuppressWarnings("unchecked") @Test diff --git a/webserver/src/test/java/io/kestra/webserver/controllers/MiscControllerTest.java b/webserver/src/test/java/io/kestra/webserver/controllers/MiscControllerTest.java index 08b3c6ce78..fdd410e00c 100644 --- a/webserver/src/test/java/io/kestra/webserver/controllers/MiscControllerTest.java +++ b/webserver/src/test/java/io/kestra/webserver/controllers/MiscControllerTest.java @@ -1,24 +1,17 @@ package io.kestra.webserver.controllers; -import io.kestra.core.models.Setting; import io.kestra.core.models.collectors.ExecutionUsage; -import io.kestra.core.repositories.SettingRepositoryInterface; -import io.kestra.core.runners.AbstractMemoryRunnerTest; +import io.kestra.webserver.controllers.h2.JdbcH2ControllerTest; import io.micronaut.http.client.annotation.Client; import io.micronaut.rxjava2.http.client.RxHttpClient; -import io.micronaut.test.annotation.MockBean; import jakarta.inject.Inject; import org.junit.jupiter.api.Test; -import java.util.Collections; -import java.util.List; -import java.util.Optional; -import javax.validation.ConstraintViolationException; - import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.notNullValue; -class MiscControllerTest extends AbstractMemoryRunnerTest { +class MiscControllerTest extends JdbcH2ControllerTest { @Inject @Client("/") RxHttpClient client; @@ -47,29 +40,4 @@ void executionUsage() { assertThat(response, notNullValue()); // the memory executor didn't support daily statistics so we cannot have real execution usage } - - @MockBean - SettingRepositoryInterface settingRepository() { - return new SettingRepositoryInterface() { - @Override - public Optional<Setting> findByKey(String key) { - return Optional.empty(); - } - - @Override - public List<Setting> findAll() { - return Collections.emptyList(); - } - - @Override - public Setting save(Setting setting) throws ConstraintViolationException { - return setting; - } - - @Override - public Setting delete(Setting setting) { - return setting; - } - }; - } } \ No newline at end of file diff --git a/webserver/src/test/java/io/kestra/webserver/controllers/TemplateControllerTest.java b/webserver/src/test/java/io/kestra/webserver/controllers/TemplateControllerTest.java index e7c5252f1b..825064bf8e 100644 --- a/webserver/src/test/java/io/kestra/webserver/controllers/TemplateControllerTest.java +++ b/webserver/src/test/java/io/kestra/webserver/controllers/TemplateControllerTest.java @@ -2,11 +2,11 @@ import io.kestra.core.models.tasks.Task; import io.kestra.core.models.templates.Template; -import io.kestra.core.runners.AbstractMemoryRunnerTest; import io.kestra.core.tasks.debugs.Return; import io.kestra.core.utils.IdUtils; -import io.kestra.repository.memory.MemoryTemplateRepository; +import io.kestra.jdbc.repository.AbstractJdbcTemplateRepository; import io.kestra.webserver.controllers.domain.IdWithNamespace; +import io.kestra.webserver.controllers.h2.JdbcH2ControllerTest; import io.kestra.webserver.responses.BulkResponse; import io.kestra.webserver.responses.PagedResults; import io.micronaut.core.type.Argument; @@ -36,20 +36,20 @@ import static org.hamcrest.Matchers.is; import static org.junit.jupiter.api.Assertions.assertThrows; -class TemplateControllerTest extends AbstractMemoryRunnerTest { +class TemplateControllerTest extends JdbcH2ControllerTest { @Inject @Client("/") RxHttpClient client; @Inject - MemoryTemplateRepository templateRepository; + AbstractJdbcTemplateRepository templateRepository; @BeforeEach protected void init() throws IOException, URISyntaxException { templateRepository.findAll() .forEach(templateRepository::delete); - super.init(); + super.setup(); } private Template createTemplate() { diff --git a/webserver/src/test/java/io/kestra/webserver/controllers/h2/JdbcH2ControllerTest.java b/webserver/src/test/java/io/kestra/webserver/controllers/h2/JdbcH2ControllerTest.java new file mode 100644 index 0000000000..76fc421e8f --- /dev/null +++ b/webserver/src/test/java/io/kestra/webserver/controllers/h2/JdbcH2ControllerTest.java @@ -0,0 +1,40 @@ +package io.kestra.webserver.controllers.h2; + + +import io.kestra.core.repositories.LocalFlowRepositoryLoader; +import io.kestra.core.runners.RunnerUtils; +import io.kestra.core.runners.StandAloneRunner; +import io.kestra.core.utils.TestsUtils; +import io.kestra.jdbc.JdbcTestUtils; +import io.micronaut.test.extensions.junit5.annotation.MicronautTest; +import jakarta.inject.Inject; +import lombok.SneakyThrows; +import org.junit.jupiter.api.BeforeEach; + +@MicronautTest(transactional = false) +public class JdbcH2ControllerTest { + @Inject + private StandAloneRunner runner; + + @Inject + private JdbcTestUtils jdbcTestUtils; + + @Inject + protected RunnerUtils runnerUtils; + + @Inject + protected LocalFlowRepositoryLoader repositoryLoader; + + @SneakyThrows + @BeforeEach + protected void setup() { + jdbcTestUtils.drop(); + jdbcTestUtils.migrate(); + + TestsUtils.loads(repositoryLoader); + + if (!runner.isRunning()) { + runner.run(); + } + } +} diff --git a/webserver/src/test/java/io/kestra/webserver/filter/AuthenticationFilterTest.java b/webserver/src/test/java/io/kestra/webserver/filter/AuthenticationFilterTest.java index f8b29163e9..6210f6c96e 100644 --- a/webserver/src/test/java/io/kestra/webserver/filter/AuthenticationFilterTest.java +++ b/webserver/src/test/java/io/kestra/webserver/filter/AuthenticationFilterTest.java @@ -2,7 +2,7 @@ import io.kestra.core.models.Setting; import io.kestra.core.repositories.SettingRepositoryInterface; -import io.kestra.core.runners.AbstractMemoryRunnerTest; +import io.kestra.webserver.controllers.h2.JdbcH2ControllerTest; import io.micronaut.context.annotation.Property; import io.micronaut.context.annotation.Value; import io.micronaut.http.HttpRequest; @@ -14,17 +14,17 @@ import jakarta.inject.Inject; import org.junit.jupiter.api.Test; +import javax.validation.ConstraintViolationException; import java.util.Collections; import java.util.List; import java.util.Optional; -import javax.validation.ConstraintViolationException; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.junit.jupiter.api.Assertions.assertThrows; @Property(name = "kestra.server.basic-auth.enabled", value = "true") -class AuthenticationFilterTest extends AbstractMemoryRunnerTest { +class AuthenticationFilterTest extends JdbcH2ControllerTest { @Inject @Client("/") private RxHttpClient client; @@ -64,29 +64,4 @@ void testAuthenticated() { assertThat(response.getStatus(), is(HttpStatus.OK)); } - - @MockBean - SettingRepositoryInterface settingRepository() { - return new SettingRepositoryInterface() { - @Override - public Optional<Setting> findByKey(String key) { - return Optional.empty(); - } - - @Override - public List<Setting> findAll() { - return Collections.emptyList(); - } - - @Override - public Setting save(Setting setting) throws ConstraintViolationException { - return setting; - } - - @Override - public Setting delete(Setting setting) { - return setting; - } - }; - } } \ No newline at end of file diff --git a/webserver/src/test/resources/application.yml b/webserver/src/test/resources/application.yml index b18ae33884..2dc1c5dd5d 100644 --- a/webserver/src/test/resources/application.yml +++ b/webserver/src/test/resources/application.yml @@ -11,10 +11,6 @@ micronaut: url: http://localhost:8081 kestra: - repository: - type: memory - queue: - type: memory storage: type: local local: @@ -34,3 +30,59 @@ kestra: open-urls: - "/ping" - "/api/v1/executions/webhook/" + queue: + type: h2 + repository: + type: h2 + jdbc: + tables: + queues: + table: "queues" + flows: + table: "flows" + cls: io.kestra.core.models.flows.Flow + executions: + table: "executions" + cls: io.kestra.core.models.executions.Execution + templates: + table: "templates" + cls: io.kestra.core.models.templates.Template + triggers: + table: "triggers" + cls: io.kestra.core.models.triggers.Trigger + logs: + table: "logs" + cls: io.kestra.core.models.executions.LogEntry + metrics: + table: "metrics" + cls: io.kestra.core.models.executions.MetricEntry + multipleconditions: + table: "multipleconditions" + cls: io.kestra.core.models.triggers.multipleflows.MultipleConditionWindow + workertaskexecutions: + table: "workertaskexecutions" + cls: io.kestra.core.runners.WorkerTaskExecution + executorstate: + table: "executorstate" + cls: io.kestra.core.runners.ExecutorState + executordelayed: + table: "executordelayed" + cls: io.kestra.core.runners.ExecutionDelay + settings: + table: "settings" + cls: io.kestra.core.models.Setting + flowtopologies: + table: "flow_topologies" + cls: io.kestra.core.models.topologies.FlowTopology +datasources: + h2: + url: jdbc:h2:mem:public;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE + username: sa + password: "" + driverClassName: org.h2.Driver +flyway: + datasources: + h2: + enabled: true + locations: + - classpath:migrations/h2 \ No newline at end of file
val
train
2023-07-21T10:08:03
"2023-05-16T17:44:24Z"
Skraye
train
kestra-io/kestra/1745_1746
kestra-io/kestra
kestra-io/kestra/1745
kestra-io/kestra/1746
[ "keyword_pr_to_issue" ]
c9c2e67ac7bbfaa202b29b521dfc96ed118cf897
d102e2265d8874f3be00ec28cd0f7424be54df43
[]
[]
"2023-07-13T15:12:44Z"
[ "bug" ]
Infinite loop in the executor if a flowable task fail
### Expected Behavior Even if a flowable task fail, there should not be any infinite loop in the executor. ### Actual Behaviour The executor entre an infinite loop as it will not be able to return the next task to run so the same task will be executed again and again. ### Steps To Reproduce _No response_ ### Environment Information - Kestra Version: 0.10 - Operating System (OS / Docker / Kubernetes): - Java Version (If not docker): ### Example flow ```yaml id: infinite-looping namespace: bug tasks: - id: channel type: io.kestra.core.tasks.flows.EachParallel tasks: - id: type type: io.kestra.core.tasks.flows.EachParallel tasks: - id: vision type: io.kestra.core.tasks.flows.EachParallel tasks: - id: metaseg_date type: io.kestra.core.tasks.flows.EachParallel tasks: - id: if type: io.kestra.core.tasks.flows.If condition: "{{parents[0].taskrun.value == 'CUMULATIVE' and {% for entry in json(taskrun.value) %}{{ entry.key }}{% endfor %}== 'NEW_MONTH'}}" then: - id: when-true type: io.kestra.core.tasks.log.Log message: 'Condition was true' else: - id: when-false type: io.kestra.core.tasks.log.Log message: 'Condition was false' value: "[{\"NEW_MONTH\":\"2018-01-01\"}, {\"NEW_YEAR\":\"2018-01-01\"}, {\"EXISTING\":\"2018-01-01\"}]" value: "[\"MONTHLY\", \"CUMULATIVE\"]" value: "[\"INHABITANT\", \"MEMBERS\"]" value: "[\"OFFLINE_ONLY\", \"ONLINE_ONLY\", \"OMNICANAL\"]" ```
[ "core/src/main/java/io/kestra/core/runners/ExecutorService.java" ]
[ "core/src/main/java/io/kestra/core/runners/ExecutorService.java" ]
[ "core/src/test/java/io/kestra/core/tasks/flows/BadFlowableTest.java", "core/src/test/java/io/kestra/core/tasks/flows/TemplateTest.java", "core/src/test/resources/flows/valids/flowable-with-parent-fail.yaml" ]
diff --git a/core/src/main/java/io/kestra/core/runners/ExecutorService.java b/core/src/main/java/io/kestra/core/runners/ExecutorService.java index 7a5ff25cff..63717e1143 100644 --- a/core/src/main/java/io/kestra/core/runners/ExecutorService.java +++ b/core/src/main/java/io/kestra/core/runners/ExecutorService.java @@ -221,23 +221,27 @@ private List<TaskRun> childNextsTaskRun(Executor executor, TaskRun parentTaskRun if (parent instanceof FlowableTask<?> flowableParent) { - List<NextTaskRun> nexts = flowableParent.resolveNexts( - runContextFactory.of( - executor.getFlow(), - parent, + try { + List<NextTaskRun> nexts = flowableParent.resolveNexts( + runContextFactory.of( + executor.getFlow(), + parent, + executor.getExecution(), + parentTaskRun + ), executor.getExecution(), parentTaskRun - ), - executor.getExecution(), - parentTaskRun - ); - - if (nexts.size() > 0) { - return this.saveFlowableOutput( - nexts, - executor, - parentTaskRun ); + + if (nexts.size() > 0) { + return this.saveFlowableOutput( + nexts, + executor, + parentTaskRun + ); + } + } catch (Exception e) { + log.warn("Unable to resolve the next tasks to run", e); } }
diff --git a/core/src/test/java/io/kestra/core/tasks/flows/BadFlowableTest.java b/core/src/test/java/io/kestra/core/tasks/flows/BadFlowableTest.java index 03948608f0..1502fbae79 100644 --- a/core/src/test/java/io/kestra/core/tasks/flows/BadFlowableTest.java +++ b/core/src/test/java/io/kestra/core/tasks/flows/BadFlowableTest.java @@ -19,4 +19,12 @@ void sequential() throws TimeoutException { assertThat(execution.getTaskRunList(), hasSize(2)); assertThat(execution.getState().getCurrent(), is(State.Type.FAILED)); } + + @Test // this test is a non-reg for an infinite loop in the executor + void flowableWithParentFail() throws TimeoutException { + Execution execution = runnerUtils.runOne("io.kestra.tests", "flowable-with-parent-fail"); + + assertThat(execution.getTaskRunList(), hasSize(5)); + assertThat(execution.getState().getCurrent(), is(State.Type.FAILED)); + } } diff --git a/core/src/test/java/io/kestra/core/tasks/flows/TemplateTest.java b/core/src/test/java/io/kestra/core/tasks/flows/TemplateTest.java index 664a935780..a847a1412d 100644 --- a/core/src/test/java/io/kestra/core/tasks/flows/TemplateTest.java +++ b/core/src/test/java/io/kestra/core/tasks/flows/TemplateTest.java @@ -85,7 +85,7 @@ public static void withFailedTemplate(RunnerUtils runnerUtils, TemplateRepositor assertThat(execution.getTaskRunList(), hasSize(1)); assertThat(execution.getState().getCurrent(), is(State.Type.FAILED)); - LogEntry matchingLog = TestsUtils.awaitLog(logs, logEntry -> logEntry.getMessage().equals("Can't find flow template 'io.kestra.tests.invalid'") && logEntry.getLevel() == Level.ERROR); + LogEntry matchingLog = TestsUtils.awaitLog(logs, logEntry -> logEntry.getMessage().endsWith("Can't find flow template 'io.kestra.tests.invalid'") && logEntry.getLevel() == Level.ERROR); assertThat(matchingLog, notNullValue()); } diff --git a/core/src/test/resources/flows/valids/flowable-with-parent-fail.yaml b/core/src/test/resources/flows/valids/flowable-with-parent-fail.yaml new file mode 100644 index 0000000000..e5126089a9 --- /dev/null +++ b/core/src/test/resources/flows/valids/flowable-with-parent-fail.yaml @@ -0,0 +1,23 @@ +id: flowable-with-parent-fail +namespace: io.kestra.tests + +tasks: + - id: vision + type: io.kestra.core.tasks.flows.EachParallel + tasks: + - id: metaseg_date + type: io.kestra.core.tasks.flows.EachParallel + tasks: + - id: if + type: io.kestra.core.tasks.flows.If + condition: "{{parents[0].taskrun.value == 'CUMULATIVE' and {% for entry in json(taskrun.value) %}{{ entry.key }}{% endfor %}== 'NEW_MONTH'}}" + then: + - id: when-true + type: io.kestra.core.tasks.log.Log + message: 'Condition was true' + else: + - id: when-false + type: io.kestra.core.tasks.log.Log + message: 'Condition was false' + value: "[{\"NEW_MONTH\":\"2018-01-01\"}]" + value: "[\"MONTHLY\", \"CUMULATIVE\"]" \ No newline at end of file
train
train
2023-07-17T09:32:03
"2023-07-13T14:51:01Z"
loicmathieu
train
kestra-io/kestra/1748_1749
kestra-io/kestra
kestra-io/kestra/1748
kestra-io/kestra/1749
[ "keyword_pr_to_issue" ]
44ecc276a605bdf64e912215e882022134aeac60
0e656921feef6f45b8755f547452b4afe61f0ef5
[]
[]
"2023-07-13T15:33:21Z"
[ "bug", "enhancement" ]
JQ Function does not allow object / array destructuring afterwards
### Expected Behavior _No response_ ### Actual Behaviour The given flow is not working since JQ filter requires a JsonNode to do its thing (which we get using Jackson readTree). We should transform resulting ObjectNodes / ArrayNodes into Map / List to allow Pebble reading attributes down the line ### Steps To Reproduce _No response_ ### Environment Information - Kestra Version: - Operating System (OS / Docker / Kubernetes): - Java Version (If not docker): ### Example flow id: jq namespace: io.kestra.bmu tasks: - id: json type: io.kestra.core.tasks.debugs.Return format: | { "name": "test", "checks": [ { "table": "worker" }, { "table": "employee" } ] } - id: log_test type: io.kestra.core.tasks.log.Log message: | {% for check in outputs['json'].value | jq('.checks[]') %} {{ check.table }} {% endfor %}
[ "core/src/main/java/io/kestra/core/runners/pebble/filters/JqFilter.java" ]
[ "core/src/main/java/io/kestra/core/runners/pebble/filters/JqFilter.java" ]
[ "core/src/test/java/io/kestra/core/runners/pebble/filters/JqFilterTest.java" ]
diff --git a/core/src/main/java/io/kestra/core/runners/pebble/filters/JqFilter.java b/core/src/main/java/io/kestra/core/runners/pebble/filters/JqFilter.java index 0d7b8521ca..579c6c29b9 100644 --- a/core/src/main/java/io/kestra/core/runners/pebble/filters/JqFilter.java +++ b/core/src/main/java/io/kestra/core/runners/pebble/filters/JqFilter.java @@ -1,15 +1,12 @@ package io.kestra.core.runners.pebble.filters; import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.BooleanNode; -import com.fasterxml.jackson.databind.node.NullNode; -import com.fasterxml.jackson.databind.node.NumericNode; -import com.fasterxml.jackson.databind.node.TextNode; +import com.fasterxml.jackson.databind.node.*; +import io.kestra.core.serializers.JacksonMapper; import io.pebbletemplates.pebble.error.PebbleException; import io.pebbletemplates.pebble.extension.Filter; import io.pebbletemplates.pebble.template.EvaluationContext; import io.pebbletemplates.pebble.template.PebbleTemplate; -import io.kestra.core.serializers.JacksonMapper; import net.thisptr.jackson.jq.BuiltinFunctionLoader; import net.thisptr.jackson.jq.JsonQuery; import net.thisptr.jackson.jq.Scope; @@ -71,17 +68,21 @@ public Object apply(Object input, Map<String, Object> args, PebbleTemplate self, out.add(v.numberValue()); } else if (v instanceof BooleanNode) { out.add(v.booleanValue()); + } else if (v instanceof ObjectNode) { + out.add(JacksonMapper.ofJson().convertValue(v, Map.class)); + } else if (v instanceof ArrayNode) { + out.add(JacksonMapper.ofJson().convertValue(v, List.class)); } else { out.add(v); } }); } catch (Exception e) { - throw new Exception("Failed to resolve JQ expression '" + pattern + "' and value '" + input + "'", e); + throw new Exception("Failed to resolve JQ expression '" + pattern + "' and value '" + input + "'", e); } return out; } catch (Exception e) { - throw new PebbleException(e, "Unable to parse jq value '" + input + "' with type '" + input.getClass().getName() + "'", lineNumber, self.getName()); + throw new PebbleException(e, "Unable to parse jq value '" + input + "' with type '" + input.getClass().getName() + "'", lineNumber, self.getName()); } } }
diff --git a/core/src/test/java/io/kestra/core/runners/pebble/filters/JqFilterTest.java b/core/src/test/java/io/kestra/core/runners/pebble/filters/JqFilterTest.java index 886f2b2e9a..6d85c48e3f 100644 --- a/core/src/test/java/io/kestra/core/runners/pebble/filters/JqFilterTest.java +++ b/core/src/test/java/io/kestra/core/runners/pebble/filters/JqFilterTest.java @@ -4,6 +4,7 @@ import io.kestra.core.exceptions.IllegalVariableEvaluationException; import io.kestra.core.runners.VariableRenderer; import io.micronaut.test.extensions.junit5.annotation.MicronautTest; +import jakarta.inject.Inject; import org.junit.jupiter.api.Test; import java.time.ZoneId; @@ -12,7 +13,6 @@ import java.util.Arrays; import java.util.HashMap; import java.util.Map; -import jakarta.inject.Inject; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; @@ -128,4 +128,20 @@ void typed() throws IllegalVariableEvaluationException { assertThat(variableRenderer.render("{{ vars | jq(\".bool\") | first | className }}", vars), is("java.lang.Boolean")); assertThat(variableRenderer.render("{{ vars | jq(\".null\") | first | className }}", vars), is("")); } + + @Test + void object() throws IllegalVariableEvaluationException { + ImmutableMap<String, Object> vars = ImmutableMap.of( + "vars", ImmutableMap.of( + "object", Map.of("key", "value"), + "array", new String[]{"arrayValue"} + ) + ); + + String render = variableRenderer.render("{% set object = vars | jq(\".object\") %}{{object[0].key}}", vars); + assertThat(render, is("value")); + + render = variableRenderer.render("{% set array = vars | jq(\".array\") %}{{array[0][0]}}", vars); + assertThat(render, is("arrayValue")); + } }
train
train
2023-07-13T14:56:34
"2023-07-13T15:31:30Z"
brian-mulier-p
train
kestra-io/kestra/1750_1752
kestra-io/kestra
kestra-io/kestra/1750
kestra-io/kestra/1752
[ "keyword_pr_to_issue" ]
0e656921feef6f45b8755f547452b4afe61f0ef5
7507ada72d88945a82ba1fc57e9537f9ecdb888d
[ "Hi @vivane,\r\nThis issue has been fixed already, we will release a new version soon (probably today) with the fix." ]
[]
"2023-07-13T17:12:48Z"
[ "bug" ]
Windows executable is not working in 0.10.0
### Expected Behavior Server should run with no issues. ### Actual Behaviour Starting server gives the following output and fails. ` 'PK♥♦¶∟│▓╬jü2Θ╔' is not recognized as an internal or external command, operable program or batch file. '┘O)¼╫↓Σ▌DEÇ─m▲' is not recognized as an internal or external command, operable program or batch file. '¬█¢S‼' is not recognized as an internal or external command, operable program or batch file. ` ### Steps To Reproduce 1. Download the server JAR-file as instructed at https://kestra.io/docs/administrator-guide/deployment/manual. 2. Ran following command: `kestra-0.10.0.cmd server standalone --config config.yml` 3. Server start fails. 4. Server runs OK with 0.9.5. Here is the configuration file: ` datasources: postgres: url: jdbc:postgresql://localhost:5432/kestra driverClassName: org.postgresql.Driver username: kestra password: k3str4 kestra: repository: type: postgres storage: type: local local: base-path: "/app/storage" queue: type: postgres tasks: tmp-dir: path: /tmp/kestra-wd/tmp url: http://localhost:8080/ ` ### Environment Information - Kestra Version: 0.10.0 - Operating System (OS / Docker / Kubernetes): Windows 10, no docker - Java Version (If not docker): 17.0.7 ### Example flow _No response_
[ "gradle/jar/selfrun.bat" ]
[ "gradle/jar/selfrun.bat" ]
[]
diff --git a/gradle/jar/selfrun.bat b/gradle/jar/selfrun.bat index 34aab9a51e..87b6caee4a 100644 --- a/gradle/jar/selfrun.bat +++ b/gradle/jar/selfrun.bat @@ -43,7 +43,7 @@ IF %java_version% NEQ 0 ( REM Opens java.nio due to https://github.com/snowflakedb/snowflake-jdbc/issues/589 REM Opens java.util due to https://github.com/Azure/azure-sdk-for-java/issues/27806 -SET JAVA_ADD_OPENS="--add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED" +SET "JAVA_ADD_OPENS=--add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED" java %JAVA_OPTS% %JAVA_ADD_OPENS% -jar "%this%" %*
null
train
train
2023-07-13T19:11:59
"2023-07-13T15:42:22Z"
vivane
train
kestra-io/kestra/1769_1771
kestra-io/kestra
kestra-io/kestra/1769
kestra-io/kestra/1771
[ "keyword_pr_to_issue" ]
52eef24de19ae17d005a5c2c290ce28bde1a4b2e
932783c0981f6eea14c0a96c1fc7df50cb36d146
[]
[ "Already did the same somewhere and Ludo told me not to and let the default html link behaviour (meaning you encapsulate with `<a>` your button for eg.)", "Not needed anymore" ]
"2023-07-18T10:25:49Z"
[ "enhancement", "frontend" ]
Change Download link in output with proper button
### Feature description Related to #1767 , use a proper button for the Download link in output tab ![image](https://github.com/kestra-io/kestra/assets/46634684/a292065f-c6f6-4617-a6cf-70859abdc73c)
[ "ui/src/components/executions/VarValue.vue" ]
[ "ui/src/components/executions/VarValue.vue" ]
[]
diff --git a/ui/src/components/executions/VarValue.vue b/ui/src/components/executions/VarValue.vue index 5c320c8eac..4bc283155e 100644 --- a/ui/src/components/executions/VarValue.vue +++ b/ui/src/components/executions/VarValue.vue @@ -1,14 +1,11 @@ <template> - <el-link - v-if="isFile(value)" - :icon="Download" - target="_blank" - type="primary" - :href="itemUrl(value)" - > + <a class="el-button el-button--primary mt-2 mb-2 " v-if="isFile(value)" :href="itemUrl(value)" target="_blank"> + <Download /> + &nbsp; {{ $t('download') }} + &nbsp; <span v-if="humanSize">({{ humanSize }})</span> - </el-link> + </a> <span v-else> {{ value }} </span> @@ -34,8 +31,7 @@ }, itemUrl(value) { return `${apiRoot}executions/${this.execution.id}/file?path=${value}`; - }, - + } }, created() { if (this.isFile(this.value)) {
null
test
train
2023-07-20T14:54:40
"2023-07-18T10:05:44Z"
Ben8t
train
kestra-io/kestra/1218_1787
kestra-io/kestra
kestra-io/kestra/1218
kestra-io/kestra/1787
[ "keyword_pr_to_issue" ]
52eef24de19ae17d005a5c2c290ce28bde1a4b2e
226e971496407e7e3a40890a0be97014bcd63c98
[ "Add custom action to this : \n\n![Image](https://github.com/kestra-io/kestra/assets/37600690/8cfe172a-f348-4192-993d-f09cd5a20db4)\n\n" ]
[ "Can't you propose browser supported fonts instead of a hardcoded list?", "I can check fonts, but not get a list", "OK then" ]
"2023-07-20T13:44:43Z"
[ "enhancement" ]
Accessibility - Users can't change editor font size
### Feature description An accessibility issue, in the editor users should be able to change the font size and font type
[ "ui/src/components/inputs/Editor.vue", "ui/src/components/inputs/MonacoEditor.vue", "ui/src/components/settings/Settings.vue", "ui/src/translations.json" ]
[ "ui/src/components/inputs/Editor.vue", "ui/src/components/inputs/MonacoEditor.vue", "ui/src/components/settings/Settings.vue", "ui/src/translations.json" ]
[]
diff --git a/ui/src/components/inputs/Editor.vue b/ui/src/components/inputs/Editor.vue index d16d6cc50d..3fcd8192f3 100644 --- a/ui/src/components/inputs/Editor.vue +++ b/ui/src/components/inputs/Editor.vue @@ -20,7 +20,7 @@ <el-button :icon="icon.Help" @click="restartGuidedTour" size="small" /> </el-tooltip> </el-button-group> - <slot name="extends-navbar"/> + <slot name="extends-navbar" /> </div> </slot> </nav> @@ -185,8 +185,8 @@ return { ...{ tabSize: 2, - fontFamily: "'Source Code Pro', monospace", - fontSize: 12, + fontFamily: localStorage.getItem("editorFontFamily") ? localStorage.getItem("editorFontFamily") : "'Source Code Pro', monospace", + fontSize: localStorage.getItem("editorFontSize") ? parseInt(localStorage.getItem("editorFontSize")) : 12, showFoldingControls: "always", scrollBeyondLastLine: false, roundedSelection: false, diff --git a/ui/src/components/inputs/MonacoEditor.vue b/ui/src/components/inputs/MonacoEditor.vue index f995cf5c07..33f5f9820a 100644 --- a/ui/src/components/inputs/MonacoEditor.vue +++ b/ui/src/components/inputs/MonacoEditor.vue @@ -12,7 +12,7 @@ import * as monaco from "monaco-editor/esm/vs/editor/editor.api"; import EditorWorker from "monaco-editor/esm/vs/editor/editor.worker?worker"; import YamlWorker from "./yaml.worker.js?worker"; - import JsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker'; + import JsonWorker from "monaco-editor/esm/vs/language/json/json.worker?worker"; import {setDiagnosticsOptions} from "monaco-yaml"; import {yamlSchemas} from "override/utils/yamlSchemas" import Utils from "../../utils/utils"; diff --git a/ui/src/components/settings/Settings.vue b/ui/src/components/settings/Settings.vue index 412afa8ebf..132ba2415e 100644 --- a/ui/src/components/settings/Settings.vue +++ b/ui/src/components/settings/Settings.vue @@ -1,6 +1,6 @@ <template> <div> - <el-form class="ks-horizontal"> + <el-form class="ks-horizontal max-size"> <el-form-item :label="$t('Language')"> <el-select :model-value="lang" @update:model-value="onLang"> <el-option @@ -34,6 +34,27 @@ </el-select> </el-form-item> + <el-form-item :label="$t('Editor fontsize')"> + <el-input-number + :model-value="editorFontSize" + @update:model-value="onFontSize" + controls-position="right" + :min="1" + :max="50" + /> + </el-form-item> + + <el-form-item :label="$t('Editor fontfamily')"> + <el-select :model-value="editorFontFamily" @update:model-value="onFontFamily"> + <el-option + v-for="item in fontFamilyOptions" + :key="item.value" + :label="item.text" + :value="item.value" + /> + </el-select> + </el-form-item> + <el-form-item label="&nbsp;"> <el-checkbox :label="$t('Fold auto')" :model-value="autofoldTextEditor" @update:model-value="onAutofoldTextEditor" /> </el-form-item> @@ -98,7 +119,9 @@ editorTheme: undefined, autofoldTextEditor: undefined, guidedTour: undefined, - logDisplay: undefined + logDisplay: undefined, + editorFontSize: undefined, + editorFontFamily: undefined }; }, created() { @@ -112,6 +135,8 @@ this.autofoldTextEditor = localStorage.getItem("autofoldTextEditor") === "true"; this.guidedTour = localStorage.getItem("tourDoneOrSkip") === "true"; this.logDisplay = localStorage.getItem("logDisplay") || logDisplayTypes.DEFAULT; + this.editorFontSize = localStorage.getItem("editorFontSize") || 12; + this.editorFontFamily = localStorage.getItem("editorFontFamily") || "'Source Code Pro', monospace"; }, methods: { onNamespaceSelect(value) { @@ -174,6 +199,16 @@ localStorage.setItem("logDisplay", value); this.logDisplay = value; this.$toast().saved(); + }, + onFontSize(value) { + localStorage.setItem("editorFontSize", value); + this.editorFontSize = value; + this.$toast().saved(); + }, + onFontFamily(value) { + localStorage.setItem("editorFontFamily", value); + this.editorFontFamily = value; + this.$toast().saved(); } }, computed: { @@ -215,6 +250,40 @@ {value: logDisplayTypes.HIDDEN, text: this.$t("collapse all")} ] }, + fontFamilyOptions() { + // Array of font family that contains arabic language and japanese, chinese, korean languages compatible font family + return [ + { + value: "'Source Code Pro', monospace", + text: "Source Code Pro" + }, + { + value: "'Courier New', monospace", + text: "Courier" + }, + { + value: "'Times New Roman', serif", + text: "Times New Roman" + }, + { + value: "'Book Antiqua', serif", + text: "Book Antiqua" + }, + { + value: "'Times New Roman Arabic', serif", + text: "Times New Roman Arabic" + }, + { + value: "'SimSun', sans-serif", + text: "SimSun" + } + ] + } } }; </script> +<style> + .el-input-number { + max-width: 20vw; + } +</style> diff --git a/ui/src/translations.json b/ui/src/translations.json index 7e9b87d465..bbdbdbc942 100644 --- a/ui/src/translations.json +++ b/ui/src/translations.json @@ -245,6 +245,8 @@ "Default log level": "Default log level", "unsaved changed ?": "You have unsaved changes, do you want to leave this page?", "Editor theme": "Editor theme", + "Editor fontsize": "Editor font size", + "Editor fontfamily": "Editor font family", "errors": { "404": { "title": "Page not found", @@ -708,6 +710,8 @@ "Default log level": "Niveau de log par défaut", "unsaved changed ?": "Vous avez des changements non sauvegardés, voulez-vous quitter la page ?", "Editor theme": "Theme de l'éditeur", + "Editor fontsize": "Taille de police de l'éditeur", + "Editor fontfamily": "Police de l'éditeur", "errors": { "404": { "title": "Page introuvable",
null
val
train
2023-07-20T14:54:40
"2023-05-03T08:47:24Z"
Ben8t
train
kestra-io/kestra/1802_1803
kestra-io/kestra
kestra-io/kestra/1802
kestra-io/kestra/1803
[ "keyword_pr_to_issue" ]
426814d14b42f0822cdb5c9d1c138cd4beabfb57
9ce70f7ef82d36acb580175ed376398c25e2470b
[]
[]
"2023-07-24T14:58:34Z"
[ "bug", "enhancement" ]
Auto refresh button is not a switch
### Expected Behavior _No response_ ### Actual Behaviour At first it looks like the auto refresh button is a switch cause when we click on it the background color stays purple. However it is only due to button keeping focus effect afterwards. If you click anywhere else on the page then you have no feedback of whether or not the auto refresh is active. Also, it is even worst when the local storage kicks in as it retrieves the previous state from the local storage. However when we come on a page with the auto refresh being active due to local storage, since we didn't click on it we don't have the "on focus" effect, which make the auto refresh looking disabled while it is active. I think we should use the [checkbox element](https://element-plus.org/en-US/component/checkbox.html) instead. ### Steps To Reproduce _No response_ ### Environment Information - Kestra Version: 0.11.0-SNAPSHOT - Operating System (OS / Docker / Kubernetes): - Java Version (If not docker): ### Example flow _No response_
[ "ui/src/components/layout/RefreshButton.vue" ]
[ "ui/src/components/layout/RefreshButton.vue" ]
[]
diff --git a/ui/src/components/layout/RefreshButton.vue b/ui/src/components/layout/RefreshButton.vue index 9fa6677b69..d5e8d6ee48 100644 --- a/ui/src/components/layout/RefreshButton.vue +++ b/ui/src/components/layout/RefreshButton.vue @@ -1,8 +1,8 @@ <template> <el-button-group> - <el-button @click="toggleAutoRefresh" :pressed="autoRefresh"> + <el-button :active="autoRefresh" @click="toggleAutoRefresh"> <kicon :tooltip="$t('toggle periodic refresh each 10 seconds')" placement="bottom"> - <clock /> + <component :is="autoRefresh ? 'auto-renew' : 'auto-renew-off'" class="auto-refresh-icon" /> </kicon> </el-button> <el-button @click="triggerRefresh"> @@ -14,10 +14,11 @@ </template> <script> import Refresh from "vue-material-design-icons/Refresh.vue"; - import Clock from "vue-material-design-icons/Clock.vue"; + import AutoRenew from "vue-material-design-icons/Autorenew.vue"; + import AutoRenewOff from "vue-material-design-icons/AutorenewOff.vue"; import Kicon from "../Kicon.vue" export default { - components: {Refresh, Clock, Kicon}, + components: {Refresh, AutoRenew, AutoRenewOff, Kicon}, emits: ["refresh"], data() { return { @@ -32,12 +33,6 @@ toggleAutoRefresh() { this.autoRefresh = !this.autoRefresh; localStorage.setItem("autoRefresh", this.autoRefresh ? "1" : "0"); - if (this.autoRefresh) { - this.refreshHandler = setInterval(this.triggerRefresh, 10000); - this.triggerRefresh() - } else { - this.stopRefresh(); - } }, triggerRefresh() { this.$emit("refresh"); @@ -51,7 +46,29 @@ }, beforeUnmount() { this.stopRefresh(); + }, + watch: { + autoRefresh(newValue) { + if (newValue) { + this.refreshHandler = setInterval(this.triggerRefresh, 10000); + this.triggerRefresh() + } else { + this.stopRefresh(); + } + } } }; </script> - +<style scoped lang="scss"> + button[active=true] .auto-refresh-icon { + animation: rotate 10s linear infinite; + } + @keyframes rotate { + 0% { + rotate: 0deg; + } + 100% { + rotate: 360deg; + } + } +</style> \ No newline at end of file
null
train
train
2023-07-24T17:02:56
"2023-07-24T14:31:48Z"
brian-mulier-p
train
kestra-io/kestra/1816_1819
kestra-io/kestra
kestra-io/kestra/1816
kestra-io/kestra/1819
[ "keyword_pr_to_issue" ]
f8c55c52b10426343ac918b0579fc875b7e5dbe8
a23bb946700cc6f603c227349e2c7b9a33c2d087
[]
[]
"2023-07-26T14:39:53Z"
[ "bug", "enhancement" ]
Remove "Use" button for users without Flow CREATE right
### Expected Behavior _No response_ ### Actual Behaviour https://demo.kestra.io/ui/blueprints/community/105 with "demo" user still shows the "Use" button ### Steps To Reproduce _No response_ ### Environment Information - Kestra Version: - Operating System (OS / Docker / Kubernetes): - Java Version (If not docker): ### Example flow _No response_
[ "ui/src/components/flows/blueprints/BlueprintDetail.vue", "ui/src/override/components/flows/blueprints/BlueprintsBrowser.vue" ]
[ "ui/src/components/flows/blueprints/BlueprintDetail.vue", "ui/src/override/components/flows/blueprints/BlueprintsBrowser.vue" ]
[]
diff --git a/ui/src/components/flows/blueprints/BlueprintDetail.vue b/ui/src/components/flows/blueprints/BlueprintDetail.vue index f30749c53b..56871259ba 100644 --- a/ui/src/components/flows/blueprints/BlueprintDetail.vue +++ b/ui/src/components/flows/blueprints/BlueprintDetail.vue @@ -11,7 +11,7 @@ <h2 class="blueprint-title align-self-center"> {{ blueprint.title }} </h2> - <div class="ms-auto align-self-center"> + <div v-if="userCanCreateFlow" class="ms-auto align-self-center"> <router-link :to="{name: 'flows/create'}" @click="asAutoRestoreDraft"> <el-button size="large" type="primary" v-if="!embed"> {{ $t('use') }} @@ -93,6 +93,9 @@ import {shallowRef} from "vue"; import ContentCopy from "vue-material-design-icons/ContentCopy.vue"; import Markdown from "../../layout/Markdown.vue"; + import {mapState} from "vuex"; + import permission from "../../../models/permission"; + import action from "../../../models/action"; export default { @@ -158,6 +161,10 @@ } }, computed: { + ...mapState("auth", ["user"]), + userCanCreateFlow() { + return this.user.hasAnyAction(permission.FLOW, action.CREATE); + }, parsedFlow() { return { ...YamlUtils.parse(this.blueprint.flow), diff --git a/ui/src/override/components/flows/blueprints/BlueprintsBrowser.vue b/ui/src/override/components/flows/blueprints/BlueprintsBrowser.vue index e5e04741eb..c44df698f8 100644 --- a/ui/src/override/components/flows/blueprints/BlueprintsBrowser.vue +++ b/ui/src/override/components/flows/blueprints/BlueprintsBrowser.vue @@ -56,7 +56,7 @@ {{ $t('copy') }} </el-button> </el-tooltip> - <el-button v-else size="large" text bg @click="blueprintToEditor(blueprint.id)"> + <el-button v-else-if="userCanCreateFlow" size="large" text bg @click="blueprintToEditor(blueprint.id)"> {{ $t('use') }} </el-button> </div> @@ -76,6 +76,9 @@ import {shallowRef} from "vue"; import ContentCopy from "vue-material-design-icons/ContentCopy.vue"; import RestoreUrl from "../../../../mixins/restoreUrl"; + import permission from "../../../../models/permission"; + import action from "../../../../models/action"; + import {mapState} from "vuex"; export default { mixins: [RestoreUrl, DataTableActions], @@ -198,6 +201,12 @@ this.load(this.onDataLoaded); } }, + computed: { + ...mapState("auth", ["user"]), + userCanCreateFlow() { + return this.user.hasAnyAction(permission.FLOW, action.CREATE); + } + }, watch: { $route(newValue, oldValue) { if (oldValue.name === newValue.name) {
null
train
train
2023-07-26T11:20:55
"2023-07-26T13:23:20Z"
brian-mulier-p
train
kestra-io/kestra/1817_1820
kestra-io/kestra
kestra-io/kestra/1817
kestra-io/kestra/1820
[ "keyword_pr_to_issue" ]
f8c55c52b10426343ac918b0579fc875b7e5dbe8
4e8c1aed75e58ddf22d6bcc6a1c5466cb42d4b82
[]
[]
"2023-07-26T15:10:00Z"
[ "bug", "enhancement" ]
Blueprints with tasks not in Kestra instance have empty plugins' icons
### Expected Behavior _No response_ ### Actual Behaviour We should fetch icons from both the Kestra instance (for custom plugins) and the Kestra's API (for non-installed plugins) ![image](https://github.com/kestra-io/kestra/assets/37618489/7848597d-b348-4694-b099-20c8397be284) ### Steps To Reproduce _No response_ ### Environment Information - Kestra Version: - Operating System (OS / Docker / Kubernetes): - Java Version (If not docker): ### Example flow _No response_
[ "ui/src/stores/api.js", "ui/src/stores/plugins.js" ]
[ "ui/src/stores/api.js", "ui/src/stores/plugins.js" ]
[]
diff --git a/ui/src/stores/api.js b/ui/src/stores/api.js index 87fcaccf7d..2c60405d5f 100644 --- a/ui/src/stores/api.js +++ b/ui/src/stores/api.js @@ -42,6 +42,9 @@ export default { counter: counter++, } }); + }, + pluginIcons(_, __) { + return axios.get(API_URL + "/v1/plugins/icons", {}) } }, mutations: { diff --git a/ui/src/stores/plugins.js b/ui/src/stores/plugins.js index fc2f08d1cd..3879176b52 100644 --- a/ui/src/stores/plugins.js +++ b/ui/src/stores/plugins.js @@ -1,3 +1,5 @@ +import _merge from "lodash/merge"; + export default { namespaced: true, state: { @@ -25,7 +27,7 @@ export default { } return this.$http.get(`/api/v1/plugins/${options.cls}`, {params: options}).then(response => { - if(options.all === true) { + if (options.all === true) { commit("setPluginAllProps", response.data) } else { commit("setPlugin", response.data) @@ -34,11 +36,15 @@ export default { }) }, icons({commit}) { - return this.$http.get("/api/v1/plugins/icons", {}).then(response => { - commit("setIcons", response.data) + return Promise.all([ + this.$http.get("/api/v1/plugins/icons", {}), + this.dispatch("api/pluginIcons") + ]).then(responses => { + const icons = _merge(responses[0].data, responses[1].data); + commit("setIcons", icons); - return response.data; - }) + return icons; + }); }, loadInputsType({commit}) { return this.$http.get(`/api/v1/plugins/inputs`, {}).then(response => {
null
train
train
2023-07-26T11:20:55
"2023-07-26T14:24:27Z"
brian-mulier-p
train
kestra-io/kestra/1827_1830
kestra-io/kestra
kestra-io/kestra/1827
kestra-io/kestra/1830
[ "keyword_pr_to_issue" ]
bde5ff692ee562d012c3890fa0fa9bb4bd28b05d
56dec7e7ca6b10cfe5313588a61700f7a6c688dc
[]
[ "```suggestion\r\n \"execution\": \"There is an execution running for this trigger\",\r\n```", "```suggestion\r\n \"execution\": \"Il existe une exécution en cours pour ce trigger\",\r\n```", "```suggestion\r\n @Post(uri = \"/{namespace}/{flowId}/{triggerId}/unlock\")\r\n```\r\n\r\nPUT is usually used to update a resource, here you don't update the trigger with a new version but perform a specific action for this. Usually POST is used for such thing (what is called a non-resource scenario), this is a best practice when designing RESTful services.", "Okay seems fair, in fact I went for a post initially but then I was like \"but it actually modifies a trigger 'state'\" :thinking: ", "As you can see in the test ahah, I didn't even made the \"put\" change" ]
"2023-07-28T13:07:09Z"
[ "backend", "enhancement" ]
Ability to unlock triggers from Administration tab
### Feature description Following #1777, we should be able to unlock triggers locked in evaluation or execution
[ "ui/src/components/admin/Triggers.vue", "ui/src/stores/trigger.js", "ui/src/translations.json", "webserver/src/main/java/io/kestra/webserver/controllers/TriggerController.java" ]
[ "ui/src/components/admin/Triggers.vue", "ui/src/stores/trigger.js", "ui/src/translations.json", "webserver/src/main/java/io/kestra/webserver/controllers/TriggerController.java" ]
[ "webserver/src/test/java/io/kestra/webserver/controllers/TriggerControllerTest.java" ]
diff --git a/ui/src/components/admin/Triggers.vue b/ui/src/components/admin/Triggers.vue index 09c61bf9bb..46d0b6f918 100644 --- a/ui/src/components/admin/Triggers.vue +++ b/ui/src/components/admin/Triggers.vue @@ -86,13 +86,41 @@ {{ scope.row.evaluateRunningDate ? $filters.date(scope.row.evaluateRunningDate, "iso") : "" }} </template> </el-table-column> + <el-table-column column-key="action" class-name="row-action"> + <template #default="scope"> + <el-button text v-if="scope.row.executionId || scope.row.evaluateRunningDate"> + <kicon + :tooltip="$t(`unlock trigger.tooltip.${scope.row.executionId ? 'execution' : 'evaluation'}`)" + placement="left" @click="triggerToUnlock = scope.row"> + <lock-off /> + </kicon> + </el-button> + </template> + </el-table-column> </el-table> </template> </data-table> + + <el-dialog v-model="triggerToUnlock" destroy-on-close :append-to-body="true"> + <template #header> + <span v-html="$t('unlock trigger.confirmation')" /> + </template> + {{ $t("unlock trigger.warning") }} + <template #footer> + <el-form-item class="submit"> + <el-button :icon="LockOff" @click="unlock" type="primary"> + {{ $t('unlock trigger.button') }} + </el-button> + </el-form-item> + </template> + </el-dialog> </div> </div> </template> - +<script setup> + import LockOff from "vue-material-design-icons/LockOff.vue"; + import Kicon from "../Kicon.vue"; +</script> <script> import NamespaceSelect from "../namespace/NamespaceSelect.vue"; import RouteContext from "../../mixins/routeContext"; @@ -115,7 +143,8 @@ data() { return { triggers: undefined, - total: undefined + total: undefined, + triggerToUnlock: undefined }; }, methods: { @@ -131,8 +160,29 @@ this.total = triggersData.total; callback(); }); + }, + async unlock() { + const namespace = this.triggerToUnlock.namespace; + const flowId = this.triggerToUnlock.flowId; + const triggerId = this.triggerToUnlock.triggerId; + const unlockedTrigger = await this.$store.dispatch("trigger/unlock", { + namespace: namespace, + flowId: flowId, + triggerId: triggerId + }); + + this.$message({ + message: this.$t("trigger unlocked"), + type: "success" + }); + + const triggerIdx = this.triggers.findIndex(trigger => trigger.namespace === namespace && trigger.flowId === flowId && trigger.triggerId === triggerId); + if (triggerIdx !== -1) { + this.triggers[triggerIdx] = unlockedTrigger; + } + + this.triggerToUnlock = undefined; } } }; -</script> - +</script> \ No newline at end of file diff --git a/ui/src/stores/trigger.js b/ui/src/stores/trigger.js index 357151ddb1..a617697fba 100644 --- a/ui/src/stores/trigger.js +++ b/ui/src/stores/trigger.js @@ -10,6 +10,9 @@ export default { }).then(response => { return response.data; }) + }, + async unlock({commit}, options) { + return (await this.$http.post(`/api/v1/triggers/${options.namespace}/${options.flowId}/${options.triggerId}/unlock`)).data; } } } diff --git a/ui/src/translations.json b/ui/src/translations.json index 7d5f901054..3034b70362 100644 --- a/ui/src/translations.json +++ b/ui/src/translations.json @@ -465,7 +465,16 @@ "cannot swap tasks": "Can't swap the tasks", "dependency task": "Task {taskId} is a dependency of another task", "administration": "Administration", - "evaluation lock date": "Evaluation lock date" + "evaluation lock date": "Evaluation lock date", + "unlock trigger": { + "tooltip": { + "execution": "There is an execution running for this trigger", + "evaluation": "The trigger is currently in evaluation" + }, + "confirmation": "Are you sure you want to unlock the trigger ?", + "warning": "It could lead to concurrent executions for the same trigger and should be considered as a last resort option.", + "button": "Unlock trigger" + } }, "fr": { "id": "Identifiant", @@ -935,6 +944,15 @@ "cannot swap tasks": "Impossible de permuter les tâches", "dependency task": "La tâche {taskId} est une dépendance d'une autre tâche", "administration": "Administration", - "evaluation lock date": "Date verrou évaluation" + "evaluation lock date": "Date verrou évaluation", + "unlock trigger": { + "tooltip": { + "execution": "Il existe une exécution en cours pour ce trigger", + "evaluation": "Le déclencheur est en cours d'évaluation" + }, + "confirmation": "Êtes vous sûr(e) de vouloir débloquer le déclencheur ?", + "warning": "Cela pourrait amener à de multiples exécutions concurrentes pour le même déclencheur et devrait être considéré comme une solution de dernier recours.", + "button": "Débloquer le déclencheur" + } } } diff --git a/webserver/src/main/java/io/kestra/webserver/controllers/TriggerController.java b/webserver/src/main/java/io/kestra/webserver/controllers/TriggerController.java index ce026498e4..bda87937ac 100644 --- a/webserver/src/main/java/io/kestra/webserver/controllers/TriggerController.java +++ b/webserver/src/main/java/io/kestra/webserver/controllers/TriggerController.java @@ -1,14 +1,15 @@ package io.kestra.webserver.controllers; import io.kestra.core.models.triggers.Trigger; +import io.kestra.core.models.triggers.TriggerContext; +import io.kestra.core.queues.QueueInterface; import io.kestra.core.repositories.TriggerRepositoryInterface; import io.kestra.webserver.responses.PagedResults; import io.kestra.webserver.utils.PageableUtils; import io.micronaut.core.annotation.Nullable; +import io.micronaut.http.HttpResponse; import io.micronaut.http.MediaType; -import io.micronaut.http.annotation.Controller; -import io.micronaut.http.annotation.Get; -import io.micronaut.http.annotation.QueryValue; +import io.micronaut.http.annotation.*; import io.micronaut.http.exceptions.HttpStatusException; import io.micronaut.scheduling.TaskExecutors; import io.micronaut.scheduling.annotation.ExecuteOn; @@ -17,12 +18,16 @@ import jakarta.inject.Inject; import java.util.List; +import java.util.Optional; @Controller("/api/v1/triggers") public class TriggerController { @Inject private TriggerRepositoryInterface triggerRepository; + @Inject + private QueueInterface<Trigger> triggerQueue; + @ExecuteOn(TaskExecutors.IO) @Get(uri = "/search", produces = MediaType.TEXT_JSON) @Operation(tags = {"Triggers"}, summary = "Search for triggers") @@ -39,4 +44,33 @@ public PagedResults<Trigger> search( namespace )); } + + @ExecuteOn(TaskExecutors.IO) + @Post(uri = "/{namespace}/{flowId}/{triggerId}/unlock") + @Operation(tags = {"Triggers"}, summary = "Unlock a trigger") + public HttpResponse<Trigger> unlock( + @Parameter(description = "The namespace") @PathVariable String namespace, + @Parameter(description = "The flow id") @PathVariable String flowId, + @Parameter(description = "The trigger id") @PathVariable String triggerId + ) throws HttpStatusException { + Optional<Trigger> triggerOpt = triggerRepository.findLast(TriggerContext.builder() + .namespace(namespace) + .flowId(flowId) + .triggerId(triggerId) + .build()); + + if (triggerOpt.isEmpty()) { + return HttpResponse.notFound(); + } + + Trigger trigger = triggerOpt.get(); + if (trigger.getExecutionId() == null && trigger.getEvaluateRunningDate() == null) { + throw new IllegalStateException("Trigger is not locked"); + } + + trigger = trigger.resetExecution(); + triggerQueue.emit(trigger); + + return HttpResponse.ok(trigger); + } }
diff --git a/webserver/src/test/java/io/kestra/webserver/controllers/TriggerControllerTest.java b/webserver/src/test/java/io/kestra/webserver/controllers/TriggerControllerTest.java index 85053107b0..071056d1a4 100644 --- a/webserver/src/test/java/io/kestra/webserver/controllers/TriggerControllerTest.java +++ b/webserver/src/test/java/io/kestra/webserver/controllers/TriggerControllerTest.java @@ -2,13 +2,16 @@ import io.kestra.core.models.triggers.Trigger; import io.kestra.core.utils.Await; +import io.kestra.core.utils.IdUtils; import io.kestra.jdbc.repository.AbstractJdbcFlowRepository; import io.kestra.jdbc.repository.AbstractJdbcTriggerRepository; import io.kestra.webserver.controllers.h2.JdbcH2ControllerTest; import io.kestra.webserver.responses.PagedResults; import io.micronaut.core.type.Argument; import io.micronaut.http.HttpRequest; +import io.micronaut.http.HttpStatus; import io.micronaut.http.client.annotation.Client; +import io.micronaut.http.client.exceptions.HttpClientResponseException; import io.micronaut.rxjava2.http.client.RxHttpClient; import jakarta.inject.Inject; import org.hamcrest.Matchers; @@ -20,6 +23,7 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; +import static org.junit.jupiter.api.Assertions.assertThrows; class TriggerControllerTest extends JdbcH2ControllerTest { @Inject @@ -65,4 +69,50 @@ void search() { ) ); } + + @Test + void unlock() { + Trigger trigger = Trigger.builder() + .flowId(IdUtils.create()) + .namespace("io.kestra.unittest") + .triggerId(IdUtils.create()) + .executionId(IdUtils.create()) + .build(); + + jdbcTriggerRepository.save(trigger); + + trigger = client.toBlocking().retrieve(HttpRequest.POST("/api/v1/triggers/%s/%s/%s/unlock".formatted( + trigger.getNamespace(), + trigger.getFlowId(), + trigger.getTriggerId() + ), null), Trigger.class); + + assertThat(trigger.getExecutionId(), is(nullValue())); + assertThat(trigger.getEvaluateRunningDate(), is(nullValue())); + + Trigger unlockedTrigger = jdbcTriggerRepository.findLast(trigger).orElseThrow(); + + assertThat(unlockedTrigger.getExecutionId(), is(nullValue())); + assertThat(unlockedTrigger.getEvaluateRunningDate(), is(nullValue())); + + HttpClientResponseException e = assertThrows(HttpClientResponseException.class, () -> + client.toBlocking().exchange(HttpRequest.POST("/api/v1/triggers/%s/%s/%s/unlock".formatted( + unlockedTrigger.getNamespace(), + unlockedTrigger.getFlowId(), + unlockedTrigger.getTriggerId() + ), null))); + + assertThat(e.getStatus(), is(HttpStatus.CONFLICT)); + assertThat(e.getMessage(), is("Illegal state: Trigger is not locked")); + + e = assertThrows(HttpClientResponseException.class, () -> + client.toBlocking().exchange(HttpRequest.POST("/api/v1/triggers/%s/%s/%s/unlock".formatted( + "bad.namespace", + "some-flow-id", + "some-trigger-id" + ), null)) + ); + + assertThat(e.getStatus(), is(HttpStatus.NOT_FOUND)); + } }
val
train
2023-07-28T11:45:40
"2023-07-27T14:28:56Z"
brian-mulier-p
train
kestra-io/kestra/1704_1836
kestra-io/kestra
kestra-io/kestra/1704
kestra-io/kestra/1836
[ "keyword_pr_to_issue" ]
e66ed6c333eac32459c58ffa719d7f11961575b1
96551f4e7672ea59e06f9c67fc8f610ccdd79380
[ "Yes, attributes from the AbstractTrigger are filtered as with attributes from the abstract Task class for all tasks.", "I think this conditions attribute is really important in doc and should be an exception for this rule 🤔" ]
[ "```suggestion\r\n // we don't return base properties unless specified with @PluginProperty\r\n```" ]
"2023-07-31T09:29:39Z"
[ "bug", "documentation", "enhancement" ]
Triggers do not display conditions attribute in doc
### Expected Behavior _No response_ ### Actual Behaviour I think it is related to the inherited attributes not being displayed, didn't you do something around it @loicmathieu recently ? ### Steps To Reproduce _No response_ ### Environment Information - Kestra Version: 0.10.0-SNAPSHOT - Operating System (OS / Docker / Kubernetes): - Java Version (If not docker): ### Example flow _No response_
[ "core/src/main/java/io/kestra/core/docs/JsonSchemaGenerator.java", "core/src/main/java/io/kestra/core/models/triggers/AbstractTrigger.java" ]
[ "core/src/main/java/io/kestra/core/docs/JsonSchemaGenerator.java", "core/src/main/java/io/kestra/core/models/triggers/AbstractTrigger.java" ]
[ "core/src/test/java/io/kestra/core/docs/JsonSchemaGeneratorTest.java" ]
diff --git a/core/src/main/java/io/kestra/core/docs/JsonSchemaGenerator.java b/core/src/main/java/io/kestra/core/docs/JsonSchemaGenerator.java index 5e381441cc..cae09adbd3 100644 --- a/core/src/main/java/io/kestra/core/docs/JsonSchemaGenerator.java +++ b/core/src/main/java/io/kestra/core/docs/JsonSchemaGenerator.java @@ -424,10 +424,10 @@ protected <T> Map<String, Object> generate(Class<? extends T> cls, @Nullable Cla this.build(builder,false); - // base is passed, we don't return base properties + // we don't return base properties unless specified with @PluginProperty builder .forFields() - .withIgnoreCheck(fieldScope -> base != null && fieldScope.getDeclaringType().getTypeName().equals(base.getName())); + .withIgnoreCheck(fieldScope -> base != null && fieldScope.getAnnotation(PluginProperty.class) == null && fieldScope.getDeclaringType().getTypeName().equals(base.getName())); SchemaGeneratorConfig schemaGeneratorConfig = builder.build(); diff --git a/core/src/main/java/io/kestra/core/models/triggers/AbstractTrigger.java b/core/src/main/java/io/kestra/core/models/triggers/AbstractTrigger.java index 4d3e6c2434..caf232712f 100644 --- a/core/src/main/java/io/kestra/core/models/triggers/AbstractTrigger.java +++ b/core/src/main/java/io/kestra/core/models/triggers/AbstractTrigger.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonTypeInfo; +import io.kestra.core.models.annotations.PluginProperty; import io.kestra.core.models.conditions.Condition; import io.kestra.core.models.tasks.WorkerGroup; import io.micronaut.core.annotation.Introspected; @@ -39,6 +40,7 @@ abstract public class AbstractTrigger { private String description; @Valid + @PluginProperty @Schema( title = "List of Conditions in order to limit the flow trigger." )
diff --git a/core/src/test/java/io/kestra/core/docs/JsonSchemaGeneratorTest.java b/core/src/test/java/io/kestra/core/docs/JsonSchemaGeneratorTest.java index 91598b4fab..2de360d3b2 100644 --- a/core/src/test/java/io/kestra/core/docs/JsonSchemaGeneratorTest.java +++ b/core/src/test/java/io/kestra/core/docs/JsonSchemaGeneratorTest.java @@ -22,6 +22,7 @@ import lombok.NoArgsConstructor; import lombok.ToString; import lombok.experimental.SuperBuilder; +import org.hamcrest.Matchers; import org.junit.jupiter.api.Test; import java.net.URISyntaxException; @@ -121,6 +122,13 @@ void trigger() throws URISyntaxException { var allOf = (List<Object>) task.get("allOf"); assertThat(allOf.size(), is(1)); + + Map<String, Object> jsonSchema = jsonSchemaGenerator.generate(AbstractTrigger.class, AbstractTrigger.class); + + assertThat((Map<String, Object>) jsonSchema.get("properties"), allOf( + Matchers.aMapWithSize(1), + hasKey("conditions") + )); }); }
train
train
2023-07-31T11:31:16
"2023-07-04T16:00:35Z"
brian-mulier-p
train
kestra-io/kestra/1801_1840
kestra-io/kestra
kestra-io/kestra/1801
kestra-io/kestra/1840
[ "keyword_pr_to_issue" ]
2b4847d02dddfba1a269eec64d117b727f0ee5ea
c5ea0bafa8f1f087b6b38af873181f75f60efdbe
[]
[]
"2023-08-01T13:17:50Z"
[ "bug", "enhancement" ]
Execution filters are emptied when going back from an execution detail
### Expected Behavior _No response_ ### Actual Behaviour Filter executions by FAILED state Go in an execution detail Go to previous page Your filters are reset ### Steps To Reproduce _No response_ ### Environment Information - Kestra Version: 0.11.0-SNAPSHOT - Operating System (OS / Docker / Kubernetes): - Java Version (If not docker): ### Example flow _No response_
[ "ui/src/components/executions/Executions.vue", "ui/src/components/taskruns/TaskRuns.vue", "ui/src/utils/utils.js" ]
[ "ui/src/components/executions/Executions.vue", "ui/src/components/taskruns/TaskRuns.vue", "ui/src/utils/utils.js" ]
[ "core/src/test/java/io/kestra/core/runners/MultipleConditionTriggerTest.java" ]
diff --git a/ui/src/components/executions/Executions.vue b/ui/src/components/executions/Executions.vue index 59d3d5792c..1a6364437d 100644 --- a/ui/src/components/executions/Executions.vue +++ b/ui/src/components/executions/Executions.vue @@ -15,7 +15,7 @@ </el-form-item> <el-form-item> <status-filter-buttons - :value="$route.query.state" + :value="Utils.asArray($route.query.state)" @update:model-value="onDataTableValue('state', $event)" /> </el-form-item> @@ -168,6 +168,7 @@ import Delete from "vue-material-design-icons/Delete.vue"; import StopCircleOutline from "vue-material-design-icons/StopCircleOutline.vue"; import Pencil from "vue-material-design-icons/Pencil.vue"; + import Utils from "../../utils/utils"; </script> <script> diff --git a/ui/src/components/taskruns/TaskRuns.vue b/ui/src/components/taskruns/TaskRuns.vue index ab90ff4a11..ec4c6f8118 100644 --- a/ui/src/components/taskruns/TaskRuns.vue +++ b/ui/src/components/taskruns/TaskRuns.vue @@ -15,7 +15,7 @@ </el-form-item> <el-form-item> <status-filter-buttons - :value="$route.query.state" + :value="Utils.asArray($route.query.state)" @update:model-value="onDataTableValue('state', $event)" /> </el-form-item> @@ -121,7 +121,9 @@ </data-table> </div> </template> - +<script setup> + import Utils from "../../utils/utils"; +</script> <script> import {mapState} from "vuex"; import DataTable from "../layout/DataTable.vue"; diff --git a/ui/src/utils/utils.js b/ui/src/utils/utils.js index 79412b7e59..2eb04fca11 100644 --- a/ui/src/utils/utils.js +++ b/ui/src/utils/utils.js @@ -184,4 +184,12 @@ export default class Utils { static splitFirst(str, separator){ return str.split(separator).slice(1).join(separator); } + + static asArray(objOrArray) { + if(objOrArray === undefined) { + return []; + } + + return Array.isArray(objOrArray) ? objOrArray : [objOrArray]; + } }
diff --git a/core/src/test/java/io/kestra/core/runners/MultipleConditionTriggerTest.java b/core/src/test/java/io/kestra/core/runners/MultipleConditionTriggerTest.java index 56263c1019..212a4d5d7d 100644 --- a/core/src/test/java/io/kestra/core/runners/MultipleConditionTriggerTest.java +++ b/core/src/test/java/io/kestra/core/runners/MultipleConditionTriggerTest.java @@ -4,6 +4,7 @@ import org.junit.jupiter.api.Test; import jakarta.inject.Inject; +import org.junitpioneer.jupiter.RetryingTest; @MicronautTest public class MultipleConditionTriggerTest extends AbstractMemoryRunnerTest { @@ -15,7 +16,7 @@ void trigger() throws Exception { runnerCaseTest.trigger(); } - @Test + @RetryingTest(5) void triggerFailed() throws Exception { runnerCaseTest.failed(); }
train
train
2023-08-04T15:13:34
"2023-07-24T13:46:42Z"
brian-mulier-p
train
kestra-io/kestra/1307_1841
kestra-io/kestra
kestra-io/kestra/1307
kestra-io/kestra/1841
[ "keyword_pr_to_issue" ]
2b4847d02dddfba1a269eec64d117b727f0ee5ea
61ffdd1bf06ea5efc34365fffe155e2f2954c902
[]
[ "```suggestion\r\ncreate index executions_labels ON executions USING GIN(value -> 'labels');\r\n```", "The first couple of parenthesis is for declaring the columns of the index, the second couple is the special way to define a column as a JSON Path. So both are needed.", ":+1: " ]
"2023-08-01T15:49:05Z"
[]
Add index on execution labels
[]
[ "jdbc-postgres/src/main/resources/migrations/postgres/V19__index_execution-labels.sql" ]
[]
diff --git a/jdbc-postgres/src/main/resources/migrations/postgres/V19__index_execution-labels.sql b/jdbc-postgres/src/main/resources/migrations/postgres/V19__index_execution-labels.sql new file mode 100644 index 0000000000..b95bf43880 --- /dev/null +++ b/jdbc-postgres/src/main/resources/migrations/postgres/V19__index_execution-labels.sql @@ -0,0 +1,1 @@ +create index executions_labels ON executions USING GIN((value -> 'labels')); \ No newline at end of file
null
train
train
2023-08-04T15:13:34
"2023-05-15T21:05:27Z"
tchiotludo
train
kestra-io/kestra/1166_1843
kestra-io/kestra
kestra-io/kestra/1166
kestra-io/kestra/1843
[ "keyword_pr_to_issue" ]
f222d87f9a8dc5ac5d916b353e47e6811241b7c6
a037a6f807361c22416d333b61e3913406650516
[]
[]
"2023-08-02T08:03:25Z"
[ "enhancement" ]
Add a date format setting
### Feature description Add a Setting to let the user choose the datetime format (Month:Day:Year / Year:Month:Day / Day:Month:Year / xx/xx/xxxx etc...) - on dashboards, flow executions, etc.. **We must add a settings with predefined format** : * YYYY-MM-DD ( follows the ISO 8601 standard, widely used) * YYYY-MM-DDThh:mm:ssZ ( follows the ISO 8601 standard, widely used) * MM/DD/YYYY (commonly used in the United States) * DD/MM/YYYY (commonly used in UE) * YYYY/MM/DD * MM/DD/YY ![image](https://user-images.githubusercontent.com/46634684/231784464-3daa135a-e2bc-4f6d-a8c4-a338b1f8f457.png)
[ "ui/package-lock.json", "ui/package.json", "ui/src/components/layout/DateAgo.vue", "ui/src/components/settings/Settings.vue", "ui/src/translations.json", "ui/src/utils/filters.js", "ui/src/utils/init.js" ]
[ "ui/package-lock.json", "ui/package.json", "ui/src/components/layout/DateAgo.vue", "ui/src/components/settings/Settings.vue", "ui/src/translations.json", "ui/src/utils/filters.js", "ui/src/utils/init.js" ]
[]
diff --git a/ui/package-lock.json b/ui/package-lock.json index 36ee4dc985..5fb94e9e01 100644 --- a/ui/package-lock.json +++ b/ui/package-lock.json @@ -31,6 +31,7 @@ "md5": "^2.3.0", "moment": "^2.29.4", "moment-range": "4.0.2", + "moment-timezone": "^0.5.43", "node-modules-polyfill": "^0.1.4", "nprogress": "^0.2.0", "prismjs": "^1.29.0", @@ -92,246 +93,6 @@ "vue": "^3.2.0" } }, - "node_modules/@esbuild/android-arm": { - "version": "0.17.19", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.17.19.tgz", - "integrity": "sha512-rIKddzqhmav7MSmoFCmDIb6e2W57geRsM94gV2l38fzhXMwq7hZoClug9USI2pFRGL06f4IOPHHpFNOkWieR8A==", - "cpu": [ - "arm" - ], - "dev": true, - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/android-arm64": { - "version": "0.17.19", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.17.19.tgz", - "integrity": "sha512-KBMWvEZooR7+kzY0BtbTQn0OAYY7CsiydT63pVEaPtVYF0hXbUaOyZog37DKxK7NF3XacBJOpYT4adIJh+avxA==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/android-x64": { - "version": "0.17.19", - "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.17.19.tgz", - "integrity": "sha512-uUTTc4xGNDT7YSArp/zbtmbhO0uEEK9/ETW29Wk1thYUJBz3IVnvgEiEwEa9IeLyvnpKrWK64Utw2bgUmDveww==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/darwin-arm64": { - "version": "0.17.19", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.17.19.tgz", - "integrity": "sha512-80wEoCfF/hFKM6WE1FyBHc9SfUblloAWx6FJkFWTWiCoht9Mc0ARGEM47e67W9rI09YoUxJL68WHfDRYEAvOhg==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/darwin-x64": { - "version": "0.17.19", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.17.19.tgz", - "integrity": "sha512-IJM4JJsLhRYr9xdtLytPLSH9k/oxR3boaUIYiHkAawtwNOXKE8KoU8tMvryogdcT8AU+Bflmh81Xn6Q0vTZbQw==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/freebsd-arm64": { - "version": "0.17.19", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.17.19.tgz", - "integrity": "sha512-pBwbc7DufluUeGdjSU5Si+P3SoMF5DQ/F/UmTSb8HXO80ZEAJmrykPyzo1IfNbAoaqw48YRpv8shwd1NoI0jcQ==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "freebsd" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/freebsd-x64": { - "version": "0.17.19", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.17.19.tgz", - "integrity": "sha512-4lu+n8Wk0XlajEhbEffdy2xy53dpR06SlzvhGByyg36qJw6Kpfk7cp45DR/62aPH9mtJRmIyrXAS5UWBrJT6TQ==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "freebsd" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-arm": { - "version": "0.17.19", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.17.19.tgz", - "integrity": "sha512-cdmT3KxjlOQ/gZ2cjfrQOtmhG4HJs6hhvm3mWSRDPtZ/lP5oe8FWceS10JaSJC13GBd4eH/haHnqf7hhGNLerA==", - "cpu": [ - "arm" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-arm64": { - "version": "0.17.19", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.17.19.tgz", - "integrity": "sha512-ct1Tg3WGwd3P+oZYqic+YZF4snNl2bsnMKRkb3ozHmnM0dGWuxcPTTntAF6bOP0Sp4x0PjSF+4uHQ1xvxfRKqg==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-ia32": { - "version": "0.17.19", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.17.19.tgz", - "integrity": "sha512-w4IRhSy1VbsNxHRQpeGCHEmibqdTUx61Vc38APcsRbuVgK0OPEnQ0YD39Brymn96mOx48Y2laBQGqgZ0j9w6SQ==", - "cpu": [ - "ia32" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-loong64": { - "version": "0.17.19", - "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.17.19.tgz", - "integrity": "sha512-2iAngUbBPMq439a+z//gE+9WBldoMp1s5GWsUSgqHLzLJ9WoZLZhpwWuym0u0u/4XmZ3gpHmzV84PonE+9IIdQ==", - "cpu": [ - "loong64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-mips64el": { - "version": "0.17.19", - "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.17.19.tgz", - "integrity": "sha512-LKJltc4LVdMKHsrFe4MGNPp0hqDFA1Wpt3jE1gEyM3nKUvOiO//9PheZZHfYRfYl6AwdTH4aTcXSqBerX0ml4A==", - "cpu": [ - "mips64el" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-ppc64": { - "version": "0.17.19", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.17.19.tgz", - "integrity": "sha512-/c/DGybs95WXNS8y3Ti/ytqETiW7EU44MEKuCAcpPto3YjQbyK3IQVKfF6nbghD7EcLUGl0NbiL5Rt5DMhn5tg==", - "cpu": [ - "ppc64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-riscv64": { - "version": "0.17.19", - "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.17.19.tgz", - "integrity": "sha512-FC3nUAWhvFoutlhAkgHf8f5HwFWUL6bYdvLc/TTuxKlvLi3+pPzdZiFKSWz/PF30TB1K19SuCxDTI5KcqASJqA==", - "cpu": [ - "riscv64" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/linux-s390x": { - "version": "0.17.19", - "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.17.19.tgz", - "integrity": "sha512-IbFsFbxMWLuKEbH+7sTkKzL6NJmG2vRyy6K7JJo55w+8xDk7RElYn6xvXtDW8HCfoKBFK69f3pgBJSUSQPr+4Q==", - "cpu": [ - "s390x" - ], - "dev": true, - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=12" - } - }, "node_modules/@esbuild/linux-x64": { "version": "0.17.19", "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.17.19.tgz", @@ -339,7 +100,6 @@ "cpu": [ "x64" ], - "dev": true, "optional": true, "os": [ "linux" @@ -348,102 +108,6 @@ "node": ">=12" } }, - "node_modules/@esbuild/netbsd-x64": { - "version": "0.17.19", - "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.17.19.tgz", - "integrity": "sha512-CwFq42rXCR8TYIjIfpXCbRX0rp1jo6cPIUPSaWwzbVI4aOfX96OXY8M6KNmtPcg7QjYeDmN+DD0Wp3LaBOLf4Q==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "netbsd" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/openbsd-x64": { - "version": "0.17.19", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.17.19.tgz", - "integrity": "sha512-cnq5brJYrSZ2CF6c35eCmviIN3k3RczmHz8eYaVlNasVqsNY+JKohZU5MKmaOI+KkllCdzOKKdPs762VCPC20g==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "openbsd" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/sunos-x64": { - "version": "0.17.19", - "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.17.19.tgz", - "integrity": "sha512-vCRT7yP3zX+bKWFeP/zdS6SqdWB8OIpaRq/mbXQxTGHnIxspRtigpkUcDMlSCOejlHowLqII7K2JKevwyRP2rg==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "sunos" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/win32-arm64": { - "version": "0.17.19", - "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.17.19.tgz", - "integrity": "sha512-yYx+8jwowUstVdorcMdNlzklLYhPxjniHWFKgRqH7IFlUEa0Umu3KuYplf1HUZZ422e3NU9F4LGb+4O0Kdcaag==", - "cpu": [ - "arm64" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/win32-ia32": { - "version": "0.17.19", - "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.17.19.tgz", - "integrity": "sha512-eggDKanJszUtCdlVs0RB+h35wNlb5v4TWEkq4vZcmVt5u/HiDZrTXe2bWFQUez3RgNHwx/x4sk5++4NSSicKkw==", - "cpu": [ - "ia32" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=12" - } - }, - "node_modules/@esbuild/win32-x64": { - "version": "0.17.19", - "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.17.19.tgz", - "integrity": "sha512-lAhycmKnVOuRYNtRtatQR1LPQf2oYCkRGkSFnseDAKPl8lu5SOsK/e1sXe5a0Pc5kHIHe6P2I/ilntNv2xf3cA==", - "cpu": [ - "x64" - ], - "dev": true, - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=12" - } - }, "node_modules/@eslint-community/eslint-utils": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", @@ -690,6 +354,12 @@ "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==", "dev": true }, + "node_modules/@types/linkify-it": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@types/linkify-it/-/linkify-it-3.0.2.tgz", + "integrity": "sha512-HZQYqbiFVWufzCwexrvh694SOim8z2d+xJl5UNamcvQFejLY/2YUtzXHYi3cHdI7PMlS8ejH2slRAOJQ32aNbA==", + "peer": true + }, "node_modules/@types/lodash": { "version": "4.14.191", "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.191.tgz", @@ -703,6 +373,22 @@ "@types/lodash": "*" } }, + "node_modules/@types/markdown-it": { + "version": "12.2.3", + "resolved": "https://registry.npmjs.org/@types/markdown-it/-/markdown-it-12.2.3.tgz", + "integrity": "sha512-GKMHFfv3458yYy+v/N8gjufHO6MSZKCOXpZc5GXIWWy8uldwfmPn98vp81gZ5f9SVw8YYBctgfJ22a2d7AOMeQ==", + "peer": true, + "dependencies": { + "@types/linkify-it": "*", + "@types/mdurl": "*" + } + }, + "node_modules/@types/mdurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@types/mdurl/-/mdurl-1.0.2.tgz", + "integrity": "sha512-eC4U9MlIcu2q0KQmXszyn5Akca/0jrQmwDRgpAMJai7qBWq4amIQhZyNau4VYGtCeALvW1/NtjzJJ567aZxfKA==", + "peer": true + }, "node_modules/@types/node": { "version": "18.11.18", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.18.tgz", @@ -1971,7 +1657,6 @@ "version": "0.17.19", "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.17.19.tgz", "integrity": "sha512-XQ0jAPFkK/u3LcVRcvVHQcTIqD6E2H1fvZMA5dQPSOWb3suUbWbfbRf94pjc0bNzRYLfIrDRQXr7X+LHIm5oHw==", - "dev": true, "hasInstallScript": true, "bin": { "esbuild": "bin/esbuild" @@ -2404,20 +2089,6 @@ "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", "dev": true }, - "node_modules/fsevents": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", - "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", - "dev": true, - "hasInstallScript": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": "^8.16.0 || ^10.6.0 || >=11.0.0" - } - }, "node_modules/get-func-name": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", @@ -3130,6 +2801,17 @@ "moment": ">= 2" } }, + "node_modules/moment-timezone": { + "version": "0.5.43", + "resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.43.tgz", + "integrity": "sha512-72j3aNyuIsDxdF1i7CEgV2FfxM1r6aaqJyLB2vwb33mXYyoyLly+F1zbWqhA3/bVIoJ4szlUoMbUnVdid32NUQ==", + "dependencies": { + "moment": "^2.29.4" + }, + "engines": { + "node": "*" + } + }, "node_modules/monaco-editor": { "version": "0.39.0", "resolved": "https://registry.npmjs.org/monaco-editor/-/monaco-editor-0.39.0.tgz", diff --git a/ui/package.json b/ui/package.json index 40d6bf0ad6..aa49a4b826 100644 --- a/ui/package.json +++ b/ui/package.json @@ -33,6 +33,7 @@ "md5": "^2.3.0", "moment": "^2.29.4", "moment-range": "4.0.2", + "moment-timezone": "^0.5.43", "node-modules-polyfill": "^0.1.4", "nprogress": "^0.2.0", "prismjs": "^1.29.0", diff --git a/ui/src/components/layout/DateAgo.vue b/ui/src/components/layout/DateAgo.vue index 6727186720..cd913373cd 100644 --- a/ui/src/components/layout/DateAgo.vue +++ b/ui/src/components/layout/DateAgo.vue @@ -15,8 +15,7 @@ default: false }, format: { - type: String, - default: "LLLL" + type: String }, className: { type: String, @@ -28,7 +27,7 @@ return this.$moment(this.date).fromNow(); }, full() { - return this.$moment(this.date).format(this.format); + return this.$filters.date(this.date, this.format); } } }; diff --git a/ui/src/components/settings/Settings.vue b/ui/src/components/settings/Settings.vue index 132ba2415e..f7f450a2e3 100644 --- a/ui/src/components/settings/Settings.vue +++ b/ui/src/components/settings/Settings.vue @@ -23,6 +23,28 @@ </el-select> </el-form-item> + <el-form-item :label="$t('date format')"> + <el-select :model-value="dateFormat" @update:model-value="onDateFormat"> + <el-option + v-for="item in dateFormats" + :key="timezone + item.value" + :label="$filters.date(now, item.value)" + :value="item.value" + /> + </el-select> + </el-form-item> + + <el-form-item :label="$t('timezone')"> + <el-select :model-value="timezone" @update:model-value="onTimezone" filterable> + <el-option + v-for="item in zonesWithOffset" + :key="item.zone" + :label="`${item.zone} (UTC${item.offset === 0 ? '' : item.formattedOffset})`" + :value="item.zone" + /> + </el-select> + </el-form-item> + <el-form-item :label="$t('Editor theme')"> <el-select :model-value="editorTheme" @update:model-value="onEditorTheme"> <el-option @@ -104,6 +126,8 @@ import action from "../../models/action"; import {logDisplayTypes} from "../../utils/constants"; + export const DATE_FORMAT_STORAGE_KEY = "dateFormat"; + export const TIMEZONE_STORAGE_KEY = "timezone"; export default { mixins: [RouteContext], components: { @@ -117,11 +141,22 @@ lang: undefined, theme: undefined, editorTheme: undefined, + dateFormat: undefined, + timezone: undefined, + zonesWithOffset: this.$moment.tz.names().map((zone) => { + const timezoneMoment = this.$moment.tz(zone); + return { + zone, + offset: timezoneMoment.utcOffset(), + formattedOffset: timezoneMoment.format("Z") + }; + }).sort((a, b) => a.offset - b.offset), autofoldTextEditor: undefined, guidedTour: undefined, logDisplay: undefined, editorFontSize: undefined, - editorFontFamily: undefined + editorFontFamily: undefined, + now: this.$moment() }; }, created() { @@ -132,6 +167,8 @@ this.lang = localStorage.getItem("lang") || "en"; this.theme = localStorage.getItem("theme") || "light"; this.editorTheme = localStorage.getItem("editorTheme") || (darkTheme ? "dark" : "vs"); + this.dateFormat = localStorage.getItem(DATE_FORMAT_STORAGE_KEY) || "llll"; + this.timezone = localStorage.getItem(TIMEZONE_STORAGE_KEY) || this.$moment.tz.guess(); this.autofoldTextEditor = localStorage.getItem("autofoldTextEditor") === "true"; this.guidedTour = localStorage.getItem("tourDoneOrSkip") === "true"; this.logDisplay = localStorage.getItem("logDisplay") || logDisplayTypes.DEFAULT; @@ -171,6 +208,16 @@ this.theme = value; this.$toast().saved(); }, + onDateFormat(value) { + localStorage.setItem(DATE_FORMAT_STORAGE_KEY, value); + this.dateFormat = value; + this.$toast().saved(); + }, + onTimezone(value) { + localStorage.setItem(TIMEZONE_STORAGE_KEY, value); + this.timezone = value; + this.$toast().saved(); + }, onEditorTheme(value) { localStorage.setItem("editorTheme", value); this.editorTheme = value; @@ -237,6 +284,17 @@ {value: "dark", text: "Dark"} ] }, + dateFormats() { + return [ + {value: "YYYY-MM-DDTHH:mm:ssZ"}, + {value: "YYYY-MM-DD hh:mm:ss A"}, + {value: "DD/MM/YYYY HH:mm:ss"}, + {value: "lll"}, + {value: "llll"}, + {value: "LLL"}, + {value: "LLLL"} + ] + }, canReadFlows() { return this.user && this.user.isAllowed(permission.FLOW, action.READ); }, diff --git a/ui/src/translations.json b/ui/src/translations.json index 3034b70362..b69f2acead 100644 --- a/ui/src/translations.json +++ b/ui/src/translations.json @@ -70,7 +70,6 @@ }, "created date": "Created date", "updated date": "Updated date", - "date": "Date", "source": "Source", "home": "Home", "create": "Create", @@ -474,7 +473,9 @@ "confirmation": "Are you sure you want to unlock the trigger ?", "warning": "It could lead to concurrent executions for the same trigger and should be considered as a last resort option.", "button": "Unlock trigger" - } + }, + "date format": "Date format", + "timezone": "Timezone" }, "fr": { "id": "Identifiant", @@ -547,7 +548,6 @@ }, "created date": "Date de création", "updated date": "Date de mise à jour", - "date": "Date", "source": "Source", "home": "Accueil", "create": "Créer", @@ -953,6 +953,8 @@ "confirmation": "Êtes vous sûr(e) de vouloir débloquer le déclencheur ?", "warning": "Cela pourrait amener à de multiples exécutions concurrentes pour le même déclencheur et devrait être considéré comme une solution de dernier recours.", "button": "Débloquer le déclencheur" - } + }, + "date format": "Format de date", + "timezone": "Fuseau horaire" } } diff --git a/ui/src/utils/filters.js b/ui/src/utils/filters.js index 5f5db2063e..b902a2c1c1 100644 --- a/ui/src/utils/filters.js +++ b/ui/src/utils/filters.js @@ -1,5 +1,8 @@ import Utils from "./utils"; import {getCurrentInstance} from "vue"; +import {DATE_FORMAT_STORAGE_KEY} from "../components/settings/Settings.vue"; +import {TIMEZONE_STORAGE_KEY} from "../components/settings/Settings.vue"; +import moment from "moment-timezone"; export default { invisibleSpace: (value) => { @@ -15,14 +18,12 @@ export default { lower: value => value ? value.toString().toLowerCase() : "", date: (dateString, format) => { let f; - if (format === undefined) { - f = "LLLL" - } else if (format === "iso") { + if (format === "iso") { f = "YYYY-MM-DD HH:mm:ss.SSS" } else { - f = format + f = format ?? localStorage.getItem(DATE_FORMAT_STORAGE_KEY) ?? "llll"; } - return getCurrentInstance().appContext.config.globalProperties.$moment(dateString).format(f) + return getCurrentInstance().appContext.config.globalProperties.$moment(dateString).tz(localStorage.getItem(TIMEZONE_STORAGE_KEY) ?? moment.tz.guess()).format(f) } } diff --git a/ui/src/utils/init.js b/ui/src/utils/init.js index f8ade16d3d..f7ed873c78 100644 --- a/ui/src/utils/init.js +++ b/ui/src/utils/init.js @@ -2,7 +2,7 @@ import {createStore} from "vuex"; import {createRouter, createWebHistory} from "vue-router"; import VueGtag from "vue-gtag"; import {createI18n} from "vue-i18n"; -import moment from "moment/moment"; +import moment from "moment-timezone"; import "moment/locale/fr" import {extendMoment} from "moment-range"; import VueSidebarMenu from "vue-sidebar-menu";
null
train
train
2023-08-04T17:27:59
"2023-04-13T14:06:20Z"
Ben8t
train
kestra-io/kestra/1333_1861
kestra-io/kestra
kestra-io/kestra/1333
kestra-io/kestra/1861
[ "keyword_pr_to_issue" ]
30ac813409a477cb6fe9f51ca416ae4099170bbb
71ec2c8817a2d45de935139f60216818522c021b
[ "When I do mass actions the buttons replace the content of the first line. This saves space for positioning the buttons, like on Notion or crowd.\r\n<img width=\"1668\" alt=\"Capture d’écran 2023-05-19 à 09 35 24\" src=\"https://github.com/kestra-io/kestra/assets/125994028/efb7c723-b1ce-4732-b93e-c65bed62bbc9\">\r\n[Figma link](https://www.figma.com/file/4tLhsoCsh9yVzYRY1N70kS/App-Kestra?type=design&node-id=843%3A3633&t=LkChqhww36cq4mBn-1)" ]
[]
"2023-08-07T08:30:17Z"
[ "frontend" ]
Button Rework - "Mass Action"
### Feature description Following #1003 issue, we want to change the positions of "mass action" buttons. 👉 Move them in the top of tables. When the user selects multiple elements, buttons should appear on the headers See @Nico-Kestra prototypes in comment
[ "ui/src/components/executions/Executions.vue", "ui/src/components/flows/Flows.vue", "ui/src/components/layout/BottomLineCounter.vue", "ui/src/components/templates/Templates.vue" ]
[ "ui/src/components/executions/Executions.vue", "ui/src/components/flows/Flows.vue", "ui/src/components/layout/BulkSelect.vue", "ui/src/components/layout/SelectTable.vue", "ui/src/components/templates/Templates.vue", "ui/src/mixins/selectTableActions.js" ]
[]
diff --git a/ui/src/components/executions/Executions.vue b/ui/src/components/executions/Executions.vue index 1a6364437d..0a1d4b1e7e 100644 --- a/ui/src/components/executions/Executions.vue +++ b/ui/src/components/executions/Executions.vue @@ -49,9 +49,9 @@ </template> <template #table> - <el-table + <select-table + ref="selectTable" :data="executions" - ref="table" :default-sort="{prop: 'state.startDate', order: 'descending'}" stripe table-layout="auto" @@ -59,93 +59,116 @@ @row-dblclick="onRowDoubleClick" @sort-change="onSort" @selection-change="handleSelectionChange" + :selectable="!hidden.includes('selection') && canCheck" > - <el-table-column type="selection" v-if="!hidden.includes('selection') && (canCheck)" /> + <template #select-actions> + <bulk-select + :select-all="queryBulkAction" + :selections="selection" + :total="total" + @update:select-all="toggleAllSelection" + @unselect="toggleAllUnselected" + > + <el-button v-if="canUpdate" :icon="Restart" @click="restartExecutions()"> + {{ $t('restart') }} + </el-button> + <el-button v-if="canUpdate" :icon="StopCircleOutline" @click="killExecutions()"> + {{ $t('kill') }} + </el-button> + <el-button v-if="canDelete" :icon="Delete" type="default" @click="deleteExecutions()"> + {{ $t('delete') }} + </el-button> + </bulk-select> + </template> + <template #default> + <el-table-column prop="id" v-if="!hidden.includes('id')" sortable="custom" + :sort-orders="['ascending', 'descending']" :label="$t('id')"> + <template #default="scope"> + <id :value="scope.row.id" :shrink="true" /> + </template> + </el-table-column> - <el-table-column prop="id" v-if="!hidden.includes('id')" sortable="custom" :sort-orders="['ascending', 'descending']" :label="$t('id')"> - <template #default="scope"> - <id :value="scope.row.id" :shrink="true" /> - </template> - </el-table-column> + <el-table-column prop="state.startDate" v-if="!hidden.includes('state.startDate')" + sortable="custom" + :sort-orders="['ascending', 'descending']" :label="$t('start date')"> + <template #default="scope"> + <date-ago :inverted="true" :date="scope.row.state.startDate" /> + </template> + </el-table-column> - <el-table-column prop="state.startDate" v-if="!hidden.includes('state.startDate')" sortable="custom" :sort-orders="['ascending', 'descending']" :label="$t('start date')"> - <template #default="scope"> - <date-ago :inverted="true" :date="scope.row.state.startDate" /> - </template> - </el-table-column> + <el-table-column prop="state.endDate" v-if="!hidden.includes('state.endDate')" sortable="custom" + :sort-orders="['ascending', 'descending']" :label="$t('end date')"> + <template #default="scope"> + <date-ago :inverted="true" :date="scope.row.state.endDate" /> + </template> + </el-table-column> - <el-table-column prop="state.endDate" v-if="!hidden.includes('state.endDate')" sortable="custom" :sort-orders="['ascending', 'descending']" :label="$t('end date')"> - <template #default="scope"> - <date-ago :inverted="true" :date="scope.row.state.endDate" /> - </template> - </el-table-column> + <el-table-column prop="state.duration" v-if="!hidden.includes('state.duration')" + sortable="custom" + :sort-orders="['ascending', 'descending']" :label="$t('duration')"> + <template #default="scope"> + <span v-if="isRunning(scope.row)">{{ + $filters.humanizeDuration(durationFrom(scope.row)) + }}</span> + <span v-else>{{ $filters.humanizeDuration(scope.row.state.duration) }}</span> + </template> + </el-table-column> - <el-table-column prop="state.duration" v-if="!hidden.includes('state.duration')" sortable="custom" :sort-orders="['ascending', 'descending']" :label="$t('duration')"> - <template #default="scope"> - <span v-if="isRunning(scope.row)">{{ $filters.humanizeDuration(durationFrom(scope.row)) }}</span> - <span v-else>{{ $filters.humanizeDuration(scope.row.state.duration) }}</span> - </template> - </el-table-column> + <el-table-column v-if="$route.name !== 'flows/update' && !hidden.includes('namespace')" + prop="namespace" + sortable="custom" :sort-orders="['ascending', 'descending']" + :label="$t('namespace')" + :formatter="(_, __, cellValue) => $filters.invisibleSpace(cellValue)" /> - <el-table-column v-if="$route.name !== 'flows/update' && !hidden.includes('namespace')" prop="namespace" sortable="custom" :sort-orders="['ascending', 'descending']" :label="$t('namespace')" :formatter="(_, __, cellValue) => $filters.invisibleSpace(cellValue)" /> + <el-table-column v-if="$route.name !== 'flows/update' && !hidden.includes('flowId')" + prop="flowId" + sortable="custom" :sort-orders="['ascending', 'descending']" + :label="$t('flow')"> + <template #default="scope"> + <router-link + :to="{name: 'flows/update', params: {namespace: scope.row.namespace, id: scope.row.flowId}}"> + {{ $filters.invisibleSpace(scope.row.flowId) }} + </router-link> + </template> + </el-table-column> - <el-table-column v-if="$route.name !== 'flows/update' && !hidden.includes('flowId')" prop="flowId" sortable="custom" :sort-orders="['ascending', 'descending']" :label="$t('flow')"> - <template #default="scope"> - <router-link :to="{name: 'flows/update', params: {namespace: scope.row.namespace, id: scope.row.flowId}}"> - {{ $filters.invisibleSpace(scope.row.flowId) }} - </router-link> - </template> - </el-table-column> + <el-table-column v-if="!hidden.includes('labels')" :label="$t('labels')"> + <template #default="scope"> + <labels :labels="scope.row.labels" /> + </template> + </el-table-column> - <el-table-column v-if="!hidden.includes('labels')" :label="$t('labels')"> - <template #default="scope"> - <labels :labels="scope.row.labels" /> - </template> - </el-table-column> + <el-table-column prop="state.current" v-if="!hidden.includes('state.current')" sortable="custom" + :sort-orders="['ascending', 'descending']" :label="$t('state')"> + <template #default="scope"> + <status :status="scope.row.state.current" size="small" /> + </template> + </el-table-column> - <el-table-column prop="state.current" v-if="!hidden.includes('state.current')" sortable="custom" :sort-orders="['ascending', 'descending']" :label="$t('state')"> - <template #default="scope"> - <status :status="scope.row.state.current" size="small" /> - </template> - </el-table-column> + <el-table-column prop="triggers" v-if="!hidden.includes('triggers')" :label="$t('triggers')" + class-name="shrink"> + <template #default="scope"> + <trigger-avatar :execution="scope.row" /> + </template> + </el-table-column> - <el-table-column prop="triggers" v-if="!hidden.includes('triggers')" :label="$t('triggers')" class-name="shrink"> - <template #default="scope"> - <trigger-avatar :execution="scope.row" /> - </template> - </el-table-column> - - <el-table-column column-key="action" class-name="row-action"> - <template #default="scope"> - <router-link :to="{name: 'executions/update', params: {namespace: scope.row.namespace, flowId: scope.row.flowId, id: scope.row.id}}"> - <kicon :tooltip="$t('details')" placement="left"> - <eye /> - </kicon> - </router-link> - </template> - </el-table-column> - </el-table> + <el-table-column column-key="action" class-name="row-action"> + <template #default="scope"> + <router-link + :to="{name: 'executions/update', params: {namespace: scope.row.namespace, flowId: scope.row.flowId, id: scope.row.id}}"> + <kicon :tooltip="$t('details')" placement="left"> + <eye /> + </kicon> + </router-link> + </template> + </el-table-column> + </template> + </select-table> </template> </data-table> <bottom-line v-if="displayBottomBar"> <ul> - <li v-if="executionsSelection.length !== 0 && (canUpdate || canDelete)"> - <bottom-line-counter v-model="queryBulkAction" :selections="executionsSelection" :total="total" @update:model-value="selectAll()"> - <el-button v-if="canUpdate" :icon="Restart" size="large" @click="restartExecutions()"> - {{ $t('restart') }} - </el-button> - <el-button v-if="canUpdate" :icon="StopCircleOutline" size="large" @click="killExecutions()"> - {{ $t('kill') }} - </el-button> - <el-button v-if="canDelete" :icon="Delete" size="large" type="default" @click="deleteExecutions()"> - {{ $t('delete') }} - </el-button> - </bottom-line-counter> - </li> - - <li class="spacer" /> - <template v-if="$route.name === 'flows/update'"> <li> <template v-if="isAllowedEdit"> @@ -155,7 +178,8 @@ </template> </li> <li> - <trigger-flow v-if="flow" :disabled="flow.disabled" :flow-id="flow.id" :namespace="flow.namespace" /> + <trigger-flow v-if="flow" :disabled="flow.disabled" :flow-id="flow.id" + :namespace="flow.namespace" /> </li> </template> </ul> @@ -164,6 +188,8 @@ </template> <script setup> + import BulkSelect from "../layout/BulkSelect.vue"; + import SelectTable from "../layout/SelectTable.vue"; import Restart from "vue-material-design-icons/Restart.vue"; import Delete from "vue-material-design-icons/Delete.vue"; import StopCircleOutline from "vue-material-design-icons/StopCircleOutline.vue"; @@ -178,6 +204,7 @@ import Status from "../Status.vue"; import RouteContext from "../../mixins/routeContext"; import DataTableActions from "../../mixins/dataTableActions"; + import SelectTableActions from "../../mixins/selectTableActions"; import SearchField from "../layout/SearchField.vue"; import NamespaceSelect from "../namespace/NamespaceSelect.vue"; import LabelFilter from "../labels/LabelFilter.vue"; @@ -194,13 +221,12 @@ import Id from "../Id.vue"; import _merge from "lodash/merge"; import BottomLine from "../layout/BottomLine.vue"; - import BottomLineCounter from "../layout/BottomLineCounter.vue"; import permission from "../../models/permission"; import action from "../../models/action"; import TriggerFlow from "../../components/flows/TriggerFlow.vue"; export default { - mixins: [RouteContext, RestoreUrl, DataTableActions], + mixins: [RouteContext, RestoreUrl, DataTableActions, SelectTableActions], components: { Status, Eye, @@ -218,7 +244,6 @@ Labels, Id, BottomLine, - BottomLineCounter, TriggerFlow }, props: { @@ -240,9 +265,7 @@ isDefaultNamespaceAllow: true, dailyReady: false, dblClickRouteName: "executions/update", - flowTriggerDetails: undefined, - executionsSelection: [], - queryBulkAction: false + flowTriggerDetails: undefined }; }, computed: { @@ -263,8 +286,7 @@ .add(-30, "days").toISOString(true); }, displayBottomBar() { - return (this.executionsSelection.length !== 0 && (this.canUpdate || this.canDelete)) || - (this.$route.name === "flows/update"); + return (this.$route.name === "flows/update"); }, canCheck() { return this.canDelete || this.canUpdate; @@ -280,18 +302,10 @@ }, }, methods: { - handleSelectionChange(val) { - if (val.length === 0) { - this.queryBulkAction = false - } - this.executionsSelection = val.map(x => x.id); + selectionMapper(execution) { + return execution.id }, - selectAll() { - if (this.$refs.table.getSelectionRows().length !== this.$refs.table.data.length) { - this.$refs.table.toggleAllSelection(); - } - }, - isRunning(item){ + isRunning(item) { return State.isRunning(item.state.current); }, onStatusChange() { @@ -338,7 +352,7 @@ }, restartExecutions() { this.$toast().confirm( - this.$t("bulk restart", {"executionCount": this.queryBulkAction ? this.total : this.executionsSelection.length}), + this.$t("bulk restart", {"executionCount": this.queryBulkAction ? this.total : this.selection.length}), () => { if (this.queryBulkAction) { return this.$store @@ -352,7 +366,7 @@ }) } else { return this.$store - .dispatch("execution/bulkRestartExecution", {executionsId: this.executionsSelection}) + .dispatch("execution/bulkRestartExecution", {executionsId: this.selection}) .then(r => { this.$toast().success(this.$t("executions restarted", {executionCount: r.data.count})); this.loadData(); @@ -361,12 +375,13 @@ }), this.$t(e.message))) } }, - () => {} + () => { + } ) }, deleteExecutions() { this.$toast().confirm( - this.$t("bulk delete", {"executionCount": this.queryBulkAction ? this.total : this.executionsSelection.length}), + this.$t("bulk delete", {"executionCount": this.queryBulkAction ? this.total : this.selection.length}), () => { if (this.queryBulkAction) { return this.$store @@ -380,7 +395,7 @@ }) } else { return this.$store - .dispatch("execution/bulkDeleteExecution", {executionsId: this.executionsSelection}) + .dispatch("execution/bulkDeleteExecution", {executionsId: this.selection}) .then(r => { this.$toast().success(this.$t("executions deleted", {executionCount: r.data.count})); this.loadData(); @@ -389,12 +404,13 @@ }), this.$t(e.message))) } }, - () => {} + () => { + } ) }, killExecutions() { this.$toast().confirm( - this.$t("bulk kill", {"executionCount": this.queryBulkAction ? this.total : this.executionsSelection.length}), + this.$t("bulk kill", {"executionCount": this.queryBulkAction ? this.total : this.selection.length}), () => { if (this.queryBulkAction) { return this.$store @@ -408,7 +424,7 @@ }) } else { return this.$store - .dispatch("execution/bulkKill", {executionsId: this.executionsSelection}) + .dispatch("execution/bulkKill", {executionsId: this.selection}) .then(r => { this.$toast().success(this.$t("executions killed", {executionCount: r.data.count})); this.loadData(); @@ -417,15 +433,18 @@ }), this.$t(e.message))) } }, - () => {} + () => { + } ) }, editFlow() { - this.$router.push({name:"flows/update", params: { - namespace: this.flow.namespace, - id: this.flow.id, - tab: "editor" - }}) + this.$router.push({ + name: "flows/update", params: { + namespace: this.flow.namespace, + id: this.flow.id, + tab: "editor" + } + }) }, } }; diff --git a/ui/src/components/flows/Flows.vue b/ui/src/components/flows/Flows.vue index 711e0f02ad..8bc5279482 100644 --- a/ui/src/components/flows/Flows.vue +++ b/ui/src/components/flows/Flows.vue @@ -35,9 +35,9 @@ </template> <template #table> - <el-table + <select-table + ref="selectTable" :data="flows" - ref="table" :default-sort="{prop: 'id', order: 'ascending'}" stripe table-layout="auto" @@ -46,89 +46,99 @@ @sort-change="onSort" :row-class-name="rowClasses" @selection-change="handleSelectionChange" + :selectable="canCheck" > - <el-table-column type="selection" v-if="(canCheck)" /> - <el-table-column prop="id" sortable="custom" :sort-orders="['ascending', 'descending']" :label="$t('id')"> - <template #default="scope"> - <router-link - :to="{name: 'flows/update', params: {namespace: scope.row.namespace, id: scope.row.id}}" - > - {{ $filters.invisibleSpace(scope.row.id) }} - </router-link> - &nbsp;<markdown-tooltip + <template #select-actions> + <bulk-select + :select-all="queryBulkAction" + :selections="selection" + :total="total" + @update:select-all="toggleAllSelection" + @unselect="toggleAllUnselected" + > + <el-button v-if="canRead" :icon="Download" @click="exportFlows()"> + {{ $t('export') }} + </el-button> + <el-button v-if="canDelete" @click="deleteFlows" :icon="TrashCan"> + {{ $t('delete') }} + </el-button> + <el-button v-if="canUpdate" @click="enableFlows" :icon="FileDocumentCheckOutline"> + {{ $t('enable') }} + </el-button> + <el-button v-if="canUpdate" @click="disableFlows" :icon="FileDocumentRemoveOutline"> + {{ $t('disable') }} + </el-button> + </bulk-select> + </template> + <template #default> + <el-table-column prop="id" sortable="custom" :sort-orders="['ascending', 'descending']" + :label="$t('id')"> + <template #default="scope"> + <router-link + :to="{name: 'flows/update', params: {namespace: scope.row.namespace, id: scope.row.id}}" + > + {{ $filters.invisibleSpace(scope.row.id) }} + </router-link> + &nbsp;<markdown-tooltip :id="scope.row.namespace + '-' + scope.row.id" :description="scope.row.description" :title="scope.row.namespace + '.' + scope.row.id" /> - </template> - </el-table-column> + </template> + </el-table-column> - <el-table-column :label="$t('labels')"> - <template #default="scope"> - <labels :labels="scope.row.labels" /> - </template> - </el-table-column> + <el-table-column :label="$t('labels')"> + <template #default="scope"> + <labels :labels="scope.row.labels" /> + </template> + </el-table-column> - <el-table-column prop="namespace" sortable="custom" :sort-orders="['ascending', 'descending']" :label="$t('namespace')" :formatter="(_, __, cellValue) => $filters.invisibleSpace(cellValue)" /> + <el-table-column prop="namespace" sortable="custom" + :sort-orders="['ascending', 'descending']" + :label="$t('namespace')" + :formatter="(_, __, cellValue) => $filters.invisibleSpace(cellValue)" /> - <el-table-column - prop="state" - :label="$t('execution statistics')" - v-if="user.hasAny(permission.EXECUTION)" - class-name="row-graph" - > - <template #default="scope"> - <state-chart - :duration="true" - :namespace="scope.row.namespace" - :flow-id="scope.row.id" - v-if="dailyGroupByFlowReady" - :data="chartData(scope.row)" - /> - </template> - </el-table-column> + <el-table-column + prop="state" + :label="$t('execution statistics')" + v-if="user.hasAny(permission.EXECUTION)" + class-name="row-graph" + > + <template #default="scope"> + <state-chart + :duration="true" + :namespace="scope.row.namespace" + :flow-id="scope.row.id" + v-if="dailyGroupByFlowReady" + :data="chartData(scope.row)" + /> + </template> + </el-table-column> - <el-table-column :label="$t('triggers')" class-name="row-action"> - <template #default="scope"> - <trigger-avatar :flow="scope.row" /> - </template> - </el-table-column> + <el-table-column :label="$t('triggers')" class-name="row-action"> + <template #default="scope"> + <trigger-avatar :flow="scope.row" /> + </template> + </el-table-column> - <el-table-column column-key="action" class-name="row-action"> - <template #default="scope"> - <router-link :to="{name: 'flows/update', params : {namespace: scope.row.namespace, id: scope.row.id}}"> - <kicon :tooltip="$t('details')" placement="left"> - <eye /> - </kicon> - </router-link> - </template> - </el-table-column> - </el-table> + <el-table-column column-key="action" class-name="row-action"> + <template #default="scope"> + <router-link + :to="{name: 'flows/update', params : {namespace: scope.row.namespace, id: scope.row.id}}"> + <kicon :tooltip="$t('details')" placement="left"> + <eye /> + </kicon> + </router-link> + </template> + </el-table-column> + </template> + </select-table> </template> </data-table> </div> <bottom-line> <ul> - <li> - <ul v-if="flowsSelection.length !== 0 && canRead"> - <bottom-line-counter v-model="queryBulkAction" :selections="flowsSelection" :total="total" @update:model-value="selectAll()"> - <el-button v-if="canRead" :icon="Download" size="large" @click="exportFlows()"> - {{ $t('export') }} - </el-button> - <el-button v-if="canDelete" @click="deleteFlows" size="large" :icon="TrashCan"> - {{ $t('delete') }} - </el-button> - <el-button v-if="canUpdate" @click="enableFlows" size="large" :icon="FileDocumentCheckOutline"> - {{ $t('enable') }} - </el-button> - <el-button v-if="canUpdate" @click="disableFlows" size="large" :icon="FileDocumentRemoveOutline"> - {{ $t('disable') }} - </el-button> - </bottom-line-counter> - </ul> - </li> - <li class="spacer" /> <li> <div class="el-input el-input-file el-input--large custom-upload"> <div class="el-input__wrapper"> @@ -166,6 +176,8 @@ </template> <script setup> + import BulkSelect from "../layout/BulkSelect.vue"; + import SelectTable from "../layout/SelectTable.vue"; import Plus from "vue-material-design-icons/Plus.vue"; import TextBoxSearch from "vue-material-design-icons/TextBoxSearch.vue"; import Download from "vue-material-design-icons/Download.vue"; @@ -184,6 +196,7 @@ import BottomLine from "../layout/BottomLine.vue"; import RouteContext from "../../mixins/routeContext"; import DataTableActions from "../../mixins/dataTableActions"; + import SelectTableActions from "../../mixins/selectTableActions"; import RestoreUrl from "../../mixins/restoreUrl"; import DataTable from "../layout/DataTable.vue"; import SearchField from "../layout/SearchField.vue"; @@ -193,12 +206,11 @@ import MarkdownTooltip from "../layout/MarkdownTooltip.vue" import Kicon from "../Kicon.vue" import Labels from "../layout/Labels.vue" - import BottomLineCounter from "../layout/BottomLineCounter.vue"; import Upload from "vue-material-design-icons/Upload.vue"; import LabelFilter from "../labels/LabelFilter.vue"; export default { - mixins: [RouteContext, RestoreUrl, DataTableActions], + mixins: [RouteContext, RestoreUrl, DataTableActions, SelectTableActions], components: { NamespaceSelect, BottomLine, @@ -211,7 +223,6 @@ MarkdownTooltip, Kicon, Labels, - BottomLineCounter, Upload, LabelFilter }, @@ -222,8 +233,6 @@ action: action, dailyGroupByFlowReady: false, dailyReady: false, - flowsSelection: [], - queryBulkAction: false, file: undefined, }; }, @@ -255,28 +264,18 @@ }, canUpdate() { return this.user && this.user.isAllowed(permission.FLOW, action.UPDATE, this.$route.query.namespace); - }, + } }, methods: { - handleSelectionChange(val) { - if (val.length === 0) { - this.queryBulkAction = false - } - this.flowsSelection = val.map(x => { - return { - id: x.id, - namespace: x.namespace - } - }); - }, - selectAll() { - if (this.$refs.table.getSelectionRows().length !== this.$refs.table.data.length) { - this.$refs.table.toggleAllSelection(); + selectionMapper(element) { + return { + id: element.id, + namespace: element.namespace } }, exportFlows() { this.$toast().confirm( - this.$t("flow export", {"flowCount": this.queryBulkAction ? this.total : this.flowsSelection.length}), + this.$t("flow export", {"flowCount": this.queryBulkAction ? this.total : this.selection.length}), () => { if (this.queryBulkAction) { return this.$store @@ -289,18 +288,19 @@ }) } else { return this.$store - .dispatch("flow/exportFlowByIds", {ids: this.flowsSelection}) + .dispatch("flow/exportFlowByIds", {ids: this.selection}) .then(_ => { this.$toast().success(this.$t("flows exported")); }) } }, - () => {} + () => { + } ) }, - disableFlows(){ + disableFlows() { this.$toast().confirm( - this.$t("flow disable", {"flowCount": this.queryBulkAction ? this.total : this.flowsSelection.length}), + this.$t("flow disable", {"flowCount": this.queryBulkAction ? this.total : this.selection.length}), () => { if (this.queryBulkAction) { return this.$store @@ -310,23 +310,26 @@ }, false)) .then(r => { this.$toast().success(this.$t("flows disabled", {count: r.data.count})); - this.loadData(() => {}) + this.loadData(() => { + }) }) } else { return this.$store - .dispatch("flow/disableFlowByIds", {ids: this.flowsSelection}) + .dispatch("flow/disableFlowByIds", {ids: this.selection}) .then(r => { this.$toast().success(this.$t("flows disabled", {count: r.data.count})); - this.loadData(() => {}) + this.loadData(() => { + }) }) } }, - () => {} + () => { + } ) }, - enableFlows(){ + enableFlows() { this.$toast().confirm( - this.$t("flow enable", {"flowCount": this.queryBulkAction ? this.total : this.flowsSelection.length}), + this.$t("flow enable", {"flowCount": this.queryBulkAction ? this.total : this.selection.length}), () => { if (this.queryBulkAction) { return this.$store @@ -336,23 +339,26 @@ }, false)) .then(r => { this.$toast().success(this.$t("flows enabled", {count: r.data.count})); - this.loadData(() => {}) + this.loadData(() => { + }) }) } else { return this.$store - .dispatch("flow/enableFlowByIds", {ids: this.flowsSelection}) + .dispatch("flow/enableFlowByIds", {ids: this.selection}) .then(r => { this.$toast().success(this.$t("flows enabled", {count: r.data.count})); - this.loadData(() => {}) + this.loadData(() => { + }) }) } }, - () => {} + () => { + } ) }, - deleteFlows(){ + deleteFlows() { this.$toast().confirm( - this.$t("flow delete", {"flowCount": this.queryBulkAction ? this.total : this.flowsSelection.length}), + this.$t("flow delete", {"flowCount": this.queryBulkAction ? this.total : this.selection.length}), () => { if (this.queryBulkAction) { return this.$store @@ -362,18 +368,21 @@ }, false)) .then(r => { this.$toast().success(this.$t("flows deleted", {count: r.data.count})); - this.loadData(() => {}) + this.loadData(() => { + }) }) } else { return this.$store - .dispatch("flow/deleteFlowByIds", {ids: this.flowsSelection}) + .dispatch("flow/deleteFlowByIds", {ids: this.selection}) .then(r => { this.$toast().success(this.$t("flows deleted", {count: r.data.count})); - this.loadData(() => {}) + this.loadData(() => { + }) }) } }, - () => {} + () => { + } ) }, importFlows() { @@ -383,7 +392,8 @@ .dispatch("flow/importFlows", formData) .then(_ => { this.$toast().success(this.$t("flows imported")); - this.loadData(() => {}) + this.loadData(() => { + }) }) }, chartData(row) { diff --git a/ui/src/components/layout/BottomLineCounter.vue b/ui/src/components/layout/BottomLineCounter.vue deleted file mode 100644 index c7e51116c7..0000000000 --- a/ui/src/components/layout/BottomLineCounter.vue +++ /dev/null @@ -1,37 +0,0 @@ -<template> - <el-button-group> - <el-button size="large" @click="all()"> - <span v-html="$t('selection.selected', {count: modelValue ? total : selections.length})" /> - - <span class="counter" v-if="selections.length<total && !modelValue" v-html="$t('selection.all', {count: total})" /> - </el-button> - <slot /> - </el-button-group> -</template> -<script> - export default { - props: { - total: {type: Number, required: true}, - selections: {type: Array, required: true}, - modelValue: {type: Boolean, required: true}, - }, - emits: ["update:modelValue"], - methods: { - all() { - this.$emit("update:modelValue", true); - } - } - } -</script> -<style lang="scss" scoped> - span { - color: var(--bs-tertiary); - } - - span.counter { - border-left: 1px solid var(--bs-gray-100-darken-5); - padding-left: 0.5rem; - margin-left: 5px; - margin-right: 5px; - } -</style> diff --git a/ui/src/components/layout/BulkSelect.vue b/ui/src/components/layout/BulkSelect.vue new file mode 100644 index 0000000000..539c2b49e3 --- /dev/null +++ b/ui/src/components/layout/BulkSelect.vue @@ -0,0 +1,69 @@ +<template> + <div class="bulk-select"> + <el-checkbox + :model-value="selections.length > 0" + @change="toggle" + :indeterminate="partialCheck" + > + <span v-html="$t('selection.selected', {count: selectAll ? total : selections.length})" /> + </el-checkbox> + <el-button-group> + <el-button + :type="selectAll ? 'primary' : 'default'" + @click="toggleAll" + v-if="selections.length < total" + v-html="$t('selection.all', {count: total})" + /> + <slot /> + </el-button-group> + </div> +</template> +<script> + export default { + props: { + total: {type: Number, required: true}, + selections: {type: Array, required: true}, + selectAll: {type: Boolean, required: true}, + }, + emits: ["update:selectAll", "unselect"], + methods: { + toggle(value) { + if (!value) { + this.$emit("unselect"); + } + }, + toggleAll(value) { + this.$emit("update:selectAll", !this.selectAll); + } + }, + computed: { + partialCheck() { + return !this.selectAll && this.selections.length < this.total; + }, + } + } +</script> + +<style lang="scss" scoped> + .bulk-select { + height: 100%; + display: flex; + align-items: center; + + .el-checkbox { + height: 100%; + + span { + padding-left: calc(var(--spacer) * 1.5); + } + } + + > * { + padding: 0 8px; + } + } + + span { + font-weight: bold; + } +</style> diff --git a/ui/src/components/layout/SelectTable.vue b/ui/src/components/layout/SelectTable.vue new file mode 100644 index 0000000000..efa3a9cec3 --- /dev/null +++ b/ui/src/components/layout/SelectTable.vue @@ -0,0 +1,63 @@ +<script> + export default { + data() { + return { + hasSelection: false + } + }, + methods: { + selectionChanged(selection) { + this.hasSelection = selection.length > 0; + this.$emit("selection-change", selection); + }, + computeHeaderSize() { + const tableHead = this.$refs.table.$el.querySelector('thead'); + this.$el.style.setProperty("--table-header-width", `${tableHead.clientWidth}px`); + this.$el.style.setProperty("--table-header-height", `${tableHead.clientHeight}px`); + } + }, + props: { + selectable: { + type: Boolean, + default: true + }, + data: { + type: Array + } + }, + mounted() { + window.onresize = this.computeHeaderSize; + }, + updated() { + this.computeHeaderSize(); + } + } +</script> + +<template> + <div class="position-relative"> + <div v-if="hasSelection" class="bulk-select-header"> + <slot name="select-actions" /> + </div> + <el-table ref="table" v-bind="$attrs" :data="data" @selection-change="selectionChanged"> + <el-table-column type="selection" v-if="selectable" /> + <slot name="default" /> + </el-table> + </div> +</template> + +<style scoped lang="scss"> + .bulk-select-header { + z-index: 1; + position: absolute; + height: var(--table-header-height); + width: var(--table-header-width); + background-color: var(--bs-gray-100-darken-3); + border-radius: var(--bs-border-radius-lg) var(--bs-border-radius-lg) 0 0; + border-bottom: 1px solid var(--bs-border-color); + + & ~ .el-table { + z-index: 0; + } + } +</style> diff --git a/ui/src/components/templates/Templates.vue b/ui/src/components/templates/Templates.vue index e94535cb97..9477dbc52e 100644 --- a/ui/src/components/templates/Templates.vue +++ b/ui/src/components/templates/Templates.vue @@ -20,9 +20,9 @@ </template> <template #table> - <el-table + <select-table + ref="selectTable" :data="templates" - ref="table" :default-sort="{prop: 'id', order: 'ascending'}" stripe table-layout="auto" @@ -30,36 +30,58 @@ @row-dblclick="onRowDoubleClick" @sort-change="onSort" @selection-change="handleSelectionChange" + :selectable="canRead || canDelete" > - <el-table-column type="selection" v-if="(canRead)" /> - - <el-table-column prop="id" sortable="custom" :sort-orders="['ascending', 'descending']" :label="$t('id')"> - <template #default="scope"> - <router-link - :to="{name: 'templates/update', params: {namespace: scope.row.namespace, id: scope.row.id}}" - > - {{ scope.row.id }} - </router-link> - &nbsp;<markdown-tooltip + <template #select-actions> + <bulk-select + :select-all="queryBulkAction" + :selections="selection" + :total="total" + @update:select-all="toggleAllSelection" + @unselect="toggleAllUnselected" + > + <el-button v-if="canRead" :icon="Download" @click="exportTemplates()"> + {{ $t('export') }} + </el-button> + <el-button v-if="canDelete" @click="deleteTemplates" :icon="TrashCan"> + {{ $t('delete') }} + </el-button> + </bulk-select> + </template> + <template #default> + <el-table-column prop="id" sortable="custom" :sort-orders="['ascending', 'descending']" + :label="$t('id')"> + <template #default="scope"> + <router-link + :to="{name: 'templates/update', params: {namespace: scope.row.namespace, id: scope.row.id}}" + > + {{ scope.row.id }} + </router-link> + &nbsp;<markdown-tooltip :id="scope.row.namespace + '-' + scope.row.id" :description="scope.row.description" :title="scope.row.namespace + '.' + scope.row.id" /> - </template> - </el-table-column> + </template> + </el-table-column> - <el-table-column prop="namespace" sortable="custom" :sort-orders="['ascending', 'descending']" :label="$t('namespace')" :formatter="(_, __, cellValue) => $filters.invisibleSpace(cellValue)" /> + <el-table-column prop="namespace" sortable="custom" + :sort-orders="['ascending', 'descending']" + :label="$t('namespace')" + :formatter="(_, __, cellValue) => $filters.invisibleSpace(cellValue)" /> - <el-table-column column-key="action" class-name="row-action"> - <template #default="scope"> - <router-link :to="{name: 'templates/update', params : {namespace: scope.row.namespace, id: scope.row.id}}"> - <kicon :tooltip="$t('details')" placement="left"> - <eye /> - </kicon> - </router-link> - </template> - </el-table-column> - </el-table> + <el-table-column column-key="action" class-name="row-action"> + <template #default="scope"> + <router-link + :to="{name: 'templates/update', params : {namespace: scope.row.namespace, id: scope.row.id}}"> + <kicon :tooltip="$t('details')" placement="left"> + <eye /> + </kicon> + </router-link> + </template> + </el-table-column> + </template> + </select-table> </template> </data-table> </div> @@ -67,18 +89,6 @@ <bottom-line v-if="user && user.hasAnyAction(permission.TEMPLATE, action.CREATE)"> <ul> - <ul v-if="templatesSelection.length !== 0 && canRead"> - <bottom-line-counter v-model="queryBulkAction" :selections="templatesSelection" :total="total" @update:model-value="selectAll()"> - <el-button v-if="canRead" :icon="Download" size="large" @click="exportTemplates()"> - {{ $t('export') }} - </el-button> - <el-button v-if="canDelete" @click="deleteTemplates" size="large" :icon="TrashCan"> - {{ $t('delete') }} - </el-button> - </bottom-line-counter> - </ul> - - <li class="spacer" /> <li> <div class="el-input el-input-file el-input--large custom-upload"> <div class="el-input__wrapper"> @@ -109,6 +119,8 @@ </template> <script setup> + import BulkSelect from "../layout/BulkSelect.vue"; + import SelectTable from "../layout/SelectTable.vue"; import Plus from "vue-material-design-icons/Plus.vue"; import Download from "vue-material-design-icons/Download.vue"; import TrashCan from "vue-material-design-icons/TrashCan.vue"; @@ -129,11 +141,11 @@ import RestoreUrl from "../../mixins/restoreUrl"; import _merge from "lodash/merge"; import MarkdownTooltip from "../../components/layout/MarkdownTooltip.vue"; - import BottomLineCounter from "../layout/BottomLineCounter.vue"; import Upload from "vue-material-design-icons/Upload.vue"; + import SelectTableActions from "../../mixins/selectTableActions"; export default { - mixins: [RouteContext, RestoreUrl, DataTableActions], + mixins: [RouteContext, RestoreUrl, DataTableActions, SelectTableActions], components: { BottomLine, Eye, @@ -142,16 +154,13 @@ NamespaceSelect, Kicon, MarkdownTooltip, - BottomLineCounter, Upload }, data() { return { isDefaultNamespaceAllow: true, permission: permission, - action: action, - templatesSelection: [], - queryBulkAction: false + action: action }; }, computed: { @@ -187,25 +196,15 @@ callback(); }); }, - handleSelectionChange(val) { - if (val.length === 0) { - this.queryBulkAction = false - } - this.templatesSelection = val.map(x => { - return { - id: x.id, - namespace: x.namespace - } - }); - }, - selectAll() { - if (this.$refs.table.getSelectionRows().length !== this.$refs.table.data.length) { - this.$refs.table.toggleAllSelection(); - } + selectionMapper(element) { + return { + id: element.id, + namespace: element.namespace + }; }, exportTemplates() { this.$toast().confirm( - this.$t("template export", {"templateCount": this.queryBulkAction ? this.total : this.templatesSelection.length}), + this.$t("template export", {"templateCount": this.queryBulkAction ? this.total : this.selection.length}), () => { if (this.queryBulkAction) { return this.$store @@ -218,13 +217,14 @@ }) } else { return this.$store - .dispatch("template/exportTemplateByIds", {ids: this.templatesSelection}) + .dispatch("template/exportTemplateByIds", {ids: this.selection}) .then(_ => { this.$toast().success(this.$t("templates exported")); }) } }, - () => {} + () => { + } ) }, importTemplates() { @@ -234,12 +234,13 @@ .dispatch("template/importTemplates", formData) .then(_ => { this.$toast().success(this.$t("templates imported")); - this.loadData(() => {}) + this.loadData(() => { + }) }) }, - deleteTemplates(){ + deleteTemplates() { this.$toast().confirm( - this.$t("template delete", {"templateCount": this.queryBulkAction ? this.total : this.templatesSelection.length}), + this.$t("template delete", {"templateCount": this.queryBulkAction ? this.total : this.selection.length}), () => { if (this.queryBulkAction) { return this.$store @@ -249,18 +250,21 @@ }, false)) .then(r => { this.$toast().success(this.$t("templates deleted", {count: r.data.count})); - this.loadData(() => {}) + this.loadData(() => { + }) }) } else { return this.$store - .dispatch("template/deleteTemplateByIds", {ids: this.templatesSelection}) + .dispatch("template/deleteTemplateByIds", {ids: this.selection}) .then(r => { this.$toast().success(this.$t("templates deleted", {count: r.data.count})); - this.loadData(() => {}) + this.loadData(() => { + }) }) } }, - () => {} + () => { + } ) }, }, diff --git a/ui/src/mixins/selectTableActions.js b/ui/src/mixins/selectTableActions.js new file mode 100644 index 0000000000..6b4bf5e096 --- /dev/null +++ b/ui/src/mixins/selectTableActions.js @@ -0,0 +1,37 @@ +export default { + data() { + return { + queryBulkAction: false, + selection: [] + }; + }, + methods: { + handleSelectionChange(val) { + if (val.length === this.total) { + this.queryBulkAction = true + } else if (val.length < this.internalPageSize) { + this.queryBulkAction = false + } + this.selection = val.map(this.selectionMapper); + }, + toggleAllUnselected() { + this.elTable.clearSelection() + }, + toggleAllSelection(active) { + // only some are selected, we should set queryBulkAction to true because it will select all + if (active && this.elTable.getSelectionRows().length > 0 && !this.queryBulkAction) { + this.queryBulkAction = true; + } else { + this.queryBulkAction = false; + } + }, + selectionMapper(element) { + return element; + } + }, + computed: { + elTable() { + return this.$refs.selectTable.$refs.table; + } + } +}
null
test
train
2023-08-08T13:19:24
"2023-05-17T14:22:16Z"
Ben8t
train
kestra-io/kestra/1483_1875
kestra-io/kestra
kestra-io/kestra/1483
kestra-io/kestra/1875
[ "keyword_pr_to_issue" ]
8dc185feff0ff9abc6bbd1e656fcdad261ba16b5
3cb3f9d3b9041b9af74f4c1a9b61c666630ec43c
[]
[]
"2023-08-10T16:32:59Z"
[ "enhancement" ]
Add a custom UI color and label helping to distinguish between development and production environments
### Feature description As shown in [this great post](https://www.morling.dev/blog/oh_this_is_prod/), it's important to be able to distinguish between development and production environments easily. However, often it's easy to accidentally confuse production and development UIs if they look the same way. ## Proposal Add an option in the UI settings to set a custom color and label so that users can OPTIONALLY customize Kestra UI based on their environment. ![image](https://github.com/kestra-io/kestra/assets/86264395/e1c45396-7daa-4d1b-81dd-63eb64e6ad30) ![image](https://github.com/kestra-io/kestra/assets/86264395/568d418a-b93a-44d5-b3e0-314baa5f9221)
[ "ui/src/components/settings/Settings.vue", "ui/src/override/components/LeftMenu.vue", "ui/src/stores/layout.js", "ui/src/translations.json", "webserver/src/main/java/io/kestra/webserver/controllers/MiscController.java" ]
[ "ui/src/components/layout/Environment.vue", "ui/src/components/settings/Settings.vue", "ui/src/override/components/LeftMenu.vue", "ui/src/stores/layout.js", "ui/src/translations.json", "webserver/src/main/java/io/kestra/webserver/controllers/MiscController.java" ]
[]
diff --git a/ui/src/components/layout/Environment.vue b/ui/src/components/layout/Environment.vue new file mode 100644 index 0000000000..25acca9d23 --- /dev/null +++ b/ui/src/components/layout/Environment.vue @@ -0,0 +1,43 @@ +<template> + <div v-if="name" id="environment"> + <strong>{{ name }}</strong> + </div> +</template> + +<script> + import {mapGetters} from "vuex"; + import {cssVariable} from "../../utils/global"; + + export default { + computed: { + ...mapGetters("layout", ["envName", "envColor"]), + ...mapGetters("misc", ["configs"]), + name() { + return this.envName || this.configs?.environment?.name; + }, + color() { + if (this.envColor) { + return this.envColor; + } + + if (this.configs?.environment?.color) { + return this.configs.environment.color; + } + + return cssVariable("--bs-info"); + } + } + } +</script> + +<style lang="scss" scoped> +#environment { + margin-bottom: 0.5em; + background-color: v-bind('color'); + text-align: center; + + strong { + color: var(--bs-body-bg); + } +} +</style> \ No newline at end of file diff --git a/ui/src/components/settings/Settings.vue b/ui/src/components/settings/Settings.vue index f7f450a2e3..ef23b3247b 100644 --- a/ui/src/components/settings/Settings.vue +++ b/ui/src/components/settings/Settings.vue @@ -108,6 +108,23 @@ /> </el-select> </el-form-item> + + <el-form-item :label="$t('environment name setting')"> + <el-input + v-model="envName" + @change="onEnvNameChange" + :placeholder="$t('name')" + clearable + /> + </el-form-item> + + <el-form-item :label="$t('environment color setting')"> + <el-color-picker + v-model="envColor" + @change="onEnvColorChange" + show-alpha + /> + </el-form-item> </el-form> </div> </template> @@ -121,7 +138,7 @@ import NamespaceSelect from "../../components/namespace/NamespaceSelect.vue"; import LogLevelSelector from "../../components/logs/LogLevelSelector.vue"; import Utils from "../../utils/utils"; - import {mapGetters, mapState} from "vuex"; + import {mapGetters, mapState, useStore} from "vuex"; import permission from "../../models/permission"; import action from "../../models/action"; import {logDisplayTypes} from "../../utils/constants"; @@ -156,11 +173,14 @@ logDisplay: undefined, editorFontSize: undefined, editorFontFamily: undefined, - now: this.$moment() + now: this.$moment(), + envName: undefined, + envColor: undefined }; }, created() { const darkTheme = document.getElementsByTagName("html")[0].className.indexOf("dark") >= 0; + const store = useStore(); this.defaultNamespace = localStorage.getItem("defaultNamespace") || ""; this.defaultLogLevel = localStorage.getItem("defaultLogLevel") || "INFO"; @@ -174,6 +194,8 @@ this.logDisplay = localStorage.getItem("logDisplay") || logDisplayTypes.DEFAULT; this.editorFontSize = localStorage.getItem("editorFontSize") || 12; this.editorFontFamily = localStorage.getItem("editorFontFamily") || "'Source Code Pro', monospace"; + this.envName = store.getters["layout/envName"] || this.configs?.environment?.name; + this.envColor = store.getters["layout/envColor"] || this.configs?.environment?.color; }, methods: { onNamespaceSelect(value) { @@ -255,12 +277,28 @@ onFontFamily(value) { localStorage.setItem("editorFontFamily", value); this.editorFontFamily = value; + this.$toast().saved(); + }, + onEnvNameChange(value) { + if (value && value !== this.configs?.environment?.name) { + this.$store.commit("layout/setEnvName", value); + } + + this.$toast().saved(); + }, + onEnvColorChange(value) { + console.log(value, this.configs?.environment?.color) + if (value && value !== this.configs?.environment?.color) { + this.$store.commit("layout/setEnvColor", value); + } + this.$toast().saved(); } }, computed: { ...mapGetters("core", ["guidedProperties"]), ...mapState("auth", ["user"]), + ...mapGetters("misc", ["configs"]), routeInfo() { return { title: this.$t("settings") diff --git a/ui/src/override/components/LeftMenu.vue b/ui/src/override/components/LeftMenu.vue index f98fb6c5d5..f1711ed831 100644 --- a/ui/src/override/components/LeftMenu.vue +++ b/ui/src/override/components/LeftMenu.vue @@ -14,6 +14,7 @@ <span class="img" /> </router-link> </div> + <Environment /> </template> <template #footer> @@ -29,6 +30,7 @@ <script> import {SidebarMenu} from "vue-sidebar-menu"; + import Environment from "../../components/layout/Environment.vue"; import ChevronLeft from "vue-material-design-icons/ChevronLeft.vue"; import ChevronRight from "vue-material-design-icons/ChevronRight.vue"; import FileTreeOutline from "vue-material-design-icons/FileTreeOutline.vue"; @@ -53,6 +55,7 @@ ChevronLeft, ChevronRight, SidebarMenu, + Environment, }, emits: ["menu-collapse"], methods: { @@ -257,7 +260,7 @@ .logo { overflow: hidden; padding: 35px 0; - height: 133px; + height: 113px; position: relative; a { diff --git a/ui/src/stores/layout.js b/ui/src/stores/layout.js index f1b845d761..537c808d54 100644 --- a/ui/src/stores/layout.js +++ b/ui/src/stores/layout.js @@ -1,13 +1,36 @@ export default { namespaced: true, state: { - topNavbar: undefined + topNavbar: undefined, + envName: undefined, + envColor: undefined }, actions: {}, mutations: { setTopNavbar(state, value) { state.topNavbar = value + }, + setEnvName(state, value) { + localStorage.setItem("envName", value); + state.envName = value; + }, + setEnvColor(state, value) { + localStorage.setItem("envColor", value); + state.envColor = value; } }, - getters: {} + getters: { + envName(state) { + if (!state.envName) { + state.envName = localStorage.getItem("envName"); + } + return state.envName; + }, + envColor(state) { + if (!state.envColor) { + state.envColor = localStorage.getItem("envColor"); + } + return state.envColor; + } + } } \ No newline at end of file diff --git a/ui/src/translations.json b/ui/src/translations.json index b69f2acead..9d27bab8f3 100644 --- a/ui/src/translations.json +++ b/ui/src/translations.json @@ -459,6 +459,8 @@ "expand all": "Expand all", "collapse all": "Collapse all", "log expand setting": "Log default display", + "environment name setting": "Environment name", + "environment color setting": "Environment color", "slack support": "Ask help on our Slack", "error detected": "Error detected", "cannot swap tasks": "Can't swap the tasks", diff --git a/webserver/src/main/java/io/kestra/webserver/controllers/MiscController.java b/webserver/src/main/java/io/kestra/webserver/controllers/MiscController.java index b3f14114d7..46807317bd 100644 --- a/webserver/src/main/java/io/kestra/webserver/controllers/MiscController.java +++ b/webserver/src/main/java/io/kestra/webserver/controllers/MiscController.java @@ -6,6 +6,7 @@ import io.kestra.core.services.CollectorService; import io.kestra.core.services.InstanceService; import io.kestra.core.utils.VersionProvider; +import io.micronaut.core.annotation.Nullable; import io.micronaut.http.HttpResponse; import io.micronaut.http.annotation.Controller; import io.micronaut.http.annotation.Get; @@ -36,6 +37,14 @@ public class MiscController { @io.micronaut.context.annotation.Value("${kestra.anonymous-usage-report.enabled}") protected Boolean isAnonymousUsageEnabled; + @io.micronaut.context.annotation.Value("${kestra.environment.name}") + @Nullable + protected String environmentName; + + @io.micronaut.context.annotation.Value("${kestra.environment.color}") + @Nullable + protected String environmentColor; + @Get("/ping") @Hidden public HttpResponse<?> ping() { @@ -46,14 +55,24 @@ public HttpResponse<?> ping() { @ExecuteOn(TaskExecutors.IO) @Operation(tags = {"Misc"}, summary = "Get current configurations") public Configuration configuration() { - return Configuration + Configuration.ConfigurationBuilder builder = Configuration .builder() .uuid(instanceService.fetch()) .version(versionProvider.getVersion()) .isTaskRunEnabled(executionRepository.isTaskRunEnabled()) .isAnonymousUsageEnabled(this.isAnonymousUsageEnabled) - .isWorkerInstanceEnabled(false) - .build(); + .isWorkerInstanceEnabled(false); + + if (this.environmentName != null || this.environmentColor != null) { + builder.environment( + Environment.builder() + .name(this.environmentName) + .color(this.environmentColor) + .build() + ); + } + + return builder.build(); } @Get("/api/v1/usages") @@ -78,5 +97,14 @@ public static class Configuration { @JsonInclude Boolean isWorkerInstanceEnabled; + + Environment environment; + } + + @Value + @Builder(toBuilder = true) + public static class Environment { + String name; + String color; } }
null
train
train
2023-08-16T10:58:31
"2023-06-09T14:16:27Z"
anna-geller
train
kestra-io/kestra/1810_1882
kestra-io/kestra
kestra-io/kestra/1810
kestra-io/kestra/1882
[ "keyword_pr_to_issue" ]
87a07ca435419aa771e19d855b873dae287fdec8
a6344b4d79bc07be6d50f3d3a236c64d75e7aefb
[ "As we can see the /logs/search is causing the timeout, I guess it has to do with what we talked about this morning @loicmathieu with index on Postgres. Still I don't know why it has loaded on Blueprint page, did you come from another page before ?", "yup, it's very likely that I came there from another page 👍 " ]
[]
"2023-08-11T16:02:44Z"
[ "bug" ]
UI: Timeout exceeded
### Issue description ![image](https://github.com/kestra-io/kestra/assets/86264395/80b22006-a33a-45f8-a86c-93f40a5d435a) ![image](https://github.com/kestra-io/kestra/assets/86264395/22d9a756-0d32-4ad7-8e91-faa87a21b6e2) ![image](https://github.com/kestra-io/kestra/assets/86264395/2d1b84f3-c7af-447d-9325-39fe1ee120ef) jump dumping it all as I have no idea what can be helpful here 😅
[]
[ "jdbc-h2/src/main/resources/migrations/h2/V18_index_logs.sql", "jdbc-mysql/src/main/resources/migrations/mysql/V16_index_logs.sql", "jdbc-postgres/src/main/resources/migrations/postgres/V21_index_logs.sql" ]
[]
diff --git a/jdbc-h2/src/main/resources/migrations/h2/V18_index_logs.sql b/jdbc-h2/src/main/resources/migrations/h2/V18_index_logs.sql new file mode 100644 index 0000000000..670d66af69 --- /dev/null +++ b/jdbc-h2/src/main/resources/migrations/h2/V18_index_logs.sql @@ -0,0 +1,3 @@ +DROP INDEX logs_namespace; +DROP INDEX logs_timestamp; +CREATE INDEX logs_namespace_flow ON logs (deleted, timestamp, level, namespace, flow_id); \ No newline at end of file diff --git a/jdbc-mysql/src/main/resources/migrations/mysql/V16_index_logs.sql b/jdbc-mysql/src/main/resources/migrations/mysql/V16_index_logs.sql new file mode 100644 index 0000000000..7d7c3d5427 --- /dev/null +++ b/jdbc-mysql/src/main/resources/migrations/mysql/V16_index_logs.sql @@ -0,0 +1,3 @@ +DROP INDEX ix_namespace ON logs; +DROP INDEX ix_timestamp ON logs; +CREATE INDEX ix_namespace_flow ON logs (deleted, timestamp, level, namespace, flow_id); \ No newline at end of file diff --git a/jdbc-postgres/src/main/resources/migrations/postgres/V21_index_logs.sql b/jdbc-postgres/src/main/resources/migrations/postgres/V21_index_logs.sql new file mode 100644 index 0000000000..670d66af69 --- /dev/null +++ b/jdbc-postgres/src/main/resources/migrations/postgres/V21_index_logs.sql @@ -0,0 +1,3 @@ +DROP INDEX logs_namespace; +DROP INDEX logs_timestamp; +CREATE INDEX logs_namespace_flow ON logs (deleted, timestamp, level, namespace, flow_id); \ No newline at end of file
null
train
train
2023-08-11T17:40:41
"2023-07-25T14:18:52Z"
anna-geller
train
kestra-io/kestra/1121_1883
kestra-io/kestra
kestra-io/kestra/1121
kestra-io/kestra/1883
[ "keyword_pr_to_issue" ]
8dc185feff0ff9abc6bbd1e656fcdad261ba16b5
a6b28d61d6a3cb48021f9040a55e71c47c46e4ed
[ "I notice that when there is a lot of new entries in the queues table it uses a SeqScan.\n\nThen, if you recompute the statistics via `analyze queues` it correctly uses the right index (Bitmap Index Scan of `queues_type__consumer_scheduler` for scheduler related queues).\n\nIs the performance issue has been found on newly executed Kestra instance after created a lot of executions (for ex during a benchmark) ? Does it disappear after time or after recomputed the statistics ?", "It was observed during performance benchmarking - the number of executions was high. Running `VACUUM ANALYZE queues;` did not have any effect on the query plan.\r\n\r\nSadly, no long term effects were observed since we hit this weird issue just during benchmarking." ]
[]
"2023-08-14T10:16:05Z"
[]
Improve PostgreSQL JDBC queue poll performance
### Issue description There has been poll performance optimization done already (#1012), although the query still tends to execute rather slow (hundreds of milliseconds). The query plan seems to use _Seq Scan_ instead of using the indexes. Query plan even after running `VACUUM ANALYZE queues;` on the table with 3+M rows: ```Limit (cost=353189.18..353195.43 rows=500 width=662) (actual time=828.565..828.566 rows=0 loops=1) Output: value, "offset", ctid -> LockRows (cost=353189.18..357966.07 rows=382151 width=662) (actual time=828.563..828.564 rows=0 loops=1) Output: value, "offset", ctid -> Sort (cost=353189.18..354144.56 rows=382151 width=662) (actual time=828.563..828.563 rows=0 loops=1) Output: value, "offset", ctid Sort Key: queues."offset" Sort Method: quicksort Memory: 25kB -> Seq Scan on public.queues (cost=0.00..334147.01 rows=382151 width=662) (actual time=828.550..828.550 rows=0 loops=1) Output: value, "offset", ctid Filter: ((NOT queues.consumer_executor) AND (queues.type = 'io.kestra.core.models.executions.Execution'::queue_type)) Rows Removed by Filter: 3094525 Query Identifier: 5205766377754712210 Planning Time: 0.092 ms Execution Time: 828.587 ms ``` Tuning the cost optimizer parameter `random_page_cost=1.1` leads to correct usage of indices: ```Limit (cost=271995.12..272001.37 rows=500 width=662) (actual time=0.015..0.016 rows=0 loops=1) Output: value, "offset", ctid -> LockRows (cost=271995.12..276772.00 rows=382151 width=662) (actual time=0.015..0.015 rows=0 loops=1) Output: value, "offset", ctid -> Sort (cost=271995.12..272950.49 rows=382151 width=662) (actual time=0.014..0.015 rows=0 loops=1) Output: value, "offset", ctid Sort Key: queues."offset" Sort Method: quicksort Memory: 25kB -> Index Scan using queues_type__consumer_executor on public.queues (cost=0.43..252952.94 rows=382151 width=662) (actual time=0.012..0.012 rows=0 loops=1) Output: value, "offset", ctid Index Cond: ((queues.type = 'io.kestra.core.models.executions.Execution'::queue_type) AND (queues.consumer_executor = false)) Query Identifier: 5205766377754712210 Planning Time: 0.091 ms Execution Time: 0.032 ms ```
[ "jdbc-postgres/src/main/resources/migrations/postgres/V13__queue_index_optim.sql", "jdbc-postgres/src/main/resources/migrations/postgres/V21_index_logs.sql" ]
[ "jdbc-h2/src/main/resources/migrations/h2/V18__index_logs.sql", "jdbc-postgres/src/main/resources/migrations/postgres/V22__index_queues.sql" ]
[]
diff --git a/jdbc-h2/src/main/resources/migrations/h2/V18__index_logs.sql b/jdbc-h2/src/main/resources/migrations/h2/V18__index_logs.sql new file mode 100644 index 0000000000..03e23cefe5 --- /dev/null +++ b/jdbc-h2/src/main/resources/migrations/h2/V18__index_logs.sql @@ -0,0 +1,3 @@ +DROP INDEX logs_namespace; +DROP INDEX logs_timestamp; +CREATE INDEX logs_namespace_flow ON logs ("deleted", "timestamp", "level", "namespace", "flow_id"); \ No newline at end of file diff --git a/jdbc-postgres/src/main/resources/migrations/postgres/V13__queue_index_optim.sql b/jdbc-postgres/src/main/resources/migrations/postgres/V13__queue_index_optim.sql deleted file mode 100644 index 6769520e51..0000000000 --- a/jdbc-postgres/src/main/resources/migrations/postgres/V13__queue_index_optim.sql +++ /dev/null @@ -1,8 +0,0 @@ --- We drop the PK and the queues_type__offset, otherwise they are used by the poll query which is sub-optimal. --- We create an hash index on offset that will be used instead when filtering on offset. - -ALTER TABLE queues DROP CONSTRAINT IF EXISTS queues_pkey; - -DROP INDEX IF EXISTS queues_type__offset; - -CREATE INDEX IF NOT EXISTS queues_offset ON queues USING hash ("offset"); diff --git a/jdbc-postgres/src/main/resources/migrations/postgres/V21_index_logs.sql b/jdbc-postgres/src/main/resources/migrations/postgres/V21_index_logs.sql deleted file mode 100644 index 670d66af69..0000000000 --- a/jdbc-postgres/src/main/resources/migrations/postgres/V21_index_logs.sql +++ /dev/null @@ -1,3 +0,0 @@ -DROP INDEX logs_namespace; -DROP INDEX logs_timestamp; -CREATE INDEX logs_namespace_flow ON logs (deleted, timestamp, level, namespace, flow_id); \ No newline at end of file diff --git a/jdbc-postgres/src/main/resources/migrations/postgres/V22__index_queues.sql b/jdbc-postgres/src/main/resources/migrations/postgres/V22__index_queues.sql new file mode 100644 index 0000000000..4fe5ac87d6 --- /dev/null +++ b/jdbc-postgres/src/main/resources/migrations/postgres/V22__index_queues.sql @@ -0,0 +1,24 @@ +-- Recreate the queues_type__* indexes by adding the offset column otherwise the index is not used as we order on offset. +-- Also make them partial to lower the index size. +DROP INDEX queues_type__consumer_flow_topology; +DROP INDEX queues_type__consumer_indexer; +DROP INDEX queues_type__consumer_executor; +DROP INDEX queues_type__consumer_worker; +DROP INDEX queues_type__consumer_scheduler; + +CREATE INDEX queues_type__consumer_flow_topology ON queues (type, consumer_flow_topology, "offset") WHERE consumer_flow_topology = false; +CREATE INDEX queues_type__consumer_indexer ON queues (type, consumer_indexer, "offset") WHERE consumer_indexer = false; +CREATE INDEX queues_type__consumer_executor ON queues (type, consumer_executor, "offset") WHERE consumer_executor = false; +CREATE INDEX queues_type__consumer_worker ON queues (type, consumer_worker, "offset") WHERE consumer_worker = false; +CREATE INDEX queues_type__consumer_scheduler ON queues (type, consumer_scheduler, "offset") WHERE consumer_scheduler = false; + +-- Go back to the original PK and queues_offset__type as they are useful for offset based poll and updates +DO $$ + BEGIN + IF NOT exists (select constraint_name from information_schema.table_constraints where table_name = 'queues' and constraint_type = 'PRIMARY KEY') then + ALTER TABLE queues ADD PRIMARY KEY("offset"); + END IF; + END; +$$; +DROP INDEX IF EXISTS queues_offset; +CREATE INDEX IF NOT EXISTS queues_type__offset ON queues (type, "offset"); \ No newline at end of file
null
val
train
2023-08-16T10:58:31
"2023-03-31T14:55:27Z"
yuri1969
train
kestra-io/kestra/1758_1887
kestra-io/kestra
kestra-io/kestra/1758
kestra-io/kestra/1887
[ "keyword_pr_to_issue" ]
8dc185feff0ff9abc6bbd1e656fcdad261ba16b5
a5048f34e55054e3c35751a1a795807ccbea47ee
[]
[]
"2023-08-16T07:05:59Z"
[ "bug" ]
Add vertical alignment to the Topology view in the editor
### Expected Behavior The button to switch between vertical/horizontal (as it used to be) would be the best solution. if not possible to bring it back, make vertical view to be the default ### Actual Behaviour the horizontal display is the default ![image](https://github.com/kestra-io/kestra/assets/86264395/ab22d9f5-4143-47b5-a841-e7858cf5820c) the ### Steps To Reproduce _No response_ ### Environment Information - Kestra Version: develop full image ### Example flow _No response_
[ "ui/src/components/inputs/LowCodeEditor.vue" ]
[ "ui/src/components/inputs/LowCodeEditor.vue" ]
[]
diff --git a/ui/src/components/inputs/LowCodeEditor.vue b/ui/src/components/inputs/LowCodeEditor.vue index 8923583025..ff587c3674 100644 --- a/ui/src/components/inputs/LowCodeEditor.vue +++ b/ui/src/components/inputs/LowCodeEditor.vue @@ -109,6 +109,12 @@ generateGraph(); }) + watch(() => props.viewType, () => { + isHorizontal.value = props.viewType === "source-topology" ? false : + (props.viewType?.indexOf("blueprint") !== -1 ? true : localStorage.getItem("topology-orientation") === "1") + generateGraph(); + }) + // Event listeners & Watchers const observeWidth = () => { const resizeObserver = new ResizeObserver(function () { @@ -549,7 +555,7 @@ <template> <div ref="vueFlow" class="vueflow"> - <slot name="top-bar"/> + <slot name="top-bar" /> <VueFlow v-model="elements" :default-marker-color="cssVariable('--bs-cyan')"
null
test
train
2023-08-16T10:58:31
"2023-07-17T11:33:45Z"
anna-geller
train
kestra-io/kestra/1884_1888
kestra-io/kestra
kestra-io/kestra/1884
kestra-io/kestra/1888
[ "keyword_pr_to_issue" ]
8dc185feff0ff9abc6bbd1e656fcdad261ba16b5
83256d7b21d586d3ec1857bb0811a7c32ef3fdb2
[ "@brian-mulier-p visually, it should select all rows on the same" ]
[]
"2023-08-16T07:55:43Z"
[ "bug" ]
Table : "Select All" is bugged
### Expected Behavior When i use the button "Select All" All flows don't have the checkmark selected. <img width="1714" alt="Capture d’écran 2023-08-14 à 10 18 14" src="https://github.com/kestra-io/kestra/assets/125994028/ac5f9cba-2cd6-4468-a9cb-91bafa93b1a4"> ### Actual Behaviour _No response_ ### Steps To Reproduce On the demo with my kestra's account ### Environment Information - Kestra Version: - Operating System (OS / Docker / Kubernetes): - Java Version (If not docker): ### Example flow _No response_
[ "ui/src/mixins/selectTableActions.js" ]
[ "ui/src/mixins/selectTableActions.js" ]
[]
diff --git a/ui/src/mixins/selectTableActions.js b/ui/src/mixins/selectTableActions.js index 6b4bf5e096..1b83eddffa 100644 --- a/ui/src/mixins/selectTableActions.js +++ b/ui/src/mixins/selectTableActions.js @@ -24,6 +24,7 @@ export default { } else { this.queryBulkAction = false; } + this.elTable.toggleAllSelection() }, selectionMapper(element) { return element;
null
train
train
2023-08-16T10:58:31
"2023-08-14T10:26:21Z"
Nico-Kestra
train
kestra-io/kestra/1878_1889
kestra-io/kestra
kestra-io/kestra/1878
kestra-io/kestra/1889
[ "keyword_pr_to_issue" ]
8dc185feff0ff9abc6bbd1e656fcdad261ba16b5
618bb1f47d8f8d30fc1c6b76b76fbe3b9ad735aa
[]
[]
"2023-08-16T08:53:04Z"
[ "bug", "enhancement" ]
Cannot read properties of null on $el (missing event unregister from new SelectTable)
### Expected Behavior _No response_ ### Actual Behaviour Uncaught TypeError: Cannot read properties of null (reading '$el') at Proxy.computeHeaderSize (index-afe23b22.js:1086:286666) The resize event triggers on the SelectTable component even if we switched tab / page. Must unregister the resize event handle on unmount ### Steps To Reproduce Execution list -> detailed execution -> resize window ### Environment Information - Kestra Version: - Operating System (OS / Docker / Kubernetes): - Java Version (If not docker): ### Example flow _No response_
[ "ui/src/components/layout/SelectTable.vue" ]
[ "ui/src/components/layout/SelectTable.vue" ]
[]
diff --git a/ui/src/components/layout/SelectTable.vue b/ui/src/components/layout/SelectTable.vue index efa3a9cec3..cf056a2235 100644 --- a/ui/src/components/layout/SelectTable.vue +++ b/ui/src/components/layout/SelectTable.vue @@ -26,7 +26,10 @@ } }, mounted() { - window.onresize = this.computeHeaderSize; + window.addEventListener("resize", this.computeHeaderSize); + }, + unmounted() { + window.removeEventListener("resize", this.computeHeaderSize); }, updated() { this.computeHeaderSize();
null
train
train
2023-08-16T10:58:31
"2023-08-11T10:57:30Z"
brian-mulier-p
train
kestra-io/kestra/1879_1890
kestra-io/kestra
kestra-io/kestra/1879
kestra-io/kestra/1890
[ "keyword_pr_to_issue" ]
8dc185feff0ff9abc6bbd1e656fcdad261ba16b5
943e03a7a53dc50d934818731c3b0cee3f0629cd
[]
[]
"2023-08-16T09:17:48Z"
[ "bug", "enhancement" ]
New bulk select header overflows when the window is too small to display the whole table header
### Expected Behavior _No response_ ### Actual Behaviour ![image](https://github.com/kestra-io/kestra/assets/37618489/4336be2d-69bc-4e27-85a8-b8598461fab0) ### Steps To Reproduce _No response_ ### Environment Information - Kestra Version: - Operating System (OS / Docker / Kubernetes): - Java Version (If not docker): ### Example flow _No response_
[ "ui/src/components/layout/SelectTable.vue" ]
[ "ui/src/components/layout/SelectTable.vue" ]
[]
diff --git a/ui/src/components/layout/SelectTable.vue b/ui/src/components/layout/SelectTable.vue index efa3a9cec3..d505ff72b6 100644 --- a/ui/src/components/layout/SelectTable.vue +++ b/ui/src/components/layout/SelectTable.vue @@ -11,9 +11,9 @@ this.$emit("selection-change", selection); }, computeHeaderSize() { - const tableHead = this.$refs.table.$el.querySelector('thead'); - this.$el.style.setProperty("--table-header-width", `${tableHead.clientWidth}px`); - this.$el.style.setProperty("--table-header-height", `${tableHead.clientHeight}px`); + const tableElement = this.$refs.table.$el; + this.$el.style.setProperty("--table-header-width", `${tableElement.clientWidth}px`); + this.$el.style.setProperty("--table-header-height", `${tableElement.querySelector('thead').clientHeight}px`); } }, props: {
null
train
train
2023-08-16T10:58:31
"2023-08-11T10:59:56Z"
brian-mulier-p
train
kestra-io/kestra/1893_1894
kestra-io/kestra
kestra-io/kestra/1893
kestra-io/kestra/1894
[ "keyword_pr_to_issue" ]
3cb3f9d3b9041b9af74f4c1a9b61c666630ec43c
2f0a9a5ddcd53a0dc135803f60136cb6716c50b0
[ "Maybe we could also put Users, Groups and Roles (and namespaces?) in there as well ?", "Hello ! The PR contains that already 👍 " ]
[]
"2023-08-16T16:39:30Z"
[ "enhancement" ]
Admin tabs as submenu items
### Feature description Trigger administration should be a submenu instead of a tab (like documentation menu)
[ "jdbc/src/main/java/io/kestra/jdbc/repository/AbstractJdbcTriggerRepository.java", "ui/src/components/admin/Triggers.vue", "ui/src/models/permission.js", "ui/src/override/components/LeftMenu.vue", "ui/src/override/components/admin/Admin.vue", "ui/src/routes/routes.js", "ui/src/translations.json" ]
[ "jdbc/src/main/java/io/kestra/jdbc/repository/AbstractJdbcTriggerRepository.java", "ui/src/components/admin/Triggers.vue", "ui/src/models/permission.js", "ui/src/override/components/LeftMenu.vue", "ui/src/routes/routes.js", "ui/src/translations.json" ]
[]
diff --git a/jdbc/src/main/java/io/kestra/jdbc/repository/AbstractJdbcTriggerRepository.java b/jdbc/src/main/java/io/kestra/jdbc/repository/AbstractJdbcTriggerRepository.java index d6df1be232..b6976c532b 100644 --- a/jdbc/src/main/java/io/kestra/jdbc/repository/AbstractJdbcTriggerRepository.java +++ b/jdbc/src/main/java/io/kestra/jdbc/repository/AbstractJdbcTriggerRepository.java @@ -102,12 +102,15 @@ public ArrayListTotal<Trigger> find(Pageable pageable, String query, String name .select(field("value")) .hint(context.dialect() == SQLDialect.MYSQL ? "SQL_CALC_FOUND_ROWS" : null) .from(this.jdbcRepository.getTable()) - .where(this.fullTextCondition(query)); + .where(this.fullTextCondition(query)) + .and(this.defaultFilter()); if (namespace != null) { select.and(DSL.or(field("namespace").eq(namespace), field("namespace").likeIgnoreCase(namespace + ".%"))); } + select.and(this.defaultFilter()); + return this.jdbcRepository.fetchPage(context, select, pageable); }); } @@ -116,6 +119,11 @@ protected Condition fullTextCondition(String query) { return query == null ? DSL.trueCondition() : jdbcRepository.fullTextCondition(List.of("fulltext"), query); } + @Override + protected Condition defaultFilter() { + return DSL.trueCondition(); + } + @Override public Function<String, String> sortMapping() throws IllegalArgumentException { Map<String, String> mapper = Map.of( diff --git a/ui/src/components/admin/Triggers.vue b/ui/src/components/admin/Triggers.vue index 46d0b6f918..4aeb1681a5 100644 --- a/ui/src/components/admin/Triggers.vue +++ b/ui/src/components/admin/Triggers.vue @@ -86,7 +86,7 @@ {{ scope.row.evaluateRunningDate ? $filters.date(scope.row.evaluateRunningDate, "iso") : "" }} </template> </el-table-column> - <el-table-column column-key="action" class-name="row-action"> + <el-table-column v-if="user.hasAnyAction(permission.FLOW, action.UPDATE)" column-key="action" class-name="row-action"> <template #default="scope"> <el-button text v-if="scope.row.executionId || scope.row.evaluateRunningDate"> <kicon @@ -120,6 +120,8 @@ <script setup> import LockOff from "vue-material-design-icons/LockOff.vue"; import Kicon from "../Kicon.vue"; + import permission from "../../models/permission"; + import action from "../../models/action"; </script> <script> import NamespaceSelect from "../namespace/NamespaceSelect.vue"; @@ -130,6 +132,7 @@ import DataTableActions from "../../mixins/dataTableActions"; import MarkdownTooltip from "../layout/MarkdownTooltip.vue"; import RefreshButton from "../layout/RefreshButton.vue"; + import {mapState} from "vuex"; export default { mixins: [RouteContext, RestoreUrl, DataTableActions], @@ -172,7 +175,7 @@ }); this.$message({ - message: this.$t("trigger unlocked"), + message: this.$t("unlock trigger.success"), type: "success" }); @@ -183,6 +186,14 @@ this.triggerToUnlock = undefined; } + }, + computed: { + ...mapState("auth", ["user"]), + routeInfo() { + return { + title: this.$t("triggers") + } + } } }; </script> \ No newline at end of file diff --git a/ui/src/models/permission.js b/ui/src/models/permission.js index 24c4167aa7..e5aee58e80 100644 --- a/ui/src/models/permission.js +++ b/ui/src/models/permission.js @@ -1,6 +1,5 @@ export default { FLOW: "FLOW", EXECUTION: "EXECUTION", - TEMPLATE: "TEMPLATE", - ADMIN: "ADMIN" + TEMPLATE: "TEMPLATE" } diff --git a/ui/src/override/components/LeftMenu.vue b/ui/src/override/components/LeftMenu.vue index f1711ed831..2ebc880455 100644 --- a/ui/src/override/components/LeftMenu.vue +++ b/ui/src/override/components/LeftMenu.vue @@ -3,8 +3,6 @@ id="side-menu" :menu="menu" @update:collapsed="onToggleCollapse" - :show-one-child="true" - :show-child="showChildren" width="268px" :collapsed="collapsed" > @@ -48,6 +46,7 @@ import CogOutline from "vue-material-design-icons/CogOutline.vue"; import ViewDashboardVariantOutline from "vue-material-design-icons/ViewDashboardVariantOutline.vue"; import FileDocumentArrowRightOutline from "vue-material-design-icons/FileDocumentArrowRightOutline.vue"; + import TimerCogOutline from "vue-material-design-icons/TimerCogOutline.vue"; import {mapState} from "vuex"; export default { @@ -68,22 +67,17 @@ return items .map(r => { if (r.href === this.$route.path) { - r.disabled = true + r.disabled = true; } - if (r.href !== "/" && this.$route.path.startsWith(r.href)) { - r.class = "vsm--link_active" + // route hack is still needed for blueprints + if (r.href !== "/" && (this.$route.path.startsWith(r.href) || r.routes?.includes(this.$route.name))) { + r.class = "vsm--link_active"; } - // special case for plugins, were parents have no href to set active - // Could be adapted to all routes to have something more generic - if (r.routes?.includes(this.$route.name)) { - r.class = "vsm--link_active" - - if (r.child) { - this.showChildren = true - r.child = this.disabledCurrentRoute(r.child) - } + if (r.child && r.child.some(c => this.$route.path.startsWith(c.href))) { + r.class = "vsm--link_active"; + r.child = this.disabledCurrentRoute(r.child); } return r; @@ -155,7 +149,6 @@ element: BookMultipleOutline, class: "menu-icon" }, - routes: ["plugins/view"], child: [ { href: "https://kestra.io/docs/", @@ -169,7 +162,6 @@ { href: "/plugins", title: this.$t("plugins.names"), - routes: ["plugins/view"], icon: { element: GoogleCirclesExtended, class: "menu-icon" @@ -214,16 +206,27 @@ } }, { - href: "/admin", title: this.$t("administration"), icon: { element: AccountSupervisorOutline, class: "menu-icon" - } + }, + child: [ + { + href: "/admin/triggers", + title: this.$t("triggers"), + icon: { + element: TimerCogOutline, + class: "menu-icon" + } + } + ] } ]; + }, + expandParentIfNeeded() { + document.querySelectorAll(".vsm--link_level-1.vsm--link_active:not(.vsm--link_open)[aria-haspopup]").forEach(e => e.click()); } - }, watch: { menu: { @@ -232,7 +235,7 @@ //empty icon name on mouseover e.setAttribute("title", "") }); - this.showChildren = false + this.expandParentIfNeeded(); }, flush: 'post' } @@ -240,7 +243,6 @@ data() { return { collapsed: localStorage.getItem("menuCollapsed") === "true", - showChildren: false }; }, computed: { @@ -248,6 +250,9 @@ menu() { return this.disabledCurrentRoute(this.generateMenu()); } + }, + mounted() { + this.expandParentIfNeeded(); } }; </script> diff --git a/ui/src/override/components/admin/Admin.vue b/ui/src/override/components/admin/Admin.vue deleted file mode 100644 index 4c47fa8674..0000000000 --- a/ui/src/override/components/admin/Admin.vue +++ /dev/null @@ -1,48 +0,0 @@ -<template> - <div> - <tabs route-name="admin" ref="currentTab" :tabs="tabs" /> - </div> -</template> - -<script> - import RouteContext from "../../../mixins/routeContext"; - import Tabs from "../../../components/Tabs.vue"; - import Triggers from "../../../components/admin/Triggers.vue"; - - export default { - mixins: [RouteContext], - components: { - Tabs - }, - data() { - return { - tabs: this.getTabs() - } - }, - methods: { - activeTabName() { - if (this.$refs.currentTab) { - return this.$refs.currentTab.activeTab.name || "triggers"; - } - - return null; - }, - getTabs() { - return [ - { - name: "triggers", - component: Triggers, - title: this.$t("triggers"), - } - ] - } - }, - computed: { - routeInfo() { - return { - title: this.$t("administration") - } - } - } - }; -</script> \ No newline at end of file diff --git a/ui/src/routes/routes.js b/ui/src/routes/routes.js index a2893a4e1a..3f4c57e7bb 100644 --- a/ui/src/routes/routes.js +++ b/ui/src/routes/routes.js @@ -16,7 +16,7 @@ import FlowCreate from "../components/flows/FlowCreate.vue"; import FlowMetrics from "../components/flows/FlowMetrics.vue"; import Blueprints from "override/components/flows/blueprints/Blueprints.vue"; import BlueprintDetail from "../components/flows/blueprints/BlueprintDetail.vue"; -import Admin from "override/components/admin/Admin.vue"; +import Triggers from "../components/admin/Triggers.vue"; export default [ //Flows @@ -55,7 +55,7 @@ export default [ {name: "settings", path: "/settings", component: Settings}, //Admin - {name: "admin", path: "/admin/:tab?", component: Admin}, + {name: "admin/triggers", path: "/admin/triggers", component: Triggers}, //Errors {name: "errors/404-wildcard", path: "/:pathMatch(.*)", component: Errors, props: {code: 404}}, diff --git a/ui/src/translations.json b/ui/src/translations.json index e5dc5b2b99..7370954455 100644 --- a/ui/src/translations.json +++ b/ui/src/translations.json @@ -476,7 +476,8 @@ }, "confirmation": "Are you sure you want to unlock the trigger ?", "warning": "It could lead to concurrent executions for the same trigger and should be considered as a last resort option.", - "button": "Unlock trigger" + "button": "Unlock trigger", + "success": "Trigger is unlocked" }, "date format": "Date format", "timezone": "Timezone" @@ -958,7 +959,8 @@ }, "confirmation": "Êtes vous sûr(e) de vouloir débloquer le déclencheur ?", "warning": "Cela pourrait amener à de multiples exécutions concurrentes pour le même déclencheur et devrait être considéré comme une solution de dernier recours.", - "button": "Débloquer le déclencheur" + "button": "Débloquer le déclencheur", + "success": "Le déclencheur est débloqué" }, "date format": "Format de date", "timezone": "Fuseau horaire"
null
train
train
2023-08-18T08:39:25
"2023-08-16T16:32:28Z"
brian-mulier-p
train
kestra-io/kestra/1895_1896
kestra-io/kestra
kestra-io/kestra/1895
kestra-io/kestra/1896
[ "keyword_pr_to_issue" ]
28e4025bcd39f34351614cbbda1c9e8a24922109
38f6048ca54b72048071b0cc03d93a3c36639df4
[]
[]
"2023-08-16T16:55:40Z"
[ "bug", "enhancement" ]
Plugin doc (dot-including URLs) are not working in devserver
### Expected Behavior _No response_ ### Actual Behaviour Go to Documentation -> Plugins -> some plugin task Refresh 404 solution -> add [vite-plugin-rewrite-all](https://www.npmjs.com/package/vite-plugin-rewrite-all) ### Steps To Reproduce _No response_ ### Environment Information - Kestra Version: - Operating System (OS / Docker / Kubernetes): - Java Version (If not docker): ### Example flow _No response_
[ "ui/package-lock.json", "ui/package.json", "ui/vite.config.js" ]
[ "ui/package-lock.json", "ui/package.json", "ui/vite.config.js" ]
[]
diff --git a/ui/package-lock.json b/ui/package-lock.json index c0a988f062..07f1c51111 100644 --- a/ui/package-lock.json +++ b/ui/package-lock.json @@ -64,6 +64,7 @@ "prettier": "^3.0.1", "sass": "^1.64.2", "vite": "^4.4.9", + "vite-plugin-rewrite-all": "^1.0.1", "vitest": "^0.34.1" } }, @@ -432,9 +433,9 @@ } }, "node_modules/@types/markdown-it": { - "version": "12.2.3", - "resolved": "https://registry.npmjs.org/@types/markdown-it/-/markdown-it-12.2.3.tgz", - "integrity": "sha512-GKMHFfv3458yYy+v/N8gjufHO6MSZKCOXpZc5GXIWWy8uldwfmPn98vp81gZ5f9SVw8YYBctgfJ22a2d7AOMeQ==", + "version": "13.0.0", + "resolved": "https://registry.npmjs.org/@types/markdown-it/-/markdown-it-13.0.0.tgz", + "integrity": "sha512-mPTaUl5glYfzdJFeCsvhXQwZKdyszNAZcMm5ZTP5SfpTu+vIbog7J3z8Fa4x/Fzv5TB4R6OA/pHBYIYmkYOWGQ==", "peer": true, "dependencies": { "@types/linkify-it": "*", @@ -1312,6 +1313,15 @@ "proto-list": "~1.2.1" } }, + "node_modules/connect-history-api-fallback": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/connect-history-api-fallback/-/connect-history-api-fallback-1.6.0.tgz", + "integrity": "sha512-e54B99q/OUoH64zYYRf3HBP5z24G38h5D3qXu23JGRoigpX5Ss4r9ZnDk3g0Z8uQC2x2lPaJ+UlWBc1ZWBWdLg==", + "dev": true, + "engines": { + "node": ">=0.8" + } + }, "node_modules/core-js": { "version": "3.32.0", "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.32.0.tgz", @@ -4294,6 +4304,21 @@ "url": "https://opencollective.com/vitest" } }, + "node_modules/vite-plugin-rewrite-all": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/vite-plugin-rewrite-all/-/vite-plugin-rewrite-all-1.0.1.tgz", + "integrity": "sha512-W0DAchC8ynuQH0lYLIu5/5+JGfYlUTRD8GGNtHFXRJX4FzzB9MajtqHBp26zq/ly9sDt5BqrfdT08rv3RbB0LQ==", + "dev": true, + "dependencies": { + "connect-history-api-fallback": "^1.6.0" + }, + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "vite": "^2.0.0 || ^3.0.0 || ^4.0.0" + } + }, "node_modules/vitest": { "version": "0.34.1", "resolved": "https://registry.npmjs.org/vitest/-/vitest-0.34.1.tgz", diff --git a/ui/package.json b/ui/package.json index 9c63a47eeb..5fa0a43806 100644 --- a/ui/package.json +++ b/ui/package.json @@ -66,6 +66,7 @@ "prettier": "^3.0.1", "sass": "^1.64.2", "vite": "^4.4.9", + "vite-plugin-rewrite-all": "^1.0.1", "vitest": "^0.34.1" } } diff --git a/ui/vite.config.js b/ui/vite.config.js index 452e672a16..22fa83028f 100644 --- a/ui/vite.config.js +++ b/ui/vite.config.js @@ -1,6 +1,7 @@ import path from "path"; import {defineConfig} from "vite"; import vue from "@vitejs/plugin-vue"; +import pluginRewriteAll from 'vite-plugin-rewrite-all'; export default defineConfig({ base: "", @@ -14,6 +15,7 @@ export default defineConfig({ }, plugins: [ vue(), + pluginRewriteAll() ], css: { devSourcemap: true
null
test
train
2023-08-16T17:12:34
"2023-08-16T16:52:18Z"
brian-mulier-p
train
kestra-io/kestra/1847_1899
kestra-io/kestra
kestra-io/kestra/1847
kestra-io/kestra/1899
[ "keyword_pr_to_issue" ]
65dcc488ccd07f531a07f6d945e6e6fdea15b857
dabb9ce7f6b6c76588c7f0a0732923cc4de7c8e5
[ "Tried to reproduce even with the 503 thing I couldn't manage to do it", "The issue is that blueprints are loaded in the editor even if the blueprint tab is not displayed.\r\nThis will also creates un-needed API calls that will overload the blueprint API.\r\n\r\n@brian-mulier-p we should load blueprint only if the tab is selected in the editor, not always!" ]
[]
"2023-08-17T10:00:12Z"
[ "bug", "enhancement", "frontend" ]
Blueprint cause issues in Editor
### Expected Behavior _No response_ ### Actual Behaviour There are different cases: - sometimes the UI raise 503 errors (probably the API is down) - I got the following screen while accessing the editor view (while topology, exeuction and other Flow view were working) ![image](https://github.com/kestra-io/kestra/assets/46634684/27d65300-eec4-444b-a26d-0fdf4d48bfcb) [Slack thread for reference](https://kestra-io.slack.com/archives/C04HTFM3VL6/p1690983912027399) ### Steps To Reproduce _No response_ ### Environment Information - Kestra Version: - Operating System (OS / Docker / Kubernetes): - Java Version (If not docker): ### Example flow _No response_
[ "ui/src/components/inputs/EditorView.vue" ]
[ "ui/src/components/inputs/EditorView.vue" ]
[]
diff --git a/ui/src/components/inputs/EditorView.vue b/ui/src/components/inputs/EditorView.vue index 90db63297b..46216aa210 100644 --- a/ui/src/components/inputs/EditorView.vue +++ b/ui/src/components/inputs/EditorView.vue @@ -135,6 +135,7 @@ const taskError = ref(store.getters["flow/taskError"]) const user = store.getters["auth/user"]; const routeParams = router.currentRoute.value.params; + const blueprintsLoaded = ref(false); const persistViewType = (value) => { viewType.value = value; @@ -442,7 +443,7 @@ timer.value = setTimeout(() => onEdit(event), 500) } - const switchView = (event) => { + const switchViewType = (event) => { persistViewType(event); if (["topology", "source-topology"].includes(viewType.value)) { isHorizontal.value = isHorizontalDefault(); @@ -621,7 +622,7 @@ </template> </editor> <div class="slider" @mousedown="dragEditor" v-if="combinedEditor" /> - <Blueprints :class="{'d-none': viewType !== 'source-blueprints'}" embed class="combined-right-view enhance-readability" :top-navbar="false" prevent-route-info /> + <Blueprints v-if="(viewType === 'source-blueprints' && (blueprintsLoaded = true)) || blueprintsLoaded" :class="{'d-none': viewType !== 'source-blueprints'}" embed class="combined-right-view enhance-readability" :top-navbar="false" prevent-route-info /> <div :class="viewType === 'source-topology' ? 'combined-right-view' : viewType === 'topology' ? 'vueflow': 'hide-view'" > @@ -721,11 +722,11 @@ </el-button> </template> </el-drawer> - <SwitchView + <switch-view v-if="!isReadOnly" :type="viewType" class="to-topology-button" - @switch-view="switchView" + @switch-view="switchViewType" /> </el-card> <bottom-line v-if="!graphOnly">
null
test
train
2023-08-17T10:12:29
"2023-08-02T15:18:34Z"
Ben8t
train
kestra-io/kestra/1798_1901
kestra-io/kestra
kestra-io/kestra/1798
kestra-io/kestra/1901
[ "keyword_pr_to_issue" ]
65dcc488ccd07f531a07f6d945e6e6fdea15b857
bcad75542ad62785a1b544072bbc6a221b866a39
[]
[]
"2023-08-17T11:24:44Z"
[ "bug" ]
Copy buttons don't work in blueprints
### Expected Behavior _No response_ ### Actual Behaviour When clicking on the button to copy blueprint code content, the clipboard doesn't get the data (pasting doesn't work). This seems to be only the case on localhost installation (when deployed on proper https endpoints the copy button works) https://stackoverflow.com/questions/51805395/navigator-clipboard-is-undefined) ### Steps To Reproduce _No response_ ### Environment Information - Kestra Version: 0.10.2 - Operating System (OS / Docker / Kubernetes): Docker, MacOS - Java Version (If not docker): ### Example flow _No response_
[ "ui/src/components/flows/blueprints/BlueprintDetail.vue", "ui/src/override/components/flows/blueprints/BlueprintsBrowser.vue", "ui/src/utils/utils.js" ]
[ "ui/src/components/flows/blueprints/BlueprintDetail.vue", "ui/src/override/components/flows/blueprints/BlueprintsBrowser.vue", "ui/src/utils/utils.js" ]
[]
diff --git a/ui/src/components/flows/blueprints/BlueprintDetail.vue b/ui/src/components/flows/blueprints/BlueprintDetail.vue index 56871259ba..b88af2c6c0 100644 --- a/ui/src/components/flows/blueprints/BlueprintDetail.vue +++ b/ui/src/components/flows/blueprints/BlueprintDetail.vue @@ -55,7 +55,7 @@ <template #nav> <div class="position-absolute copy-wrapper"> <el-tooltip trigger="click" content="Copied" placement="left" :auto-close="2000"> - <el-button text round :icon="icon.ContentCopy" @click="copy(blueprint.flow)" /> + <el-button text round :icon="icon.ContentCopy" @click="Utils.copy(blueprint.flow)" /> </el-tooltip> </div> </template> @@ -87,6 +87,7 @@ import LowCodeEditor from "../../inputs/LowCodeEditor.vue"; import TaskIcon from "../../plugins/TaskIcon.vue"; import HomeOutline from "vue-material-design-icons/HomeOutline.vue"; + import Utils from "../../../utils/utils"; </script> <script> import YamlUtils from "../../../utils/yamlUtils"; @@ -97,7 +98,6 @@ import permission from "../../../models/permission"; import action from "../../../models/action"; - export default { components: {Markdown}, data() { @@ -130,9 +130,6 @@ this.$router.push({name: "blueprints"}) } }, - copy(text) { - navigator.clipboard.writeText(text); - }, asAutoRestoreDraft() { localStorage.setItem("autoRestore-creation_draft", this.blueprint.flow); } diff --git a/ui/src/override/components/flows/blueprints/BlueprintsBrowser.vue b/ui/src/override/components/flows/blueprints/BlueprintsBrowser.vue index e41dfb91d9..cfdfc486f3 100644 --- a/ui/src/override/components/flows/blueprints/BlueprintsBrowser.vue +++ b/ui/src/override/components/flows/blueprints/BlueprintsBrowser.vue @@ -79,6 +79,7 @@ import permission from "../../../../models/permission"; import action from "../../../../models/action"; import {mapState} from "vuex"; + import Utils from "../../../../utils/utils"; export default { mixins: [RestoreUrl, DataTableActions], @@ -115,7 +116,7 @@ return this.$route?.query?.selectedTag ?? 0 }, async copy(blueprintId) { - await navigator.clipboard.writeText( + await Utils.copy( (await this.$http.get(`${this.blueprintBaseUri}/${blueprintId}/flow`)).data ); }, diff --git a/ui/src/utils/utils.js b/ui/src/utils/utils.js index 2eb04fca11..bcae98933a 100644 --- a/ui/src/utils/utils.js +++ b/ui/src/utils/utils.js @@ -192,4 +192,22 @@ export default class Utils { return Array.isArray(objOrArray) ? objOrArray : [objOrArray]; } + + static async copy(text) { + if(navigator.clipboard) { + await navigator.clipboard.writeText(text); + return; + } + + const node = document.createElement("textarea"); + node.style.position = "absolute"; + node.style.left = "-9999px"; + node.textContent = text; + document.body.appendChild(node).value = text; + node.select() + + document.execCommand('copy'); + + document.body.removeChild(node); + } }
null
val
train
2023-08-17T10:12:29
"2023-07-24T07:47:19Z"
Ben8t
train
kestra-io/kestra/1648_1923
kestra-io/kestra
kestra-io/kestra/1648
kestra-io/kestra/1923
[ "keyword_pr_to_issue" ]
f214f2f98bcc461135fe94748e2e0ec014861bf9
f34f7f99c37b1e01975944e667421ea4bff45b20
[]
[]
"2023-08-21T13:20:06Z"
[ "enhancement" ]
Blueprint - When clicking on "Use" go to source/topo default editor view
### Feature description Blueprint - When clicking on "Use" go to source/topo default editor view
[ "ui/src/components/inputs/EditorView.vue", "ui/src/components/inputs/SwitchView.vue", "ui/src/override/components/flows/blueprints/BlueprintsBrowser.vue", "ui/src/utils/constants.js" ]
[ "ui/src/components/inputs/EditorView.vue", "ui/src/components/inputs/SwitchView.vue", "ui/src/override/components/flows/blueprints/BlueprintsBrowser.vue", "ui/src/utils/constants.js" ]
[]
diff --git a/ui/src/components/inputs/EditorView.vue b/ui/src/components/inputs/EditorView.vue index 88bf05ac6e..2b3c59a338 100644 --- a/ui/src/components/inputs/EditorView.vue +++ b/ui/src/components/inputs/EditorView.vue @@ -27,6 +27,7 @@ import {pageFromRoute} from "../../utils/eventsRouter"; import {SECTIONS} from "../../utils/constants.js"; import LowCodeEditor from "../inputs/LowCodeEditor.vue"; + import {editorViewTypes} from "../../utils/constants"; const store = useStore(); const router = getCurrentInstance().appContext.config.globalProperties.$router; @@ -90,17 +91,15 @@ } }) - const viewTypeStorageKey = "view-type"; - const loadViewType = () => { - return localStorage.getItem(viewTypeStorageKey); + return localStorage.getItem(editorViewTypes.STORAGE_KEY); } const initViewType = () => { - const defaultValue = "source-doc"; + const defaultValue = editorViewTypes.SOURCE_DOC; if (props.execution || props.isReadOnly) { - return "topology"; + return editorViewTypes.TOPOLOGY; } const storedValue = loadViewType(); @@ -108,12 +107,12 @@ return storedValue; } - localStorage.setItem(viewTypeStorageKey, defaultValue); + localStorage.setItem(editorViewTypes.STORAGE_KEY, defaultValue); return defaultValue; } const isHorizontalDefault = () => { - return viewType.value === "source-topology" ? false : localStorage.getItem("topology-orientation") === "1" + return viewType.value === editorViewTypes.SOURCE_TOPOLOGY ? false : localStorage.getItem("topology-orientation") === "1" } const editorDomElement = ref(null); @@ -139,7 +138,7 @@ const persistViewType = (value) => { viewType.value = value; - localStorage.setItem(viewTypeStorageKey, value); + localStorage.setItem(editorViewTypes.STORAGE_KEY, value); } const localStorageKey = computed(() => { @@ -197,7 +196,7 @@ && localStorage.getItem("tourDoneOrSkip") !== "true" && props.total === 0) { tours["guidedTour"].start(); - persistViewType("source"); + persistViewType(editorViewTypes.SOURCE); } }, 200) window.addEventListener("popstate", () => { @@ -233,14 +232,14 @@ const viewTypeOnReadOnly = () => { - const defaultValue = "source-topology"; + const defaultValue = SOURCE_TOPOLOGY_VIEW_TYPE; if (props.isCreating) { - return "source"; + return editorViewTypes.SOURCE; } if (props.execution || props.isReadOnly) { - return "topology"; + return editorViewTypes.TOPOLOGY; } const storedValue = loadViewType(); @@ -341,7 +340,7 @@ clearTimeout(timer.value) return store.dispatch("flow/validateFlow", {flow: event}) .then(value => { - if (flowHaveTasks() && ["topology", "source-topology"].includes(viewType.value)) { + if (flowHaveTasks() && [editorViewTypes.TOPOLOGY, editorViewTypes.SOURCE_TOPOLOGY].includes(viewType.value)) { generateGraph() } @@ -445,14 +444,14 @@ const switchViewType = (event) => { persistViewType(event); - if (["topology", "source-topology"].includes(viewType.value)) { + if ([editorViewTypes.TOPOLOGY, editorViewTypes.SOURCE_TOPOLOGY].includes(viewType.value)) { isHorizontal.value = isHorizontalDefault(); if (updatedFromEditor.value) { onEdit(flowYaml.value) updatedFromEditor.value = false; } } - if (event === "source" && editorDomElement?.value?.$el) { + if (event === editorViewTypes.SOURCE && editorDomElement?.value?.$el) { editorDomElement.value.$el.style = null; } } @@ -576,7 +575,7 @@ }); } - const combinedEditor = computed(() => ["source-doc", "source-topology", "source-blueprints"].includes(viewType.value)); + const combinedEditor = computed(() => [editorViewTypes.SOURCE_DOC, editorViewTypes.SOURCE_TOPOLOGY, editorViewTypes.SOURCE_BLUEPRINTS].includes(viewType.value)); const dragEditor = (e) => { let dragX = e.clientX; @@ -605,7 +604,7 @@ <el-card shadow="never" v-loading="isLoading"> <editor ref="editorDomElement" - v-if="combinedEditor || viewType === 'source'" + v-if="combinedEditor || viewType === editorViewTypes.SOURCE" :class="combinedEditor ? 'editor-combined' : ''" :style="combinedEditor ? {width: editorWidthPercentage} : {}" @save="save" @@ -615,16 +614,16 @@ @update:model-value="editorUpdate($event)" @cursor="updatePluginDocumentation($event)" :creating="isCreating" - @restartGuidedTour="() => persistViewType('source')" + @restartGuidedTour="() => persistViewType(editorViewTypes.SOURCE)" > <template #extends-navbar> <ValidationError tooltip-placement="bottom-start" size="small" class="ms-2" :error="flowError" /> </template> </editor> <div class="slider" @mousedown="dragEditor" v-if="combinedEditor" /> - <Blueprints v-if="viewType === 'source-blueprints' || blueprintsLoaded" @loaded="blueprintsLoaded = true" :class="{'d-none': viewType !== 'source-blueprints'}" embed class="combined-right-view enhance-readability" :top-navbar="false" prevent-route-info /> + <Blueprints v-if="viewType === 'source-blueprints' || blueprintsLoaded" @loaded="blueprintsLoaded = true" :class="{'d-none': viewType !== editorViewTypes.SOURCE_BLUEPRINTS}" embed class="combined-right-view enhance-readability" :top-navbar="false" prevent-route-info /> <div - :class="viewType === 'source-topology' ? 'combined-right-view' : viewType === 'topology' ? 'vueflow': 'hide-view'" + :class="viewType === editorViewTypes.SOURCE_TOPOLOGY ? 'combined-right-view' : viewType === editorViewTypes.TOPOLOGY ? 'vueflow': 'hide-view'" > <LowCodeEditor v-if="flowGraph" @@ -641,13 +640,13 @@ :is-allowed-edit="isAllowedEdit()" :view-type="viewType" > - <template #top-bar v-if="viewType === 'topology'"> + <template #top-bar v-if="viewType === editorViewTypes.TOPOLOGY"> <ValidationError tooltip-placement="bottom-start" size="small" class="ms-2" :error="flowError" /> </template> </LowCodeEditor> </div> <PluginDocumentation - v-if="viewType === 'source-doc'" + v-if="viewType === editorViewTypes.SOURCE_DOC" class="plugin-doc combined-right-view enhance-readability" /> <el-drawer diff --git a/ui/src/components/inputs/SwitchView.vue b/ui/src/components/inputs/SwitchView.vue index 6ec5b5c18a..5a7a6cd59b 100644 --- a/ui/src/components/inputs/SwitchView.vue +++ b/ui/src/components/inputs/SwitchView.vue @@ -1,19 +1,19 @@ <template> <el-button-group size="small"> <el-tooltip :content="$t('source')" transition="" :hide-after="0" :persistent="false"> - <el-button :type="buttonType('source')" @click="switchView('source')" :icon="FileDocumentEdit" /> + <el-button :type="buttonType(editorViewTypes.SOURCE)" @click="switchView(editorViewTypes.SOURCE)" :icon="FileDocumentEdit" /> </el-tooltip> <el-tooltip :content="$t('source and doc')" transition="" :hide-after="0" :persistent="false"> - <el-button :type="buttonType('source-doc')" @click="switchView('source-doc')" :icon="BookOpenPageVariantOutline" /> + <el-button :type="buttonType(editorViewTypes.SOURCE_DOC)" @click="switchView(editorViewTypes.SOURCE_DOC)" :icon="BookOpenPageVariantOutline" /> </el-tooltip> <el-tooltip :content="$t('source and topology')" transition="" :hide-after="0" :persistent="false"> - <el-button :type="buttonType('source-topology')" @click="switchView('source-topology')" :icon="FileChart" /> + <el-button :type="buttonType(editorViewTypes.SOURCE_TOPOLOGY)" @click="switchView(editorViewTypes.SOURCE_TOPOLOGY)" :icon="FileChart" /> </el-tooltip> <el-tooltip :content="$t('topology')" transition="" :hide-after="0" :persistent="false"> - <el-button :type="buttonType('topology')" @click="switchView('topology')" :icon="Graph" /> + <el-button :type="buttonType(editorViewTypes.TOPOLOGY)" @click="switchView(editorViewTypes.TOPOLOGY)" :icon="Graph" /> </el-tooltip> <el-tooltip :content="$t('source and blueprints')" transition="" :hide-after="0" :persistent="false"> - <el-button :type="buttonType('source-blueprints')" @click="switchView('source-blueprints')" :icon="ImageSearch" /> + <el-button :type="buttonType(editorViewTypes.SOURCE_BLUEPRINTS)" @click="switchView(editorViewTypes.SOURCE_BLUEPRINTS)" :icon="ImageSearch" /> </el-tooltip> </el-button-group> </template> @@ -24,13 +24,13 @@ import ImageSearch from "vue-material-design-icons/ImageSearch.vue"; import FileChart from "vue-material-design-icons/FileChart.vue"; import BookOpenPageVariantOutline from "vue-material-design-icons/BookOpenPageVariantOutline.vue"; + import {editorViewTypes} from "../../utils/constants"; </script> <script> import ValidationError from "../flows/ValidationError.vue"; export default { - components: {ValidationError}, props: { type: { diff --git a/ui/src/override/components/flows/blueprints/BlueprintsBrowser.vue b/ui/src/override/components/flows/blueprints/BlueprintsBrowser.vue index 813da406bb..4169d8f5ef 100644 --- a/ui/src/override/components/flows/blueprints/BlueprintsBrowser.vue +++ b/ui/src/override/components/flows/blueprints/BlueprintsBrowser.vue @@ -82,6 +82,7 @@ import {mapState} from "vuex"; import Utils from "../../../../utils/utils"; import Errors from "../../../../components/errors/Errors.vue"; + import {editorViewTypes} from "../../../../utils/constants"; export default { mixins: [RestoreUrl, DataTableActions], @@ -124,6 +125,7 @@ ); }, async blueprintToEditor(blueprintId) { + localStorage.setItem(editorViewTypes.STORAGE_KEY, editorViewTypes.SOURCE_TOPOLOGY); localStorage.setItem("autoRestore-creation_draft", (await this.$http.get(`${this.blueprintBaseUri}/${blueprintId}/flow`)).data); this.$router.push({name: 'flows/create'}); }, diff --git a/ui/src/utils/constants.js b/ui/src/utils/constants.js index af4cbe71c1..51cf75e0b2 100644 --- a/ui/src/utils/constants.js +++ b/ui/src/utils/constants.js @@ -13,4 +13,13 @@ export const logDisplayTypes = { ERROR: "error", HIDDEN: "hidden", DEFAULT: "all" +} + +export const editorViewTypes = { + STORAGE_KEY: "view-type", + SOURCE: "source", + SOURCE_TOPOLOGY: "source-topology", + SOURCE_DOC: "source-doc", + TOPOLOGY: "topology", + SOURCE_BLUEPRINTS: "source-blueprints" } \ No newline at end of file
null
test
train
2023-08-22T22:37:48
"2023-06-27T15:44:05Z"
Ben8t
train
kestra-io/kestra/1849_1924
kestra-io/kestra
kestra-io/kestra/1849
kestra-io/kestra/1924
[ "keyword_pr_to_issue" ]
88b11ddfb339aa36544ab04d525f818dbef64a58
b81147d3d1d51aa3e8195e515403f5e260859fcf
[]
[]
"2023-08-21T14:33:27Z"
[ "enhancement", "frontend" ]
Display nice message when Blueprint can't be accessible
### Feature description Some users could be in a private network/isolated and so they can't access blueprints. Would it be possible to display a message (like the 404 one maybe) in the Blueprint page.
[ "ui/src/components/inputs/EditorView.vue", "ui/src/override/components/flows/blueprints/Blueprints.vue", "ui/src/override/components/flows/blueprints/BlueprintsBrowser.vue" ]
[ "ui/src/components/inputs/EditorView.vue", "ui/src/override/components/flows/blueprints/Blueprints.vue", "ui/src/override/components/flows/blueprints/BlueprintsBrowser.vue" ]
[]
diff --git a/ui/src/components/inputs/EditorView.vue b/ui/src/components/inputs/EditorView.vue index 46216aa210..88bf05ac6e 100644 --- a/ui/src/components/inputs/EditorView.vue +++ b/ui/src/components/inputs/EditorView.vue @@ -622,7 +622,7 @@ </template> </editor> <div class="slider" @mousedown="dragEditor" v-if="combinedEditor" /> - <Blueprints v-if="(viewType === 'source-blueprints' && (blueprintsLoaded = true)) || blueprintsLoaded" :class="{'d-none': viewType !== 'source-blueprints'}" embed class="combined-right-view enhance-readability" :top-navbar="false" prevent-route-info /> + <Blueprints v-if="viewType === 'source-blueprints' || blueprintsLoaded" @loaded="blueprintsLoaded = true" :class="{'d-none': viewType !== 'source-blueprints'}" embed class="combined-right-view enhance-readability" :top-navbar="false" prevent-route-info /> <div :class="viewType === 'source-topology' ? 'combined-right-view' : viewType === 'topology' ? 'vueflow': 'hide-view'" > diff --git a/ui/src/override/components/flows/blueprints/Blueprints.vue b/ui/src/override/components/flows/blueprints/Blueprints.vue index 1922590001..270a646cfc 100644 --- a/ui/src/override/components/flows/blueprints/Blueprints.vue +++ b/ui/src/override/components/flows/blueprints/Blueprints.vue @@ -2,7 +2,7 @@ <blueprints-page-header v-if="!embed" /> <div class="main-container" v-bind="$attrs"> <blueprint-detail v-if="selectedBlueprintId" :embed="embed" :blueprint-id="selectedBlueprintId" @back="selectedBlueprintId = undefined" /> - <blueprints-browser :class="{'d-none': !!selectedBlueprintId}" :embed="embed" blueprint-base-uri="/api/v1/blueprints/community" @go-to-detail="blueprintId => selectedBlueprintId = blueprintId" /> + <blueprints-browser @loaded="$emit('loaded', $event)" :class="{'d-none': !!selectedBlueprintId}" :embed="embed" blueprint-base-uri="/api/v1/blueprints/community" @go-to-detail="blueprintId => selectedBlueprintId = blueprintId" /> </div> </template> <script> diff --git a/ui/src/override/components/flows/blueprints/BlueprintsBrowser.vue b/ui/src/override/components/flows/blueprints/BlueprintsBrowser.vue index cfdfc486f3..813da406bb 100644 --- a/ui/src/override/components/flows/blueprints/BlueprintsBrowser.vue +++ b/ui/src/override/components/flows/blueprints/BlueprintsBrowser.vue @@ -1,5 +1,6 @@ <template> - <div> + <errors code="404" v-if="error && embed"/> + <div v-else> <data-table class="blueprints" @page-changed="onPageChanged" ref="dataTable" :total="total" divider> <template #navbar> <div class="d-flex sub-nav"> @@ -80,11 +81,12 @@ import action from "../../../../models/action"; import {mapState} from "vuex"; import Utils from "../../../../utils/utils"; + import Errors from "../../../../components/errors/Errors.vue"; export default { mixins: [RestoreUrl, DataTableActions], - components: {TaskIcon, DataTable, SearchField}, - emits: ["goToDetail"], + components: {TaskIcon, DataTable, SearchField, Errors}, + emits: ["goToDetail", "loaded"], props: { blueprintBaseUri: { type: String, @@ -108,7 +110,8 @@ total: 0, icon: { ContentCopy: shallowRef(ContentCopy) - } + }, + error: false } }, methods: { @@ -189,7 +192,15 @@ Promise.all([ this.loadTags(beforeLoadBlueprintBaseUri), this.loadBlueprints(beforeLoadBlueprintBaseUri) - ]).finally(() => { + ]).then(() => { + this.$emit("loaded"); + }).catch(() => { + if(this.embed) { + this.error = true; + } else { + this.$store.dispatch("core/showError", 404); + } + }).finally(() => { // Handle switch tab while fetching data if (this.blueprintBaseUri === beforeLoadBlueprintBaseUri) { callback();
null
test
train
2023-08-21T14:34:00
"2023-08-03T08:45:18Z"
Ben8t
train
kestra-io/kestra/1929_1934
kestra-io/kestra
kestra-io/kestra/1929
kestra-io/kestra/1934
[ "keyword_pr_to_issue" ]
296e9246169e6c9eba081a9d6ae9288cbaccbf7e
f214f2f98bcc461135fe94748e2e0ec014861bf9
[]
[]
"2023-08-22T19:10:37Z"
[ "bug" ]
warningOnRetry shows up even with no retry/failure
### Expected Behavior `warningOnRetry` should only shows a warning when an actual retry is done ### Actual Behaviour The following Flow ends on warning state while there is no retry or failure ``` - id: this-does-not-retry type: io.kestra.plugin.scripts.shell.Commands runner: PROCESS commands: - 'echo "foo"' retry: type: constant interval: PT0.25S maxAttempt: 2 maxDuration: PT1M warningOnRetry: true ``` ![image](https://github.com/kestra-io/kestra/assets/46634684/ee6cb4de-fb1f-4149-bfd8-462c88ef7390) ### Steps To Reproduce _No response_ ### Environment Information - Kestra Version: - Operating System (OS / Docker / Kubernetes): - Java Version (If not docker): ### Example flow _No response_
[ "core/src/main/java/io/kestra/core/runners/Worker.java" ]
[ "core/src/main/java/io/kestra/core/runners/Worker.java" ]
[ "core/src/test/java/io/kestra/core/runners/RetryTest.java", "core/src/test/resources/flows/valids/retry-success-first-attempt.yaml" ]
diff --git a/core/src/main/java/io/kestra/core/runners/Worker.java b/core/src/main/java/io/kestra/core/runners/Worker.java index ef8264d86d..d748e79f22 100644 --- a/core/src/main/java/io/kestra/core/runners/Worker.java +++ b/core/src/main/java/io/kestra/core/runners/Worker.java @@ -355,7 +355,7 @@ private WorkerTaskResult run(WorkerTask workerTask, Boolean cleanUp) throws Queu if (workerTask.getTask().getRetry() != null && workerTask.getTask().getRetry().getWarningOnRetry() && - finalWorkerTask.getTaskRun().getAttempts().size() > 0 && + finalWorkerTask.getTaskRun().attemptNumber() > 1 && state == State.Type.SUCCESS ) { state = State.Type.WARNING;
diff --git a/core/src/test/java/io/kestra/core/runners/RetryTest.java b/core/src/test/java/io/kestra/core/runners/RetryTest.java index de5b7f6a28..bc2c1d54d7 100644 --- a/core/src/test/java/io/kestra/core/runners/RetryTest.java +++ b/core/src/test/java/io/kestra/core/runners/RetryTest.java @@ -29,6 +29,15 @@ void retrySuccess() throws TimeoutException { assertThat(execution.getTaskRunList().get(0).getAttempts(), hasSize(5)); } + @Test + void retrySuccessAtFirstAttempt() throws TimeoutException { + Execution execution = runnerUtils.runOne("io.kestra.tests", "retry-success-first-attempt"); + + assertThat(execution.getState().getCurrent(), is(State.Type.SUCCESS)); + assertThat(execution.getTaskRunList(), hasSize(1)); + assertThat(execution.getTaskRunList().get(0).getAttempts(), hasSize(1)); + } + @Test void retryFailed() throws TimeoutException { List<Execution> executions = new ArrayList<>(); diff --git a/core/src/test/resources/flows/valids/retry-success-first-attempt.yaml b/core/src/test/resources/flows/valids/retry-success-first-attempt.yaml new file mode 100644 index 0000000000..d959f09e7b --- /dev/null +++ b/core/src/test/resources/flows/valids/retry-success-first-attempt.yaml @@ -0,0 +1,18 @@ +id: retry-success-first-attempt +namespace: io.kestra.tests + +tasks: +- id: not-retry-and-no-warning + type: io.kestra.core.tasks.log.Log + message: "foo" + retry: + type: constant + interval: PT0.250S + maxAttempt: 5 + maxDuration: PT15S + warningOnRetry: true + +errors: + - id: never-happen + type: io.kestra.core.tasks.log.Log + message: Never {{task.id}}
test
train
2023-08-22T18:29:43
"2023-08-22T08:59:37Z"
Ben8t
train
kestra-io/kestra/1928_1938
kestra-io/kestra
kestra-io/kestra/1928
kestra-io/kestra/1938
[ "keyword_pr_to_issue" ]
f214f2f98bcc461135fe94748e2e0ec014861bf9
72d8c0ce1d779ebac5494067e54cdc8887df5e62
[]
[]
"2023-08-23T12:09:51Z"
[ "bug", "frontend" ]
Mass action selection is not working
### Expected Behavior _No response_ ### Actual Behaviour https://github.com/kestra-io/kestra/assets/46634684/10ebe95c-b61d-4ffc-9743-bfff8baf4390 ### Steps To Reproduce _No response_ ### Environment Information - Kestra Version: 0.11.0 SNAPSHOT - Operating System (OS / Docker / Kubernetes): Docker - Java Version (If not docker): ### Example flow _No response_
[ "ui/src/components/layout/BulkSelect.vue", "ui/src/mixins/dataTableActions.js", "ui/src/mixins/selectTableActions.js" ]
[ "ui/src/components/layout/BulkSelect.vue", "ui/src/mixins/dataTableActions.js", "ui/src/mixins/selectTableActions.js" ]
[]
diff --git a/ui/src/components/layout/BulkSelect.vue b/ui/src/components/layout/BulkSelect.vue index 539c2b49e3..cf9060dce0 100644 --- a/ui/src/components/layout/BulkSelect.vue +++ b/ui/src/components/layout/BulkSelect.vue @@ -32,7 +32,7 @@ this.$emit("unselect"); } }, - toggleAll(value) { + toggleAll() { this.$emit("update:selectAll", !this.selectAll); } }, diff --git a/ui/src/mixins/dataTableActions.js b/ui/src/mixins/dataTableActions.js index efb996bb1c..b4b23553bf 100644 --- a/ui/src/mixins/dataTableActions.js +++ b/ui/src/mixins/dataTableActions.js @@ -4,8 +4,8 @@ import _isEqual from "lodash/isEqual"; export default { created() { - this.internalPageSize = this.pageSize; - this.internalPageNumber = this.pageNumber; + this.internalPageSize = this.pageSize ?? this.$route.query.size ?? 25; + this.internalPageNumber = this.pageNumber ?? this.$route.query.page ?? 1; // @TODO: ugly hack from restoreUrl if (this.loadInit) { @@ -29,12 +29,10 @@ export default { default: () => {} }, pageSize: { - type: Number, - default: 25 + type: Number }, pageNumber: { - type: Number, - default: 1 + type: Number }, }, watch: { diff --git a/ui/src/mixins/selectTableActions.js b/ui/src/mixins/selectTableActions.js index 1b83eddffa..73648cd4e2 100644 --- a/ui/src/mixins/selectTableActions.js +++ b/ui/src/mixins/selectTableActions.js @@ -17,14 +17,11 @@ export default { toggleAllUnselected() { this.elTable.clearSelection() }, - toggleAllSelection(active) { - // only some are selected, we should set queryBulkAction to true because it will select all - if (active && this.elTable.getSelectionRows().length > 0 && !this.queryBulkAction) { - this.queryBulkAction = true; - } else { - this.queryBulkAction = false; + toggleAllSelection() { + if (this.elTable.getSelectionRows().length < this.elTable.data.length) { + this.elTable.toggleAllSelection() } - this.elTable.toggleAllSelection() + this.queryBulkAction = true; }, selectionMapper(element) { return element;
null
train
train
2023-08-22T22:37:48
"2023-08-22T07:58:00Z"
Ben8t
train
kestra-io/kestra/1914_1942
kestra-io/kestra
kestra-io/kestra/1914
kestra-io/kestra/1942
[ "keyword_pr_to_issue" ]
06f23fbee3b038daaf745d3b1f0e43a10e2d66a5
123a977ad6df9ce32e410a61a2dd1d51fd63b4af
[]
[]
"2023-08-24T09:54:12Z"
[ "frontend" ]
Trigger page - sort are not working
Sorting on cols for trigger page are not working except on the id
[ "ui/src/components/admin/Triggers.vue" ]
[ "ui/src/components/admin/Triggers.vue" ]
[]
diff --git a/ui/src/components/admin/Triggers.vue b/ui/src/components/admin/Triggers.vue index 4aeb1681a5..ff0004bd44 100644 --- a/ui/src/components/admin/Triggers.vue +++ b/ui/src/components/admin/Triggers.vue @@ -34,7 +34,7 @@ > <el-table-column prop="triggerId" sortable="custom" :sort-orders="['ascending', 'descending']" :label="$t('id')" /> - <el-table-column sortable="custom" :sort-orders="['ascending', 'descending']" + <el-table-column prop="flowId" sortable="custom" :sort-orders="['ascending', 'descending']" :label="$t('flow')"> <template #default="scope"> <router-link @@ -49,7 +49,7 @@ /> </template> </el-table-column> - <el-table-column sortable="custom" :sort-orders="['ascending', 'descending']" + <el-table-column prop="namespace" sortable="custom" :sort-orders="['ascending', 'descending']" :label="$t('namespace')"> <template #default="scope"> {{ $filters.invisibleSpace(scope.row.namespace) }} @@ -68,20 +68,17 @@ </el-table-column> <el-table-column prop="executionCurrentState" :label="$t('state')" /> - <el-table-column sortable="custom" :sort-orders="['ascending', 'descending']" - :label="$t('date')"> + <el-table-column :label="$t('date')"> <template #default="scope"> {{ scope.row.date ? $filters.date(scope.row.date, "iso") : "" }} </template> </el-table-column> - <el-table-column sortable="custom" :sort-orders="['ascending', 'descending']" - :label="$t('updated date')"> + <el-table-column :label="$t('updated date')"> <template #default="scope"> {{ scope.row.updatedDate ? $filters.date(scope.row.updatedDate, "iso") : "" }} </template> </el-table-column> - <el-table-column sortable="custom" :sort-orders="['ascending', 'descending']" - :label="$t('evaluation lock date')"> + <el-table-column :label="$t('evaluation lock date')"> <template #default="scope"> {{ scope.row.evaluateRunningDate ? $filters.date(scope.row.evaluateRunningDate, "iso") : "" }} </template>
null
test
train
2023-08-24T09:46:23
"2023-08-18T12:46:07Z"
tchiotludo
train
kestra-io/kestra/1866_1944
kestra-io/kestra
kestra-io/kestra/1866
kestra-io/kestra/1944
[ "keyword_pr_to_issue" ]
04e7618fc99a10d81f1b2a5197357444fd179b58
894a312e13724d5078a307f5fb4623a18616e3fc
[ "When updating the flow, an exception message is correctly displayed.\r\n\r\nWhen loading the flow, a FlowWithException is correctly created, this is done at the deserialization level and set an empty list of tasks wich is normal as one of the task didn't exist so we must remove all tasks (as we don't know wich one ... and there can be several).\r\n\r\nSo the issue is:\r\n1. On the UI: no validation is performed when opening the editor of an existing flow\r\n2. On the UI: the graph didn't show an error when a flow is invalid\r\n3. This has been like this since at least one year and it's a good thing as at least one of the task is invalid so it cannot be rendered properly\r\n4. We must generates a comprehensive message for such cases\r\n\r\nWhat complexifies stuff a little is that, on the UI, everything is loaded when first loading the flow, for ex the graph is not computed when displaying the topology tab but when loading the flow.\r\n\r\nI'll see what I can do to improve the overall experience.", "- The exception is not returned to the ui, see the screenshot : \r\n![image](https://github.com/kestra-io/kestra/assets/2064609/2caf002b-0ca0-4fb6-8541-02b893c85fcf)\r\n- I really think the `FlowWithException` should not extends directly the `Flow` one to avoid empty task\r\n- I will add we should never be able to start a `FlowWithException` which is actually possible ", "> I really think the FlowWithException should not extends directly the Flow one to avoid empty task\r\n\r\nThis would require a lot of refactoring as this class is directly used inside the serializer used in database queries. But maybe we should directly add the exception (or an invalid boolean) in the flow itself so it'll be available in the UI.\r\n\r\n> I will add we should never be able to start a FlowWithException which is actually possible\r\n\r\nIt's no more possible after https://github.com/kestra-io/kestra/pull/1900", "> The exception is not returned to the ui, see the screenshot :\r\n\r\nYou tried with https://github.com/kestra-io/kestra/pull/1900? It's returned not when loading the flow (as there is no issue at this stage) but when validating the flow. As the API is using a Flow and not a FlowWithException, there is no exception on the UI as the API is not aware of it.\r\n\r\nSo, https://github.com/kestra-io/kestra/pull/1900 is a step in the right direction, but to go deeper we should get rid of the FlowWithException and add an exception attribute directly inside the FLow so it will be available in the UI. This can be a lot of work as a lot of places will be impacted (everywhere where a flow is loaded this field should be checked).", "@loicmathieu what's the state of this? there were multiple PRs - is this done, or still planned for 0.14 or for 0.15?", "@anna-geller it is waiting for feedback from Ludo, I think most of the issues are resolved now.", "working well, nice :+1: " ]
[]
"2023-08-24T10:27:00Z"
[ "bug", "medium-sized-issue" ]
Missing plugins are not correctly handled
- create a flow with only 1 task from a plugins - remove the plugin and restart the instance - go on the flow editor Issues: 1. The flow is show as valid without any errors ![image](https://github.com/kestra-io/kestra/assets/2064609/3acb3ede-0a9f-40c8-8cc2-dc2b95653e80) 2. Error on the console ![image](https://github.com/kestra-io/kestra/assets/2064609/ee4a1b02-e41f-49f9-9f85-51f741715254) 3. The flow endpoint silently remove the tasks (see `tasks: []`), in previous version it should be a [FlowWithException](https://github.com/kestra-io/kestra/blob/develop/core/src/main/java/io/kestra/core/models/flows/FlowWithException.java) object returned ![image](https://github.com/kestra-io/kestra/assets/2064609/2caf002b-0ca0-4fb6-8541-02b893c85fcf) 4. If I start the execution, the flow failed with no proper log, no proper tasks : ``` 2023-08-09 08:45:17,021 WARN jdbc-queue_4 i.k.core.models.executions.Execution [namespace: com.kestra.lde] [flow: hot-reload] [execution: 2lo2XYrQHNFouG2d3SYQfj] Flow failed from executor in 00:00:01.366 with exception 'Cannot invoke "java.util.List.size()" because "resolvedTasks" is null' java.lang.NullPointerException: Cannot invoke "java.util.List.size()" because "resolvedTasks" is null at io.kestra.core.models.executions.Execution.isTerminated(Execution.java:352) at io.kestra.core.models.executions.Execution.isTerminated(Execution.java:342) at io.kestra.core.runners.ExecutorService.handleEnd(ExecutorService.java:487) at io.kestra.core.runners.ExecutorService.process(ExecutorService.java:66) at io.kestra.jdbc.runner.JdbcExecutor.lambda$executionQueue$13(JdbcExecutor.java:204) at io.kestra.jdbc.repository.AbstractJdbcExecutionRepository.lambda$lock$21(AbstractJdbcExecutionRepository.java:684) ```
[ "core/src/main/java/io/kestra/core/runners/Executor.java", "core/src/main/java/io/kestra/core/tasks/flows/Flow.java", "webserver/src/main/java/io/kestra/webserver/controllers/ExecutionController.java" ]
[ "core/src/main/java/io/kestra/core/runners/Executor.java", "core/src/main/java/io/kestra/core/tasks/flows/Flow.java", "webserver/src/main/java/io/kestra/webserver/controllers/ExecutionController.java" ]
[]
diff --git a/core/src/main/java/io/kestra/core/runners/Executor.java b/core/src/main/java/io/kestra/core/runners/Executor.java index 2695ed42d3..a0a1a2b64e 100644 --- a/core/src/main/java/io/kestra/core/runners/Executor.java +++ b/core/src/main/java/io/kestra/core/runners/Executor.java @@ -4,6 +4,7 @@ import io.kestra.core.models.executions.Execution; import io.kestra.core.models.executions.TaskRun; import io.kestra.core.models.flows.Flow; +import io.kestra.core.models.flows.FlowWithException; import lombok.AllArgsConstructor; import lombok.Getter; @@ -37,7 +38,7 @@ public Executor(WorkerTaskResult workerTaskResult) { } public Boolean canBeProcessed() { - return !(this.getException() != null || this.getFlow() == null || this.getExecution().isDeleted()); + return !(this.getException() != null || this.getFlow() == null || this.getFlow() instanceof FlowWithException || this.getExecution().isDeleted()); } public Executor withFlow(Flow flow) { diff --git a/core/src/main/java/io/kestra/core/tasks/flows/Flow.java b/core/src/main/java/io/kestra/core/tasks/flows/Flow.java index 1b12d9e2e9..182cf36d9e 100644 --- a/core/src/main/java/io/kestra/core/tasks/flows/Flow.java +++ b/core/src/main/java/io/kestra/core/tasks/flows/Flow.java @@ -8,6 +8,7 @@ import io.kestra.core.models.executions.Execution; import io.kestra.core.models.executions.ExecutionTrigger; import io.kestra.core.models.executions.TaskRun; +import io.kestra.core.models.flows.FlowWithException; import io.kestra.core.models.flows.State; import io.kestra.core.models.tasks.RunnableTask; import io.kestra.core.models.tasks.Task; @@ -143,6 +144,10 @@ public Execution createExecution(RunContext runContext, FlowExecutorInterface fl throw new IllegalStateException("Cannot execute disabled flow"); } + if (flow instanceof FlowWithException fwe) { + throw new IllegalStateException("Cannot execute an invalid flow: " + fwe.getException()); + } + return runnerUtils .newExecution( flow, diff --git a/webserver/src/main/java/io/kestra/webserver/controllers/ExecutionController.java b/webserver/src/main/java/io/kestra/webserver/controllers/ExecutionController.java index f41f76bd55..2cbaafe02e 100644 --- a/webserver/src/main/java/io/kestra/webserver/controllers/ExecutionController.java +++ b/webserver/src/main/java/io/kestra/webserver/controllers/ExecutionController.java @@ -9,6 +9,7 @@ import io.kestra.core.models.executions.ExecutionKilled; import io.kestra.core.models.executions.TaskRun; import io.kestra.core.models.flows.Flow; +import io.kestra.core.models.flows.FlowWithException; import io.kestra.core.models.flows.State; import io.kestra.core.models.hierarchies.FlowGraph; import io.kestra.core.models.storage.FileMetas; @@ -410,6 +411,10 @@ private Execution webhook( throw new IllegalStateException("Cannot execute disabled flow"); } + if (flow instanceof FlowWithException fwe) { + throw new IllegalStateException("Cannot execute an invalid flow: " + fwe.getException()); + } + Optional<Webhook> webhook = (flow.getTriggers() == null ? new ArrayList<AbstractTrigger>() : flow .getTriggers()) .stream() @@ -465,12 +470,17 @@ public Execution trigger( return null; } - if (find.get().isDisabled()) { + Flow found = find.get(); + if (found.isDisabled()) { throw new IllegalStateException("Cannot execute disabled flow"); } + if (found instanceof FlowWithException fwe) { + throw new IllegalStateException("Cannot execute an invalid flow: " + fwe.getException()); + } + Execution current = runnerUtils.newExecution( - find.get(), + found, (flow, execution) -> runnerUtils.typedInputs(flow, execution, inputs, files), parseLabels(labels) );
null
train
train
2023-08-24T11:58:29
"2023-08-09T06:55:05Z"
tchiotludo
train
kestra-io/kestra/1814_1948
kestra-io/kestra
kestra-io/kestra/1814
kestra-io/kestra/1948
[ "keyword_pr_to_issue" ]
b6b426f6170a16a9733c681cfeffbbe509a62c2e
1cdfdc2953d75c51226c4ab150f07a403fca4001
[]
[]
"2023-08-24T17:00:52Z"
[ "enhancement" ]
Add CTRL-X shortcut to execute a flow
### Feature description While editing a flow, you can save it with CTRL-S but not execute it. Add CTRL-X to execute it (CTRL-E is already used in Chrome), then make the execution form to be submitable with ENTER. Whith both these, you can edit your flow then CTRL-S -> CTRL-X -> ENTER
[ "ui/src/components/flows/FlowRun.vue", "ui/src/components/inputs/Editor.vue", "ui/src/components/inputs/EditorView.vue" ]
[ "ui/src/components/flows/FlowRun.vue", "ui/src/components/inputs/Editor.vue", "ui/src/components/inputs/EditorView.vue" ]
[]
diff --git a/ui/src/components/flows/FlowRun.vue b/ui/src/components/flows/FlowRun.vue index fdc17f460c..4ab793d556 100644 --- a/ui/src/components/flows/FlowRun.vue +++ b/ui/src/components/flows/FlowRun.vue @@ -5,7 +5,7 @@ {{ $t('disabled flow desc') }} </el-alert> - <el-form label-position="top" :model="inputs" ref="form" @submit.prevent> + <el-form label-position="top" :model="inputs" ref="form" @submit.prevent="onSubmit($refs.form)"> <el-form-item v-for="input in flow.inputs || []" :key="input.id" @@ -96,7 +96,7 @@ </div> <div class="right-align"> <el-form-item class="submit"> - <el-button :icon="Flash" class="flow-run-trigger-button" @click="onSubmit($refs.form)" type="primary" :disabled="flow.disabled || haveBadLabels"> + <el-button :icon="Flash" class="flow-run-trigger-button" @click="onSubmit($refs.form)" type="primary" native-type="submit" :disabled="flow.disabled || haveBadLabels"> {{ $t('launch execution') }} </el-button> <el-text v-if="haveBadLabels" type="danger" size="small"> diff --git a/ui/src/components/inputs/Editor.vue b/ui/src/components/inputs/Editor.vue index 7cf274649b..af57dc0688 100644 --- a/ui/src/components/inputs/Editor.vue +++ b/ui/src/components/inputs/Editor.vue @@ -85,7 +85,7 @@ components: { MonacoEditor, }, - emits: ["save", "focusout", "tab", "update:modelValue", "cursor", "restartGuidedTour"], + emits: ["save", "execute", "focusout", "tab", "update:modelValue", "cursor", "restartGuidedTour"], editor: undefined, data() { return { @@ -230,6 +230,19 @@ } }); + this.editor.addAction({ + id: "kestra-execute", + label: "Execute the flow", + keybindings: [ + KeyMod.CtrlCmd | KeyCode.KeyE, + ], + contextMenuGroupId: "navigation", + contextMenuOrder: 1.5, + run: (ed) => { + this.$emit("execute", ed.getValue()) + } + }); + if (this.input) { this.editor.addCommand(KeyMod.CtrlCmd | KeyCode.KeyF, () => { }) diff --git a/ui/src/components/inputs/EditorView.vue b/ui/src/components/inputs/EditorView.vue index 1615b00103..4449dace58 100644 --- a/ui/src/components/inputs/EditorView.vue +++ b/ui/src/components/inputs/EditorView.vue @@ -121,6 +121,7 @@ const isLoading = ref(false); const haveChange = ref(false) const flowYaml = ref("") + const triggerFlow = ref(null); const newTrigger = ref(null) const isNewTriggerOpen = ref(false) const newError = ref(null) @@ -521,6 +522,13 @@ }) }; + const execute = (_) => { + if (!triggerFlow.value) { + return; + } + triggerFlow.value.onClick(); + }; + const canDelete = () => { return ( user.isAllowed( @@ -608,6 +616,7 @@ :class="combinedEditor ? 'editor-combined' : ''" :style="combinedEditor ? {width: editorWidthPercentage} : {}" @save="save" + @execute="execute" v-model="flowYaml" schema-type="flow" lang="yaml" @@ -793,6 +802,7 @@ <li v-if="flow"> <trigger-flow v-if="!props.isCreating" + ref="triggerFlow" type="default" :disabled="flow.disabled" :flow-id="flow.id"
null
test
train
2023-08-25T15:43:42
"2023-07-26T10:47:30Z"
loicmathieu
train
kestra-io/kestra/1917_1950
kestra-io/kestra
kestra-io/kestra/1917
kestra-io/kestra/1950
[ "keyword_pr_to_issue" ]
a5fdd0626aaca73cd10940c2701688616914d81f
5c61c4b0199c0daba8c73c110e43871e8222e390
[]
[ "I don't see the point of having a type parameter here, we usually inject the interface and depending on the runner and implementation is choosed.", "Please choose between field injection or constructor injection but don't use both.", "Shouldn't this on be moved to the new AbstractFlowTriggerService?", "I think this method is only used on the new AbstractFlowTriggerService, if so, move it there", "It seems that all runner have a multiple condition storage so why is it optional?", "That's something I forgot to remove as before the save & delete methods weren't in the interface so I had to have access to the impl directly to be able to do such action and that was preventing the need to cast", "Then I'll have to stick with constructor as Kafka provides its multipleConditionStorage based on a State Store which is a runtime thing :'(", "If both JdbcFlowTriggerService and MemoryFlowTriggerService are the same maybe you can create a DefaultFlowTriggerService (or just a FlowTrigerServiceImpl) that will be the default and replaces inside the Kafka runner." ]
"2023-08-24T17:28:01Z"
[ "bug" ]
Multiple condition on flow trigger does not handle consistently the flow state
### Expected Behavior I have a flow that need to have two flows dependencies in success, to run. More precisely: - Given flow A and B in success state during the last time window, flow C will be trigger and run - Given flow A in error and flow B in success state during the last time window, flow C will **not** be trigger and will not run - Given flow A and flow B in error state during the last minute, flow C will **not** be trigger and will not run ### Actual Behaviour When flow A is in error state and flow B is in success state, flow C will run when it should not. ### Steps To Reproduce In the same time window configured in flow C: 1. Run flow A that will fail 2. Run flow B that will succeed 3. Check that flow C has been executed when it should not ### Environment Information - Kestra Version: 0.9.8 dep graph: ![image](https://github.com/kestra-io/kestra/assets/113910656/f387eba5-bdfd-4b87-8602-6f2a57dfc92a) ### Example flow Time window for testing: 1 minute ```yaml id: trigger_test namespace: my.namespace tasks: - id: test type: io.kestra.core.tasks.log.Log message: "OK" triggers: - id: multiple-listen-flow type: io.kestra.core.models.triggers.types.Flow conditions: - type: io.kestra.core.models.conditions.types.ExecutionStatusCondition in: - SUCCESS - id: multiple type: io.kestra.core.models.conditions.types.MultipleCondition window: PT1M windowAdvance: PT0S conditions: flow_a: type: io.kestra.core.models.conditions.types.ExecutionFlowCondition namespace: my.namespace flowId: flow_a flow_b: type: io.kestra.core.models.conditions.types.ExecutionFlowCondition namespace: my.namespace flowId: flow_b ``` flow A: ```yaml id: flow_a namespace: my.namespace tasks: - id: test type: io.kestra.core.tasks.log.Log message: "OK" - id: fail type: io.kestra.core.tasks.executions.Fail ``` flow B: ```yaml id: flow_b namespace: my.namespace tasks: - id: test type: io.kestra.core.tasks.log.Log message: "OK" #- id: fail # type: io.kestra.core.tasks.executions.Fail ```
[ "core/src/main/java/io/kestra/core/models/triggers/multipleflows/MultipleConditionStorageInterface.java", "core/src/main/java/io/kestra/core/services/FlowService.java", "jdbc/src/main/java/io/kestra/jdbc/runner/AbstractJdbcMultipleConditionStorage.java", "jdbc/src/main/java/io/kestra/jdbc/runner/JdbcExecutor.java", "runner-memory/src/main/java/io/kestra/runner/memory/MemoryExecutor.java", "runner-memory/src/main/java/io/kestra/runner/memory/MemoryMultipleConditionStorage.java" ]
[ "core/src/main/java/io/kestra/core/models/triggers/multipleflows/MultipleConditionStorageInterface.java", "core/src/main/java/io/kestra/core/services/AbstractFlowTriggerService.java", "core/src/main/java/io/kestra/core/services/DefaultFlowTriggerService.java", "core/src/main/java/io/kestra/core/services/FlowService.java", "jdbc/src/main/java/io/kestra/jdbc/runner/AbstractJdbcMultipleConditionStorage.java", "jdbc/src/main/java/io/kestra/jdbc/runner/JdbcExecutor.java", "runner-memory/src/main/java/io/kestra/runner/memory/MemoryExecutor.java", "runner-memory/src/main/java/io/kestra/runner/memory/MemoryMultipleConditionStorage.java" ]
[ "core/src/test/java/io/kestra/core/runners/MultipleConditionTriggerCaseTest.java" ]
diff --git a/core/src/main/java/io/kestra/core/models/triggers/multipleflows/MultipleConditionStorageInterface.java b/core/src/main/java/io/kestra/core/models/triggers/multipleflows/MultipleConditionStorageInterface.java index f5672eebb6..3e774f9747 100644 --- a/core/src/main/java/io/kestra/core/models/triggers/multipleflows/MultipleConditionStorageInterface.java +++ b/core/src/main/java/io/kestra/core/models/triggers/multipleflows/MultipleConditionStorageInterface.java @@ -48,4 +48,8 @@ default MultipleConditionWindow getOrCreate(Flow flow, MultipleCondition multipl .build() ); } + + void save(List<MultipleConditionWindow> multipleConditionWindows); + + void delete(MultipleConditionWindow multipleConditionWindow); } diff --git a/core/src/main/java/io/kestra/core/services/AbstractFlowTriggerService.java b/core/src/main/java/io/kestra/core/services/AbstractFlowTriggerService.java new file mode 100644 index 0000000000..80ae142b6d --- /dev/null +++ b/core/src/main/java/io/kestra/core/services/AbstractFlowTriggerService.java @@ -0,0 +1,156 @@ +package io.kestra.core.services; + +import io.kestra.core.models.conditions.types.MultipleCondition; +import io.kestra.core.models.executions.Execution; +import io.kestra.core.models.flows.Flow; +import io.kestra.core.models.triggers.AbstractTrigger; +import io.kestra.core.models.triggers.multipleflows.MultipleConditionStorageInterface; +import io.kestra.core.models.triggers.multipleflows.MultipleConditionWindow; +import io.kestra.core.runners.RunContextFactory; +import jakarta.inject.Inject; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.ToString; + +import java.util.*; +import java.util.function.Predicate; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +public abstract class AbstractFlowTriggerService { + @Inject + private ConditionService conditionService; + + @Inject + private RunContextFactory runContextFactory; + + @Inject + private FlowService flowService; + + public Stream<FlowWithFlowTrigger> withFlowTriggersOnly(Stream<Flow> allFlows) { + return allFlows + .filter(flow -> !flow.isDisabled()) + .filter(flow -> flow.getTriggers() != null && !flow.getTriggers().isEmpty()) + .flatMap(flow -> flowTriggers(flow).map(trigger -> new FlowWithFlowTrigger(flow, trigger))); + } + + public Stream<io.kestra.core.models.triggers.types.Flow> flowTriggers(Flow flow) { + return flow.getTriggers() + .stream() + .filter(Predicate.not(AbstractTrigger::isDisabled)) + .filter(io.kestra.core.models.triggers.types.Flow.class::isInstance) + .map(io.kestra.core.models.triggers.types.Flow.class::cast); + } + + public List<Execution> computeExecutionsFromFlowTriggers(Execution execution, List<Flow> allFlows, Optional<MultipleConditionStorageInterface> multipleConditionStorage) { + List<FlowWithFlowTrigger> validTriggersBeforeMultipleConditionEval = allFlows.stream() + // prevent recursive flow triggers + .filter(flow -> flowService.removeUnwanted(flow, execution)) + // ensure flow & triggers are enabled + .filter(flow -> !flow.isDisabled()) + .filter(flow -> flow.getTriggers() != null && !flow.getTriggers().isEmpty()) + // validate flow triggers conditions excluding multiple conditions + .flatMap(flow -> flowTriggers(flow).map(trigger -> new FlowWithFlowTrigger(flow, trigger))) + .filter(flowWithFlowTrigger -> conditionService.valid( + flowWithFlowTrigger.getFlow(), + flowWithFlowTrigger.getTrigger().getConditions().stream() + .filter(Predicate.not(MultipleCondition.class::isInstance)) + .toList(), + conditionService.conditionContext( + runContextFactory.of(flowWithFlowTrigger.getFlow(), execution), + flowWithFlowTrigger.getFlow(), + execution + ) + )).toList(); + + Map<FlowWithFlowTriggerAndMultipleCondition, MultipleConditionWindow> multipleConditionWindowsByFlow = null; + if (multipleConditionStorage.isPresent()) { + List<FlowWithFlowTriggerAndMultipleCondition> flowWithMultipleConditionsToEvaluate = validTriggersBeforeMultipleConditionEval.stream() + .flatMap(flowWithFlowTrigger -> + flowWithFlowTrigger.getTrigger().getConditions().stream() + .filter(MultipleCondition.class::isInstance) + .map(MultipleCondition.class::cast) + .map(multipleCondition -> new FlowWithFlowTriggerAndMultipleCondition( + flowWithFlowTrigger.getFlow(), + multipleConditionStorage.get().getOrCreate(flowWithFlowTrigger.getFlow(), multipleCondition), + flowWithFlowTrigger.getTrigger(), + multipleCondition + ) + ) + ).toList(); + + // evaluate multiple conditions + multipleConditionWindowsByFlow = flowWithMultipleConditionsToEvaluate.stream().map(f -> { + Map<String, Boolean> results = f.getMultipleCondition() + .getConditions() + .entrySet() + .stream() + .map(e -> new AbstractMap.SimpleEntry<>( + e.getKey(), + conditionService.isValid(e.getValue(), f.getFlow(), execution) + )) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + return Map.entry(f, f.getMultipleConditionWindow().with(results)); + }) + .filter(e -> !e.getValue().getResults().isEmpty()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + // persist results + multipleConditionStorage.get().save(new ArrayList<>(multipleConditionWindowsByFlow.values())); + } + + // compute all executions to create from flow triggers now that multiple conditions storage is populated + List<Execution> executions = validTriggersBeforeMultipleConditionEval.stream().filter(flowWithFlowTrigger -> + conditionService.isValid( + flowWithFlowTrigger.getTrigger(), + flowWithFlowTrigger.getFlow(), + execution, + multipleConditionStorage.orElse(null) + ) + ).map(f -> f.getTrigger().evaluate( + runContextFactory.of(f.getFlow(), execution), + f.getFlow(), + execution + )) + .filter(Optional::isPresent) + .map(Optional::get) + .toList(); + + if(multipleConditionStorage.isPresent() && multipleConditionWindowsByFlow != null) { + // purge fulfilled or expired multiple condition windows + Stream.concat( + multipleConditionWindowsByFlow.keySet().stream() + .map(f -> Map.entry( + f.getMultipleCondition().getConditions(), + multipleConditionStorage.get().getOrCreate(f.getFlow(), f.getMultipleCondition()) + )) + .filter(e -> e.getKey().size() == Optional.ofNullable(e.getValue().getResults()) + .map(Map::size) + .orElse(0)) + .map(Map.Entry::getValue), + multipleConditionStorage.get().expired().stream() + ).forEach(multipleConditionStorage.get()::delete); + } + + return executions; + } + + @AllArgsConstructor + @Getter + @ToString + protected static class FlowWithFlowTriggerAndMultipleCondition { + private final Flow flow; + private final MultipleConditionWindow multipleConditionWindow; + private final io.kestra.core.models.triggers.types.Flow trigger; + private final MultipleCondition multipleCondition; + } + + @AllArgsConstructor + @Getter + @ToString + public static class FlowWithFlowTrigger { + private final Flow flow; + private final io.kestra.core.models.triggers.types.Flow trigger; + } +} diff --git a/core/src/main/java/io/kestra/core/services/DefaultFlowTriggerService.java b/core/src/main/java/io/kestra/core/services/DefaultFlowTriggerService.java new file mode 100644 index 0000000000..ff90610246 --- /dev/null +++ b/core/src/main/java/io/kestra/core/services/DefaultFlowTriggerService.java @@ -0,0 +1,7 @@ +package io.kestra.core.services; + +import jakarta.inject.Singleton; + +@Singleton +public class DefaultFlowTriggerService extends AbstractFlowTriggerService { +} \ No newline at end of file diff --git a/core/src/main/java/io/kestra/core/services/FlowService.java b/core/src/main/java/io/kestra/core/services/FlowService.java index f0c080f9af..18cfc3b975 100644 --- a/core/src/main/java/io/kestra/core/services/FlowService.java +++ b/core/src/main/java/io/kestra/core/services/FlowService.java @@ -2,12 +2,9 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.core.JsonProcessingException; -import io.kestra.core.models.conditions.types.MultipleCondition; import io.kestra.core.models.executions.Execution; import io.kestra.core.models.flows.Flow; import io.kestra.core.models.triggers.AbstractTrigger; -import io.kestra.core.models.triggers.multipleflows.MultipleConditionStorageInterface; -import io.kestra.core.models.triggers.multipleflows.MultipleConditionWindow; import io.kestra.core.runners.RunContextFactory; import io.kestra.core.serializers.JacksonMapper; import io.kestra.core.utils.ListUtils; @@ -15,10 +12,7 @@ import io.micronaut.core.annotation.Nullable; import jakarta.inject.Inject; import jakarta.inject.Singleton; -import lombok.AllArgsConstructor; -import lombok.Getter; import lombok.SneakyThrows; -import lombok.ToString; import lombok.extern.slf4j.Slf4j; import java.util.*; @@ -83,131 +77,11 @@ private Stream<Flow> keepLastVersionCollector(Stream<Flow> stream) { .filter(Objects::nonNull); } - public List<FlowWithFlowTrigger> flowWithFlowTrigger(Stream<Flow> flowStream) { - return flowStream - .filter(flow -> flow.getTriggers() != null && flow.getTriggers().size() > 0) - .filter(flow -> !flow.isDisabled()) - .flatMap(flow -> flow.getTriggers() - .stream() - .filter(abstractTrigger -> !abstractTrigger.isDisabled()) - .map(trigger -> new FlowWithTrigger(flow, trigger)) - ) - .filter(f -> f.getTrigger() instanceof io.kestra.core.models.triggers.types.Flow) - .map(f -> new FlowWithFlowTrigger( - f.getFlow(), - (io.kestra.core.models.triggers.types.Flow) f.getTrigger() - ) - ) - .collect(Collectors.toList()); - } - protected boolean removeUnwanted(Flow f, Execution execution) { // we don't allow recursive return !f.uidWithoutRevision().equals(Flow.uidWithoutRevision(execution)); } - public List<Execution> flowTriggerExecution(Stream<Flow> flowStream, Execution execution, @Nullable MultipleConditionStorageInterface multipleConditionStorage) { - return flowStream - .filter(flow -> flow.getTriggers() != null && flow.getTriggers().size() > 0) - .filter(flow -> !flow.isDisabled()) - .flatMap(flow -> flow.getTriggers() - .stream() - .filter(abstractTrigger -> !abstractTrigger.isDisabled()) - .map(trigger -> new FlowWithTrigger(flow, trigger)) - ) - .filter(f -> conditionService.isValid( - f.getTrigger(), - f.getFlow(), - execution, - multipleConditionStorage - )) - .filter(f -> f.getTrigger() instanceof io.kestra.core.models.triggers.types.Flow) - .map(f -> new FlowWithFlowTrigger( - f.getFlow(), - (io.kestra.core.models.triggers.types.Flow) f.getTrigger() - ) - ) - .filter(f -> this.removeUnwanted(f.getFlow(), execution)) - .map(f -> f.getTrigger().evaluate( - runContextFactory.of(f.getFlow(), execution), - f.getFlow(), - execution - )) - .filter(Optional::isPresent) - .map(Optional::get) - .collect(Collectors.toList()); - } - - private Stream<FlowWithFlowTriggerAndMultipleCondition> multipleFlowStream( - Stream<Flow> flowStream, - MultipleConditionStorageInterface multipleConditionStorage - ) { - return flowWithFlowTrigger(flowStream) - .stream() - .flatMap(e -> e.getTrigger() - .getConditions() - .stream() - .filter(condition -> condition instanceof MultipleCondition) - .map(condition -> { - MultipleCondition multipleCondition = (MultipleCondition) condition; - - return new FlowWithFlowTriggerAndMultipleCondition( - e.getFlow(), - multipleConditionStorage.getOrCreate(e.getFlow(), multipleCondition), - e.getTrigger(), - multipleCondition - ); - }) - ); - } - - public List<MultipleConditionWindow> multipleFlowTrigger( - Stream<Flow> flowStream, - Flow flow, - Execution execution, - MultipleConditionStorageInterface multipleConditionStorage - ) { - return multipleFlowStream(flowStream, multipleConditionStorage) - .map(f -> { - Map<String, Boolean> results = f.getMultipleCondition() - .getConditions() - .entrySet() - .stream() - .map(e -> new AbstractMap.SimpleEntry<>( - e.getKey(), - conditionService.isValid(e.getValue(), flow, execution) - )) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); - - return f.getMultipleConditionWindow().with(results); - }) - .filter(multipleConditionWindow -> multipleConditionWindow.getResults().size() > 0) - .collect(Collectors.toList()); - } - - public List<MultipleConditionWindow> multipleFlowToDelete( - Stream<Flow> flowStream, - MultipleConditionStorageInterface multipleConditionStorage - ) { - return Stream - .concat( - multipleFlowStream(flowStream, multipleConditionStorage) - .filter(f -> f.getMultipleCondition().getConditions().size() == - (f.getMultipleConditionWindow().getResults() == null ? 0 : - f.getMultipleConditionWindow() - .getResults() - .entrySet() - .stream() - .filter(Map.Entry::getValue) - .count() - ) - ) - .map(FlowWithFlowTriggerAndMultipleCondition::getMultipleConditionWindow), - multipleConditionStorage.expired().stream() - ) - .collect(Collectors.toList()); - } - public static List<AbstractTrigger> findRemovedTrigger(Flow flow, Flow previous) { return ListUtils.emptyOnNull(previous.getTriggers()) .stream() @@ -219,7 +93,7 @@ public static List<AbstractTrigger> findRemovedTrigger(Flow flow, Flow previous) } public static String cleanupSource(String source) { - return source.replaceFirst("(?m)^revision: \\d+\n?",""); + return source.replaceFirst("(?m)^revision: \\d+\n?", ""); } public static String injectDisabled(String source, Boolean disabled) { @@ -306,29 +180,4 @@ private static Object fixSnakeYaml(Object object) { return object; } - - @AllArgsConstructor - @Getter - private static class FlowWithTrigger { - private final Flow flow; - private final AbstractTrigger trigger; - } - - @AllArgsConstructor - @Getter - @ToString - public static class FlowWithFlowTrigger { - private final Flow flow; - private final io.kestra.core.models.triggers.types.Flow trigger; - } - - @AllArgsConstructor - @Getter - @ToString - private static class FlowWithFlowTriggerAndMultipleCondition { - private final Flow flow; - private final MultipleConditionWindow multipleConditionWindow; - private final io.kestra.core.models.triggers.types.Flow trigger; - private final MultipleCondition multipleCondition; - } } diff --git a/jdbc/src/main/java/io/kestra/jdbc/runner/AbstractJdbcMultipleConditionStorage.java b/jdbc/src/main/java/io/kestra/jdbc/runner/AbstractJdbcMultipleConditionStorage.java index 702d807b13..24d0eaa2ad 100644 --- a/jdbc/src/main/java/io/kestra/jdbc/runner/AbstractJdbcMultipleConditionStorage.java +++ b/jdbc/src/main/java/io/kestra/jdbc/runner/AbstractJdbcMultipleConditionStorage.java @@ -61,6 +61,7 @@ public List<MultipleConditionWindow> expired() { }); } + @Override public synchronized void save(List<MultipleConditionWindow> multipleConditionWindows) { this.jdbcRepository .getDslContextWrapper() @@ -75,6 +76,7 @@ public synchronized void save(List<MultipleConditionWindow> multipleConditionWin }); } + @Override public void delete(MultipleConditionWindow multipleConditionWindow) { this.jdbcRepository.delete(multipleConditionWindow); } diff --git a/jdbc/src/main/java/io/kestra/jdbc/runner/JdbcExecutor.java b/jdbc/src/main/java/io/kestra/jdbc/runner/JdbcExecutor.java index 3f3c25c3a5..c6ad983e9c 100644 --- a/jdbc/src/main/java/io/kestra/jdbc/runner/JdbcExecutor.java +++ b/jdbc/src/main/java/io/kestra/jdbc/runner/JdbcExecutor.java @@ -9,6 +9,7 @@ import io.kestra.core.models.flows.FlowWithException; import io.kestra.core.models.flows.State; import io.kestra.core.models.topologies.FlowTopology; +import io.kestra.core.models.triggers.multipleflows.MultipleConditionStorageInterface; import io.kestra.core.queues.QueueFactoryInterface; import io.kestra.core.queues.QueueInterface; import io.kestra.core.repositories.FlowRepositoryInterface; @@ -75,9 +76,6 @@ public class JdbcExecutor implements ExecutorInterface { @Inject private RunContextFactory runContextFactory; - @Inject - private FlowService flowService; - @Inject private TaskDefaultService taskDefaultService; @@ -91,13 +89,16 @@ public class JdbcExecutor implements ExecutorInterface { private ConditionService conditionService; @Inject - private MetricRegistry metricRegistry; + private MultipleConditionStorageInterface multipleConditionStorage; @Inject - protected FlowListenersInterface flowListeners; + private AbstractFlowTriggerService flowTriggerService; @Inject - private AbstractJdbcMultipleConditionStorage multipleConditionStorage; + private MetricRegistry metricRegistry; + + @Inject + protected FlowListenersInterface flowListeners; @Inject private AbstractJdbcWorkerTaskExecutionStorage workerTaskExecutionStorage; @@ -295,21 +296,8 @@ private void executionQueue(Execution message) { conditionService.isTerminatedWithListeners(flow, execution) && this.deduplicateFlowTrigger(execution, executorState) ) { - // multiple conditions storage - multipleConditionStorage.save( - flowService - .multipleFlowTrigger(allFlows.stream(), flow, execution, multipleConditionStorage) - ); - - // Flow Trigger - flowService - .flowTriggerExecution(allFlows.stream(), execution, multipleConditionStorage) + flowTriggerService.computeExecutionsFromFlowTriggers(execution, allFlows, Optional.of(multipleConditionStorage)) .forEach(this.executionQueue::emit); - - // Trigger is done, remove matching multiple condition - flowService - .multipleFlowToDelete(allFlows.stream(), multipleConditionStorage) - .forEach(multipleConditionStorage::delete); } // worker task execution diff --git a/runner-memory/src/main/java/io/kestra/runner/memory/MemoryExecutor.java b/runner-memory/src/main/java/io/kestra/runner/memory/MemoryExecutor.java index bcfd8f3e8e..a27104637d 100644 --- a/runner-memory/src/main/java/io/kestra/runner/memory/MemoryExecutor.java +++ b/runner-memory/src/main/java/io/kestra/runner/memory/MemoryExecutor.java @@ -7,6 +7,7 @@ import io.kestra.core.models.executions.TaskRun; import io.kestra.core.models.flows.Flow; import io.kestra.core.models.flows.State; +import io.kestra.core.models.triggers.multipleflows.MultipleConditionStorageInterface; import io.kestra.core.queues.QueueFactoryInterface; import io.kestra.core.queues.QueueInterface; import io.kestra.core.repositories.FlowRepositoryInterface; @@ -35,7 +36,6 @@ @MemoryQueueEnabled @Slf4j public class MemoryExecutor implements ExecutorInterface { - private static final MemoryMultipleConditionStorage multipleConditionStorage = new MemoryMultipleConditionStorage(); private static final ConcurrentHashMap<String, ExecutionState> EXECUTIONS = new ConcurrentHashMap<>(); private static final ConcurrentHashMap<String, WorkerTaskExecution> WORKERTASKEXECUTIONS_WATCHER = new ConcurrentHashMap<>(); private List<Flow> allFlows; @@ -93,6 +93,11 @@ public class MemoryExecutor implements ExecutorInterface { @Inject private SkipExecutionService skipExecutionService; + @Inject + private AbstractFlowTriggerService flowTriggerService; + + private final MultipleConditionStorageInterface multipleConditionStorage = new MemoryMultipleConditionStorage(); + @Override public void run() { flowListeners.run(); @@ -124,7 +129,7 @@ private Flow transform(Flow flow, Execution execution) { (namespace, id) -> templateExecutorInterface.get().findById(namespace, id).orElse(null) ); } catch (InternalException e) { - log.debug("Failed to inject template", e); + log.debug("Failed to inject template", e); } } @@ -231,21 +236,8 @@ private void handleExecution(ExecutionState state) { // multiple condition if (conditionService.isTerminatedWithListeners(flow, execution)) { - // multiple conditions storage - multipleConditionStorage.save( - flowService - .multipleFlowTrigger(allFlows.stream(), flow, execution, multipleConditionStorage) - ); - - // Flow Trigger - flowService - .flowTriggerExecution(allFlows.stream(), execution, multipleConditionStorage) + flowTriggerService.computeExecutionsFromFlowTriggers(execution, allFlows, Optional.of(multipleConditionStorage)) .forEach(this.executionQueue::emit); - - // Trigger is done, remove matching multiple condition - flowService - .multipleFlowToDelete(allFlows.stream(), multipleConditionStorage) - .forEach(multipleConditionStorage::delete); } // worker task execution @@ -385,7 +377,6 @@ private boolean deduplicateNexts(Execution execution, List<TaskRun> taskRuns) { } - private static class ExecutionState { private final Execution execution; private Map<String, TaskRun> taskRuns = new ConcurrentHashMap<>(); diff --git a/runner-memory/src/main/java/io/kestra/runner/memory/MemoryMultipleConditionStorage.java b/runner-memory/src/main/java/io/kestra/runner/memory/MemoryMultipleConditionStorage.java index b59d1d1744..ce3d10d966 100644 --- a/runner-memory/src/main/java/io/kestra/runner/memory/MemoryMultipleConditionStorage.java +++ b/runner-memory/src/main/java/io/kestra/runner/memory/MemoryMultipleConditionStorage.java @@ -51,6 +51,7 @@ public List<MultipleConditionWindow> expired() { .collect(Collectors.toList()); } + @Override public synchronized void save(List<MultipleConditionWindow> multipleConditionWindows) { multipleConditionWindows .forEach(window -> { @@ -70,6 +71,7 @@ public synchronized void save(List<MultipleConditionWindow> multipleConditionWin }); } + @Override public void delete(MultipleConditionWindow multipleConditionWindow) { find(multipleConditionWindow.getNamespace(), multipleConditionWindow.getFlowId()) .ifPresent(byCondition -> {
diff --git a/core/src/test/java/io/kestra/core/runners/MultipleConditionTriggerCaseTest.java b/core/src/test/java/io/kestra/core/runners/MultipleConditionTriggerCaseTest.java index d11b82c9b6..bd92823eaf 100644 --- a/core/src/test/java/io/kestra/core/runners/MultipleConditionTriggerCaseTest.java +++ b/core/src/test/java/io/kestra/core/runners/MultipleConditionTriggerCaseTest.java @@ -101,18 +101,18 @@ public void failed() throws InterruptedException, TimeoutException { }); // first one - Execution execution = runnerUtils.runOne("io.kestra.tests", "trigger-multiplecondition-flow-d", Duration.ofSeconds(60)); + Execution execution = runnerUtils.runOne("io.kestra.tests", "trigger-multiplecondition-flow-c", Duration.ofSeconds(60)); assertThat(execution.getTaskRunList().size(), is(1)); - assertThat(execution.getState().getCurrent(), is(State.Type.SUCCESS)); + assertThat(execution.getState().getCurrent(), is(State.Type.FAILED)); // wait a little to be sure that the trigger is not launching execution countDownLatch.await(1, TimeUnit.SECONDS); assertThat(ended.size(), is(1)); // second one - execution = runnerUtils.runOne("io.kestra.tests", "trigger-multiplecondition-flow-c", Duration.ofSeconds(60)); + execution = runnerUtils.runOne("io.kestra.tests", "trigger-multiplecondition-flow-d", Duration.ofSeconds(60)); assertThat(execution.getTaskRunList().size(), is(1)); - assertThat(execution.getState().getCurrent(), is(State.Type.FAILED)); + assertThat(execution.getState().getCurrent(), is(State.Type.SUCCESS)); // trigger was not done countDownLatch.await(10, TimeUnit.SECONDS); diff --git a/core/src/test/java/io/kestra/core/runners/MultipleConditionTriggerFailedTest.java b/core/src/test/java/io/kestra/core/runners/MultipleConditionTriggerFailedTest.java deleted file mode 100644 index 57232b1b68..0000000000 --- a/core/src/test/java/io/kestra/core/runners/MultipleConditionTriggerFailedTest.java +++ /dev/null @@ -1,12 +0,0 @@ -package io.kestra.core.runners; - -import io.micronaut.test.extensions.junit5.annotation.MicronautTest; -import jakarta.inject.Inject; -import org.junit.jupiter.api.Test; - -@MicronautTest -public class MultipleConditionTriggerFailedTest extends AbstractMemoryRunnerTest { - @Inject - private MultipleConditionTriggerCaseTest runnerCaseTest; - -}
train
train
2023-08-28T09:01:53
"2023-08-18T16:38:00Z"
sboisgontier-lmfr
train
kestra-io/kestra/1978_1982
kestra-io/kestra
kestra-io/kestra/1978
kestra-io/kestra/1982
[ "keyword_pr_to_issue" ]
188d67cac9c587cb1991d5b0e0164dd6601e9408
01eae694579153ab91769d3959c15d1eb4c45781
[]
[]
"2023-08-28T15:54:08Z"
[ "bug" ]
Exposing metrics without tags is not working
### Expected Behavior _No response_ ### Actual Behaviour See https://demo.kestra.io/ui/blueprints/community/86 which is not working ### Steps To Reproduce _No response_ ### Environment Information - Kestra Version: - Operating System (OS / Docker / Kubernetes): - Java Version (If not docker): ### Example flow _No response_
[ "core/src/main/java/io/kestra/core/models/executions/AbstractMetricEntry.java" ]
[ "core/src/main/java/io/kestra/core/models/executions/AbstractMetricEntry.java" ]
[]
diff --git a/core/src/main/java/io/kestra/core/models/executions/AbstractMetricEntry.java b/core/src/main/java/io/kestra/core/models/executions/AbstractMetricEntry.java index c7647246b9..181bcf2a6d 100644 --- a/core/src/main/java/io/kestra/core/models/executions/AbstractMetricEntry.java +++ b/core/src/main/java/io/kestra/core/models/executions/AbstractMetricEntry.java @@ -13,7 +13,9 @@ import lombok.ToString; import java.time.Instant; +import java.util.Collection; import java.util.Map; +import java.util.Optional; import java.util.stream.Collectors; import java.util.stream.Stream; import javax.validation.constraints.NotNull; @@ -63,9 +65,9 @@ private static Map<String, String> tagsAsMap(String... keyValues) { protected String[] tagsAsArray(Map<String, String> others) { return Stream.concat( - this.tags.entrySet().stream(), - others.entrySet().stream() - ) + Optional.ofNullable(this.tags).map(Map::entrySet).stream().flatMap(Collection::stream), + others.entrySet().stream() + ) .flatMap(e -> Stream.of(e.getKey(), e.getValue())) .collect(Collectors.toList()) .toArray(String[]::new);
null
train
train
2023-08-28T21:11:16
"2023-08-28T14:46:04Z"
brian-mulier-p
train
kestra-io/kestra/1963_1984
kestra-io/kestra
kestra-io/kestra/1963
kestra-io/kestra/1984
[ "keyword_pr_to_issue" ]
d28b63de0feef1ea629ce04e76987af4f6076c1d
188d67cac9c587cb1991d5b0e0164dd6601e9408
[]
[]
"2023-08-28T16:24:01Z"
[]
Reorder the left navigation bar
### Feature description It seems natural when the **Settings** section is either the last navigation item or when it is located entirely in the bottom left corner The following order is worth considering in OSS: 1. Home 2. Flows 3. Blueprints 4. Executions 5. Logs 6. Administration 7. Documentation 8. Settings In EE: 1. Home 2. Flows 3. Blueprints 4. Executions 5. Logs 6. Task Runs 7. Namespaces 8. Administration (include Audit Logs) 9. Documentation 10. Settings Goals: - push Blueprints to be even more visible by being placed higher -- might be nice for new users getting started - make the navigation between OSS and EE as similar as possible to make it easy to switch to EE after using OSS for a while - Logs and Audit Logs is something you'd typically look at fairly irregularly (usually only when something bad happens and you need to troubleshoot), so worth adding them to the Administration section as well to make the main navigation even cleaner - Documentation and Administration are both expandable fields with submenu items so nice to have them next to each other - Settings at the very bottom ![image](https://github.com/kestra-io/kestra/assets/86264395/4c8eeb25-7a48-4256-ae3b-23feaf4cb902)
[ "ui/src/override/components/LeftMenu.vue", "ui/src/translations.json" ]
[ "ui/src/override/components/LeftMenu.vue", "ui/src/translations.json" ]
[]
diff --git a/ui/src/override/components/LeftMenu.vue b/ui/src/override/components/LeftMenu.vue index 199e95c093..2cd05d581e 100644 --- a/ui/src/override/components/LeftMenu.vue +++ b/ui/src/override/components/LeftMenu.vue @@ -45,7 +45,6 @@ import Github from "vue-material-design-icons/Github.vue"; import CogOutline from "vue-material-design-icons/CogOutline.vue"; import ViewDashboardVariantOutline from "vue-material-design-icons/ViewDashboardVariantOutline.vue"; - import FileDocumentArrowRightOutline from "vue-material-design-icons/FileDocumentArrowRightOutline.vue"; import TimerCogOutline from "vue-material-design-icons/TimerCogOutline.vue"; import {mapState} from "vuex"; @@ -168,15 +167,6 @@ class: "menu-icon" }, }, - { - href: "https://kestra.io/docs/flow-examples/", - title: this.$t("documentation.examples"), - icon: { - element: FileDocumentArrowRightOutline, - class: "menu-icon" - }, - external: true - }, { href: "https://kestra.io/slack", title: "Slack", @@ -198,14 +188,6 @@ ] }, - { - href: "/settings", - title: this.$t("settings"), - icon: { - element: CogOutline, - class: "menu-icon" - } - }, { title: this.$t("administration"), icon: { @@ -222,6 +204,14 @@ } } ] + }, + { + href: "/settings", + title: this.$t("settings"), + icon: { + element: CogOutline, + class: "menu-icon" + } } ]; }, diff --git a/ui/src/translations.json b/ui/src/translations.json index ab5b760b6c..285486dd74 100644 --- a/ui/src/translations.json +++ b/ui/src/translations.json @@ -197,7 +197,6 @@ "download": "Download", "documentation": { "documentation": "Documentation", - "examples": "Flow examples", "developer": "Developer Guide", "github": "GitHub Issues" },
null
train
train
2023-08-28T18:11:37
"2023-08-25T14:50:37Z"
anna-geller
train
kestra-io/kestra/1955_1988
kestra-io/kestra
kestra-io/kestra/1955
kestra-io/kestra/1988
[ "keyword_pr_to_issue" ]
838cfa7afe461893f64ae28fa79d71542e768a93
aa2632018a72af38a51cc201a032b286f04eed92
[]
[]
"2023-08-29T09:18:08Z"
[ "bug", "frontend" ]
[UI] Execution Topology -> show task source -> the low code editor is empty
### Expected Behavior Execution Topology -> show task sourc -> the low code editor should be removed from the view of correctly set with the task properties ### Actual Behaviour See the screencast [screen-capture (1).webm](https://github.com/kestra-io/kestra/assets/1819009/a6b048a7-056c-44e8-b6f2-2b63c5ff1028) ### Steps To Reproduce _No response_ ### Environment Information - Kestra Version: - Operating System (OS / Docker / Kubernetes): - Java Version (If not docker): ### Example flow _No response_
[ "ui/src/components/flows/TaskEdit.vue" ]
[ "ui/src/components/flows/TaskEdit.vue" ]
[]
diff --git a/ui/src/components/flows/TaskEdit.vue b/ui/src/components/flows/TaskEdit.vue index 97f3d45c4a..4a08d46856 100644 --- a/ui/src/components/flows/TaskEdit.vue +++ b/ui/src/components/flows/TaskEdit.vue @@ -24,7 +24,7 @@ <el-button :icon="ContentSave" @click="saveTask" - v-if="canSave && !isReadOnly" + v-if="canSave && !readOnly" :disabled="taskError !== undefined" type="primary" > @@ -34,7 +34,7 @@ show-icon :closable="false" class="mb-0 mt-3" - v-if="revision && isReadOnly" + v-if="revision && readOnly" type="warning" > <strong>{{ $t("seeing old revision", {revision: revision}) }}</strong> @@ -43,7 +43,7 @@ </template> <el-tabs v-model="activeTabs"> - <el-tab-pane name="form"> + <el-tab-pane v-if="!readOnly" name="form"> <template #label> <span>{{ $t("form") }}</span> </template> @@ -59,7 +59,7 @@ <span>{{ $t("source") }}</span> </template> <editor - :read-only="isReadOnly" + :read-only="readOnly" ref="editor" @save="saveTask" v-model="taskYaml" @@ -148,6 +148,10 @@ type: Boolean, default: false }, + readOnly: { + type: Boolean, + default: false + } }, watch: { task: { @@ -178,7 +182,7 @@ handler() { if (!this.isModalOpen) { this.$emit("close"); - this.activeTabs = "form"; + this.activeTabs = this.defaultActiveTab(); } } } @@ -252,22 +256,23 @@ this.$store.dispatch("flow/validateTask", {task: value, section: this.section}) }, 500); }, + defaultActiveTab() { + return this.readOnly ? "source" : "form"; + } }, data() { return { uuid: Utils.uid(), taskYaml: "", isModalOpen: false, - activeTabs: "form", + activeTabs: this.defaultActiveTab(), type: null, }; }, computed: { - ...mapState("flow", ["flow"]), + ...mapState("flow", ["flow", "revisions"]), ...mapGetters("flow", ["taskError"]), ...mapState("auth", ["user"]), - ...mapState("flow", ["revisions"]), - ...mapState("flow", ["revisions"]), ...mapState("plugin", ["plugin"]), pluginMardown() { if (this.plugin && this.plugin.markdown && YamlUtils.parse(this.taskYaml)?.type) { @@ -280,9 +285,6 @@ }, isLoading() { return this.taskYaml === undefined; - }, - isReadOnly() { - return this.flow && this.revision && this.flow.revision !== this.revision } } };
null
val
train
2023-08-29T09:26:57
"2023-08-25T12:18:05Z"
loicmathieu
train
kestra-io/kestra/2005_2008
kestra-io/kestra
kestra-io/kestra/2005
kestra-io/kestra/2008
[ "keyword_pr_to_issue" ]
0965126450acd405ecf7513cd25c5dfb507eb1a6
102e84ccb22f05c09299ac8d39f70db339567981
[ "I agree we should have a validation rule for that and display an error.", "I think we should more prevent to set the value (maybe with a simple setter that thrown an exception) that prevent all usage everywhere", "I have an old plan to break the dependency of the Schedule task to the PollingTrigger interface because it's 2 different things. This would remove the useless interval field that should not be set on this task.\r\n\r\nSo things can be done properly by refactoring and breaking this dependency ... or as a temporal workaround, we can add a setter that throws and see how we can prevent using it in the yaml schema. ", "We discuss it this morning and will implement a workaround so that setting interval is not possible on a Schedule trigger (raises an error)." ]
[]
"2023-09-01T10:05:22Z"
[ "bug" ]
Raise an error in the editor when both `cron` and `interval` properties are defined in a `Schedule` trigger
### Feature description ## Problem When a trigger is defined using both CRON and interval as follows: ```yaml triggers: - id: everyMinute type: io.kestra.core.models.triggers.types.Schedule cron: "*/1 * * * *" interval: "PT1M" ``` it results in no scheduled executions according to user report: https://kestra-io.slack.com/archives/C03FQKXRK3K/p1693486310182389 ## Possible resolution Display a warning, or even better, raise an error within the editor if both properties are defined at the same time. Additionally, it's worth introducing an extra logic to handle it directly within the `Schedule` trigger itself.
[ "core/src/main/java/io/kestra/core/models/triggers/types/Schedule.java" ]
[ "core/src/main/java/io/kestra/core/models/triggers/types/Schedule.java" ]
[ "core/src/test/java/io/kestra/core/validations/ScheduleTest.java" ]
diff --git a/core/src/main/java/io/kestra/core/models/triggers/types/Schedule.java b/core/src/main/java/io/kestra/core/models/triggers/types/Schedule.java index efdd8ea8a3..2552436f3d 100644 --- a/core/src/main/java/io/kestra/core/models/triggers/types/Schedule.java +++ b/core/src/main/java/io/kestra/core/models/triggers/types/Schedule.java @@ -21,6 +21,7 @@ import io.kestra.core.runners.RunnerUtils; import io.kestra.core.services.ConditionService; import io.kestra.core.validations.CronExpression; +import io.swagger.v3.oas.annotations.Hidden; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; import lombok.experimental.SuperBuilder; @@ -35,6 +36,7 @@ import java.util.Optional; import javax.validation.Valid; import javax.validation.constraints.NotNull; +import javax.validation.constraints.Null; @SuperBuilder @ToString @@ -143,7 +145,9 @@ public class Schedule extends AbstractTrigger implements PollingTriggerInterface @PluginProperty private ScheduleBackfill backfill; + @Schema(hidden = true) @Builder.Default + @Null private final Duration interval = null; @Valid
diff --git a/core/src/test/java/io/kestra/core/validations/ScheduleTest.java b/core/src/test/java/io/kestra/core/validations/ScheduleTest.java index 9759d3d281..d2370afeed 100644 --- a/core/src/test/java/io/kestra/core/validations/ScheduleTest.java +++ b/core/src/test/java/io/kestra/core/validations/ScheduleTest.java @@ -33,4 +33,19 @@ void cronValidation() { assertThat(modelValidator.isValid(build).isPresent(), is(true)); assertThat(modelValidator.isValid(build).get().getMessage(), containsString("backfill and lateMaximumDelay are incompatible options")); } + + @Test + void intervalValidation() { + Schedule build = Schedule.builder() + .id(IdUtils.create()) + .type(Schedule.class.getName()) + .cron("* * * * *") + .interval(Duration.ofSeconds(5)) + .build(); + + + assertThat(modelValidator.isValid(build).isPresent(), is(true)); + assertThat(modelValidator.isValid(build).get().getMessage(), containsString("interval: must be null")); + + } }
train
train
2023-09-01T16:15:35
"2023-08-31T15:29:10Z"
anna-geller
train
kestra-io/kestra/2006_2009
kestra-io/kestra
kestra-io/kestra/2006
kestra-io/kestra/2009
[ "keyword_pr_to_issue" ]
102e84ccb22f05c09299ac8d39f70db339567981
b08f7010c102974b88d58fa792a63a37d86c6cc0
[ "We can support both but in this case the validator will not be aware of the `Label` type anymore so it will validate any arrays.\n\nUsing a map will works\n```\nlabels:\n key: value\n```\n\nUsing a list of labels will work\n```\nlabels:\n - key: key\n value: value1\n```\n\nThe following will validate but create an invalid label in the database (not that it will not crash even at validation time)\n```\nlabels:\n - toto: titi\n```\n\n" ]
[]
"2023-09-01T13:10:14Z"
[ "enhancement" ]
Add support for a map of `labels` in the flow validator
### Feature description We want to support both options for the definition of `labels`. 1. A list of key-value pairs: ```yaml id: myflow namespace: dev labels: - key: team value: data - key: project value: dwh ``` 2. A map of labels: ```yaml id: myflow namespace: dev labels: team: data project: dwh ``` Initially, option 2 was the default. Now, option 1 is the default and the validator complains when using the Map syntax. Both work, but the validator currently only accepts the first option. Both options are valid. This issue is to bring back support for the Map of labels on the schema for both web validator and VS Code extension.
[ "core/src/main/java/io/kestra/core/models/flows/Flow.java" ]
[ "core/src/main/java/io/kestra/core/models/flows/Flow.java" ]
[]
diff --git a/core/src/main/java/io/kestra/core/models/flows/Flow.java b/core/src/main/java/io/kestra/core/models/flows/Flow.java index bde1b57026..f1d3a59b12 100644 --- a/core/src/main/java/io/kestra/core/models/flows/Flow.java +++ b/core/src/main/java/io/kestra/core/models/flows/Flow.java @@ -10,6 +10,7 @@ import io.kestra.core.exceptions.InternalException; import io.kestra.core.models.DeletedInterface; import io.kestra.core.models.Label; +import io.kestra.core.models.annotations.PluginProperty; import io.kestra.core.models.executions.Execution; import io.kestra.core.models.listeners.Listener; import io.kestra.core.models.tasks.FlowableTask; @@ -22,6 +23,7 @@ import io.kestra.core.services.FlowService; import io.kestra.core.validations.FlowValidation; import io.micronaut.core.annotation.Introspected; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; import lombok.experimental.SuperBuilder; import org.slf4j.Logger; @@ -70,6 +72,7 @@ public boolean hasIgnoreMarker(final AnnotatedMember m) { @JsonSerialize(using = ListOrMapOfLabelSerializer.class) @JsonDeserialize(using = ListOrMapOfLabelDeserializer.class) + @Schema(implementation = Object.class, anyOf = {List.class, Map.class}) List<Label> labels;
null
train
train
2023-09-01T23:30:41
"2023-08-31T16:29:16Z"
anna-geller
train
kestra-io/kestra/1409_2020
kestra-io/kestra
kestra-io/kestra/1409
kestra-io/kestra/2020
[ "keyword_pr_to_issue" ]
e02a72b0ebab1f90c64d667a1d6cf18fe48d2e54
29410df0315e7b81c23c3855a5f1eac12dd5c3eb
[ "related to #1713 ", "acc to @Skraye and @Ben8t, listeners can be used for lineage to avoid an extra flow, they will be added to the topology", "Keeping the debat open for the following reasons : \r\n\r\n- creating an external flow (with trigger) to resolve failure notification seems a bit overwhelming 🤔 \r\n- the concept of listeners could be used for #1246 (+ see this [Notion page](https://www.notion.so/kestra-io/SLA-Freshness-Timeout-0cf7cf6bf89e42eaa453de0bc4966591?pvs=4)), especially for running tasks after the main flow execution.\r\n- the concept of listeners could be used for metadata management, for example \"when the flow finished with success then upload this metadata to an external system (data lineage/catalog tools for example), expose metadata in Kestra, etc.\"", "1. why overwhelming? you need to define it usually once for the entire namespace, otherwise you can just use the `errors`\r\n2. SLA is also listening to some conditions the same way as triggers which are more flexible and decoupled than listeners \r\n3. for metadata management, it would be especially useful to define it once on a namespace level with a trigger than adding boilerplate listeners to each flow only to collect metadata \r\n\r\nmaybe the issue you see is that the trigger dependencies are not displayed directly in the same DAG view? if so, maybe better to postpone this discussion until the topology redesign is done? with triggers being displayed faster/better, there is no need for listeners (of which the only benefit is being coupled to a flow rather than decoupled)", "Yes my main doubt is about having one main flow where you have usual tasks, and then have to create another flow with triggers where you put your \"SLA\", \"Trigger/Freshness\" conditions. Uncoupled, but for what purpose ? It also makes sense to have them close the actual flow.\r\n\r\nWith SLA ~ listeners we don't have this \"listening/polling pattern\" consuming ressources (actually a better wording would be something like \"afterExecution\"), i.e. when the flow has finished to run do X/expose SLA values in the data model/dashboard.\r\n\r\nFeeling like the debate Trigger vs Listeners is like the Push (listeners) vs Pull (trigger) pattern - both are good depending of the context, but I might be wrong 🤔 \r\n\r\nOn 1., I agree `errors` do the work, but isn't it just a specific type of \"listeners\" 🤔 ? What about \"my flow is in WARNING\", \"this task metric value is equal to X\", etc... worth considering this as a whole maybe\r\n\r\nFor metadata I agree too, we might have a better space than Flow for this 🤔 (that's another discussion 😅)", "afterExecution is equivalent to adding one more downstream task\r\n\r\nif you have more nuanced conditions, that's what triggers are for", "@brian-mulier-p can you add annotation to the UI to show that Listeners are deprecated?", "> @brian-mulier-p can you add annotation to the UI to show that Listeners are deprecated?\r\n\r\nSure", "done in #2020 " ]
[]
"2023-09-04T15:30:13Z"
[]
Deprecate listeners in favor of triggers
### Feature description this pattern will be deprecated: ```yaml id: slackFailureNotifications namespace: prod tasks: - id: fail type: io.kestra.core.tasks.scripts.Bash commands: - exit 1 listeners: - conditions: - type: io.kestra.core.models.conditions.types.ExecutionStatusCondition in: - FAILED tasks: - id: slack type: io.kestra.plugin.notifications.slack.SlackExecution url: {{envs.slack_webhook}} channel: "#general" ``` in favor of triggers: ```yaml id: slack-global namespace: com.kestra.monitoring tasks: - id: send type: io.kestra.plugin.notifications.slack.SlackExecution url: "{{ namespace.slack.webhook }}" channel: "C02U601DNAJ" username: "Kestra" iconEmoji: ":kestra:" executionId: "{{ trigger.executionId }}" triggers: - id: listen type: io.kestra.core.models.triggers.types.Flow conditions: - type: io.kestra.core.models.conditions.types.ExecutionStatusCondition in: - FAILED - WARNING - type: io.kestra.core.models.conditions.types.ExecutionNamespaceCondition namespace: com.kestra prefix: true ``` cc @Ben8t backlog
[ "core/src/main/java/io/kestra/core/models/flows/Flow.java", "core/src/main/java/io/kestra/core/services/FlowService.java" ]
[ "core/src/main/java/io/kestra/core/models/flows/Flow.java", "core/src/main/java/io/kestra/core/services/FlowService.java" ]
[ "webserver/src/test/java/io/kestra/webserver/controllers/FlowControllerTest.java", "webserver/src/test/resources/flows/validateMultipleValidFlows.yaml" ]
diff --git a/core/src/main/java/io/kestra/core/models/flows/Flow.java b/core/src/main/java/io/kestra/core/models/flows/Flow.java index bde1b57026..dc57407abc 100644 --- a/core/src/main/java/io/kestra/core/models/flows/Flow.java +++ b/core/src/main/java/io/kestra/core/models/flows/Flow.java @@ -86,6 +86,7 @@ public boolean hasIgnoreMarker(final AnnotatedMember m) { List<Task> errors; @Valid + @Deprecated List<Listener> listeners; @Valid diff --git a/core/src/main/java/io/kestra/core/services/FlowService.java b/core/src/main/java/io/kestra/core/services/FlowService.java index f2ed1f97e1..7ce8be4e21 100644 --- a/core/src/main/java/io/kestra/core/services/FlowService.java +++ b/core/src/main/java/io/kestra/core/services/FlowService.java @@ -72,7 +72,7 @@ private Stream<String> deprecationTraversal(String prefix, Object object) { } return Stream.concat( - method.isAnnotationPresent(Deprecated.class) && fieldValue != null ? Stream.of(prefix + "." + fieldName) : Stream.empty(), + method.isAnnotationPresent(Deprecated.class) && fieldValue != null ? Stream.of(prefix.isEmpty() ? fieldName : prefix + "." + fieldName) : Stream.empty(), additionalDeprecationPaths ); } catch (IllegalAccessException | InvocationTargetException e) {
diff --git a/webserver/src/test/java/io/kestra/webserver/controllers/FlowControllerTest.java b/webserver/src/test/java/io/kestra/webserver/controllers/FlowControllerTest.java index 44116136ba..40b9b336f7 100644 --- a/webserver/src/test/java/io/kestra/webserver/controllers/FlowControllerTest.java +++ b/webserver/src/test/java/io/kestra/webserver/controllers/FlowControllerTest.java @@ -669,8 +669,8 @@ void validateFlows() throws IOException { List<ValidateConstraintViolation> body = response.body(); assertThat(body.size(), is(2)); - assertThat(body.get(0).getDeprecationPaths(), hasSize(2)); - assertThat(body.get(0).getDeprecationPaths(), containsInAnyOrder("tasks[1]", "tasks[1].additionalProperty")); + assertThat(body.get(0).getDeprecationPaths(), hasSize(3)); + assertThat(body.get(0).getDeprecationPaths(), containsInAnyOrder("tasks[1]", "tasks[1].additionalProperty", "listeners")); assertThat(body.get(1).getDeprecationPaths(), empty()); assertThat(body, everyItem( Matchers.hasProperty("constraints", is(nullValue())) diff --git a/webserver/src/test/resources/flows/validateMultipleValidFlows.yaml b/webserver/src/test/resources/flows/validateMultipleValidFlows.yaml index 7918ca47c2..50980dd1cb 100644 --- a/webserver/src/test/resources/flows/validateMultipleValidFlows.yaml +++ b/webserver/src/test/resources/flows/validateMultipleValidFlows.yaml @@ -7,6 +7,11 @@ tasks: - id: deprecated_task type: io.kestra.core.plugins.test.DeprecatedTask additionalProperty: "value" +listeners: + - tasks: + - id: log + type: io.kestra.core.tasks.log.Log + message: logging ---
train
train
2023-09-05T12:08:09
"2023-05-25T15:45:19Z"
anna-geller
train
kestra-io/kestra/2021_2022
kestra-io/kestra
kestra-io/kestra/2021
kestra-io/kestra/2022
[ "keyword_pr_to_issue" ]
8fba5eed01081f2904dea3a14f61589a81bea7e4
516d5fbace52b143fc7b92a8324d5548eb095b5a
[]
[ "You cannot merge tasks and triggers, they are different things.\r\nFor a trigger you expect having a message \"Duplicate trigger id with name ...\"", "There is a `allTriggerIds()` in the Flow class." ]
"2023-09-04T16:18:48Z"
[ "bug", "backend" ]
Trigger ids should be unique in a flow
### Expected Behavior _No response_ ### Actual Behaviour See https://kestra-io.slack.com/archives/C03FQKXRK3K/p1693832885758649 Missing a validation on trigger ids ### Steps To Reproduce _No response_ ### Environment Information - Kestra Version: 0.12.0-SNAPSHOT - Operating System (OS / Docker / Kubernetes): - Java Version (If not docker): ### Example flow _No response_
[ "core/src/main/java/io/kestra/core/validations/ValidationFactory.java" ]
[ "core/src/main/java/io/kestra/core/validations/ValidationFactory.java" ]
[ "core/src/test/java/io/kestra/core/models/flows/FlowTest.java", "core/src/test/resources/flows/invalids/duplicate.yaml" ]
diff --git a/core/src/main/java/io/kestra/core/validations/ValidationFactory.java b/core/src/main/java/io/kestra/core/validations/ValidationFactory.java index 33c2b9b99c..57ca63b3f4 100644 --- a/core/src/main/java/io/kestra/core/validations/ValidationFactory.java +++ b/core/src/main/java/io/kestra/core/validations/ValidationFactory.java @@ -6,8 +6,8 @@ import io.kestra.core.models.flows.Input; import io.kestra.core.models.tasks.RunnableTask; import io.kestra.core.models.tasks.Task; -import io.kestra.core.tasks.flows.Dag; import io.kestra.core.models.tasks.WorkerGroup; +import io.kestra.core.tasks.flows.Dag; import io.kestra.core.tasks.flows.Switch; import io.kestra.core.tasks.flows.WorkingDirectory; import io.micronaut.context.annotation.Factory; @@ -17,9 +17,13 @@ import java.io.IOException; import java.text.SimpleDateFormat; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.List; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; +import java.util.stream.Collectors; @Factory public class ValidationFactory { @@ -183,18 +187,22 @@ ConstraintValidator<FlowValidation, Flow> flowValidation() { List<String> violations = new ArrayList<>(); - // task unique id + // tasks unique id List<String> taskIds = value.allTasksWithChilds() .stream() .map(Task::getId) .toList(); - List<String> taskDuplicates = taskIds - .stream() - .distinct() - .filter(entry -> Collections.frequency(taskIds, entry) > 1) - .toList(); - if (taskDuplicates.size() > 0) { - violations.add("Duplicate task id with name [" + String.join(", ", taskDuplicates) + "]"); + + List<String> duplicateIds = getDuplicates(taskIds); + + if (!duplicateIds.isEmpty()) { + violations.add("Duplicate task id with name [" + String.join(", ", duplicateIds) + "]"); + } + + duplicateIds = getDuplicates(value.allTriggerIds()); + + if (!duplicateIds.isEmpty()) { + violations.add("Duplicate trigger id with name [" + String.join(", ", duplicateIds) + "]"); } value.allTasksWithChilds() @@ -202,8 +210,8 @@ ConstraintValidator<FlowValidation, Flow> flowValidation() { .forEach( task -> { if (task instanceof io.kestra.core.tasks.flows.Flow taskFlow - && taskFlow.getFlowId().equals(value.getId()) - && taskFlow.getNamespace().equals(value.getNamespace())) { + && taskFlow.getFlowId().equals(value.getId()) + && taskFlow.getNamespace().equals(value.getNamespace())) { violations.add("Recursive call to flow [" + value.getId() + "]"); } } @@ -234,6 +242,13 @@ ConstraintValidator<FlowValidation, Flow> flowValidation() { }; } + private static List<String> getDuplicates(List<String> taskIds) { + return taskIds.stream() + .distinct() + .filter(entry -> Collections.frequency(taskIds, entry) > 1) + .collect(Collectors.toList()); + } + @Singleton ConstraintValidator<Regex, String> patternValidator() { return (value, annotationMetadata, context) -> { @@ -243,7 +258,7 @@ ConstraintValidator<Regex, String> patternValidator() { try { Pattern.compile(value); - } catch(PatternSyntaxException e) { + } catch (PatternSyntaxException e) { context.messageTemplate("invalid pattern [" + value + "]"); return false; }
diff --git a/core/src/test/java/io/kestra/core/models/flows/FlowTest.java b/core/src/test/java/io/kestra/core/models/flows/FlowTest.java index 80802f1451..cb8a06f999 100644 --- a/core/src/test/java/io/kestra/core/models/flows/FlowTest.java +++ b/core/src/test/java/io/kestra/core/models/flows/FlowTest.java @@ -35,7 +35,8 @@ void duplicate() { assertThat(validate.isPresent(), is(true)); assertThat(validate.get().getConstraintViolations().size(), is(1)); - assertThat(validate.get().getMessage(), containsString("Duplicate task id with name [date]")); + assertThat(validate.get().getMessage(), containsString("Duplicate task id with name [date, listen]")); + assertThat(validate.get().getMessage(), containsString("Duplicate trigger id with name [trigger]")); } @Test diff --git a/core/src/test/resources/flows/invalids/duplicate.yaml b/core/src/test/resources/flows/invalids/duplicate.yaml index 594efc0b87..671f30b656 100644 --- a/core/src/test/resources/flows/invalids/duplicate.yaml +++ b/core/src/test/resources/flows/invalids/duplicate.yaml @@ -3,7 +3,7 @@ namespace: io.kestra.tests listeners: - tasks: - - id: date + - id: listen type: io.kestra.core.tasks.debugs.Return format: "{{taskrun.startDate}}" @@ -11,6 +11,9 @@ tasks: - id: date type: io.kestra.core.tasks.debugs.Return format: "{{taskrun.startDate}}" + - id: listen + type: io.kestra.core.tasks.debugs.Return + format: "{{taskrun.startDate}}" - id: seq type: io.kestra.core.tasks.flows.Sequential @@ -27,3 +30,10 @@ errors: - id: date type: io.kestra.core.tasks.debugs.Return format: "{{taskrun.startDate}}" +triggers: + - id: trigger + type: io.kestra.core.models.triggers.types.Schedule + cron: '* * * * *' + - id: trigger + type: io.kestra.core.models.triggers.types.Webhook + key: t \ No newline at end of file
val
train
2023-09-04T16:47:32
"2023-09-04T16:16:01Z"
brian-mulier-p
train
kestra-io/kestra/2040_2049
kestra-io/kestra
kestra-io/kestra/2040
kestra-io/kestra/2049
[ "keyword_pr_to_issue" ]
89f7827ca91b6d553034a9f740215a62ce160c6d
b2fcf42fca3c0e92a81f61d4bf16b434c9fc19b6
[]
[]
"2023-09-06T13:43:54Z"
[ "bug" ]
Creating a flow from JSON didn't use the custom label deserializer
### Expected Behavior Creating a flow from JSON must use the custom label deserializer otherwise labe as map is not possibe. ### Actual Behaviour Using the following cURL example: ``` curl --location 'http://localhost:8080/api/v1/flows' \ --header 'Content-Type: application/json' \ --header 'Accept: text/json' \ --data '{ "id": "hello-world-5", "namespace": "dev", "revision": 1, "labels":{ "key": "value" }, "tasks": [ { "id": "hello", "type": "io.kestra.core.tasks.log.Log", "message": "Kestra team wishes you a great day! 👋" } ] }' ``` When the flow is created it has one label `value=null` as it reads the map as a list as the `ListOrMapOfLabelDeserializer` is not used. ### Steps To Reproduce _No response_ ### Environment Information - Kestra Version: - Operating System (OS / Docker / Kubernetes): - Java Version (If not docker): ### Example flow _No response_
[ "core/src/main/java/io/kestra/core/models/flows/Flow.java", "core/src/main/java/io/kestra/core/models/flows/FlowWithException.java", "core/src/main/java/io/kestra/core/models/flows/FlowWithSource.java", "jdbc/src/main/java/io/kestra/jdbc/repository/AbstractJdbcFlowRepository.java", "repository-memory/src/main/java/io/kestra/repository/memory/MemoryFlowRepository.java" ]
[ "core/src/main/java/io/kestra/core/models/flows/Flow.java", "core/src/main/java/io/kestra/core/models/flows/FlowWithException.java", "core/src/main/java/io/kestra/core/models/flows/FlowWithSource.java", "jdbc/src/main/java/io/kestra/jdbc/repository/AbstractJdbcFlowRepository.java", "repository-memory/src/main/java/io/kestra/repository/memory/MemoryFlowRepository.java" ]
[ "core/src/test/java/io/kestra/core/services/FlowTopologyServiceTest.java", "webserver/src/test/java/io/kestra/webserver/controllers/FlowControllerTest.java" ]
diff --git a/core/src/main/java/io/kestra/core/models/flows/Flow.java b/core/src/main/java/io/kestra/core/models/flows/Flow.java index e29e7d1df6..a12b51a664 100644 --- a/core/src/main/java/io/kestra/core/models/flows/Flow.java +++ b/core/src/main/java/io/kestra/core/models/flows/Flow.java @@ -10,7 +10,6 @@ import io.kestra.core.exceptions.InternalException; import io.kestra.core.models.DeletedInterface; import io.kestra.core.models.Label; -import io.kestra.core.models.annotations.PluginProperty; import io.kestra.core.models.executions.Execution; import io.kestra.core.models.listeners.Listener; import io.kestra.core.models.tasks.FlowableTask; @@ -29,17 +28,16 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.*; +import java.util.stream.Collectors; +import java.util.stream.Stream; import javax.validation.ConstraintViolation; import javax.validation.ConstraintViolationException; import javax.validation.Valid; import javax.validation.constraints.*; -import java.util.*; -import java.util.stream.Collectors; -import java.util.stream.Stream; @SuperBuilder(toBuilder = true) @Getter -@AllArgsConstructor @NoArgsConstructor @Introspected @ToString @@ -64,7 +62,6 @@ public boolean hasIgnoreMarker(final AnnotatedMember m) { @Pattern(regexp = "[a-z0-9._-]+") String namespace; - @With @Min(value = 1) Integer revision; @@ -75,7 +72,6 @@ public boolean hasIgnoreMarker(final AnnotatedMember m) { @Schema(implementation = Object.class, anyOf = {List.class, Map.class}) List<Label> labels; - @Valid List<Input<?>> inputs; @@ -322,21 +318,9 @@ public String generateSource() { } public Flow toDeleted() { - return new Flow( - this.id, - this.namespace, - this.revision + 1, - this.description, - this.labels, - this.inputs, - this.variables, - this.tasks, - this.errors, - this.listeners, - this.triggers, - this.taskDefaults, - this.disabled, - true - ); + return this.toBuilder() + .revision(this.revision + 1) + .deleted(true) + .build(); } } diff --git a/core/src/main/java/io/kestra/core/models/flows/FlowWithException.java b/core/src/main/java/io/kestra/core/models/flows/FlowWithException.java index abf1c5a5d2..4e09794ba3 100644 --- a/core/src/main/java/io/kestra/core/models/flows/FlowWithException.java +++ b/core/src/main/java/io/kestra/core/models/flows/FlowWithException.java @@ -1,12 +1,14 @@ package io.kestra.core.models.flows; import io.micronaut.core.annotation.Introspected; -import lombok.*; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.ToString; import lombok.experimental.SuperBuilder; @SuperBuilder(toBuilder = true) @Getter -@AllArgsConstructor @NoArgsConstructor @Introspected @ToString diff --git a/core/src/main/java/io/kestra/core/models/flows/FlowWithSource.java b/core/src/main/java/io/kestra/core/models/flows/FlowWithSource.java index 6c950f01c4..be9049b12a 100644 --- a/core/src/main/java/io/kestra/core/models/flows/FlowWithSource.java +++ b/core/src/main/java/io/kestra/core/models/flows/FlowWithSource.java @@ -2,20 +2,16 @@ import io.kestra.core.services.FlowService; import io.micronaut.core.annotation.Introspected; -import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.ToString; import lombok.experimental.SuperBuilder; -import lombok.extern.slf4j.Slf4j; @SuperBuilder(toBuilder = true) @Getter -@AllArgsConstructor @NoArgsConstructor @Introspected @ToString -@Slf4j public class FlowWithSource extends Flow { String source; diff --git a/jdbc/src/main/java/io/kestra/jdbc/repository/AbstractJdbcFlowRepository.java b/jdbc/src/main/java/io/kestra/jdbc/repository/AbstractJdbcFlowRepository.java index 8f10e1f2ff..13defaef92 100644 --- a/jdbc/src/main/java/io/kestra/jdbc/repository/AbstractJdbcFlowRepository.java +++ b/jdbc/src/main/java/io/kestra/jdbc/repository/AbstractJdbcFlowRepository.java @@ -348,6 +348,10 @@ public FlowWithSource update(Flow flow, Flow previous, String flowSource, Flow f @SneakyThrows private FlowWithSource save(Flow flow, CrudEventType crudEventType, String flowSource) throws ConstraintViolationException { + if (flow instanceof FlowWithSource) { + flow = ((FlowWithSource) flow).toFlow(); + } + // flow exists, return it Optional<FlowWithSource> exists = this.findByIdWithSource(flow.getNamespace(), flow.getId()); if (exists.isPresent() && exists.get().isUpdatable(flow, flowSource)) { @@ -357,9 +361,9 @@ private FlowWithSource save(Flow flow, CrudEventType crudEventType, String flowS List<FlowWithSource> revisions = this.findRevisions(flow.getNamespace(), flow.getId()); if (revisions.size() > 0) { - flow = flow.withRevision(revisions.get(revisions.size() - 1).getRevision() + 1); + flow = flow.toBuilder().revision(revisions.get(revisions.size() - 1).getRevision() + 1).build(); } else { - flow = flow.withRevision(1); + flow = flow.toBuilder().revision(1).build(); } Map<Field<Object>, Object> fields = this.jdbcRepository.persistFields(flow); @@ -376,6 +380,10 @@ private FlowWithSource save(Flow flow, CrudEventType crudEventType, String flowS @SneakyThrows @Override public Flow delete(Flow flow) { + if (flow instanceof FlowWithSource) { + flow = ((FlowWithSource) flow).toFlow(); + } + Optional<Flow> revision = this.findById(flow.getNamespace(), flow.getId(), Optional.of(flow.getRevision())); if (revision.isEmpty()) { throw new IllegalStateException("Flow " + flow.getId() + " doesn't exists"); diff --git a/repository-memory/src/main/java/io/kestra/repository/memory/MemoryFlowRepository.java b/repository-memory/src/main/java/io/kestra/repository/memory/MemoryFlowRepository.java index 31abf66595..9e3e49e8dc 100644 --- a/repository-memory/src/main/java/io/kestra/repository/memory/MemoryFlowRepository.java +++ b/repository-memory/src/main/java/io/kestra/repository/memory/MemoryFlowRepository.java @@ -195,6 +195,10 @@ public FlowWithSource update(Flow flow, Flow previous, String flowSource, Flow f } private FlowWithSource save(Flow flow, CrudEventType crudEventType, String flowSource) throws ConstraintViolationException { + if (flow instanceof FlowWithSource) { + flow = ((FlowWithSource) flow).toFlow(); + } + // flow exists, return it Optional<Flow> exists = this.findById(flow.getNamespace(), flow.getId()); Optional<String> existsSource = this.findSourceById(flow.getNamespace(), flow.getId()); @@ -205,9 +209,9 @@ private FlowWithSource save(Flow flow, CrudEventType crudEventType, String flowS List<FlowWithSource> revisions = this.findRevisions(flow.getNamespace(), flow.getId()); if (revisions.size() > 0) { - flow = flow.withRevision(revisions.get(revisions.size() - 1).getRevision() + 1); + flow = flow.toBuilder().revision(revisions.get(revisions.size() - 1).getRevision() + 1).build(); } else { - flow = flow.withRevision(1); + flow = flow.toBuilder().revision(1).build(); } this.flows.put(flowId(flow), flow); @@ -222,6 +226,10 @@ private FlowWithSource save(Flow flow, CrudEventType crudEventType, String flowS @Override public Flow delete(Flow flow) { + if (flow instanceof FlowWithSource) { + flow = ((FlowWithSource) flow).toFlow(); + } + if (this.findById(flow.getNamespace(), flow.getId(), Optional.of(flow.getRevision())).isEmpty()) { throw new IllegalStateException("Flow " + flow.getId() + " doesn't exists"); } @@ -232,8 +240,9 @@ public Flow delete(Flow flow) { this.flows.remove(flowId(deleted)); this.revisions.put(deleted.uid(), deleted); + Flow finalFlow = flow; ListUtils.emptyOnNull(flow.getTriggers()) - .forEach(abstractTrigger -> triggerQueue.delete(Trigger.of(flow, abstractTrigger))); + .forEach(abstractTrigger -> triggerQueue.delete(Trigger.of(finalFlow, abstractTrigger))); eventPublisher.publishEvent(new CrudEvent<>(flow, CrudEventType.DELETE));
diff --git a/core/src/test/java/io/kestra/core/services/FlowTopologyServiceTest.java b/core/src/test/java/io/kestra/core/services/FlowTopologyServiceTest.java index 70e7042aec..553c383dab 100644 --- a/core/src/test/java/io/kestra/core/services/FlowTopologyServiceTest.java +++ b/core/src/test/java/io/kestra/core/services/FlowTopologyServiceTest.java @@ -173,14 +173,14 @@ public void multipleCondition() { @Test public void self1() { - Flow flow = parse("flows/valids/trigger-multiplecondition-listener.yaml").withRevision(1); + Flow flow = parse("flows/valids/trigger-multiplecondition-listener.yaml").toBuilder().revision(1).build(); assertThat(flowTopologyService.isChild(flow, flow), nullValue()); } @Test public void self() { - Flow flow = parse("flows/valids/trigger-flow-listener.yaml").withRevision(1); + Flow flow = parse("flows/valids/trigger-flow-listener.yaml").toBuilder().revision(1).build(); assertThat(flowTopologyService.isChild(flow, flow), nullValue()); } diff --git a/webserver/src/test/java/io/kestra/webserver/controllers/FlowControllerTest.java b/webserver/src/test/java/io/kestra/webserver/controllers/FlowControllerTest.java index 40b9b336f7..e2f8c18722 100644 --- a/webserver/src/test/java/io/kestra/webserver/controllers/FlowControllerTest.java +++ b/webserver/src/test/java/io/kestra/webserver/controllers/FlowControllerTest.java @@ -10,6 +10,7 @@ import io.kestra.core.models.hierarchies.FlowGraph; import io.kestra.core.models.tasks.Task; import io.kestra.core.models.validations.ValidateConstraintViolation; +import io.kestra.core.serializers.JacksonMapper; import io.kestra.core.serializers.YamlFlowParser; import io.kestra.core.tasks.debugs.Return; import io.kestra.core.tasks.flows.Sequential; @@ -251,7 +252,18 @@ void createFlow() { Flow get = parseFlow(client.toBlocking().retrieve(HttpRequest.GET("/api/v1/flows/" + flow.getNamespace() + "/" + flow.getId()), String.class)); assertThat(get.getId(), is(flow.getId())); assertThat(get.getInputs().get(0).getName(), is("a")); + } + + @Test + void createFlowWithJsonLabels() { + Map<String, Object> flow = JacksonMapper.toMap(generateFlow("io.kestra.unittest", "a")); + flow.put("labels", Map.of("a", "b")); + + Flow result = parseFlow(client.toBlocking().retrieve(POST("/api/v1/flows", flow), String.class)); + assertThat(result.getId(), is(flow.get("id"))); + assertThat(result.getLabels().get(0).key(), is("a")); + assertThat(result.getLabels().get(0).value(), is("b")); } @Test
val
train
2023-09-08T12:09:43
"2023-09-05T15:35:01Z"
loicmathieu
train
kestra-io/kestra/2037_2049
kestra-io/kestra
kestra-io/kestra/2037
kestra-io/kestra/2049
[ "keyword_pr_to_issue", "connected" ]
89f7827ca91b6d553034a9f740215a62ce160c6d
b2fcf42fca3c0e92a81f61d4bf16b434c9fc19b6
[ "can you try to update terraform provider version please to [0.10.0](https://registry.terraform.io/providers/kestra-io/kestra/latest) please ? ", "Hello!\r\n\r\nIndeed, upgrading the TF provider to 0.10.0+ solved our issue. The problem seems to originate from the JSON resource on the web server, which was used to deploy flows in previous versions.\r\n\r\nThis also involved updating the flows, and adding/uncommenting the id/namespace pairs: they were previously not allowed with the JSON resource, but are now required with the YAML resource. If a flow is created without them, the web server returns an HTTP 401 error without clear explanation.\r\n\r\nThanks for your help,\r\nYoann" ]
[]
"2023-09-06T13:43:54Z"
[ "bug" ]
Labels are not created correctly when deployed by Terraform
### Expected Behavior When deploying a flow using Terraform, I want the labels to be created correctly. If I wrote labels in a flow, using the key/value representation, such as ```yaml labels: env: prd country: FR ``` I want them to be created as following, in the target Kestra server: ```yaml labels: env: prd country: FR ``` ### Actual Behaviour Instead of the expected behavior, the flows created by Terraform don't contain labels. Instead, we get a list with an empty object. ```yaml labels: - {} ``` We get this unexpected behavior for any flow. ### Steps To Reproduce _No response_ ### Environment Information - Kestra Version: 0.11.0 - Operating System (OS / Docker / Kubernetes): Kubernetes - Kestra TF Operator Version: 0.7.0 ### Example flow _No response_
[ "core/src/main/java/io/kestra/core/models/flows/Flow.java", "core/src/main/java/io/kestra/core/models/flows/FlowWithException.java", "core/src/main/java/io/kestra/core/models/flows/FlowWithSource.java", "jdbc/src/main/java/io/kestra/jdbc/repository/AbstractJdbcFlowRepository.java", "repository-memory/src/main/java/io/kestra/repository/memory/MemoryFlowRepository.java" ]
[ "core/src/main/java/io/kestra/core/models/flows/Flow.java", "core/src/main/java/io/kestra/core/models/flows/FlowWithException.java", "core/src/main/java/io/kestra/core/models/flows/FlowWithSource.java", "jdbc/src/main/java/io/kestra/jdbc/repository/AbstractJdbcFlowRepository.java", "repository-memory/src/main/java/io/kestra/repository/memory/MemoryFlowRepository.java" ]
[ "core/src/test/java/io/kestra/core/services/FlowTopologyServiceTest.java", "webserver/src/test/java/io/kestra/webserver/controllers/FlowControllerTest.java" ]
diff --git a/core/src/main/java/io/kestra/core/models/flows/Flow.java b/core/src/main/java/io/kestra/core/models/flows/Flow.java index e29e7d1df6..a12b51a664 100644 --- a/core/src/main/java/io/kestra/core/models/flows/Flow.java +++ b/core/src/main/java/io/kestra/core/models/flows/Flow.java @@ -10,7 +10,6 @@ import io.kestra.core.exceptions.InternalException; import io.kestra.core.models.DeletedInterface; import io.kestra.core.models.Label; -import io.kestra.core.models.annotations.PluginProperty; import io.kestra.core.models.executions.Execution; import io.kestra.core.models.listeners.Listener; import io.kestra.core.models.tasks.FlowableTask; @@ -29,17 +28,16 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.*; +import java.util.stream.Collectors; +import java.util.stream.Stream; import javax.validation.ConstraintViolation; import javax.validation.ConstraintViolationException; import javax.validation.Valid; import javax.validation.constraints.*; -import java.util.*; -import java.util.stream.Collectors; -import java.util.stream.Stream; @SuperBuilder(toBuilder = true) @Getter -@AllArgsConstructor @NoArgsConstructor @Introspected @ToString @@ -64,7 +62,6 @@ public boolean hasIgnoreMarker(final AnnotatedMember m) { @Pattern(regexp = "[a-z0-9._-]+") String namespace; - @With @Min(value = 1) Integer revision; @@ -75,7 +72,6 @@ public boolean hasIgnoreMarker(final AnnotatedMember m) { @Schema(implementation = Object.class, anyOf = {List.class, Map.class}) List<Label> labels; - @Valid List<Input<?>> inputs; @@ -322,21 +318,9 @@ public String generateSource() { } public Flow toDeleted() { - return new Flow( - this.id, - this.namespace, - this.revision + 1, - this.description, - this.labels, - this.inputs, - this.variables, - this.tasks, - this.errors, - this.listeners, - this.triggers, - this.taskDefaults, - this.disabled, - true - ); + return this.toBuilder() + .revision(this.revision + 1) + .deleted(true) + .build(); } } diff --git a/core/src/main/java/io/kestra/core/models/flows/FlowWithException.java b/core/src/main/java/io/kestra/core/models/flows/FlowWithException.java index abf1c5a5d2..4e09794ba3 100644 --- a/core/src/main/java/io/kestra/core/models/flows/FlowWithException.java +++ b/core/src/main/java/io/kestra/core/models/flows/FlowWithException.java @@ -1,12 +1,14 @@ package io.kestra.core.models.flows; import io.micronaut.core.annotation.Introspected; -import lombok.*; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.ToString; import lombok.experimental.SuperBuilder; @SuperBuilder(toBuilder = true) @Getter -@AllArgsConstructor @NoArgsConstructor @Introspected @ToString diff --git a/core/src/main/java/io/kestra/core/models/flows/FlowWithSource.java b/core/src/main/java/io/kestra/core/models/flows/FlowWithSource.java index 6c950f01c4..be9049b12a 100644 --- a/core/src/main/java/io/kestra/core/models/flows/FlowWithSource.java +++ b/core/src/main/java/io/kestra/core/models/flows/FlowWithSource.java @@ -2,20 +2,16 @@ import io.kestra.core.services.FlowService; import io.micronaut.core.annotation.Introspected; -import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.ToString; import lombok.experimental.SuperBuilder; -import lombok.extern.slf4j.Slf4j; @SuperBuilder(toBuilder = true) @Getter -@AllArgsConstructor @NoArgsConstructor @Introspected @ToString -@Slf4j public class FlowWithSource extends Flow { String source; diff --git a/jdbc/src/main/java/io/kestra/jdbc/repository/AbstractJdbcFlowRepository.java b/jdbc/src/main/java/io/kestra/jdbc/repository/AbstractJdbcFlowRepository.java index 8f10e1f2ff..13defaef92 100644 --- a/jdbc/src/main/java/io/kestra/jdbc/repository/AbstractJdbcFlowRepository.java +++ b/jdbc/src/main/java/io/kestra/jdbc/repository/AbstractJdbcFlowRepository.java @@ -348,6 +348,10 @@ public FlowWithSource update(Flow flow, Flow previous, String flowSource, Flow f @SneakyThrows private FlowWithSource save(Flow flow, CrudEventType crudEventType, String flowSource) throws ConstraintViolationException { + if (flow instanceof FlowWithSource) { + flow = ((FlowWithSource) flow).toFlow(); + } + // flow exists, return it Optional<FlowWithSource> exists = this.findByIdWithSource(flow.getNamespace(), flow.getId()); if (exists.isPresent() && exists.get().isUpdatable(flow, flowSource)) { @@ -357,9 +361,9 @@ private FlowWithSource save(Flow flow, CrudEventType crudEventType, String flowS List<FlowWithSource> revisions = this.findRevisions(flow.getNamespace(), flow.getId()); if (revisions.size() > 0) { - flow = flow.withRevision(revisions.get(revisions.size() - 1).getRevision() + 1); + flow = flow.toBuilder().revision(revisions.get(revisions.size() - 1).getRevision() + 1).build(); } else { - flow = flow.withRevision(1); + flow = flow.toBuilder().revision(1).build(); } Map<Field<Object>, Object> fields = this.jdbcRepository.persistFields(flow); @@ -376,6 +380,10 @@ private FlowWithSource save(Flow flow, CrudEventType crudEventType, String flowS @SneakyThrows @Override public Flow delete(Flow flow) { + if (flow instanceof FlowWithSource) { + flow = ((FlowWithSource) flow).toFlow(); + } + Optional<Flow> revision = this.findById(flow.getNamespace(), flow.getId(), Optional.of(flow.getRevision())); if (revision.isEmpty()) { throw new IllegalStateException("Flow " + flow.getId() + " doesn't exists"); diff --git a/repository-memory/src/main/java/io/kestra/repository/memory/MemoryFlowRepository.java b/repository-memory/src/main/java/io/kestra/repository/memory/MemoryFlowRepository.java index 31abf66595..9e3e49e8dc 100644 --- a/repository-memory/src/main/java/io/kestra/repository/memory/MemoryFlowRepository.java +++ b/repository-memory/src/main/java/io/kestra/repository/memory/MemoryFlowRepository.java @@ -195,6 +195,10 @@ public FlowWithSource update(Flow flow, Flow previous, String flowSource, Flow f } private FlowWithSource save(Flow flow, CrudEventType crudEventType, String flowSource) throws ConstraintViolationException { + if (flow instanceof FlowWithSource) { + flow = ((FlowWithSource) flow).toFlow(); + } + // flow exists, return it Optional<Flow> exists = this.findById(flow.getNamespace(), flow.getId()); Optional<String> existsSource = this.findSourceById(flow.getNamespace(), flow.getId()); @@ -205,9 +209,9 @@ private FlowWithSource save(Flow flow, CrudEventType crudEventType, String flowS List<FlowWithSource> revisions = this.findRevisions(flow.getNamespace(), flow.getId()); if (revisions.size() > 0) { - flow = flow.withRevision(revisions.get(revisions.size() - 1).getRevision() + 1); + flow = flow.toBuilder().revision(revisions.get(revisions.size() - 1).getRevision() + 1).build(); } else { - flow = flow.withRevision(1); + flow = flow.toBuilder().revision(1).build(); } this.flows.put(flowId(flow), flow); @@ -222,6 +226,10 @@ private FlowWithSource save(Flow flow, CrudEventType crudEventType, String flowS @Override public Flow delete(Flow flow) { + if (flow instanceof FlowWithSource) { + flow = ((FlowWithSource) flow).toFlow(); + } + if (this.findById(flow.getNamespace(), flow.getId(), Optional.of(flow.getRevision())).isEmpty()) { throw new IllegalStateException("Flow " + flow.getId() + " doesn't exists"); } @@ -232,8 +240,9 @@ public Flow delete(Flow flow) { this.flows.remove(flowId(deleted)); this.revisions.put(deleted.uid(), deleted); + Flow finalFlow = flow; ListUtils.emptyOnNull(flow.getTriggers()) - .forEach(abstractTrigger -> triggerQueue.delete(Trigger.of(flow, abstractTrigger))); + .forEach(abstractTrigger -> triggerQueue.delete(Trigger.of(finalFlow, abstractTrigger))); eventPublisher.publishEvent(new CrudEvent<>(flow, CrudEventType.DELETE));
diff --git a/core/src/test/java/io/kestra/core/services/FlowTopologyServiceTest.java b/core/src/test/java/io/kestra/core/services/FlowTopologyServiceTest.java index 70e7042aec..553c383dab 100644 --- a/core/src/test/java/io/kestra/core/services/FlowTopologyServiceTest.java +++ b/core/src/test/java/io/kestra/core/services/FlowTopologyServiceTest.java @@ -173,14 +173,14 @@ public void multipleCondition() { @Test public void self1() { - Flow flow = parse("flows/valids/trigger-multiplecondition-listener.yaml").withRevision(1); + Flow flow = parse("flows/valids/trigger-multiplecondition-listener.yaml").toBuilder().revision(1).build(); assertThat(flowTopologyService.isChild(flow, flow), nullValue()); } @Test public void self() { - Flow flow = parse("flows/valids/trigger-flow-listener.yaml").withRevision(1); + Flow flow = parse("flows/valids/trigger-flow-listener.yaml").toBuilder().revision(1).build(); assertThat(flowTopologyService.isChild(flow, flow), nullValue()); } diff --git a/webserver/src/test/java/io/kestra/webserver/controllers/FlowControllerTest.java b/webserver/src/test/java/io/kestra/webserver/controllers/FlowControllerTest.java index 40b9b336f7..e2f8c18722 100644 --- a/webserver/src/test/java/io/kestra/webserver/controllers/FlowControllerTest.java +++ b/webserver/src/test/java/io/kestra/webserver/controllers/FlowControllerTest.java @@ -10,6 +10,7 @@ import io.kestra.core.models.hierarchies.FlowGraph; import io.kestra.core.models.tasks.Task; import io.kestra.core.models.validations.ValidateConstraintViolation; +import io.kestra.core.serializers.JacksonMapper; import io.kestra.core.serializers.YamlFlowParser; import io.kestra.core.tasks.debugs.Return; import io.kestra.core.tasks.flows.Sequential; @@ -251,7 +252,18 @@ void createFlow() { Flow get = parseFlow(client.toBlocking().retrieve(HttpRequest.GET("/api/v1/flows/" + flow.getNamespace() + "/" + flow.getId()), String.class)); assertThat(get.getId(), is(flow.getId())); assertThat(get.getInputs().get(0).getName(), is("a")); + } + + @Test + void createFlowWithJsonLabels() { + Map<String, Object> flow = JacksonMapper.toMap(generateFlow("io.kestra.unittest", "a")); + flow.put("labels", Map.of("a", "b")); + + Flow result = parseFlow(client.toBlocking().retrieve(POST("/api/v1/flows", flow), String.class)); + assertThat(result.getId(), is(flow.get("id"))); + assertThat(result.getLabels().get(0).key(), is("a")); + assertThat(result.getLabels().get(0).value(), is("b")); } @Test
train
train
2023-09-08T12:09:43
"2023-09-05T13:20:49Z"
yvrng
train
kestra-io/kestra/2060_2061
kestra-io/kestra
kestra-io/kestra/2060
kestra-io/kestra/2061
[ "keyword_pr_to_issue" ]
92b1c21557bd54babca701996aabc885085d7a01
7044a4cf1896a018dcaf796753c1a044bc97fb2d
[]
[]
"2023-09-08T06:43:46Z"
[ "bug", "backend" ]
"Flows" trigger can't have null conditions
### Expected Behavior _No response_ ### Actual Behaviour Following the rework on multiple conditions, having a Flow trigger with no conditions leads to a crash of the instance ### Steps To Reproduce _No response_ ### Environment Information - Kestra Version: 0.12.0-SNAPSHOT - Operating System (OS / Docker / Kubernetes): - Java Version (If not docker): ### Example flow _No response_
[ "core/src/main/java/io/kestra/core/services/AbstractFlowTriggerService.java" ]
[ "core/src/main/java/io/kestra/core/services/AbstractFlowTriggerService.java" ]
[ "core/src/test/java/io/kestra/core/runners/MultipleConditionTriggerCaseTest.java", "core/src/test/java/io/kestra/core/runners/RestartCaseTest.java", "core/src/test/java/io/kestra/core/tasks/flows/BadFlowableTest.java", "core/src/test/java/io/kestra/core/tasks/flows/PauseTest.java", "core/src/test/resources/flows/valids/trigger-flow-listener-no-condition.yaml" ]
diff --git a/core/src/main/java/io/kestra/core/services/AbstractFlowTriggerService.java b/core/src/main/java/io/kestra/core/services/AbstractFlowTriggerService.java index 80ae142b6d..acbc6e1076 100644 --- a/core/src/main/java/io/kestra/core/services/AbstractFlowTriggerService.java +++ b/core/src/main/java/io/kestra/core/services/AbstractFlowTriggerService.java @@ -53,7 +53,7 @@ public List<Execution> computeExecutionsFromFlowTriggers(Execution execution, Li .flatMap(flow -> flowTriggers(flow).map(trigger -> new FlowWithFlowTrigger(flow, trigger))) .filter(flowWithFlowTrigger -> conditionService.valid( flowWithFlowTrigger.getFlow(), - flowWithFlowTrigger.getTrigger().getConditions().stream() + Optional.ofNullable(flowWithFlowTrigger.getTrigger().getConditions()).stream().flatMap(Collection::stream) .filter(Predicate.not(MultipleCondition.class::isInstance)) .toList(), conditionService.conditionContext( @@ -67,7 +67,7 @@ public List<Execution> computeExecutionsFromFlowTriggers(Execution execution, Li if (multipleConditionStorage.isPresent()) { List<FlowWithFlowTriggerAndMultipleCondition> flowWithMultipleConditionsToEvaluate = validTriggersBeforeMultipleConditionEval.stream() .flatMap(flowWithFlowTrigger -> - flowWithFlowTrigger.getTrigger().getConditions().stream() + Optional.ofNullable(flowWithFlowTrigger.getTrigger().getConditions()).stream().flatMap(Collection::stream) .filter(MultipleCondition.class::isInstance) .map(MultipleCondition.class::cast) .map(multipleCondition -> new FlowWithFlowTriggerAndMultipleCondition(
diff --git a/core/src/test/java/io/kestra/core/runners/MultipleConditionTriggerCaseTest.java b/core/src/test/java/io/kestra/core/runners/MultipleConditionTriggerCaseTest.java index 0e37819d6e..4a5b70ceda 100644 --- a/core/src/test/java/io/kestra/core/runners/MultipleConditionTriggerCaseTest.java +++ b/core/src/test/java/io/kestra/core/runners/MultipleConditionTriggerCaseTest.java @@ -44,7 +44,7 @@ public void trigger() throws InterruptedException, TimeoutException { executionQueue.receive(either -> { Execution execution = either.getLeft(); synchronized (ended) { - if (execution.getState().getCurrent() == State.Type.SUCCESS) { + if (execution.getState().getCurrent() == State.Type.SUCCESS && !execution.getFlowId().equals("trigger-flow-listener-no-condition")) { if (!ended.containsKey(execution.getId())) { ended.put(execution.getId(), execution); countDownLatch.countDown(); @@ -93,7 +93,7 @@ public void failed() throws InterruptedException, TimeoutException { executionQueue.receive(either -> { synchronized (ended) { Execution execution = either.getLeft(); - if (execution.getState().getCurrent().isTerminated()) { + if (execution.getState().getCurrent().isTerminated() && !execution.getFlowId().equals("trigger-flow-listener-no-condition")) { if (!ended.containsKey(execution.getId())) { ended.put(execution.getId(), execution); countDownLatch.countDown(); diff --git a/core/src/test/java/io/kestra/core/runners/RestartCaseTest.java b/core/src/test/java/io/kestra/core/runners/RestartCaseTest.java index bc28e3b931..93e97bf8ea 100644 --- a/core/src/test/java/io/kestra/core/runners/RestartCaseTest.java +++ b/core/src/test/java/io/kestra/core/runners/RestartCaseTest.java @@ -48,7 +48,7 @@ public void restartFailedThenSuccess() throws Exception { // wait Execution finishedRestartedExecution = runnerUtils.awaitExecution( - execution -> execution.getState().getCurrent() == State.Type.SUCCESS, + execution -> !execution.getFlowId().equals("trigger-flow-listener-no-condition") && execution.getState().getCurrent() == State.Type.SUCCESS, throwRunnable(() -> { Execution restartedExec = executionService.restart(firstExecution, null); executionQueue.emit(restartedExec); diff --git a/core/src/test/java/io/kestra/core/tasks/flows/BadFlowableTest.java b/core/src/test/java/io/kestra/core/tasks/flows/BadFlowableTest.java index 1502fbae79..3438ad8d43 100644 --- a/core/src/test/java/io/kestra/core/tasks/flows/BadFlowableTest.java +++ b/core/src/test/java/io/kestra/core/tasks/flows/BadFlowableTest.java @@ -1,11 +1,14 @@ package io.kestra.core.tasks.flows; import io.kestra.core.models.executions.Execution; +import io.kestra.core.models.executions.TaskRun; import io.kestra.core.models.flows.State; import io.kestra.core.runners.AbstractMemoryRunnerTest; import org.junit.jupiter.api.Test; +import java.util.Arrays; import java.util.concurrent.TimeoutException; +import java.util.stream.Collectors; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.hasSize; @@ -16,7 +19,7 @@ public class BadFlowableTest extends AbstractMemoryRunnerTest { void sequential() throws TimeoutException { Execution execution = runnerUtils.runOne("io.kestra.tests", "bad-flowable"); - assertThat(execution.getTaskRunList(), hasSize(2)); + assertThat("Task runs were: "+ execution.getTaskRunList().stream().map(TaskRun::getTaskId).toList(), execution.getTaskRunList(), hasSize(2)); assertThat(execution.getState().getCurrent(), is(State.Type.FAILED)); } diff --git a/core/src/test/java/io/kestra/core/tasks/flows/PauseTest.java b/core/src/test/java/io/kestra/core/tasks/flows/PauseTest.java index 92e0cc1f09..bfe260d457 100644 --- a/core/src/test/java/io/kestra/core/tasks/flows/PauseTest.java +++ b/core/src/test/java/io/kestra/core/tasks/flows/PauseTest.java @@ -66,7 +66,7 @@ public void run(RunnerUtils runnerUtils) throws Exception { ); execution = runnerUtils.awaitExecution( - e -> e.getState().getCurrent() == State.Type.SUCCESS, + e -> !e.getFlowId().equals("trigger-flow-listener-no-condition") && e.getState().getCurrent() == State.Type.SUCCESS, () -> executionQueue.emit(restarted), Duration.ofSeconds(5) ); @@ -81,7 +81,7 @@ public void runDelay(RunnerUtils runnerUtils) throws Exception { assertThat(execution.getTaskRunList(), hasSize(1)); execution = runnerUtils.awaitExecution( - e -> e.getState().getCurrent() == State.Type.SUCCESS, + e -> !e.getFlowId().equals("trigger-flow-listener-no-condition") && e.getState().getCurrent() == State.Type.SUCCESS, () -> {}, Duration.ofSeconds(5) ); @@ -104,7 +104,7 @@ public void runTimeout(RunnerUtils runnerUtils) throws Exception { Duration.ofSeconds(5) ); - assertThat(execution.getTaskRunList().get(0).getState().getHistories().stream().filter(history -> history.getState() == State.Type.PAUSED).count(), is(1L)); + assertThat("Task runs were: " + execution.getTaskRunList().toString(), execution.getTaskRunList().get(0).getState().getHistories().stream().filter(history -> history.getState() == State.Type.PAUSED).count(), is(1L)); assertThat(execution.getTaskRunList().get(0).getState().getHistories().stream().filter(history -> history.getState() == State.Type.RUNNING).count(), is(1L)); assertThat(execution.getTaskRunList().get(0).getState().getHistories().stream().filter(history -> history.getState() == State.Type.FAILED).count(), is(1L)); assertThat(execution.getTaskRunList(), hasSize(1)); diff --git a/core/src/test/resources/flows/valids/trigger-flow-listener-no-condition.yaml b/core/src/test/resources/flows/valids/trigger-flow-listener-no-condition.yaml new file mode 100644 index 0000000000..158d1df227 --- /dev/null +++ b/core/src/test/resources/flows/valids/trigger-flow-listener-no-condition.yaml @@ -0,0 +1,15 @@ +id: trigger-flow-listener-no-condition +namespace: io.kestra.tests + +inputs: + - name: from-parent + type: STRING + +tasks: + - id: only-listener + type: io.kestra.core.tasks.debugs.Return + format: "simple return" + +triggers: + - id: listen-flow + type: io.kestra.core.models.triggers.types.Flow \ No newline at end of file
train
val
2023-09-07T18:34:55
"2023-09-07T21:27:52Z"
brian-mulier-p
train
kestra-io/kestra/1902_2068
kestra-io/kestra
kestra-io/kestra/1902
kestra-io/kestra/2068
[ "keyword_pr_to_issue" ]
a2c81b2071e7a2cd9f33f5f954a77b70b77c3a8a
e9517a520f4e4e3f64e4dd44c1d75f7e0c8846e5
[ "would a multiline string work here? if so I'll add a PR\r\n\r\n```\r\n@Schema(\r\n title = \"Set a state in the state store.\",\r\n description = \"\"\"\r\n Values will be added or modified for a given key:\r\n * If you provide a new key, the new key will be added\r\n * If you provide an existing key, the existing value for that key will be overwritten.\r\n \r\n ::alert{type=\"warning\"}\r\n This method is not thread-safe. When many concurrent executions are trying to set a value for the same key, there is no ACID guarantee for such write operations.\r\n ::\r\n \"\"\"\r\n)\r\n```", "I think it's unrelated and we only have to remove that [lign](https://github.com/kestra-io/kestra/blob/3e1da9df6783d7b448c5d49556a0c50fba74c5e3/core/src/main/java/io/kestra/core/docs/DocumentationGenerator.java#L264), but seems weird, no need to dig", "Thanks. In that case, for now, I'll add a PR to remove those warning boxes, they don't seem to be mission-critical to communicate the intent :) I'll make important parts bold to keep the important message highlighted.", "was a good chance to fix wording anyway https://github.com/kestra-io/kestra/pull/1903/files ", "@tchiotludo \r\n\r\n> I think it's unrelated and we only have to remove that [lign](https://github.com/kestra-io/kestra/blob/3e1da9df6783d7b448c5d49556a0c50fba74c5e3/core/src/main/java/io/kestra/core/docs/DocumentationGenerator.java#L264), but seems weird, no need to dig\r\n\r\nNo, if you do this you will avoid displaying it in the UI.\r\n\r\nLet me explain what I think happen.\r\nWhen we move the website to the new framework, the standard markdown alert block `::: warning [...] :::` was not supported anymore so we replace them with `::alert{type=warning} [...] :: `\r\nThen this new format didn't work on the UI markdown view, so we replace them back from the API to the standard makrdown alert.\r\nIt works.\r\nBut at some point, it stop working on the website, I have the feeling that the website which previously load the content from the documentation generation commands now load it from the plugin API. If it's the case the replacement should move to the UI (or be done only based on a boolean).\r\n\r\nRemoving the replacement will make the doc good on the website but wrong on the UI.", "we just need to align them (ui & website) to have a common language ", "WDYT about just not using alert/info blocks in the plugin docs? this might be a lazy approach but they are really not needed. We can highlight something in bold to highlight important information or add a ⚠️ emoji \r\n\r\nin the other PR I removed all alerts from plugins, they are no more left if https://github.com/kestra-io/kestra/pull/1903 gets merged and the problem would be solved\r\n", "> we just need to align them (ui & website) to have a common language\r\n\r\nIt would be better, I tried to support standard markdown alert bloc on the website without success that's why I ends up with this hack.\r\n\r\nWe use this kind of block for deprecated task so it's important to have them @anna-geller ", "gotcha - I'll remove \"closes\" mark then" ]
[]
"2023-09-08T12:56:12Z"
[ "bug" ]
Warning on documentation are not rendered
see [here](https://kestra.io/plugins/core/tasks/states/io.kestra.core.tasks.states.set)
[ "core/src/main/java/io/kestra/core/docs/DocumentationGenerator.java", "webserver/src/main/java/io/kestra/webserver/controllers/PluginController.java" ]
[ "core/src/main/java/io/kestra/core/docs/DocumentationGenerator.java", "webserver/src/main/java/io/kestra/webserver/controllers/PluginController.java" ]
[ "core/src/test/java/io/kestra/core/docs/DocumentationGeneratorTest.java", "webserver/src/test/java/io/kestra/webserver/controllers/PluginControllerTest.java" ]
diff --git a/core/src/main/java/io/kestra/core/docs/DocumentationGenerator.java b/core/src/main/java/io/kestra/core/docs/DocumentationGenerator.java index fc48b92d46..59b9f53de5 100644 --- a/core/src/main/java/io/kestra/core/docs/DocumentationGenerator.java +++ b/core/src/main/java/io/kestra/core/docs/DocumentationGenerator.java @@ -260,10 +260,6 @@ public static <T> String render(String templateName, Map<String, Object> vars) t Pattern pattern = Pattern.compile("`\\{\\{(.*?)\\}\\}`", Pattern.MULTILINE); renderer = pattern.matcher(renderer).replaceAll("<code v-pre>{{ $1 }}</code>"); - // alert - renderer = renderer.replaceAll("\n::alert\\{type=\"(.*)\"\\}\n", "\n::: $1\n"); - renderer = renderer.replaceAll("\n::\n", "\n:::\n"); - return renderer; } } diff --git a/webserver/src/main/java/io/kestra/webserver/controllers/PluginController.java b/webserver/src/main/java/io/kestra/webserver/controllers/PluginController.java index 2857a56544..a9be02ca7e 100644 --- a/webserver/src/main/java/io/kestra/webserver/controllers/PluginController.java +++ b/webserver/src/main/java/io/kestra/webserver/controllers/PluginController.java @@ -10,6 +10,7 @@ import io.kestra.core.plugins.RegisteredPlugin; import io.kestra.core.services.PluginService; import io.micronaut.cache.annotation.Cacheable; +import io.micronaut.core.annotation.NonNull; import io.micronaut.http.HttpResponse; import io.micronaut.http.MutableHttpResponse; import io.micronaut.http.annotation.Controller; @@ -95,7 +96,7 @@ public MutableHttpResponse<DocumentationWithSchema> inputSchemas( return HttpResponse.ok() .body(new DocumentationWithSchema( - DocumentationGenerator.render(classInputDocumentation), + alertReplacement(DocumentationGenerator.render(classInputDocumentation)), new Schema( classInputDocumentation.getPropertiesSchema(), null, @@ -164,7 +165,7 @@ public HttpResponse<DocumentationWithSchema> pluginDocumentation( allProperties ); - var doc = DocumentationGenerator.render(classPluginDocumentation); + var doc = alertReplacement(DocumentationGenerator.render(classPluginDocumentation)); return HttpResponse.ok() .body(new DocumentationWithSchema( @@ -196,4 +197,10 @@ protected ClassPluginDocumentation<?> pluginDocumentation(List<RegisteredPlugin> return ClassPluginDocumentation.of(jsonSchemaGenerator, registeredPlugin, cls, allProperties ? null : baseCls); } + + private String alertReplacement(@NonNull String original) { + // we need to replace the NuxtJS ::alert{type=} :: with the more standard ::: warning ::: + return original.replaceAll("\n::alert\\{type=\"(.*)\"\\}\n", "\n::: $1\n") + .replaceAll("\n::\n", "\n:::\n"); + } }
diff --git a/core/src/test/java/io/kestra/core/docs/DocumentationGeneratorTest.java b/core/src/test/java/io/kestra/core/docs/DocumentationGeneratorTest.java index 3629dd2f48..5ef990b854 100644 --- a/core/src/test/java/io/kestra/core/docs/DocumentationGeneratorTest.java +++ b/core/src/test/java/io/kestra/core/docs/DocumentationGeneratorTest.java @@ -7,6 +7,7 @@ import io.kestra.core.tasks.debugs.Return; import io.kestra.core.tasks.flows.Dag; import io.kestra.core.tasks.flows.Flow; +import io.kestra.core.tasks.states.Set; import io.micronaut.test.extensions.junit5.annotation.MicronautTest; import jakarta.inject.Inject; import org.junit.jupiter.api.Test; @@ -131,6 +132,20 @@ void echo() throws IOException { assertThat(render, containsString("- \uD83D\uDD12 Deprecated")); } + @Test + void state() throws IOException { + PluginScanner pluginScanner = new PluginScanner(ClassPluginDocumentationTest.class.getClassLoader()); + RegisteredPlugin scan = pluginScanner.scan(); + Class<Set> set = scan.findClass(Set.class.getName()).orElseThrow(); + + ClassPluginDocumentation<? extends Task> doc = ClassPluginDocumentation.of(jsonSchemaGenerator, scan, set, Task.class); + + String render = DocumentationGenerator.render(doc); + + assertThat(render, containsString("Set")); + assertThat(render, containsString("::alert{type=\"warning\"}\n")); + } + @Test void pluginDoc() throws Exception { PluginScanner pluginScanner = new PluginScanner(ClassPluginDocumentationTest.class.getClassLoader()); diff --git a/webserver/src/test/java/io/kestra/webserver/controllers/PluginControllerTest.java b/webserver/src/test/java/io/kestra/webserver/controllers/PluginControllerTest.java index 7d438002b9..b325ed2780 100644 --- a/webserver/src/test/java/io/kestra/webserver/controllers/PluginControllerTest.java +++ b/webserver/src/test/java/io/kestra/webserver/controllers/PluginControllerTest.java @@ -108,6 +108,21 @@ void docs() throws URISyntaxException { }); } + @Test + void docWithAlert() throws URISyntaxException { + Helpers.runApplicationContext((applicationContext, embeddedServer) -> { + RxHttpClient client = RxHttpClient.create(embeddedServer.getURL()); + + DocumentationWithSchema doc = client.toBlocking().retrieve( + HttpRequest.GET("/api/v1/plugins/io.kestra.core.tasks.states.Set"), + DocumentationWithSchema.class + ); + + assertThat(doc.getMarkdown(), containsString("io.kestra.core.tasks.states.Set")); + assertThat(doc.getMarkdown(), containsString("::: warning\n")); + }); + } + @SuppressWarnings("unchecked") @Test
train
val
2023-09-09T00:11:06
"2023-08-17T13:44:00Z"
tchiotludo
train
kestra-io/kestra/2030_2090
kestra-io/kestra
kestra-io/kestra/2030
kestra-io/kestra/2090
[ "keyword_pr_to_issue" ]
58fc39da46b5502dfdba9a01e172367faeb7a82c
44f9e56ada291b9e94001a8d13ba34976b2351f2
[]
[]
"2023-09-12T10:51:04Z"
[]
FlowListener should not filter FlowWithException
### Issue description Currently, the FlowListener filter any FlowWithException which means consumers have no idea of these flows. The issue is that a flow can become a FlowWithException after an update, which means the flow definition will be wrond and potentially leads to exception or strange behaviour on the executor. We should update the FlowListener to send FlowWithException and update all consumes to handle them properly.
[ "core/src/main/java/io/kestra/core/runners/FlowListeners.java", "core/src/main/java/io/kestra/core/schedulers/AbstractScheduler.java", "core/src/main/java/io/kestra/core/services/AbstractFlowTriggerService.java" ]
[ "core/src/main/java/io/kestra/core/runners/FlowListeners.java", "core/src/main/java/io/kestra/core/schedulers/AbstractScheduler.java", "core/src/main/java/io/kestra/core/services/AbstractFlowTriggerService.java" ]
[]
diff --git a/core/src/main/java/io/kestra/core/runners/FlowListeners.java b/core/src/main/java/io/kestra/core/runners/FlowListeners.java index 039a12271d..3f07e51ca5 100644 --- a/core/src/main/java/io/kestra/core/runners/FlowListeners.java +++ b/core/src/main/java/io/kestra/core/runners/FlowListeners.java @@ -2,7 +2,6 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import io.kestra.core.models.flows.FlowWithException; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import io.kestra.core.models.flows.Flow; @@ -17,7 +16,6 @@ import java.util.Optional; import java.util.function.BiConsumer; import java.util.function.Consumer; -import java.util.stream.Collectors; import jakarta.inject.Inject; import jakarta.inject.Named; @@ -26,9 +24,6 @@ @Singleton @Slf4j public class FlowListeners implements FlowListenersInterface { - private static final ObjectMapper MAPPER = JacksonMapper.ofJson(); - private static final TypeReference<List<Flow>> TYPE_REFERENCE = new TypeReference<>(){}; - private Boolean isStarted = false; private final QueueInterface<Flow> flowQueue; private final List<Flow> flows; @@ -42,10 +37,7 @@ public FlowListeners( @Named(QueueFactoryInterface.FLOW_NAMED) QueueInterface<Flow> flowQueue ) { this.flowQueue = flowQueue; - this.flows = flowRepository.findAllForAllTenants() - .stream() - .filter(flow -> !(flow instanceof FlowWithException)) - .collect(Collectors.toList()); + this.flows = flowRepository.findAllForAllTenants(); } @Override @@ -150,6 +142,6 @@ public void listen(BiConsumer<Flow, Flow> consumer) { @Override public List<Flow> flows() { // we forced a deep clone to avoid concurrency where instance are changed during iteration (especially scheduler). - return MAPPER.readValue(MAPPER.writeValueAsString(this.flows), TYPE_REFERENCE); + return new ArrayList<>(this.flows); } } diff --git a/core/src/main/java/io/kestra/core/schedulers/AbstractScheduler.java b/core/src/main/java/io/kestra/core/schedulers/AbstractScheduler.java index 2a7dc859f3..184e08f3eb 100644 --- a/core/src/main/java/io/kestra/core/schedulers/AbstractScheduler.java +++ b/core/src/main/java/io/kestra/core/schedulers/AbstractScheduler.java @@ -6,6 +6,7 @@ import io.kestra.core.models.conditions.ConditionContext; import io.kestra.core.models.executions.Execution; import io.kestra.core.models.flows.Flow; +import io.kestra.core.models.flows.FlowWithException; import io.kestra.core.models.triggers.AbstractTrigger; import io.kestra.core.models.triggers.PollingTriggerInterface; import io.kestra.core.models.triggers.Trigger; @@ -66,7 +67,7 @@ public abstract class AbstractScheduler implements Scheduler { @Getter private volatile List<FlowWithTrigger> schedulable = new ArrayList<>(); @Getter - private volatile Map<String, FlowWithPollingTriggerNextDate> schedulableNextDate = new HashMap<>(); + private volatile Map<String, FlowWithPollingTriggerNextDate> schedulableNextDate = new ConcurrentHashMap<>(); @SuppressWarnings("unchecked") @Inject @@ -183,8 +184,8 @@ private synchronized void computeSchedulable(List<Flow> flows) { this.schedulable = flows .stream() - .filter(flow -> flow.getTriggers() != null && flow.getTriggers().size() > 0) - .filter(flow -> !flow.isDisabled()) + .filter(flow -> flow.getTriggers() != null && !flow.getTriggers().isEmpty()) + .filter(flow -> !flow.isDisabled() && !(flow instanceof FlowWithException)) .flatMap(flow -> flow.getTriggers() .stream() .filter(abstractTrigger -> !abstractTrigger.isDisabled() && abstractTrigger instanceof PollingTriggerInterface) diff --git a/core/src/main/java/io/kestra/core/services/AbstractFlowTriggerService.java b/core/src/main/java/io/kestra/core/services/AbstractFlowTriggerService.java index acbc6e1076..0590d6852f 100644 --- a/core/src/main/java/io/kestra/core/services/AbstractFlowTriggerService.java +++ b/core/src/main/java/io/kestra/core/services/AbstractFlowTriggerService.java @@ -3,6 +3,7 @@ import io.kestra.core.models.conditions.types.MultipleCondition; import io.kestra.core.models.executions.Execution; import io.kestra.core.models.flows.Flow; +import io.kestra.core.models.flows.FlowWithException; import io.kestra.core.models.triggers.AbstractTrigger; import io.kestra.core.models.triggers.multipleflows.MultipleConditionStorageInterface; import io.kestra.core.models.triggers.multipleflows.MultipleConditionWindow; @@ -47,7 +48,7 @@ public List<Execution> computeExecutionsFromFlowTriggers(Execution execution, Li // prevent recursive flow triggers .filter(flow -> flowService.removeUnwanted(flow, execution)) // ensure flow & triggers are enabled - .filter(flow -> !flow.isDisabled()) + .filter(flow -> !flow.isDisabled() && !(flow instanceof FlowWithException)) .filter(flow -> flow.getTriggers() != null && !flow.getTriggers().isEmpty()) // validate flow triggers conditions excluding multiple conditions .flatMap(flow -> flowTriggers(flow).map(trigger -> new FlowWithFlowTrigger(flow, trigger)))
null
train
val
2023-10-12T21:13:07
"2023-09-05T07:52:30Z"
loicmathieu
train
kestra-io/kestra/1423_2097
kestra-io/kestra
kestra-io/kestra/1423
kestra-io/kestra/2097
[ "keyword_pr_to_issue" ]
a8cb1e741764a0ea335aab4a668fcae1f53e3b1b
0a1b7725c8ffb33bf7ee1ada17569c4be96789a6
[ "relate to https://github.com/kestra-io/kestra/issues/1866", "We should validate the flow when loading the graph on the topology tab (on the split editor the error status exists so no need to revalidate)." ]
[]
"2023-09-12T15:40:33Z"
[ "bug" ]
Flow with invalid type generate an empty graph
If I have a missing plugins, the flow graph endpoint will generate an empty graph and not an error. We have remove the validation of the flow, because the we don't care missing properties, but the task type is necessary and should need an error
[ "ui/src/components/executions/ExecutionRoot.vue", "ui/src/components/executions/Topology.vue", "ui/src/components/flows/FlowRoot.vue", "ui/src/components/flows/Topology.vue", "ui/src/components/inputs/EditorView.vue", "ui/src/translations.json", "webserver/src/main/java/io/kestra/webserver/controllers/FlowController.java" ]
[ "ui/src/components/executions/ExecutionRoot.vue", "ui/src/components/executions/Topology.vue", "ui/src/components/flows/FlowRoot.vue", "ui/src/components/flows/Topology.vue", "ui/src/components/inputs/EditorView.vue", "ui/src/translations.json", "webserver/src/main/java/io/kestra/webserver/controllers/FlowController.java" ]
[ "webserver/src/test/java/io/kestra/webserver/controllers/FlowControllerTest.java" ]
diff --git a/ui/src/components/executions/ExecutionRoot.vue b/ui/src/components/executions/ExecutionRoot.vue index a345e0f1fb..4a01bb7356 100644 --- a/ui/src/components/executions/ExecutionRoot.vue +++ b/ui/src/components/executions/ExecutionRoot.vue @@ -266,6 +266,8 @@ this.closeSSE(); window.removeEventListener("popstate", this.follow) this.$store.commit("execution/setExecution", undefined); + this.$store.commit("flow/setFlow", undefined); + this.$store.commit("flow/setFlowGraph", undefined); } }; </script> diff --git a/ui/src/components/executions/Topology.vue b/ui/src/components/executions/Topology.vue index c4df520c29..1b6605443e 100644 --- a/ui/src/components/executions/Topology.vue +++ b/ui/src/components/executions/Topology.vue @@ -15,6 +15,9 @@ view-type="topology" @expand-subflow="onExpandSubflow($event)" /> + <el-alert v-else type="warning" :closable="false"> + {{ $t("unable to generate graph")}} + </el-alert> </div> </el-card> </template> diff --git a/ui/src/components/flows/FlowRoot.vue b/ui/src/components/flows/FlowRoot.vue index 63035e3022..566903189d 100644 --- a/ui/src/components/flows/FlowRoot.vue +++ b/ui/src/components/flows/FlowRoot.vue @@ -240,6 +240,7 @@ }, unmounted () { this.$store.commit("flow/setFlow", undefined) + this.$store.commit("flow/setFlowGraph", undefined) } }; </script> diff --git a/ui/src/components/flows/Topology.vue b/ui/src/components/flows/Topology.vue index fc10b953ea..2a0f627a50 100644 --- a/ui/src/components/flows/Topology.vue +++ b/ui/src/components/flows/Topology.vue @@ -12,6 +12,9 @@ view-type="topology" @expand-subflow="onExpandSubflow($event)" /> + <el-alert v-else type="warning" :closable="false"> + {{ $t("unable to generate graph")}} + </el-alert> </div> </el-card> </template> diff --git a/ui/src/components/inputs/EditorView.vue b/ui/src/components/inputs/EditorView.vue index d41af84c72..209d41c455 100644 --- a/ui/src/components/inputs/EditorView.vue +++ b/ui/src/components/inputs/EditorView.vue @@ -706,6 +706,7 @@ <div class="slider" @mousedown="dragEditor" v-if="combinedEditor" /> <Blueprints v-if="viewType === 'source-blueprints' || blueprintsLoaded" @loaded="blueprintsLoaded = true" :class="{'d-none': viewType !== editorViewTypes.SOURCE_BLUEPRINTS}" embed class="combined-right-view enhance-readability" :top-navbar="false" prevent-route-info /> <div + class="topology-display" :class="viewType === editorViewTypes.SOURCE_TOPOLOGY ? 'combined-right-view' : viewType === editorViewTypes.TOPOLOGY ? 'vueflow': 'hide-view'" > <LowCodeEditor @@ -730,6 +731,9 @@ <ValidationError tooltip-placement="bottom-start" size="small" class="ms-2" :error="flowError" :warnings="flowWarnings" /> </template> </LowCodeEditor> + <el-alert v-else type="warning" :closable="false"> + {{ $t("unable to generate graph")}} + </el-alert> </div> <PluginDocumentation v-if="viewType === editorViewTypes.SOURCE_DOC" @@ -960,6 +964,7 @@ .hide-view { width: 0; + overflow: hidden; } .plugin-doc { @@ -985,4 +990,8 @@ background-color: var(--bs-secondary); } } + + .topology-display .el-alert { + margin-top: calc(3 * var(--spacer)); + } </style> diff --git a/ui/src/translations.json b/ui/src/translations.json index 540ffe9bb9..fd98c20f9d 100644 --- a/ui/src/translations.json +++ b/ui/src/translations.json @@ -497,6 +497,7 @@ "date format": "Date format", "timezone": "Timezone", "add task": "Add a task", + "unable to generate graph": "An issue occurred while generating the graph which prevent the topology to be displayed.", "attempts": "Attempt(s)" }, "fr": { @@ -989,6 +990,7 @@ "date format": "Format de date", "timezone": "Fuseau horaire", "add task": "Ajouter une tâche", + "unable to generate graph": "Une erreur est survenue lors de la génération du graphe empêchant l'affichage de la topologie.", "attempts": "Tentative(s)" } } diff --git a/webserver/src/main/java/io/kestra/webserver/controllers/FlowController.java b/webserver/src/main/java/io/kestra/webserver/controllers/FlowController.java index f5d6eb636e..c04d61a1f3 100644 --- a/webserver/src/main/java/io/kestra/webserver/controllers/FlowController.java +++ b/webserver/src/main/java/io/kestra/webserver/controllers/FlowController.java @@ -4,6 +4,7 @@ import io.kestra.core.exceptions.InternalException; import io.kestra.core.models.SearchResult; import io.kestra.core.models.flows.Flow; +import io.kestra.core.models.flows.FlowWithException; import io.kestra.core.models.flows.FlowWithSource; import io.kestra.core.models.hierarchies.FlowGraph; import io.kestra.core.models.tasks.Task; @@ -91,10 +92,25 @@ public FlowGraph flowGraph( @Parameter(description = "The flow revision") @QueryValue Optional<Integer> revision, @Parameter(description = "The subflow tasks to display") @Nullable @QueryValue List<String> subflows ) throws IllegalVariableEvaluationException { - return flowRepository + Flow flow = flowRepository .findById(namespace, id, revision) - .map(throwFunction(flow -> graphService.flowGraph(flow, subflows))) .orElse(null); + + String flowUid = revision.isEmpty() ? Flow.uidWithoutRevision(namespace, id) : Flow.uid(namespace, id, revision); + if(flow == null) { + throw new NoSuchElementException( + "Unable to find flow " + flowUid + ); + } + + if(flow instanceof FlowWithException fwe) { + throw new IllegalStateException( + "Unable to generate graph for flow " + flowUid + + " because of exception " + fwe.getException() + ); + } + + return graphService.flowGraph(flow, subflows); } @ExecuteOn(TaskExecutors.IO)
diff --git a/webserver/src/test/java/io/kestra/webserver/controllers/FlowControllerTest.java b/webserver/src/test/java/io/kestra/webserver/controllers/FlowControllerTest.java index b1eb0429c9..005a8f9c38 100644 --- a/webserver/src/test/java/io/kestra/webserver/controllers/FlowControllerTest.java +++ b/webserver/src/test/java/io/kestra/webserver/controllers/FlowControllerTest.java @@ -103,8 +103,7 @@ void taskNotFound() { @Test void graph() { - FlowGraph result = client.toBlocking().retrieve(HttpRequest.GET("/api/v1/flows/io.kestra" + - ".tests/all-flowable/graph"), FlowGraph.class); + FlowGraph result = client.toBlocking().retrieve(HttpRequest.GET("/api/v1/flows/io.kestra.tests/all-flowable/graph"), FlowGraph.class); assertThat(result.getNodes().size(), is(38)); assertThat(result.getEdges().size(), is(42)); @@ -114,6 +113,14 @@ void graph() { )); } + @Test + void graph_FlowNotFound() { + HttpClientResponseException exception = assertThrows(HttpClientResponseException.class, () -> client.toBlocking().retrieve(GET("/api/v1/flows/io.kestra.tests/unknown-flow/graph"))); + + assertThat(exception.getStatus(), is(NOT_FOUND)); + assertThat(exception.getMessage(), is("Not Found: Unable to find flow io.kestra.tests_unknown-flow")); + } + @Test void idNotFound() { HttpClientResponseException e = assertThrows(HttpClientResponseException.class, () -> {
val
val
2023-09-18T17:07:33
"2023-05-29T14:46:09Z"
tchiotludo
train
kestra-io/kestra/2098_2099
kestra-io/kestra
kestra-io/kestra/2098
kestra-io/kestra/2099
[ "keyword_pr_to_issue" ]
0328e829e89eb5394aa8169df6a2be17f03d569c
ad54f84b1517e96aae23aaf04723e688a6667b99
[]
[ "Would be more readable if expand on multiple line" ]
"2023-09-12T17:13:27Z"
[ "bug", "backend" ]
Subflow task logs are not shown
### Expected Behavior _No response_ ### Actual Behaviour See https://demo.kestra.io/ui/executions/io.kestra.bmu/call-simple-subflow/2euoLKmgwfLH0lAlHu9uU/logs where there is no logs boxes due to Subflow tasks not producing any attempt making it a edge case ### Steps To Reproduce _No response_ ### Environment Information - Kestra Version: 0.12.0-SNAPSHOT - Operating System (OS / Docker / Kubernetes): - Java Version (If not docker): ### Example flow ``` id: call-simple-subflow namespace: io.kestra.bmu tasks: - id: subflow type: io.kestra.core.tasks.flows.Flow flowId: simple-subflow namespace: io.kestra.bmu ``` ``` id: simple-subflow namespace: io.kestra.bmu tasks: - id: hello type: io.kestra.core.tasks.log.Log message: Kestra team wishes you a great day! 👋 ```
[ "core/src/main/java/io/kestra/core/runners/ExecutorService.java", "core/src/main/java/io/kestra/core/tasks/flows/Flow.java" ]
[ "core/src/main/java/io/kestra/core/runners/ExecutorService.java", "core/src/main/java/io/kestra/core/tasks/flows/Flow.java" ]
[ "core/src/test/java/io/kestra/core/tasks/flows/FlowCaseTest.java" ]
diff --git a/core/src/main/java/io/kestra/core/runners/ExecutorService.java b/core/src/main/java/io/kestra/core/runners/ExecutorService.java index 63717e1143..de656bbf80 100644 --- a/core/src/main/java/io/kestra/core/runners/ExecutorService.java +++ b/core/src/main/java/io/kestra/core/runners/ExecutorService.java @@ -6,6 +6,7 @@ import io.kestra.core.models.executions.Execution; import io.kestra.core.models.executions.NextTaskRun; import io.kestra.core.models.executions.TaskRun; +import io.kestra.core.models.executions.TaskRunAttempt; import io.kestra.core.models.flows.Flow; import io.kestra.core.models.flows.State; import io.kestra.core.models.tasks.FlowableTask; @@ -598,7 +599,11 @@ private Executor handleFlowTask(final Executor executor) { } } catch (Exception e) { workerTaskResults.add(WorkerTaskResult.builder() - .taskRun(workerTask.getTaskRun().withState(State.Type.FAILED)) + .taskRun(workerTask.getTaskRun().withState(State.Type.FAILED) + .withAttempts(Collections.singletonList( + TaskRunAttempt.builder().state(new State().withState(State.Type.FAILED)).build() + )) + ) .build() ); executor.withException(e, "handleFlowTask"); diff --git a/core/src/main/java/io/kestra/core/tasks/flows/Flow.java b/core/src/main/java/io/kestra/core/tasks/flows/Flow.java index 182cf36d9e..a5e5eed0f3 100644 --- a/core/src/main/java/io/kestra/core/tasks/flows/Flow.java +++ b/core/src/main/java/io/kestra/core/tasks/flows/Flow.java @@ -8,6 +8,7 @@ import io.kestra.core.models.executions.Execution; import io.kestra.core.models.executions.ExecutionTrigger; import io.kestra.core.models.executions.TaskRun; +import io.kestra.core.models.executions.TaskRunAttempt; import io.kestra.core.models.flows.FlowWithException; import io.kestra.core.models.flows.State; import io.kestra.core.models.tasks.RunnableTask; @@ -19,11 +20,7 @@ import javax.annotation.Nullable; import javax.validation.constraints.NotNull; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; +import java.util.*; @SuperBuilder @ToString @@ -188,9 +185,10 @@ public WorkerTaskResult createWorkerTaskResult( try { builder.outputs(runContext.render(workerTaskExecution.getTask().getOutputs())); } catch (Exception e) { - runContext.logger().warn("Failed to extract ouputs with error: '" + e.getMessage() + "'", e); + runContext.logger().warn("Failed to extract outputs with error: '" + e.getMessage() + "'", e); taskRun = taskRun .withState(State.Type.FAILED) + .withAttempts(Collections.singletonList(TaskRunAttempt.builder().state(new State().withState(State.Type.FAILED)).build())) .withOutputs(builder.build().toMap()); return WorkerTaskResult.builder() @@ -212,7 +210,9 @@ public WorkerTaskResult createWorkerTaskResult( } return WorkerTaskResult.builder() - .taskRun(taskRun) + .taskRun(taskRun.withAttempts( + Collections.singletonList(TaskRunAttempt.builder().state(new State().withState(taskRun.getState().getCurrent())).build()) + )) .build(); }
diff --git a/core/src/test/java/io/kestra/core/tasks/flows/FlowCaseTest.java b/core/src/test/java/io/kestra/core/tasks/flows/FlowCaseTest.java index 5805453b3e..79deee8031 100644 --- a/core/src/test/java/io/kestra/core/tasks/flows/FlowCaseTest.java +++ b/core/src/test/java/io/kestra/core/tasks/flows/FlowCaseTest.java @@ -64,6 +64,8 @@ void run(String input, State.Type fromState, State.Type triggerState, int count countDownLatch.await(1, TimeUnit.MINUTES); assertThat(execution.getTaskRunList(), hasSize(1)); + assertThat(execution.getTaskRunList().get(0).getAttempts(), hasSize(1)); + assertThat(execution.getTaskRunList().get(0).getAttempts().get(0).getState().getCurrent(), is(fromState)); assertThat(execution.getState().getCurrent(), is(fromState)); if (outputs != null) {
train
val
2023-09-13T11:00:27
"2023-09-12T17:12:02Z"
brian-mulier-p
train
kestra-io/kestra/2105_2106
kestra-io/kestra
kestra-io/kestra/2105
kestra-io/kestra/2106
[ "keyword_pr_to_issue" ]
8c47569ad73750ad86cf8cfac9f76d2a60c497c1
0328e829e89eb5394aa8169df6a2be17f03d569c
[]
[]
"2023-09-13T07:55:36Z"
[ "bug", "backend" ]
Return task with empty "format" property will fail
### Expected Behavior _No response_ ### Actual Behaviour Failing due to length check for metrics, needs a null guard ### Steps To Reproduce _No response_ ### Environment Information - Kestra Version: - Operating System (OS / Docker / Kubernetes): - Java Version (If not docker): ### Example flow _No response_
[ "core/src/main/java/io/kestra/core/tasks/debugs/Return.java" ]
[ "core/src/main/java/io/kestra/core/tasks/debugs/Return.java" ]
[]
diff --git a/core/src/main/java/io/kestra/core/tasks/debugs/Return.java b/core/src/main/java/io/kestra/core/tasks/debugs/Return.java index 532986dca3..279d3af677 100644 --- a/core/src/main/java/io/kestra/core/tasks/debugs/Return.java +++ b/core/src/main/java/io/kestra/core/tasks/debugs/Return.java @@ -15,6 +15,7 @@ import org.slf4j.Logger; import java.time.Duration; +import java.util.Optional; @SuperBuilder @ToString @@ -56,7 +57,7 @@ public Return.Output run(RunContext runContext) throws Exception { long end = System.nanoTime(); runContext - .metric(Counter.of("length", render.length(), "format", format)) + .metric(Counter.of("length", Optional.ofNullable(render).map(String::length).orElse(0), "format", format)) .metric(Timer.of("duration", Duration.ofNanos(end - start), "format", format)); return Output.builder()
null
val
val
2023-09-12T16:15:13
"2023-09-13T07:53:53Z"
brian-mulier-p
train
kestra-io/kestra/2107_2110
kestra-io/kestra
kestra-io/kestra/2107
kestra-io/kestra/2110
[ "keyword_pr_to_issue" ]
ad54f84b1517e96aae23aaf04723e688a6667b99
e861adc448e39167b0547b37013ec56e390864a5
[]
[]
"2023-09-14T08:08:27Z"
[ "bug" ]
Selecting all flow with a filter should only select all flow in the filtered list
### Expected Behavior When clicking on "select all" or just selecting the displayed list in the UI, it should only select all the flow return with the differents filters ### Actual Behaviour When clicking on "select all" or checking the select list select more than what it should and apply the action on all flows ### Steps To Reproduce _No response_ ### Environment Information - Kestra Version: 0.11.0 ### Example flow _No response_
[ "ui/src/stores/flow.js" ]
[ "ui/src/stores/flow.js" ]
[]
diff --git a/ui/src/stores/flow.js b/ui/src/stores/flow.js index d47fc77613..ae7e2ce15b 100644 --- a/ui/src/stores/flow.js +++ b/ui/src/stores/flow.js @@ -226,7 +226,7 @@ export default { return this.$http.delete("/api/v1/flows/delete/by-ids", {data: options.ids}) }, deleteFlowByQuery(_, options) { - return this.$http.delete("/api/v1/flows/delete/by-query", options, {params: options}) + return this.$http.delete("/api/v1/flows/delete/by-query", {params: options}) }, validateFlow({commit}, options) { return axios.post(`${apiRoot}flows/validate`, options.flow, textYamlHeader)
null
train
val
2023-09-13T20:27:50
"2023-09-13T15:08:54Z"
Skraye
train
kestra-io/kestra/2114_2121
kestra-io/kestra
kestra-io/kestra/2114
kestra-io/kestra/2121
[ "keyword_pr_to_issue" ]
3d8c291c7b47432a24ad3b8f5e8363acb7936253
456b18d24c1140906164de4dac139a163254efab
[]
[ "Please also add labels to switch flow and within the \"launch\" subflow task to ensure you're not overriding subflow default labels", "Please don't use the ExecutionRepository, you can instead change the method signature to include the parent execution and retrieve the information you want.\r\nThe only place where this method is called is [here](https://github.com/kestra-io/kestra/blob/develop/core/src/main/java/io/kestra/core/runners/ExecutorService.java#L582) so you can just add it there :+1: " ]
"2023-09-14T20:32:33Z"
[ "enhancement" ]
Allow a subflow to inherit parent flow's execution labels
### Feature description When triggering a subflow, the user currently can define custom execution labels using the `labels` property. It would be great to allow a subflow to inherit labels from a parent flow's execution. ## Possible implementation Add an optional boolean property `inheritLabels` to the `Flow` task which should be by default set to `false` https://kestra.io/plugins/core/tasks/flows/io.kestra.core.tasks.flows.flow#labels
[ "core/src/main/java/io/kestra/core/runners/ExecutorService.java", "core/src/main/java/io/kestra/core/tasks/flows/Flow.java" ]
[ "core/src/main/java/io/kestra/core/runners/ExecutorService.java", "core/src/main/java/io/kestra/core/tasks/flows/Flow.java" ]
[ "core/src/test/java/io/kestra/core/tasks/flows/FlowCaseTest.java", "core/src/test/resources/flows/valids/switch.yaml", "core/src/test/resources/flows/valids/task-flow.yaml" ]
diff --git a/core/src/main/java/io/kestra/core/runners/ExecutorService.java b/core/src/main/java/io/kestra/core/runners/ExecutorService.java index de656bbf80..f869302b94 100644 --- a/core/src/main/java/io/kestra/core/runners/ExecutorService.java +++ b/core/src/main/java/io/kestra/core/runners/ExecutorService.java @@ -579,7 +579,7 @@ private Executor handleFlowTask(final Executor executor) { ); try { - Execution execution = flowTask.createExecution(runContext, flowExecutorInterface()); + Execution execution = flowTask.createExecution(runContext, flowExecutorInterface(), executor.getExecution()); WorkerTaskExecution workerTaskExecution = WorkerTaskExecution.builder() .task(flowTask) diff --git a/core/src/main/java/io/kestra/core/tasks/flows/Flow.java b/core/src/main/java/io/kestra/core/tasks/flows/Flow.java index cedce2ebb7..29b503beb0 100644 --- a/core/src/main/java/io/kestra/core/tasks/flows/Flow.java +++ b/core/src/main/java/io/kestra/core/tasks/flows/Flow.java @@ -95,6 +95,14 @@ public class Flow extends Task implements RunnableTask<Flow.Output> { @PluginProperty private final Boolean transmitFailed = false; + @Builder.Default + @Schema( + title = "Inherit labels from the calling execution", + description = "By default, we don't inherit any labels of the calling execution" + ) + @PluginProperty + private final Boolean inheritLabels = false; + @Schema( title = "Extract outputs from triggered executions.", description = "Allow to specify key value (with value rendered), in order to extract any outputs from " + @@ -117,7 +125,7 @@ public String flowUidWithoutRevision() { } @SuppressWarnings("unchecked") - public Execution createExecution(RunContext runContext, FlowExecutorInterface flowExecutorInterface) throws Exception { + public Execution createExecution(RunContext runContext, FlowExecutorInterface flowExecutorInterface, Execution currentExecution) throws Exception { RunnerUtils runnerUtils = runContext.getApplicationContext().getBean(RunnerUtils.class); Map<String, String> inputs = new HashMap<>(); @@ -128,6 +136,9 @@ public Execution createExecution(RunContext runContext, FlowExecutorInterface fl } List<Label> labels = new ArrayList<>(); + if (this.inheritLabels) { + labels.addAll(currentExecution.getLabels()); + } if (this.labels != null) { for (Map.Entry<String, String> entry: this.labels.entrySet()) { labels.add(new Label(entry.getKey(), runContext.render(entry.getValue())));
diff --git a/core/src/test/java/io/kestra/core/tasks/flows/FlowCaseTest.java b/core/src/test/java/io/kestra/core/tasks/flows/FlowCaseTest.java index 79deee8031..4e04d4c647 100644 --- a/core/src/test/java/io/kestra/core/tasks/flows/FlowCaseTest.java +++ b/core/src/test/java/io/kestra/core/tasks/flows/FlowCaseTest.java @@ -1,6 +1,7 @@ package io.kestra.core.tasks.flows; import com.google.common.collect.ImmutableMap; +import io.kestra.core.models.Label; import io.kestra.core.models.executions.Execution; import io.kestra.core.models.flows.State; import io.kestra.core.queues.QueueFactoryInterface; @@ -8,10 +9,12 @@ import io.kestra.core.runners.RunnerUtils; import java.time.Duration; +import java.util.List; import java.util.Map; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; + import jakarta.inject.Inject; import jakarta.inject.Named; import jakarta.inject.Singleton; @@ -41,7 +44,7 @@ public void invalidOutputs() throws Exception { } @SuppressWarnings({"ResultOfMethodCallIgnored", "unchecked"}) - void run(String input, State.Type fromState, State.Type triggerState, int count, String outputs) throws Exception { + void run(String input, State.Type fromState, State.Type triggerState, int count, String outputs) throws Exception { CountDownLatch countDownLatch = new CountDownLatch(1); AtomicReference<Execution> triggered = new AtomicReference<>(); @@ -58,7 +61,8 @@ void run(String input, State.Type fromState, State.Type triggerState, int count "task-flow", null, (f, e) -> ImmutableMap.of("string", input), - Duration.ofMinutes(1) + Duration.ofMinutes(1), + List.of(new Label("mainFlowExecutionLabel", "execFoo")) ); countDownLatch.await(1, TimeUnit.MINUTES); @@ -85,5 +89,12 @@ void run(String input, State.Type fromState, State.Type triggerState, int count assertThat(triggered.get().getTaskRunList(), hasSize(count)); assertThat(triggered.get().getState().getCurrent(), is(triggerState)); + + assertThat(triggered.get().getLabels(), hasItems( + new Label("mainFlowExecutionLabel", "execFoo"), + new Label("mainFlowLabel", "flowFoo"), + new Label("launchTaskLabel", "launchFoo"), + new Label("switchFlowLabel", "switchFoo") + )); } } diff --git a/core/src/test/resources/flows/valids/switch.yaml b/core/src/test/resources/flows/valids/switch.yaml index b2c88be514..f911bcbacf 100644 --- a/core/src/test/resources/flows/valids/switch.yaml +++ b/core/src/test/resources/flows/valids/switch.yaml @@ -8,6 +8,9 @@ inputs: type: STRING defaults: amazing +labels: + switchFlowLabel: switchFoo + tasks: - id: parent-seq type: io.kestra.core.tasks.flows.Switch diff --git a/core/src/test/resources/flows/valids/task-flow.yaml b/core/src/test/resources/flows/valids/task-flow.yaml index 4097259810..54a0a74579 100644 --- a/core/src/test/resources/flows/valids/task-flow.yaml +++ b/core/src/test/resources/flows/valids/task-flow.yaml @@ -5,6 +5,9 @@ inputs: - name: string type: STRING +labels: + mainFlowLabel: flowFoo + tasks: - id: launch type: io.kestra.core.tasks.flows.Flow @@ -14,5 +17,8 @@ tasks: string: "{{ inputs.string }}" wait: true transmitFailed: true + inheritLabels: true + labels: + launchTaskLabel: launchFoo outputs: extracted: "{{ outputs.default.value ?? outputs['error-t1'].value }}" \ No newline at end of file
test
val
2023-09-22T15:23:14
"2023-09-14T13:29:17Z"
anna-geller
train
kestra-io/kestra/2123_2127
kestra-io/kestra
kestra-io/kestra/2123
kestra-io/kestra/2127
[ "keyword_pr_to_issue" ]
a8cb1e741764a0ea335aab4a668fcae1f53e3b1b
6003dfbbd860871b1342cb5abb671d5d13fdb6b6
[ "same when using input from JDBC query passed to the same subflow \r\n\r\n```yaml\r\nid: each_item_rows\r\nnamespace: dev\r\n\r\ntasks:\r\n - id: extract\r\n type: io.kestra.plugin.jdbc.duckdb.Query\r\n sql: |\r\n INSTALL httpfs;\r\n LOAD httpfs;\r\n SELECT *\r\n FROM read_csv_auto('https://raw.githubusercontent.com/kestra-io/datasets/main/csv/orders.csv', header=True);\r\n store: true\r\n\r\n - id: split\r\n type: io.kestra.core.tasks.storages.Split\r\n from: \"{{ outputs.extract.uri }}\"\r\n rows: 1\r\n \r\n - id: each\r\n type: io.kestra.core.tasks.flows.EachParallel\r\n value: \"{{ outputs.split.uris }}\"\r\n tasks:\r\n - id: subflow\r\n type: io.kestra.core.tasks.flows.Flow\r\n namespace: dev\r\n flowId: file\r\n inputs:\r\n file: \"{{ taskrun.value }}\"\r\n wait: true\r\n transmitFailed: true\r\n```" ]
[]
"2023-09-16T20:22:10Z"
[ "bug" ]
File preview doesn't show data for some subflow's FILE inputs
### Expected Behavior Reproducer 1. Subflow: ```yaml id: file namespace: dev inputs: - name: file type: FILE tasks: - id: file type: io.kestra.plugin.scripts.shell.Commands runner: PROCESS commands: - cat {{ inputs.file }} ``` 2. Parent flow: ```yaml id: eachItemRows namespace: dev tasks: - id: extract type: io.kestra.plugin.fs.http.Download uri: https://raw.githubusercontent.com/kestra-io/datasets/main/csv/orders.csv - id: split type: io.kestra.core.tasks.storages.Split from: "{{ outputs.extract.uri }}" rows: 1 # also try running this with 2 - id: each type: io.kestra.core.tasks.flows.EachParallel value: "{{ outputs.split.uris }}" tasks: - id: subflow type: io.kestra.core.tasks.flows.Flow namespace: dev flowId: file inputs: file: "{{ taskrun.value }}" wait: true transmitFailed: true ``` I believe the issue might be caused by CSV file headers https://share.descript.com/view/nH4woU2zNMv ### Environment Information - Kestra Version: 0.12.0
[ "webserver/src/main/java/io/kestra/webserver/controllers/ExecutionController.java" ]
[ "webserver/src/main/java/io/kestra/webserver/controllers/ExecutionController.java" ]
[]
diff --git a/webserver/src/main/java/io/kestra/webserver/controllers/ExecutionController.java b/webserver/src/main/java/io/kestra/webserver/controllers/ExecutionController.java index 2a91c58c42..c592e753b2 100644 --- a/webserver/src/main/java/io/kestra/webserver/controllers/ExecutionController.java +++ b/webserver/src/main/java/io/kestra/webserver/controllers/ExecutionController.java @@ -967,10 +967,7 @@ public HttpResponse<?> filePreview( @Parameter(description = "The execution id") @PathVariable String executionId, @Parameter(description = "The internal storage uri") @QueryValue URI path ) throws IOException { - HttpResponse<StreamedFile> httpResponse = this.validateFile(executionId, path, "/api/v1/executions/{executionId}/file?path=" + path); - if (httpResponse != null) { - return httpResponse; - } + this.validateFile(executionId, path, "/api/v1/executions/{executionId}/file?path=" + path); String extension = FilenameUtils.getExtension(path.toString()); InputStream fileStream = storageInterface.get(path);
null
train
val
2023-09-18T17:07:33
"2023-09-15T07:59:31Z"
anna-geller
train
kestra-io/kestra/2138_2148
kestra-io/kestra
kestra-io/kestra/2138
kestra-io/kestra/2148
[ "keyword_pr_to_issue" ]
456b18d24c1140906164de4dac139a163254efab
06963c23908b83a7c94af681e18cbb3c72b3e80e
[ "This is an issue due to the secret function that adds a new line at the end of the rendered value." ]
[]
"2023-09-20T09:09:08Z"
[ "bug" ]
Dynamically generated webhook key doesn't work as expected
In the last 0.11.0 release, we added the feature to fetch the webhook key from secrets. However, it didn't work for me. See in the video that when using the webhook key from the Secret, no Execution was triggered. After hardcoding the key, the event from EventBridge got passed to the webhook without any issues: https://share.descript.com/view/kytVX5bnfp5 ### Environment Information - Kestra Version: 0.12.0
[ "build.gradle", "webserver/src/main/java/io/kestra/webserver/controllers/ExecutionController.java" ]
[ "build.gradle", "webserver/src/main/java/io/kestra/webserver/controllers/ExecutionController.java" ]
[ "core/src/test/resources/flows/valids/webhook-secret-key.yaml", "webserver/src/test/java/io/kestra/webserver/controllers/ExecutionControllerTest.java" ]
diff --git a/build.gradle b/build.gradle index 8754b1b083..663578a51a 100644 --- a/build.gradle +++ b/build.gradle @@ -187,6 +187,7 @@ subprojects { systemProperty 'user.country', 'US' environment 'SECRET_MY_SECRET', "{\"secretKey\":\"secretValue\"}".bytes.encodeBase64().toString() + environment 'SECRET_WEBHOOK_KEY', "secretKey".bytes.encodeBase64().toString() environment 'SECRET_NON_B64_SECRET', "some secret value" } diff --git a/webserver/src/main/java/io/kestra/webserver/controllers/ExecutionController.java b/webserver/src/main/java/io/kestra/webserver/controllers/ExecutionController.java index 2a91c58c42..4031870cdf 100644 --- a/webserver/src/main/java/io/kestra/webserver/controllers/ExecutionController.java +++ b/webserver/src/main/java/io/kestra/webserver/controllers/ExecutionController.java @@ -391,7 +391,7 @@ private Execution webhook( .filter(w -> { RunContext runContext = runContextFactory.of(flow, w); try { - String webhookKey = runContext.render(w.getKey()); + String webhookKey = runContext.render(w.getKey()).trim(); return webhookKey.equals(key); } catch (IllegalVariableEvaluationException e) { // be conservative, don't crash but filter the webhook
diff --git a/core/src/test/resources/flows/valids/webhook-secret-key.yaml b/core/src/test/resources/flows/valids/webhook-secret-key.yaml new file mode 100644 index 0000000000..30329b26ba --- /dev/null +++ b/core/src/test/resources/flows/valids/webhook-secret-key.yaml @@ -0,0 +1,13 @@ +id: webhook-secret-key +namespace: io.kestra.tests + +tasks: + - id: out + type: io.kestra.core.tasks.debugs.Return + format: "{{trigger | json }}" + + +triggers: + - id: webhook + type: io.kestra.core.models.triggers.types.Webhook + key: "{{ secret('WEBHOOK_KEY') }}" diff --git a/webserver/src/test/java/io/kestra/webserver/controllers/ExecutionControllerTest.java b/webserver/src/test/java/io/kestra/webserver/controllers/ExecutionControllerTest.java index 531f4b8d2a..62b185354d 100644 --- a/webserver/src/test/java/io/kestra/webserver/controllers/ExecutionControllerTest.java +++ b/webserver/src/test/java/io/kestra/webserver/controllers/ExecutionControllerTest.java @@ -33,6 +33,7 @@ import jakarta.inject.Inject; import jakarta.inject.Named; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; import java.io.File; import java.time.Duration; @@ -526,6 +527,21 @@ void webhookDynamicKey() { assertThat(execution.getId(), notNullValue()); } + @Test + @EnabledIfEnvironmentVariable(named = "SECRET_WEBHOOK_KEY", matches = ".*") + void webhookDynamicKeyFromASecret() { + Execution execution = client.toBlocking().retrieve( + HttpRequest + .GET( + "/api/v1/executions/webhook/" + TESTS_FLOW_NS + "/webhook-secret-key/secretKey" + ), + Execution.class + ); + + assertThat(execution, notNullValue()); + assertThat(execution.getId(), notNullValue()); + } + @Test void resumePaused() throws TimeoutException, InterruptedException { // Run execution until it is paused
train
val
2023-09-22T17:47:22
"2023-09-18T21:45:12Z"
anna-geller
train
kestra-io/kestra/2158_2159
kestra-io/kestra
kestra-io/kestra/2158
kestra-io/kestra/2159
[ "keyword_pr_to_issue" ]
0b4660f3ebc0a59b0f7f8e94eaee848ae66b38c3
c7947198612f5751ed72d17bbab9e193d131270e
[]
[]
"2023-09-21T08:54:47Z"
[ "bug" ]
Flow task error message when not found
### Explain the bug It displays namespace.taskId instead of namespace.flowId in the error message ### Environment Information - Kestra Version: - Operating System and Java Version (if not using Kestra Docker image):
[ "core/src/main/java/io/kestra/core/tasks/flows/Flow.java" ]
[ "core/src/main/java/io/kestra/core/tasks/flows/Flow.java" ]
[]
diff --git a/core/src/main/java/io/kestra/core/tasks/flows/Flow.java b/core/src/main/java/io/kestra/core/tasks/flows/Flow.java index 1869e6d99e..cedce2ebb7 100644 --- a/core/src/main/java/io/kestra/core/tasks/flows/Flow.java +++ b/core/src/main/java/io/kestra/core/tasks/flows/Flow.java @@ -143,7 +143,7 @@ public Execution createExecution(RunContext runContext, FlowExecutorInterface fl flowVars.get("namespace"), flowVars.get("id") ) - .orElseThrow(() -> new IllegalStateException("Unable to find flow '" + namespace + "." + id + "' with revision + '" + revision + "'")); + .orElseThrow(() -> new IllegalStateException("Unable to find flow '" + namespace + "'.'" + flowId + "' with revision + '" + revision + "'")); if (flow.isDisabled()) { throw new IllegalStateException("Cannot execute disabled flow");
null
val
val
2023-09-20T22:02:51
"2023-09-21T08:54:07Z"
brian-mulier-p
train
kestra-io/kestra/2164_2165
kestra-io/kestra
kestra-io/kestra/2164
kestra-io/kestra/2165
[ "keyword_pr_to_issue" ]
3d8c291c7b47432a24ad3b8f5e8363acb7936253
444a7753a3f5d344a610291f846055a3bd17c7d9
[]
[]
"2023-09-22T15:03:32Z"
[ "bug" ]
DBT subtasks logs don't have icon
### Explain the bug ![image](https://github.com/kestra-io/kestra/assets/37618489/4918d457-aa68-47f5-afae-44a984b49a3b) Should fallback on the parentTaskRunId when retrieving icon if we don't have an actual task linked ### Environment Information - Kestra Version: - Operating System and Java Version (if not using Kestra Docker image):
[ "ui/src/components/logs/LogList.vue" ]
[ "ui/src/components/logs/LogList.vue" ]
[]
diff --git a/ui/src/components/logs/LogList.vue b/ui/src/components/logs/LogList.vue index 3e0fd8a5f2..bfd453518f 100644 --- a/ui/src/components/logs/LogList.vue +++ b/ui/src/components/logs/LogList.vue @@ -10,8 +10,8 @@ class="task-icon me-1" > <task-icon - :cls="taskIcon(currentTaskRun.taskId)" - v-if="taskIcon(currentTaskRun.taskId)" + :cls="taskIcon(currentTaskRun)" + v-if="taskIcon(currentTaskRun)" only-icon /> </div> @@ -550,9 +550,13 @@ uniqueTaskRunDisplayFilter(currentTaskRun) { return !(this.taskRunId && this.taskRunId !== currentTaskRun.id); }, - taskIcon(taskId) { - let findTaskById = FlowUtils.findTaskById(this.flow, taskId); - return findTaskById ? findTaskById.type : undefined; + taskIcon(taskRun) { + const task = FlowUtils.findTaskById(this.flow, taskRun.taskId); + const parentTaskRunId = taskRun.parentTaskRunId; + if(task === undefined && parentTaskRunId) { + return this.taskIcon(this.taskRunById[parentTaskRunId]) + } + return task ? task.type : undefined; }, loadLogs(executionId) { this.$store.dispatch("execution/loadLogsNoCommit", {
null
val
val
2023-09-22T15:23:14
"2023-09-22T15:01:58Z"
brian-mulier-p
train
kestra-io/kestra/1563_2185
kestra-io/kestra
kestra-io/kestra/1563
kestra-io/kestra/2185
[ "keyword_pr_to_issue" ]
8414b77f654f31f83fccf0a3528488d87c3938ec
e16fb4e7509f454212b8ada6e1112f127772964e
[ "Video showing the issue: https://share.descript.com/view/bgxZPEqDn55 \r\n\r\nThe entire tile displaying those numbers would need to be adjusted based on the screen resolution" ]
[ "Please remove any mb / me & use \r\n```\r\ncolumn-gap: calc(var(--spacer) * 1.5);\r\nrow-gap: calc(var(--spacer) / 2);\r\n```" ]
"2023-09-26T09:34:03Z"
[ "bug", "frontend" ]
Home Dashboard: unresponsive display of tiles displaying the number of Successful, Failed and Running Executions
### Expected Behavior _No response_ ### Actual Behaviour Display is not responsive for digits in dashboard ![image](https://github.com/kestra-io/kestra/assets/46634684/83a11b25-5420-4989-8011-08a38ecce9d5) ![image](https://github.com/kestra-io/kestra/assets/46634684/741f3631-6c3e-4067-9206-4a10bae6999e) ### Steps To Reproduce _No response_ ### Environment Information - Kestra Version: - Operating System (OS / Docker / Kubernetes): - Java Version (If not docker): ### Example flow _No response_
[ "ui/src/components/home/HomeSummaryStatusLabel.vue" ]
[ "ui/src/components/home/HomeSummaryStatusLabel.vue" ]
[]
diff --git a/ui/src/components/home/HomeSummaryStatusLabel.vue b/ui/src/components/home/HomeSummaryStatusLabel.vue index c634272b26..7d7ffc65c2 100644 --- a/ui/src/components/home/HomeSummaryStatusLabel.vue +++ b/ui/src/components/home/HomeSummaryStatusLabel.vue @@ -1,12 +1,12 @@ <template> <div class="list"> <template v-for="[status, count] of sorted"> - <div v-if="count > 0" :key="status" class="d-flex w-100 justify-content-between mb-2"> - <div class="me-4 icon"> + <div v-if="count > 0" :key="status" class="d-flex justify-content-around mb-4 column-gap-4 row-gap-2 flex-wrap"> + <div class="icon"> <status :label="false" :status="status" /> </div> - <div class="me-4 center"> + <div class="center"> <h6> {{ status.toLowerCase().capitalize() }} </h6> @@ -15,7 +15,7 @@ </div> </div> - <div class="big-number"> + <div class="big-number text-break"> {{ count }} </div> </div> @@ -84,11 +84,9 @@ .big-number { vertical-align: middle; - font-size: 150%; font-weight: bold; } } } - </style>
null
test
val
2023-09-27T17:28:27
"2023-06-20T12:20:57Z"
Ben8t
train
kestra-io/kestra/1904_2186
kestra-io/kestra
kestra-io/kestra/1904
kestra-io/kestra/2186
[ "keyword_pr_to_issue" ]
08cb9e48355903dc62e64c4b378f04b41a266138
6b3cd88fa288a887af4b847ea7411be60bafebfd
[]
[ "Avoid console logging (twice)", "```suggestion\r\n if (input.type === \"BOOLEAN\" && input.defaults === undefined){\r\n```", "```suggestion\r\n <el-radio-button :label=\"$t('true')\" />\r\n <el-radio-button :label=\"$t('false')\" />\r\n <el-radio-button :label=\"$t('undefined')\"/>\r\n```" ]
"2023-09-26T10:05:28Z"
[ "bug" ]
[UI] Boolean input always have a value
### Expected Behavior Boolean inputs should be able to have no value. ### Actual Behaviour When executing a flow that have a boolean input from the UI, the execution will always have a value for the input even if it has a default value or is not mandatory. This is because the UI uses a Switch with true/false so no-value or undefined didn't exist. As the input is always send, if it's optional or with a default value of true, it will be set to false which is not what we want. ### Steps To Reproduce _No response_ ### Environment Information - Kestra Version: - Operating System (OS / Docker / Kubernetes): - Java Version (If not docker): ### Example flow Launching this flow from the UI will output false in the logs whereas true should be outputted as the default of the input is true. ``` id: hello-world namespace: dev inputs: - name: clear_landing_before type: BOOLEAN required: true defaults: true tasks: - id: echo_input type: io.kestra.core.tasks.debugs.Echo format: "{{inputs.clear_landing_before}}" ```
[ "ui/src/components/flows/FlowRun.vue" ]
[ "ui/src/components/flows/FlowRun.vue" ]
[]
diff --git a/ui/src/components/flows/FlowRun.vue b/ui/src/components/flows/FlowRun.vue index a66721107d..ad3fc6bed5 100644 --- a/ui/src/components/flows/FlowRun.vue +++ b/ui/src/components/flows/FlowRun.vue @@ -36,10 +36,14 @@ v-model="inputs[input.name]" :step="0.001" /> - <el-switch + <el-radio-group v-if="input.type === 'BOOLEAN'" v-model="inputs[input.name]" - /> + > + <el-radio-button label="true" /> + <el-radio-button label="false" /> + <el-radio-button label="undefined" /> + </el-radio-group> <el-date-picker v-if="input.type === 'DATETIME'" v-model="inputs[input.name]" @@ -146,8 +150,8 @@ for (const input of this.flow.inputs || []) { this.inputs[input.name] = input.defaults; - if (input.type === "BOOLEAN" && input.defaults){ - this.inputs[input.name] = (/true/i).test(input.defaults) || input.defaults === true; + if (input.type === "BOOLEAN" && input.defaults === undefined){ + this.inputs[input.name] = "undefined"; } } }, @@ -177,6 +181,16 @@ ...mapState("execution", ["execution"]), haveBadLabels() { return this.executionLabels.some(label => (label.key && !label.value) || (!label.key && label.value)); + }, + // Required to have "undefined" value for boolean + cleanInputs() { + var inputs = this.inputs + for (const input of this.flow.inputs || []) { + if (input.type === "BOOLEAN" && inputs[input.name] === "undefined") { + inputs[input.name] = undefined; + } + } + return inputs; } }, methods: { @@ -210,7 +224,7 @@ return false; } - executeTask(this, this.flow, this.inputs, { + executeTask(this, this.flow, this.cleanInputs, { redirect: this.redirect, id: this.flow.id, namespace: this.flow.namespace,
null
val
val
2023-09-26T16:36:20
"2023-08-17T14:18:26Z"
loicmathieu
train
kestra-io/kestra/2112_2192
kestra-io/kestra
kestra-io/kestra/2112
kestra-io/kestra/2192
[ "keyword_pr_to_issue" ]
f9f95feebc4f33ead5c2aab583782448684b7dc4
c500667e8915a2000d05d736223f094cae9ac244
[ "issue doesn't happen anymore on my local instance; we only found it on the preview when loading logs\r\n\r\n![image](https://github.com/kestra-io/kestra/assets/86264395/aec3b807-ada7-4c80-a5e2-ebabd11f024b)\r\n\r\n\r\nTODO: improve the DB index or optimize the log query for the Logs page -- it's likely only a Postgres indexing issue, not a UI issue", "On the logs page, by default, there is no date filter which is causing the full table to be read. We cannot really do anything about it, we should set a default date filter (like 30 days as in the homepage).", "@anna-geller the same issue exist on the executions page, I think we should set a default date filter of 30 days on both these pages as otherwise they'll read the full table then sort on the date which is impossible for large tables.", "@loicmathieu good point - WDYT about only 7 days filter by default? seems like a good option for those who run thousands of executions", "even if there is a limit ? ", "@tchiotludo in fact there should be a limit as there is pagination, I'll double-check what was done on the log page.", "~I checked and the LogRepository didn't fetch a page like other repository but all logs. That's why it takes so long.\r\nSo the bug is that the JDBC repository didn't paginate the find query.~", "Forget my last comment I was on 0.9 checking for a bug so not looking at the latest code that correctly select a page.\r\nAs we order by timestamp, even if we only load 50 logs we must scan the all table, if we add a time we will only scan the index so it will work (and the same issue should exist for the execution page).\r\n\r\nSo back to my idea of limiting to 30 (or 7) days by default on both the executions and logs page.", "By the way the same issue exist on the Flows page as it display an histogram of flow executions so we may also add a time filter here (which will be a little strange) or maybe just remove the diagram as it's a duplication of the one in the Executions page.", "> As we order by timestamp, even if we only load 50 logs we must scan the all table, if we add a time we will only scan the index so it will work (and the same issue should exist for the execution page).\r\n\r\nIndex on the timestamp must limit on the latest 50 only, it's the main goal of this index", "Postgres is not a vector database, indexes are stored using a B-Tree structure, which is not suitable for limiting the number of rows scanned so all rows will be scanned (whether on the index or on the table which will not make any difference)." ]
[]
"2023-09-26T13:42:10Z"
[ "bug" ]
Set the default filter to 7 days on the Logs and Executions pages to prevent `Timeout of 15000ms exceeded` when loading those UI pages
### Expected Behavior the issue we identified with Brian: on the homepage at the bottom, there's an element that logs errors and it's not properly unloaded when switching pages from Home to any other page - flows/logs etc. ![image](https://github.com/kestra-io/kestra/assets/86264395/51f6f3bf-9d8b-4366-9ac4-c32552d42603) ### Actual Behaviour _No response_ ### Steps To Reproduce _No response_ ### Environment Information - Kestra Version: 0.12 snapshot develop full image with Docker Compose ### Example flow _No response_
[ "ui/src/components/executions/Executions.vue", "ui/src/components/logs/LogsWrapper.vue" ]
[ "ui/src/components/executions/Executions.vue", "ui/src/components/logs/LogsWrapper.vue" ]
[]
diff --git a/ui/src/components/executions/Executions.vue b/ui/src/components/executions/Executions.vue index a3905c0d79..c810771cfb 100644 --- a/ui/src/components/executions/Executions.vue +++ b/ui/src/components/executions/Executions.vue @@ -21,8 +21,8 @@ </el-form-item> <el-form-item> <date-range - :start-date="$route.query.startDate" - :end-date="$route.query.endDate" + :start-date="startDate" + :end-date="endDate" @update:model-value="onDataTableValue($event)" /> </el-form-item> @@ -303,7 +303,7 @@ }, isAllowedEdit() { return this.user.isAllowed(permission.FLOW, action.UPDATE, this.flow.namespace); - }, + } }, methods: { selectionMapper(execution) { @@ -318,6 +318,11 @@ loadQuery(base, stats) { let queryFilter = this.queryWithFilter(); + if ((!queryFilter["startDate"] || !queryFilter["endDate"]) && !stats) { + queryFilter["startDate"] = this.startDate; + queryFilter["endDate"] = this.endDate; + } + if (stats) { delete queryFilter["startDate"]; delete queryFilter["endDate"]; diff --git a/ui/src/components/logs/LogsWrapper.vue b/ui/src/components/logs/LogsWrapper.vue index b91322da84..186b6939c0 100644 --- a/ui/src/components/logs/LogsWrapper.vue +++ b/ui/src/components/logs/LogsWrapper.vue @@ -22,8 +22,8 @@ </el-form-item> <el-form-item> <date-range - :start-date="$route.query.startDate" - :end-date="$route.query.endDate" + :start-date="startDate" + :end-date="endDate" @update:model-value="onDataTableValue($event)" /> </el-form-item> @@ -102,6 +102,13 @@ }, selectedLogLevel() { return this.logLevel || this.$route.query.level || localStorage.getItem("defaultLogLevel") || "INFO"; + }, + endDate() { + return this.$route.query.endDate ? this.$route.query.endDate : this.$moment().toISOString(true); + }, + startDate() { + return this.$route.query.startDate ? this.$route.query.startDate : this.$moment(this.endDate) + .add(-7, "days").toISOString(true); } }, methods: { @@ -113,6 +120,11 @@ queryFilter["flowId"] = this.$route.params.id; } + if (!queryFilter["startDate"] || !queryFilter["endDate"]) { + queryFilter["startDate"] = this.startDate; + queryFilter["endDate"] = this.endDate; + } + delete queryFilter["level"]; return _merge(base, queryFilter)
null
train
val
2023-09-26T14:29:07
"2023-09-14T12:42:03Z"
anna-geller
train
kestra-io/kestra/2190_2193
kestra-io/kestra
kestra-io/kestra/2190
kestra-io/kestra/2193
[ "keyword_pr_to_issue" ]
f9f95feebc4f33ead5c2aab583782448684b7dc4
e64f716a8624a86c16ac3e8e4dacf351eb73025f
[]
[]
"2023-09-26T13:44:54Z"
[ "bug" ]
New execution-Prefill treats empty inputs as `"null"` values
### Explain the bug Starting a new execution using _New execution - Prefill_ provides the literal value `"null"` for blank inputs - optional inputs with no default value. This leads to unexpected consequences during flow logic execution. Request body using _New execution - Prefill_: ``` -----------------------------427174669639266022113998627081 Content-Disposition: form-data; name="foo" null -----------------------------427174669639266022113998627081-- ``` Request body using just _New execution_: ``` -----------------------------120578406022738925912912645969-- ``` Example flow: ``` id: hello-world-inputs namespace: dev inputs: - name: foo type: STRING required: false tasks: - id: valid-value-or-not type: io.kestra.core.tasks.log.Log message: "{{ inputs.foo ?? inputs.foo ?? 'no valid value' }}" ``` ### Environment Information - Kestra Version: 0.12.0 as of Sep 26th 2023 - Operating System and Java Version (if not using Kestra Docker image):
[ "ui/src/components/flows/FlowRun.vue" ]
[ "ui/src/components/flows/FlowRun.vue" ]
[]
diff --git a/ui/src/components/flows/FlowRun.vue b/ui/src/components/flows/FlowRun.vue index a66721107d..f36eefcf1e 100644 --- a/ui/src/components/flows/FlowRun.vue +++ b/ui/src/components/flows/FlowRun.vue @@ -86,6 +86,7 @@ :label="$t('execution labels')" > <label-input + :key="executionLabels" v-model:labels="executionLabels" /> </el-form-item> @@ -196,9 +197,15 @@ inputValue = JSON.stringify(inputValue).toString() } + if(inputValue === null) { + inputValue = undefined; + } + return [inputName, inputValue] }) ); + // add all labels except the one from flow to prevent duplicates + this.executionLabels = this.execution.labels.filter(label => !this.flow.labels.some(flowLabel => flowLabel.key === label.key && flowLabel.value === label.value)); }, onSubmit(formRef) { if (this.$tours["guidedTour"].isRunning.value) {
null
train
val
2023-09-26T14:29:07
"2023-09-26T10:47:13Z"
yuri1969
train
kestra-io/kestra/2191_2193
kestra-io/kestra
kestra-io/kestra/2191
kestra-io/kestra/2193
[ "keyword_pr_to_issue" ]
f9f95feebc4f33ead5c2aab583782448684b7dc4
e64f716a8624a86c16ac3e8e4dacf351eb73025f
[]
[]
"2023-09-26T13:44:54Z"
[ "bug" ]
New execution-Prefill doesn't prefill the Execution labels
### Explain the bug Using the _New execution-Prefill_ is designed to easily allow starting a new execution using selected execution with modified "input set". The "set" includes both flow inputs and execution labels. The labels are currently not prefilled. This leads to errors due to mislabeled executions. ### Environment Information - Kestra Version: 0.12.0 as of Sep 26th 2023 - Operating System and Java Version (if not using Kestra Docker image):
[ "ui/src/components/flows/FlowRun.vue" ]
[ "ui/src/components/flows/FlowRun.vue" ]
[]
diff --git a/ui/src/components/flows/FlowRun.vue b/ui/src/components/flows/FlowRun.vue index a66721107d..f36eefcf1e 100644 --- a/ui/src/components/flows/FlowRun.vue +++ b/ui/src/components/flows/FlowRun.vue @@ -86,6 +86,7 @@ :label="$t('execution labels')" > <label-input + :key="executionLabels" v-model:labels="executionLabels" /> </el-form-item> @@ -196,9 +197,15 @@ inputValue = JSON.stringify(inputValue).toString() } + if(inputValue === null) { + inputValue = undefined; + } + return [inputName, inputValue] }) ); + // add all labels except the one from flow to prevent duplicates + this.executionLabels = this.execution.labels.filter(label => !this.flow.labels.some(flowLabel => flowLabel.key === label.key && flowLabel.value === label.value)); }, onSubmit(formRef) { if (this.$tours["guidedTour"].isRunning.value) {
null
train
val
2023-09-26T14:29:07
"2023-09-26T10:54:56Z"
yuri1969
train
kestra-io/kestra/2207_2208
kestra-io/kestra
kestra-io/kestra/2207
kestra-io/kestra/2208
[ "keyword_pr_to_issue" ]
3dcd480218121c155c8d4191bad2048afa5b94e5
44a8da8a417a5b4519e9dda231ab1befddb205cd
[]
[]
"2023-09-28T09:20:17Z"
[ "bug", "frontend" ]
7 days interval by default leads to auto reload not fetching latest data
### Explain the bug On auto-reload I think we should reset the 7 day interval to fetch live data ### Environment Information - Kestra Version: - Operating System and Java Version (if not using Kestra Docker image):
[ "ui/src/components/executions/Executions.vue", "ui/src/components/logs/LogsWrapper.vue" ]
[ "ui/src/components/executions/Executions.vue", "ui/src/components/logs/LogsWrapper.vue" ]
[]
diff --git a/ui/src/components/executions/Executions.vue b/ui/src/components/executions/Executions.vue index c810771cfb..6cb6dc08ca 100644 --- a/ui/src/components/executions/Executions.vue +++ b/ui/src/components/executions/Executions.vue @@ -33,7 +33,7 @@ /> </el-form-item> <el-form-item> - <refresh-button class="float-right" @refresh="load" /> + <refresh-button class="float-right" @refresh="refresh" /> </el-form-item> </template> @@ -269,7 +269,8 @@ isDefaultNamespaceAllow: true, dailyReady: false, dblClickRouteName: "executions/update", - flowTriggerDetails: undefined + flowTriggerDetails: undefined, + recomputeInterval: false }; }, computed: { @@ -283,9 +284,13 @@ }; }, endDate() { + // used to be able to force refresh the base interval when auto-reloading + this.recomputeInterval; return this.$route.query.endDate ? this.$route.query.endDate : this.$moment().toISOString(true); }, startDate() { + // used to be able to force refresh the base interval when auto-reloading + this.recomputeInterval; return this.$route.query.startDate ? this.$route.query.startDate : this.$moment(this.endDate) .add(-30, "days").toISOString(true); }, @@ -306,6 +311,10 @@ } }, methods: { + refresh() { + this.recomputeInterval = !this.recomputeInterval; + this.load(); + }, selectionMapper(execution) { return execution.id }, diff --git a/ui/src/components/logs/LogsWrapper.vue b/ui/src/components/logs/LogsWrapper.vue index 186b6939c0..81dc5c72d7 100644 --- a/ui/src/components/logs/LogsWrapper.vue +++ b/ui/src/components/logs/LogsWrapper.vue @@ -28,7 +28,7 @@ /> </el-form-item> <el-form-item> - <refresh-button class="float-right" @refresh="load" /> + <refresh-button class="float-right" @refresh="refresh" /> </el-form-item> </template> @@ -87,7 +87,8 @@ return { isDefaultNamespaceAllow: true, task: undefined, - isLoading: false + isLoading: false, + recomputeInterval: false }; }, computed: { @@ -104,14 +105,22 @@ return this.logLevel || this.$route.query.level || localStorage.getItem("defaultLogLevel") || "INFO"; }, endDate() { + // used to be able to force refresh the base interval when auto-reloading + this.recomputeInterval; return this.$route.query.endDate ? this.$route.query.endDate : this.$moment().toISOString(true); }, startDate() { + // used to be able to force refresh the base interval when auto-reloading + this.recomputeInterval; return this.$route.query.startDate ? this.$route.query.startDate : this.$moment(this.endDate) .add(-7, "days").toISOString(true); } }, methods: { + refresh() { + this.recomputeInterval = !this.recomputeInterval; + this.load(); + }, loadQuery(base) { let queryFilter = this.queryWithFilter();
null
test
val
2023-09-28T10:17:39
"2023-09-28T08:58:19Z"
brian-mulier-p
train
kestra-io/kestra/2179_2209
kestra-io/kestra
kestra-io/kestra/2179
kestra-io/kestra/2209
[ "keyword_pr_to_issue" ]
d90945d054ed404bda2ec1a41b8e2f4aeb36b3b6
4544412629fc8026822efd2b217a2922c2987e72
[ "By enabling debug logs you can see that there is a race with each parallel. Each worker task result will update the execution but as it is in parallel the second execution will override the first one leading to an update of the state FAILED -> RUNNING.\n\nSee this log for ex:\n\n```\n2023-09-26 11:52:59,667 DEBUG jdbc-queue_4 io.kestra.jdbc.runner.JdbcExecutor << IN WorkerTaskResult : TaskRun(id=7AvuI1Kju4reZKAFHfaa4s, taskId=subflow-not-exist, value=value-1, state=FAILED)\n2023-09-26 11:52:59,686 DEBUG jdbc-queue_3 io.kestra.jdbc.runner.JdbcExecutor >> OUT Executor [key='1U9r6jVLDa2EmGKLhJCixl', from='[handleWorkerTask, handleFlowTaskRunning, handleFlowTask, handleFlowTaskRunning, handleFlowTask, handleFlowTask, handleFlowTaskWorkerTaskResults, exception]', offset='null', crc32='1802776287']\n(\n state=RUNNING\n taskRunList=\n [\n TaskRun(id=1DeewFxjBElUNzjcuJAavb, taskId=1_each, value=null, state=RUNNING),\n TaskRun(id=7AvuI1Kju4reZKAFHfaa4s, taskId=subflow-not-exist, value=value-1, state=RUNNING),\n TaskRun(id=2OOZACsrK8Sur9qWCjM9e0, taskId=subflow-not-exist, value=value-2, state=FAILED)\n ] \n)\n2023-09-26 11:52:59,698 DEBUG jdbc-queue_4 io.kestra.jdbc.runner.JdbcExecutor >> OUT Executor [key='1U9r6jVLDa2EmGKLhJCixl', from='[joinWorkerResult]', offset='null', crc32='905070044']\n(\n state=RUNNING\n taskRunList=\n [\n TaskRun(id=1DeewFxjBElUNzjcuJAavb, taskId=1_each, value=null, state=RUNNING),\n TaskRun(id=7AvuI1Kju4reZKAFHfaa4s, taskId=subflow-not-exist, value=value-1, state=FAILED),\n TaskRun(id=2OOZACsrK8Sur9qWCjM9e0, taskId=subflow-not-exist, value=value-2, state=RUNNING)\n ] \n)\n2023-09-26 11:52:59,700 DEBUG jdbc-queue_4 io.kestra.jdbc.runner.JdbcExecutor << IN WorkerTaskResult : TaskRun(id=2OOZACsrK8Sur9qWCjM9e0, taskId=subflow-not-exist, value=value-2, state=FAILED)\n2023-09-26 11:52:59,730 DEBUG jdbc-queue_3 io.kestra.jdbc.runner.JdbcExecutor << IN Executor [key='1U9r6jVLDa2EmGKLhJCixl', from='[]', offset='null', crc32='1802776287']\n(\n state=RUNNING\n taskRunList=\n [\n TaskRun(id=1DeewFxjBElUNzjcuJAavb, taskId=1_each, value=null, state=RUNNING),\n TaskRun(id=7AvuI1Kju4reZKAFHfaa4s, taskId=subflow-not-exist, value=value-1, state=RUNNING),\n TaskRun(id=2OOZACsrK8Sur9qWCjM9e0, taskId=subflow-not-exist, value=value-2, state=FAILED)\n ] \n)\n```" ]
[]
"2023-09-28T09:46:06Z"
[ "bug" ]
Flow with an EachParallel with failing tasks ends before all tasks ends
### Explain the bug Given the following flow: ```yaml id: each-parallel-subflow-notfound namespace: io.kestra.tests tasks: - id: 1_each type: io.kestra.core.tasks.flows.EachParallel value: - value-1 - value-2 tasks: - id: subflow-not-exist type: io.kestra.core.tasks.flows.Flow flowId: "{{ taskrun.value }}" namespace: dev wait: true ``` Using the JDBC runner, the flow ends in FAILED before all subtasks of the EachParalle tasks ends. This can be seen in the following unit test: `JdbcRunnerTest.eachParallelWithSubflowMissing()`. ### Environment Information - Kestra Version: 0.12.0-SPNASHOT - Operating System and Java Version (if not using Kestra Docker image):
[ "jdbc/src/main/java/io/kestra/jdbc/runner/JdbcExecutor.java" ]
[ "jdbc/src/main/java/io/kestra/jdbc/runner/JdbcExecutor.java" ]
[ "jdbc/src/test/java/io/kestra/jdbc/runner/JdbcRunnerTest.java" ]
diff --git a/jdbc/src/main/java/io/kestra/jdbc/runner/JdbcExecutor.java b/jdbc/src/main/java/io/kestra/jdbc/runner/JdbcExecutor.java index 0f4b46508a..7cf65c305a 100644 --- a/jdbc/src/main/java/io/kestra/jdbc/runner/JdbcExecutor.java +++ b/jdbc/src/main/java/io/kestra/jdbc/runner/JdbcExecutor.java @@ -284,7 +284,8 @@ private void executionQueue(Either<Execution, DeserializationException> either) } Executor result = executionRepository.lock(message.getId(), pair -> { - Execution execution = pair.getLeft(); + // as tasks can be processed in parallel, we must merge the execution from the database to the one we received in the queue + Execution execution = mergeExecution(pair.getLeft(), message); ExecutorState executorState = pair.getRight(); final Flow flow = transform(this.flowRepository.findByExecution(execution), execution); @@ -296,7 +297,7 @@ private void executionQueue(Either<Execution, DeserializationException> either) executor = executorService.process(executor); - if (executor.getNexts().size() > 0 && deduplicateNexts(execution, executorState, executor.getNexts())) { + if (!executor.getNexts().isEmpty() && deduplicateNexts(execution, executorState, executor.getNexts())) { executor.withExecution( executorService.onNexts(executor.getFlow(), executor.getExecution(), executor.getNexts()), "onNexts" @@ -304,7 +305,7 @@ private void executionQueue(Either<Execution, DeserializationException> either) } // worker task - if (executor.getWorkerTasks().size() > 0) { + if (!executor.getWorkerTasks().isEmpty()) { List<WorkerTask> workerTasksDedup = executor .getWorkerTasks() .stream() @@ -326,26 +327,26 @@ private void executionQueue(Either<Execution, DeserializationException> either) } // worker tasks results - if (executor.getWorkerTaskResults().size() > 0) { + if (!executor.getWorkerTaskResults().isEmpty()) { executor.getWorkerTaskResults() .forEach(workerTaskResultQueue::emit); } // schedulerDelay - if (executor.getExecutionDelays().size() > 0) { + if (!executor.getExecutionDelays().isEmpty()) { executor.getExecutionDelays() .forEach(executionDelay -> abstractExecutionDelayStorage.save(executionDelay)); } // worker task execution watchers - if (executor.getWorkerTaskExecutions().size() > 0) { + if (!executor.getWorkerTaskExecutions().isEmpty()) { workerTaskExecutionStorage.save(executor.getWorkerTaskExecutions()); List<WorkerTaskExecution> workerTasksExecutionDedup = executor .getWorkerTaskExecutions() .stream() .filter(workerTaskExecution -> this.deduplicateWorkerTaskExecution(execution, executorState, workerTaskExecution.getTaskRun())) - .collect(Collectors.toList()); + .toList(); workerTasksExecutionDedup .forEach(workerTaskExecution -> { @@ -409,6 +410,25 @@ private void executionQueue(Either<Execution, DeserializationException> either) } } + private Execution mergeExecution(Execution locked, Execution message) { + Execution newExecution = locked; + if (message.getTaskRunList() != null) { + for (TaskRun taskRun : message.getTaskRunList()) { + try { + TaskRun existing = newExecution.findTaskRunByTaskRunId(taskRun.getId()); + // if the taskrun from the message is newer than the one from the execution, we replace it! + if (existing != null && taskRun.getState().maxDate().isAfter(existing.getState().maxDate())) { + newExecution = newExecution.withTaskRun(taskRun); + } + } + catch (InternalException e) { + throw new RuntimeException(e); + } + } + } + return newExecution; + } + private void workerTaskResultQueue(Either<WorkerTaskResult, DeserializationException> either) { if (either.isRight()) { log.error("Unable to deserialize a worker task result: {}", either.getRight().getMessage()); @@ -425,20 +445,6 @@ private void workerTaskResultQueue(Either<WorkerTaskResult, DeserializationExcep executorService.log(log, true, message); } - // send metrics on terminated - if (message.getTaskRun().getState().isTerminated()) { - metricRegistry - .counter(MetricRegistry.EXECUTOR_TASKRUN_ENDED_COUNT, metricRegistry.tags(message)) - .increment(); - - metricRegistry - .timer(MetricRegistry.EXECUTOR_TASKRUN_ENDED_DURATION, metricRegistry.tags(message)) - .record(message.getTaskRun().getState().getDuration()); - - log.trace("TaskRun terminated: {}", message.getTaskRun()); - workerJobRunningRepository.deleteByTaskRunId(message.getTaskRun().getId()); - } - Executor executor = executionRepository.lock(message.getTaskRun().getExecutionId(), pair -> { Execution execution = pair.getLeft(); Executor current = new Executor(execution, null); @@ -459,10 +465,23 @@ private void workerTaskResultQueue(Either<WorkerTaskResult, DeserializationExcep if (newExecution != null) { current = current.withExecution(newExecution, "addDynamicTaskRun"); } + newExecution = current.getExecution().withTaskRun(message.getTaskRun()); + current = current.withExecution(newExecution, "joinWorkerResult"); + + // send metrics on terminated + if (message.getTaskRun().getState().isTerminated()) { + metricRegistry + .counter(MetricRegistry.EXECUTOR_TASKRUN_ENDED_COUNT, metricRegistry.tags(message)) + .increment(); + + metricRegistry + .timer(MetricRegistry.EXECUTOR_TASKRUN_ENDED_DURATION, metricRegistry.tags(message)) + .record(message.getTaskRun().getState().getDuration()); + } // join worker result return Pair.of( - current.withExecution(current.getExecution().withTaskRun(message.getTaskRun()), "joinWorkerResult"), + current, pair.getRight() ); } catch (InternalException e) {
diff --git a/jdbc/src/test/java/io/kestra/jdbc/runner/JdbcRunnerTest.java b/jdbc/src/test/java/io/kestra/jdbc/runner/JdbcRunnerTest.java index d09377e24b..8812c36c60 100644 --- a/jdbc/src/test/java/io/kestra/jdbc/runner/JdbcRunnerTest.java +++ b/jdbc/src/test/java/io/kestra/jdbc/runner/JdbcRunnerTest.java @@ -135,10 +135,7 @@ void eachParallelWithSubflowMissing() throws TimeoutException { assertThat(execution, notNullValue()); assertThat(execution.getState().getCurrent(), is(State.Type.FAILED)); - // on JDBC, when using an each parallel, the flow is failed even if not all subtasks of the each parallel are ended as soon as - // there is one failed task FIXME https://github.com/kestra-io/kestra/issues/2179 - // so instead of asserting that all tasks FAILED we assert that at least two failed (the each parallel and one of its subtasks) - assertThat(execution.getTaskRunList().stream().filter(taskRun -> taskRun.getState().isFailed()).count(), greaterThanOrEqualTo(2L)); // Should be 3 + assertThat(execution.getTaskRunList().stream().filter(taskRun -> taskRun.getState().isFailed()).count(), is(3L)); } @Test
val
val
2023-09-29T22:09:15
"2023-09-25T14:27:17Z"
loicmathieu
train
kestra-io/kestra/2128_2213
kestra-io/kestra
kestra-io/kestra/2128
kestra-io/kestra/2213
[ "keyword_pr_to_issue" ]
d90945d054ed404bda2ec1a41b8e2f4aeb36b3b6
ebce1260dc5ba599411308f05e3f5cef9d33addc
[ "I can reproduce this on the `develop` branch:\r\n\r\n```yaml\r\nid: hello-log\r\nnamespace: dev\r\ntasks:\r\n - id: wdir\r\n type: io.kestra.core.tasks.flows.WorkingDirectory\r\n tasks:\r\n - id: log \r\n type: io.kestra.core.tasks.log.Log\r\n message: \"{{ taskrun }}\"\r\n disabled: true\r\n```\r\n\r\nThe log is printed, and the execution seems to be stuck in a running state due to `WorkingDirectory` never finishing \r\n\r\n![image](https://github.com/kestra-io/kestra/assets/86264395/121e67fd-3bbc-44b0-aa53-8f448a59bd5e)\r\n" ]
[]
"2023-09-28T15:38:17Z"
[]
The `disabled` flag is not respected on a WorkingDirectory task and leads to a never-ending Execution
```yaml - id: wdir type: io.kestra.core.tasks.flows.WorkingDirectory tasks: - id: log type: io.kestra.core.tasks.log.Log message: "{{ taskrun }}" disabled: true ``` the log task will start
[ "core/src/main/java/io/kestra/core/runners/FlowableUtils.java", "core/src/main/java/io/kestra/core/runners/Worker.java" ]
[ "core/src/main/java/io/kestra/core/runners/FlowableUtils.java", "core/src/main/java/io/kestra/core/runners/Worker.java" ]
[ "core/src/test/resources/flows/valids/working-directory.yaml" ]
diff --git a/core/src/main/java/io/kestra/core/runners/FlowableUtils.java b/core/src/main/java/io/kestra/core/runners/FlowableUtils.java index f93fe7b6d9..9f50132f3b 100644 --- a/core/src/main/java/io/kestra/core/runners/FlowableUtils.java +++ b/core/src/main/java/io/kestra/core/runners/FlowableUtils.java @@ -107,6 +107,9 @@ public static Optional<State.Type> resolveState( ); return Optional.of(State.Type.FAILED); + } else if (currentTasks.stream().allMatch(t -> t.getTask().getDisabled()) && !currentTasks.isEmpty()) { + // if all child tasks are disabled, we end in SUCCESS + return Optional.of(State.Type.SUCCESS); } else if (!currentTasks.isEmpty()) { // handle nominal case, tasks or errors flow are ready to be analysed if (execution.isTerminated(currentTasks, parentTaskRun)) { diff --git a/core/src/main/java/io/kestra/core/runners/Worker.java b/core/src/main/java/io/kestra/core/runners/Worker.java index 36fc1549d4..62bafa15e8 100644 --- a/core/src/main/java/io/kestra/core/runners/Worker.java +++ b/core/src/main/java/io/kestra/core/runners/Worker.java @@ -154,6 +154,10 @@ private void handleTask(WorkerTask workerTask) { workingDirectory.preExecuteTasks(runContext, workerTask.getTaskRun()); for (Task currentTask : workingDirectory.getTasks()) { + if (Boolean.TRUE.equals(currentTask.getDisabled())) { + continue; + } + WorkerTask currentWorkerTask = workingDirectory.workerTask( workerTask.getTaskRun(), currentTask,
diff --git a/core/src/test/resources/flows/valids/working-directory.yaml b/core/src/test/resources/flows/valids/working-directory.yaml index 5c309079bf..0bf3eda150 100644 --- a/core/src/test/resources/flows/valids/working-directory.yaml +++ b/core/src/test/resources/flows/valids/working-directory.yaml @@ -17,6 +17,9 @@ tasks: type: io.kestra.core.tasks.storages.LocalFiles outputs: - out/* + - id: disabled + type: io.kestra.core.tasks.debugs.Return + disabled: true errors: - id: error-t1 type: io.kestra.core.tasks.debugs.Return
val
val
2023-09-29T22:09:15
"2023-09-17T20:32:35Z"
tchiotludo
train
kestra-io/kestra/2226_2243
kestra-io/kestra
kestra-io/kestra/2226
kestra-io/kestra/2243
[ "keyword_pr_to_issue" ]
175510fd4909df5be1173270599f114f5758e569
d2360eb8d5c58884e80ea3b0b51a311e8e906361
[ "Can I offer a PR ?", "@aballiet To fix that we need to remove the forced `endDate`, you can give it a try.\r\nLater we plan on improving the way the date filter works.", "In the end, I will not have the time to do it. I let you @Skraye 👍 " ]
[]
"2023-10-06T11:00:34Z"
[ "bug" ]
Running executions are not shown with default date filter
### Explain the bug Due to end date filter, we should remove it ### Environment Information - Kestra Version: - Operating System and Java Version (if not using Kestra Docker image):
[ "ui/src/components/executions/Executions.vue", "ui/src/components/logs/LogsWrapper.vue" ]
[ "ui/src/components/executions/Executions.vue", "ui/src/components/logs/LogsWrapper.vue" ]
[]
diff --git a/ui/src/components/executions/Executions.vue b/ui/src/components/executions/Executions.vue index 6cb6dc08ca..1b6fb23df1 100644 --- a/ui/src/components/executions/Executions.vue +++ b/ui/src/components/executions/Executions.vue @@ -286,7 +286,7 @@ endDate() { // used to be able to force refresh the base interval when auto-reloading this.recomputeInterval; - return this.$route.query.endDate ? this.$route.query.endDate : this.$moment().toISOString(true); + return this.$route.query.endDate ? this.$route.query.endDate : undefined; }, startDate() { // used to be able to force refresh the base interval when auto-reloading diff --git a/ui/src/components/logs/LogsWrapper.vue b/ui/src/components/logs/LogsWrapper.vue index 81dc5c72d7..929dcce440 100644 --- a/ui/src/components/logs/LogsWrapper.vue +++ b/ui/src/components/logs/LogsWrapper.vue @@ -107,7 +107,7 @@ endDate() { // used to be able to force refresh the base interval when auto-reloading this.recomputeInterval; - return this.$route.query.endDate ? this.$route.query.endDate : this.$moment().toISOString(true); + return this.$route.query.endDate ? this.$route.query.endDate : undefined; }, startDate() { // used to be able to force refresh the base interval when auto-reloading
null
train
val
2023-10-05T23:08:28
"2023-10-03T13:10:26Z"
brian-mulier-p
train
kestra-io/kestra/2210_2253
kestra-io/kestra
kestra-io/kestra/2210
kestra-io/kestra/2253
[ "keyword_pr_to_issue" ]
d2360eb8d5c58884e80ea3b0b51a311e8e906361
45ad053ccd6b5513fb3f06fe85c69e812ce4f9c0
[ "Hey @anna-geller , \r\nCan I contribute to this ?", "@chinmaym07 for sure, the task is for you ", "@anna-geller @tchiotludo\r\nHey guys, hope you don't mind I've implemented it. Seemed like low hanging fruit. ", "for sure, thanks so much!" ]
[]
"2023-10-09T12:26:40Z"
[ "enhancement", "frontend", "good first issue" ]
[UI] Add "Last 5 minutes" filter to Metrics
### Feature description It would be useful to allow a fine-granular overview of metrics from the last couple of runs. ![image](https://github.com/kestra-io/kestra/assets/86264395/dacd0bd5-c3e7-46d0-bf0a-ebf42dcedec0) see https://github.com/kestra-io/kestra/issues/1753#issuecomment-1705727664 (the period is TBD, 5 min seems to make sense - it could be 15 min)
[ "ui/src/components/layout/DateRange.vue", "ui/src/translations.json" ]
[ "ui/src/components/layout/DateRange.vue", "ui/src/translations.json" ]
[]
diff --git a/ui/src/components/layout/DateRange.vue b/ui/src/components/layout/DateRange.vue index ff2aef399b..7fe91c7e3c 100644 --- a/ui/src/components/layout/DateRange.vue +++ b/ui/src/components/layout/DateRange.vue @@ -22,110 +22,117 @@ monthBeforeYear: false, }, shortcuts: [ + { + text: this.$t("datepicker.last5minutes"), + value: () => ([ + this.$moment().add(-5, "minutes").toDate(), + this.$moment().toDate() + ]), + }, { text: this.$t("datepicker.last1hour"), - value: [ + value: () => ([ this.$moment().add(-1, "hour").toDate(), this.$moment().toDate() - ], + ]), }, { text: this.$t("datepicker.last12hours"), - value: [ + value: () => ([ this.$moment().add(-12, "hour").toDate(), this.$moment().toDate() - ], + ]), }, { text: this.$t("datepicker.last24hours"), - value: [ + value: () => ([ this.$moment().add(-1, "day").toDate(), this.$moment().toDate() - ], + ]), }, { text: this.$t("datepicker.today"), - value: [ + value: () => ([ this.$moment().startOf("day").toDate(), this.$moment().endOf("day").toDate() - ], + ]), }, { text: this.$t("datepicker.yesterday"), - value: [ + value: () => ([ this.$moment().add(-1, "day").startOf("day").toDate(), this.$moment().add(-1, "day").endOf("day").toDate() - ], + ]), }, { text: this.$t("datepicker.dayBeforeYesterday"), - onClick: () => [ + value: () => ([ this.$moment().add(-2, "day").startOf("day").toDate(), this.$moment().add(-2, "day").endOf("day").toDate() - ], + ]), }, { text: this.$t("datepicker.thisWeek"), - value: [ + value: () => ([ this.$moment().startOf("isoWeek").toDate(), this.$moment().endOf("isoWeek").toDate() - ], + ]), }, { text: this.$t("datepicker.thisWeekSoFar"), - value: [ + value: () => ([ this.$moment().add(-1, "isoWeek").toDate(), this.$moment().toDate() - ], + ]), }, { text: this.$t("datepicker.previousWeek"), - value: [ + value: () => ([ this.$moment().add(-1, "week").startOf("isoWeek").toDate(), this.$moment().add(-1, "week").endOf("isoWeek").toDate() - ], + ]), }, { text: this.$t("datepicker.thisMonth"), - value: [ + value: () => ([ this.$moment().startOf("month").toDate(), this.$moment().endOf("month").toDate(), - ], + ]), }, { text: this.$t("datepicker.thisMonthSoFar"), - value: [ + value: () => ([ this.$moment().add(-1, "month").toDate(), this.$moment().toDate() - ], + ]), }, { text: this.$t("datepicker.previousMonth"), - value: [ + value: () => ([ this.$moment().add(-1, "month").startOf("month").toDate(), this.$moment().add(-1, "month").endOf("month").toDate() - ], + ]), }, { text: this.$t("datepicker.thisYear"), - value: [ + value: () => ([ this.$moment().startOf("year").toDate(), this.$moment().endOf("year").toDate(), - ], + ]), }, { text: this.$t("datepicker.thisYearSoFar"), - value: [ + value: () => ([ this.$moment().add(-1, "year").toDate(), this.$moment().toDate() - ], + ]), }, { text: this.$t("datepicker.previousYear"), - value: [ + value: () => ([ this.$moment().add(-1, "year").startOf("year").toDate(), this.$moment().add(-1, "year").endOf("year").toDate() - ], + ]), }, ], } @@ -151,7 +158,7 @@ computed: { date() { return [new Date(this.startDate), new Date(this.endDate)]; - } + }, } }; </script> diff --git a/ui/src/translations.json b/ui/src/translations.json index 8234bf8722..cca8dd93de 100644 --- a/ui/src/translations.json +++ b/ui/src/translations.json @@ -53,6 +53,7 @@ "topology": "Topology", "date": "Date", "datepicker": { + "last5minutes": "Last 5 minutes", "last1hour": "Last 1 hour", "last12hours": "Last 12 hours", "last24hours": "Last 24 hours", @@ -560,6 +561,7 @@ "topology": "Topologie", "date": "Date", "datepicker": { + "last5minutes": "5 dernières minutes", "last1hour": "Dernière heure", "last12hours": "12 dernières heures", "last24hours": "24 dernières heures",
null
train
val
2023-10-06T13:18:00
"2023-09-28T09:52:01Z"
anna-geller
train
kestra-io/kestra/1862_2265
kestra-io/kestra
kestra-io/kestra/1862
kestra-io/kestra/2265
[ "keyword_pr_to_issue" ]
e01f798b76d5083eb9f9a8801afd79758d7294e6
2508f2efe30d4eb6ae839b62aeefd72105d963e8
[ "only worth noting that it would be nice to use the new script plugin as a basis for the plugin :) \r\n\r\n```yaml\r\nid: cloudquery\r\nnamespace: dev\r\n\r\ntasks:\r\n - id: wdir\r\n type: io.kestra.core.tasks.flows.WorkingDirectory\r\n tasks:\r\n - id: config\r\n type: io.kestra.core.tasks.storages.LocalFiles\r\n inputs:\r\n config.yml: |\r\n kind: source\r\n spec:\r\n name: aws\r\n path: cloudquery/aws\r\n version: \"v22.4.0\"\r\n tables: [\"aws_s3*\", \"aws_ec2*\", \"aws_ecs*\", \"aws_iam*\", \"aws_glue*\", \"aws_dynamodb*\"]\r\n destinations: [\"postgresql\"]\r\n spec:\r\n ---\r\n kind: destination\r\n spec:\r\n name: \"postgresql\"\r\n version: \"v5.0.3\"\r\n path: \"cloudquery/postgresql\"\r\n write_mode: \"overwrite-delete-stale\"\r\n spec:\r\n connection_string: ${PG_CONNECTION_STRING}\r\n\r\n - id: cloudQuery\r\n type: io.kestra.plugin.scripts.shell.Commands\r\n runner: DOCKER\r\n env:\r\n AWS_ACCESS_KEY_ID: \"{{ secret('AWS_ACCESS_KEY_ID') }}\"\r\n AWS_SECRET_ACCESS_KEY: \"{{ secret('AWS_SECRET_ACCESS_KEY') }}\"\r\n AWS_DEFAULT_REGION: \"{{ secret('AWS_DEFAULT_REGION') }}\" \r\n PG_CONNECTION_STRING: \"postgresql://postgres:{{secret('DB_PASSWORD')}}@host.docker.internal:5432/demo?sslmode=disable\"\r\n docker:\r\n image: ghcr.io/cloudquery/cloudquery:latest\r\n entryPoint: [\"\"]\r\n warningOnStdErr: false\r\n commands:\r\n - /app/cloudquery sync config.yml --log-console\r\n``` " ]
[]
"2023-10-10T07:43:08Z"
[ "backend", "plugin", "enhancement" ]
New Plugins: Cloud Query
https://www.cloudquery.io/ Seems that the solution is expanding to other things that query cloud account ```yaml id: "bash" type: "io.kestra.core.tasks.scripts.Bash" runner: DOCKER inputFiles: config.yml: | kind: source spec: name: "sharepoint" registry: "github" path: "koltyakov/sharepoint" version: "v1.7.1" tables: ["*"] destinations: ["meilisearch"] spec: auth: strategy: "addin" creds: siteUrl: "url" clientId: "id" clientSecret: "secret" realm: "realm" lists: Shared Documents: select: - FileLeafRef -> file_name - FileRef -> file_path - FileDirRef -> file_dir - Author/Title -> author - File/Length -> file_size(mb) - EncodedAbsUrl -> file_url expand: - File - Author alias: "shareddocs" --- kind: destination spec: name: meilisearch registry: github path: cloudquery/meilisearch version: "v1.1.0" write_mode: "overwrite" spec: api_key: "api-key" host: "host" dockerOptions: image: ghcr.io/cloudquery/cloudquery:latest entryPoint: [ "" ] warningOnStdErr: false commands: - 'ls {{ workingDir }}' - '/app/cloudquery sync {{ workingDir }}/config.yml --log-console' ``` Need to save [the state inside Kestra](https://www.cloudquery.io/docs/advanced-topics/managing-incremental-tables)
[ ".github/workflows/main.yml" ]
[ ".github/workflows/main.yml" ]
[]
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5bbffa630a..3ef1cf3de7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,7 +15,7 @@ on: - release - develop repository_dispatch: - types: [rebuild] + types: [ rebuild ] workflow_dispatch: inputs: skip-test: @@ -164,6 +164,7 @@ jobs: io.kestra.plugin:plugin-aws:LATEST io.kestra.plugin:plugin-azure:LATEST io.kestra.plugin:plugin-cassandra:LATEST + io.kestra.plugin:plugin-cloudquery:LATEST io.kestra.plugin:plugin-compress:LATEST io.kestra.plugin:plugin-couchbase:LATEST io.kestra.plugin:plugin-crypto:LATEST
null
val
val
2023-10-10T00:09:36
"2023-08-07T14:11:14Z"
tchiotludo
train
kestra-io/kestra/2267_2272
kestra-io/kestra
kestra-io/kestra/2267
kestra-io/kestra/2272
[ "keyword_pr_to_issue" ]
58fc39da46b5502dfdba9a01e172367faeb7a82c
78641ad259a614a0da6232016c4af4d908c61816
[ "Great idea to add event filters! We'd only need to make it a bit more flexible to allow: \r\n- filtering for specific header and body properties\r\n- multiple filters e.g. filter on both header and body or multiple body filters\r\n\r\nSome examples of how other tools approach it:\r\n- [Azure DevOps](https://learn.microsoft.com/en-us/azure/devops/pipelines/yaml-schema/resources-webhooks-webhook-filters-filter?view=azure-pipelines)\r\n- [Close.com](https://developer.close.com/resources/webhook-subscriptions/webhook-filters/)\r\n\r\nProposed syntax:\r\n```yaml\r\ntriggers:\r\n - id: github\r\n type: io.kestra.core.models.triggers.types.Webhook\r\n key: ThisIsaSuperSecretKey42\r\n conditions:\r\n - type: io.kestra.core.models.conditions.types.WebhookCondition\r\n body: \"{{ pull_request.comments_url ?? true : false }}\"\r\n headers:\r\n X-GitHub-Event: pull_request\r\n```", "> Great idea to add event filters! We'd only need to make it a bit more flexible to allow:\r\n> \r\n> * filtering for specific header and body properties\r\n> * multiple filters e.g. filter on both header and body or multiple body filters\r\n> \r\n> Some examples of how other tools approach it:\r\n> \r\n> * [Azure DevOps](https://learn.microsoft.com/en-us/azure/devops/pipelines/yaml-schema/resources-webhooks-webhook-filters-filter?view=azure-pipelines)\r\n> * [Close.com](https://developer.close.com/resources/webhook-subscriptions/webhook-filters/)\r\n> \r\n> Proposed syntax:\r\n> \r\n> ```yaml\r\n> triggers:\r\n> - id: github\r\n> type: io.kestra.core.models.triggers.types.Webhook\r\n> key: ThisIsaSuperSecretKey42\r\n> conditions:\r\n> - type: io.kestra.core.models.conditions.types.WebhookCondition\r\n> body: \"{{ pull_request.comments_url ?? true : false }}\"\r\n> headers:\r\n> X-GitHub-Event: pull_request\r\n> ```\r\n\r\nThanks for the details ! I will try to provide a PR for this 👍 ", "@aballiet just talked to the team and this will be a little bit more complex to handle. @loicmathieu said he will help with that\r\n\r\nthe planned syntax is to use already existing variable condition:\r\n```yaml\r\nid: webhook_test\r\nnamespace: prod\r\ntasks:\r\n - id: hello\r\n type: io.kestra.core.tasks.log.Log\r\n message: \"{{ trigger.body }}\"\r\n\r\ntriggers:\r\n - id: eventBridge\r\n type: io.kestra.core.models.triggers.types.Webhook\r\n key: ThisIsaSuperSecretKey42\r\n conditions:\r\n - type: io.kestra.core.models.conditions.types.VariableCondition\r\n expression: \"{{ trigger.body.github.pull_request.comments_url != null }}\"\r\n - type: io.kestra.core.models.conditions.types.VariableCondition\r\n expression: \"{{ trigger.headers.X-GitHub-Event.0 == 'pull_request' }}\"\r\n```" ]
[ "```suggestion\r\n Webhook trigger allows you to create a unique URL that you can use to trigger a Kestra flow execution based on a presence of events in another application such as GitHub or Amazon EventBridge. In order to use that URL, you have to add a secret key that will secure your webhook URL. \r\n \r\n The URL will then follow the following format: `https://{your_hostname}/api/v1/executions/webhook/{namespace}/{flowId}/{key}`. Replace the templated values accordingly to your workflow setup.\r\n \r\n The webhook URL accepts `GET`, `POST` and `PUT` requests.\r\n\r\n You can access the request body and headers sent by another application using the following template variables:\r\n - `{{ trigger.body }}`\r\n - `{{ trigger.headers }}`.\r\n\r\n The webhook response will be one of the following HTTP status codes:\r\n - 404 if the namespace, flow or webhook key is not found\r\n - 200 if the webhook triggers an execution\r\n - 204 if the webhook cannot trigger an execution due to a lack of matching event conditions sent by other application.\"\"\"\r\n```", "```suggestion\r\n Add a trigger matching specific webhook event condition. The flow will be executed only if the condition is met.`.\r\n```", "```suggestion\r\n \"Make sure to keep the webhook key secure. It's the only security mechanism to protect your endpoint from bad actors, and must be considered as a secret. You can use a random key generator to create the key.\\n\" +\r\n```", "```suggestion\r\nnamespace: dev\r\n```\r\n", "```suggestion\r\n format: \"{{ trigger | json }}\"\r\n```\r\nnitpick", "We always use this namesapce in our tests, this is not something visible to users", "We always use this namesapce in our tests, this is not something visible to users" ]
"2023-10-10T15:45:55Z"
[ "enhancement" ]
Webhook trigger : allow to specify condition on payload to trigger execution
### Feature description For some APIs we might want to check a condition (key exists, value is a specific one we are interested in) to decide to trigger our flow or not. Currently this is doable within the flow definition but add some complexity, still generate flow execution and pollute history. => Can be nice to have an optional parameter `payloadCondition` which would contain our condition. Flow could look like : ```YAML triggers: - id: webhook type: io.kestra.core.models.triggers.types.Webhook key: 4wjtkzwVGBM9yKnjm3yv8r payloadCondition: {{ trigger.body.pull_request.comments_url ?? true : false }} ```
[ "core/src/main/java/io/kestra/core/models/triggers/types/Webhook.java", "webserver/src/main/java/io/kestra/webserver/controllers/ExecutionController.java" ]
[ "core/src/main/java/io/kestra/core/models/triggers/types/Webhook.java", "webserver/src/main/java/io/kestra/webserver/controllers/ExecutionController.java" ]
[ "core/src/test/resources/flows/valids/webhook-with-condition.yaml", "webserver/src/test/java/io/kestra/webserver/controllers/ExecutionControllerTest.java" ]
diff --git a/core/src/main/java/io/kestra/core/models/triggers/types/Webhook.java b/core/src/main/java/io/kestra/core/models/triggers/types/Webhook.java index 1c044ae58f..4440bc3c67 100644 --- a/core/src/main/java/io/kestra/core/models/triggers/types/Webhook.java +++ b/core/src/main/java/io/kestra/core/models/triggers/types/Webhook.java @@ -31,12 +31,21 @@ @NoArgsConstructor @Schema( title = "Trigger a flow from a webhook", - description = "Webhook trigger allow you to trigger a flow from a webhook url. " + - "The trigger will generate a `key` that must be used on url : `/api/v1/executions/webhook/{namespace}/[flowId]/{key}`. " + - "Kestra accept `GET`, `POST` & `PUT` request on this url. " + - "The whole body & headers will be available as variable:\n " + - "- `trigger.body`\n" + - "- `trigger.headers`" + description = """ + Webhook trigger allows you to create a unique URL that you can use to trigger a Kestra flow execution based on a presence of events in another application such as GitHub or Amazon EventBridge. In order to use that URL, you have to add a secret key that will secure your webhook URL. + + The URL will then follow the following format: `https://{your_hostname}/api/v1/executions/webhook/{namespace}/{flowId}/{key}`. Replace the templated values accordingly to your workflow setup. + + The webhook URL accepts `GET`, `POST` and `PUT` requests. + + You can access the request body and headers sent by another application using the following template variables: + - `{{ trigger.body }}` + - `{{ trigger.headers }}`. + + The webhook response will be one of the following HTTP status codes: + - 404 if the namespace, flow or webhook key is not found + - 200 if the webhook triggers an execution + - 204 if the webhook cannot trigger an execution due to a lack of matching event conditions sent by other application.""" ) @Plugin( examples = { @@ -49,6 +58,21 @@ " key: 4wjtkzwVGBM9yKnjm3yv8r" }, full = true + ), + @Example( + title = """ + Add a trigger matching specific webhook event condition. The flow will be executed only if the condition is met.`. + """, + code = { + "triggers:", + " - id: webhook", + " type: io.kestra.core.models.triggers.types.Webhook", + " key: 4wjtkzwVGBM9yKnjm3yv8r", + " conditions:", + " - type: io.kestra.core.models.conditions.types.VariableCondition", + " expression: \"{{ trigger.body.hello == 'world' }}\"" + }, + full = true ) } ) @@ -60,7 +84,7 @@ public class Webhook extends AbstractTrigger implements TriggerOutput<Webhook.Ou description = "The key is used for generating the url of the webhook.\n" + "\n" + "::alert{type=\"warning\"}\n" + - "Take care when using manual key, the key is the only security to protect your webhook and must be considered as a secret !\n" + + "Make sure to keep the webhook key secure. It's the only security mechanism to protect your endpoint from bad actors, and must be considered as a secret. You can use a random key generator to create the key.\n" + "::\n" ) @PluginProperty(dynamic = true) diff --git a/webserver/src/main/java/io/kestra/webserver/controllers/ExecutionController.java b/webserver/src/main/java/io/kestra/webserver/controllers/ExecutionController.java index 9a74902a99..be2d489b47 100644 --- a/webserver/src/main/java/io/kestra/webserver/controllers/ExecutionController.java +++ b/webserver/src/main/java/io/kestra/webserver/controllers/ExecutionController.java @@ -15,6 +15,7 @@ import io.kestra.core.models.storage.FileMetas; import io.kestra.core.models.tasks.Task; import io.kestra.core.models.triggers.AbstractTrigger; +import io.kestra.core.models.triggers.multipleflows.MultipleConditionStorageInterface; import io.kestra.core.models.triggers.types.Webhook; import io.kestra.core.models.validations.ManualConstraintViolation; import io.kestra.core.queues.QueueFactoryInterface; @@ -129,6 +130,9 @@ public class ExecutionController { @Inject private TenantService tenantService; + @Inject + private MultipleConditionStorageInterface multipleConditionStorageInterface; + @ExecuteOn(TaskExecutors.IO) @Get(uri = "/search", produces = MediaType.TEXT_JSON) @Operation(tags = {"Executions"}, summary = "Search for executions") @@ -343,7 +347,7 @@ public PagedResults<Execution> findByFlowId( @ExecuteOn(TaskExecutors.IO) @Post(uri = "/webhook/{namespace}/{id}/{key}", produces = MediaType.TEXT_JSON) @Operation(tags = {"Executions"}, summary = "Trigger a new execution by POST webhook trigger") - public Execution webhookTriggerPost( + public HttpResponse<Execution> webhookTriggerPost( @Parameter(description = "The flow namespace") @PathVariable String namespace, @Parameter(description = "The flow id") @PathVariable String id, @Parameter(description = "The webhook trigger uid") @PathVariable String key, @@ -355,7 +359,7 @@ public Execution webhookTriggerPost( @ExecuteOn(TaskExecutors.IO) @Get(uri = "/webhook/{namespace}/{id}/{key}", produces = MediaType.TEXT_JSON) @Operation(tags = {"Executions"}, summary = "Trigger a new execution by GET webhook trigger") - public Execution webhookTriggerGet( + public HttpResponse<Execution> webhookTriggerGet( @Parameter(description = "The flow namespace") @PathVariable String namespace, @Parameter(description = "The flow id") @PathVariable String id, @Parameter(description = "The webhook trigger uid") @PathVariable String key, @@ -367,7 +371,7 @@ public Execution webhookTriggerGet( @ExecuteOn(TaskExecutors.IO) @Put(uri = "/webhook/{namespace}/{id}/{key}", produces = MediaType.TEXT_JSON) @Operation(tags = {"Executions"}, summary = "Trigger a new execution by PUT webhook trigger") - public Execution webhookTriggerPut( + public HttpResponse<Execution> webhookTriggerPut( @Parameter(description = "The flow namespace") @PathVariable String namespace, @Parameter(description = "The flow id") @PathVariable String id, @Parameter(description = "The webhook trigger uid") @PathVariable String key, @@ -376,7 +380,7 @@ public Execution webhookTriggerPut( return this.webhook(namespace, id, key, request); } - private Execution webhook( + private HttpResponse<Execution> webhook( String namespace, String id, String key, @@ -384,7 +388,7 @@ private Execution webhook( ) { Optional<Flow> find = flowRepository.findById(tenantService.resolveTenant(), namespace, id); if (find.isEmpty()) { - return null; + return HttpResponse.notFound(); } var flow = find.get(); @@ -414,23 +418,29 @@ private Execution webhook( .findFirst(); if (webhook.isEmpty()) { - return null; + return HttpResponse.notFound(); } Optional<Execution> execution = webhook.get().evaluate(request, flow); if (execution.isEmpty()) { - return null; + return HttpResponse.notFound(); } var result = execution.get(); if (flow.getLabels() != null) { result = result.withLabels(flow.getLabels()); } + + // we check conditions here as it's easier as the execution is created we have the body and headers available for the runContext + if (!conditionService.isValid(webhook.get(), flow, result, multipleConditionStorageInterface)) { + return HttpResponse.noContent(); + } + executionQueue.emit(result); eventPublisher.publishEvent(new CrudEvent<>(result, CrudEventType.CREATE)); - return result; + return HttpResponse.ok(result); } @ExecuteOn(TaskExecutors.IO)
diff --git a/core/src/test/resources/flows/valids/webhook-with-condition.yaml b/core/src/test/resources/flows/valids/webhook-with-condition.yaml new file mode 100644 index 0000000000..08de8f3668 --- /dev/null +++ b/core/src/test/resources/flows/valids/webhook-with-condition.yaml @@ -0,0 +1,15 @@ +id: webhook-with-condition +namespace: io.kestra.tests + +tasks: + - id: out + type: io.kestra.core.tasks.debugs.Return + format: "{{ trigger | json }}" + +triggers: + - id: webhook + type: io.kestra.core.models.triggers.types.Webhook + key: webhookKey + conditions: + - type: io.kestra.core.models.conditions.types.VariableCondition + expression: "{{trigger.body.hello == 'world'}}" \ No newline at end of file diff --git a/webserver/src/test/java/io/kestra/webserver/controllers/ExecutionControllerTest.java b/webserver/src/test/java/io/kestra/webserver/controllers/ExecutionControllerTest.java index aefdd32994..43a1af7131 100644 --- a/webserver/src/test/java/io/kestra/webserver/controllers/ExecutionControllerTest.java +++ b/webserver/src/test/java/io/kestra/webserver/controllers/ExecutionControllerTest.java @@ -542,6 +542,34 @@ void webhookDynamicKeyFromASecret() { assertThat(execution.getId(), notNullValue()); } + @Test + void webhookWithCondition() { + record Hello(String hello) {} + + Execution execution = client.toBlocking().retrieve( + HttpRequest + .POST( + "/api/v1/executions/webhook/" + TESTS_FLOW_NS + "/webhook-with-condition/webhookKey", + new Hello("world") + ), + Execution.class + ); + + assertThat(execution, notNullValue()); + assertThat(execution.getId(), notNullValue()); + + HttpResponse<Execution> response = client.toBlocking().exchange( + HttpRequest + .POST( + "/api/v1/executions/webhook/" + TESTS_FLOW_NS + "/webhook-with-condition/webhookKey", + new Hello("webhook") + ), + Execution.class + ); + assertThat(response.getStatus(), is(HttpStatus.NO_CONTENT)); + assertThat(response.body(), nullValue()); + } + @Test void resumePaused() throws TimeoutException, InterruptedException { // Run execution until it is paused
train
val
2023-10-12T21:13:07
"2023-10-10T08:46:22Z"
aballiet
train
kestra-io/kestra/2111_2276
kestra-io/kestra
kestra-io/kestra/2111
kestra-io/kestra/2276
[ "keyword_pr_to_issue" ]
9af64102b0f5cd67e0bb33c502684b498f68dbfc
da2fc3c5466cc50b297eb4c1b28159dea999a332
[]
[ "You can use `.map(...).orElse()` it would be more compact", "You can use `.map(...).orElse()` it would be more compact" ]
"2023-10-11T09:00:32Z"
[ "bug", "backend" ]
Failing task with error handler in a DAG will hang forever leading to zombie execution
### Expected Behavior _No response_ ### Actual Behaviour See https://demo.kestra.io/ui/executions/io.kestra.bmu/dag-test-error/2lJMuZsJdIvt7GqobvxeQR/gantt It only happens if we add an error handler, without it a failing task will stop the execution properly ### Steps To Reproduce _No response_ ### Environment Information - Kestra Version: 0.12.0-SNAPSHOT - Operating System (OS / Docker / Kubernetes): - Java Version (If not docker): ### Example flow ``` id: dag-test-error namespace: io.kestra.bmu tasks: - id: dag type: io.kestra.core.tasks.flows.Dag tasks: - task: id: Log type: io.kestra.core.tasks.log.Log message: Some log dependsOn: - failing - task: id: failing type: io.kestra.core.tasks.executions.Fail errors: - id: error type: io.kestra.core.tasks.log.Log message: error handler ```
[ "core/src/main/java/io/kestra/core/runners/FlowableUtils.java" ]
[ "core/src/main/java/io/kestra/core/runners/FlowableUtils.java" ]
[]
diff --git a/core/src/main/java/io/kestra/core/runners/FlowableUtils.java b/core/src/main/java/io/kestra/core/runners/FlowableUtils.java index 9f50132f3b..419d5de819 100644 --- a/core/src/main/java/io/kestra/core/runners/FlowableUtils.java +++ b/core/src/main/java/io/kestra/core/runners/FlowableUtils.java @@ -15,7 +15,6 @@ import java.util.*; import java.util.function.BiFunction; -import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -166,7 +165,8 @@ public static List<NextTaskRun> resolveDagNexts( ) { return resolveParallelNexts( execution, - tasks, errors, + tasks, + errors, parentTaskRun, concurrency, (nextTaskRunStream, taskRuns) -> nextTaskRunStream @@ -180,8 +180,8 @@ public static List<NextTaskRun> resolveDagNexts( .equals(task.getId()) ) .findFirst() - .get() - .getDependsOn(); + .map(Dag.DagTask::getDependsOn) + .orElse(null); // Check if have no dependencies OR all dependencies are terminated return taskDependIds == null ||
null
train
val
2023-10-11T10:41:20
"2023-09-14T09:24:09Z"
brian-mulier-p
train
kestra-io/kestra/2289_2290
kestra-io/kestra
kestra-io/kestra/2289
kestra-io/kestra/2290
[ "keyword_pr_to_issue" ]
0dc270d6c2acb76d0004e1ff67ec53a6775edce6
fa7de6bed82856b3902e7227dee98e2f626b89ef
[]
[]
"2023-10-12T13:26:23Z"
[ "bug" ]
Bad usage of path instead of route
### Explain the bug Route should be use instead of path ![image](https://github.com/kestra-io/kestra/assets/37600690/6ecbf063-758a-4fe4-a249-abc03e13de8c) ### Environment Information 0.13.0
[ "ui/src/override/components/LeftMenu.vue" ]
[ "ui/src/override/components/LeftMenu.vue" ]
[]
diff --git a/ui/src/override/components/LeftMenu.vue b/ui/src/override/components/LeftMenu.vue index 173ee29bfd..04823a82ea 100644 --- a/ui/src/override/components/LeftMenu.vue +++ b/ui/src/override/components/LeftMenu.vue @@ -206,7 +206,7 @@ } }, { - href: "/admin/workers", + href: {name: "admin/workers"}, title: this.$t("workers"), icon: { element: AccountHardHatOutline,
null
train
val
2023-10-12T14:40:38
"2023-10-12T13:26:15Z"
Skraye
train
kestra-io/kestra/2288_2292
kestra-io/kestra
kestra-io/kestra/2288
kestra-io/kestra/2292
[ "keyword_pr_to_issue" ]
fa7de6bed82856b3902e7227dee98e2f626b89ef
4a1a8a2515dcf0931c95b2fca57407df46b28a2e
[]
[]
"2023-10-12T13:44:32Z"
[ "bug", "frontend" ]
[UI] Something broke Cross-flow dependency view
### Explain the bug ![image](https://github.com/kestra-io/kestra/assets/86264395/a6ab5d25-e7e1-4dae-b06b-17ab0e5c7185) ![image](https://github.com/kestra-io/kestra/assets/86264395/7c98fd58-d592-4e0b-b379-ccdf24427ac7) ### Environment Information - Kestra Version: 0.13.0 - Operating System and Java Version (if not using Kestra Docker image):
[ "ui/package-lock.json", "ui/package.json" ]
[ "ui/package-lock.json", "ui/package.json" ]
[]
diff --git a/ui/package-lock.json b/ui/package-lock.json index 30d9fe71db..12a32910d5 100644 --- a/ui/package-lock.json +++ b/ui/package-lock.json @@ -8,7 +8,7 @@ "name": "kestra", "version": "0.1.0", "dependencies": { - "@kestra-io/ui-libs": "^0.0.28", + "@kestra-io/ui-libs": "^0.0.29", "@popperjs/core": "npm:@sxzz/[email protected]", "@vue-flow/background": "^1.2.0", "@vue-flow/controls": "1.0.6", @@ -630,9 +630,9 @@ "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==" }, "node_modules/@kestra-io/ui-libs": { - "version": "0.0.28", - "resolved": "https://registry.npmjs.org/@kestra-io/ui-libs/-/ui-libs-0.0.28.tgz", - "integrity": "sha512-Hvi8ACLElFdP9NDbl1o5o99sbQkxDb6YGWSx3ITLCYBGPjxjEMdl5lDbgCE0uAgTzfebbjKDwAIiBh74LVJSXw==", + "version": "0.0.29", + "resolved": "https://registry.npmjs.org/@kestra-io/ui-libs/-/ui-libs-0.0.29.tgz", + "integrity": "sha512-ZVWQ5k1M0C4ZMCoparMBAOWdtQ0CMKaDdeQz8y/yqNKxtekGl3bOnSFvzwTotGzHhjC+6B77192IgefQTp9faw==", "peerDependencies": { "@vue-flow/background": "^1.2.0", "@vue-flow/controls": "1.0.6", diff --git a/ui/package.json b/ui/package.json index c3cba2e1ae..2e4ba93407 100644 --- a/ui/package.json +++ b/ui/package.json @@ -11,7 +11,7 @@ "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path ../.gitignore" }, "dependencies": { - "@kestra-io/ui-libs": "^0.0.28", + "@kestra-io/ui-libs": "^0.0.29", "@popperjs/core": "npm:@sxzz/[email protected]", "@vue-flow/background": "^1.2.0", "@vue-flow/controls": "1.0.6",
null
train
val
2023-10-12T15:28:28
"2023-10-12T10:01:43Z"
anna-geller
train
kestra-io/kestra/1809_2293
kestra-io/kestra
kestra-io/kestra/1809
kestra-io/kestra/2293
[ "keyword_pr_to_issue" ]
58fc39da46b5502dfdba9a01e172367faeb7a82c
5f7adbb064457d2cbd3c25918dbe098ce330c15c
[ "As you're in a nested flowable, it should be `parent.taskRun.value` to access the Each value.\r\nWhat is strange is that it seems to works with the expression eval (the property `taskRun` also works):\r\n![image](https://github.com/kestra-io/kestra/assets/37600690/633fe61f-eb1e-4c1c-8ed6-050f72e2c339)\r\n", "The fix didn't seems to solve the issue.\r\n\r\nThe following flow fail with a variable exception (parent is not present):\r\n\r\n```yaml\r\nid: working-dir-value\r\nnamespace: dev\r\ntasks:\r\n - id: each\r\n type: io.kestra.core.tasks.flows.EachSequential\r\n value: [\"1\", \"2\", \"3\"]\r\n tasks:\r\n - id: workingDir\r\n type: io.kestra.core.tasks.flows.WorkingDirectory\r\n tasks:\r\n - id: log\r\n type: io.kestra.core.tasks.log.Log\r\n message: \"{{ parent }}\"\r\n```", "@loicmathieu As stated here : https://github.com/kestra-io/kestra/pull/2293\r\nWhen using a WorkingDirectory, you're not adding a flowable level (even if workingDirectory is a flowable)\r\nSo parent wont exists because there is only one level of flowable, so you need to use `taskrun.value`", "I see you reopened the issue -- worth checking this follow-up issue then https://github.com/kestra-io/kestra/issues/2513 \r\n\r\nThe main request is avoiding a new vocabulary through `workerTaskrun.value` and replace it with:\r\n\r\n1. taskrun.value\r\n2. parent.taskrun.value\r\n3. or if needed: worker.taskrun.value\r\n\r\nfor consistency. the 1 and 2 are preferable. \r\n\r\nThe comment from @loicmathieu is correct, using both taskrun.value and parent.taskrun.value will fail here\r\n\r\n![image](https://github.com/kestra-io/kestra/assets/86264395/cf540c05-73e4-425f-adbb-bc0d040e3304)\r\n![image](https://github.com/kestra-io/kestra/assets/86264395/2ba60421-17f1-4345-b802-4dc532ced789)\r\n\r\nthe workerTaskrun.value is the only one that works atm:\r\n\r\n```yaml\r\nid: working-dir-value\r\nnamespace: dev\r\ntasks:\r\n - id: each\r\n type: io.kestra.core.tasks.flows.EachSequential\r\n value: [\"1\", \"2\", \"3\"]\r\n tasks:\r\n - id: workingDir\r\n type: io.kestra.core.tasks.flows.WorkingDirectory\r\n tasks:\r\n - id: log\r\n type: io.kestra.core.tasks.log.Log\r\n message: \"{{ workerTaskrun.value }}\"\r\n```\r\n\r\nit would be great if using message: \"{{ taskrun.value }}\" would work", "`taskrun.value` should works, and this is the recommended way, the same way you should be doing if there was not workingDirectory\r\n\r\nAgain, please refer to the comment [here](https://github.com/kestra-io/kestra/pull/2293#issuecomment-1764379306) to read what have been done\r\n\r\nedit: Works properly when there is more than 2 flowables (not counting workingDirectory)\r\nneed a small fix for when there is only 1 level", "done in https://github.com/kestra-io/kestra/pull/2528 " ]
[ "Can you merge those two methods in one ?\r\n\r\nWe really don't want a method that allow mutation of variables to be public!" ]
"2023-10-12T18:18:13Z"
[ "bug" ]
Simplify `EachParallel` with `WorkingDirectory` child tasks
### Issue description This flow works: ```yaml id: reproducer namespace: dev tasks: - id: parallel type: io.kestra.core.tasks.flows.EachParallel value: ["1", "2", "3", "4", "5", "6"] tasks: - id: seq type: io.kestra.core.tasks.flows.Sequential tasks: - id: pythonScripts type: io.kestra.core.tasks.flows.WorkingDirectory tasks: - id: cloneRepository type: io.kestra.plugin.git.Clone url: https://github.com/kestra-io/scripts branch: main - id: python type: io.kestra.plugin.scripts.python.Commands runner: DOCKER docker: image: ghcr.io/kestra-io/pydata:latest commands: - python etl/parametrized.py {{ parents[0].taskrun.value }} ``` however, it seems that it should already work without having to add the `Sequential` task, because `WorkingDirectory` already runs everything sequentially. However, without Sequential, the `taskrun.value` cannot be accessed: ```yaml id: reproducer namespace: dev tasks: - id: parallel type: io.kestra.core.tasks.flows.EachParallel value: ["1", "2", "3", "4", "5", "6"] tasks: - id: pythonScripts type: io.kestra.core.tasks.flows.WorkingDirectory tasks: - id: cloneRepository type: io.kestra.plugin.git.Clone url: https://github.com/kestra-io/scripts branch: main - id: python type: io.kestra.plugin.scripts.python.Commands runner: DOCKER docker: image: ghcr.io/kestra-io/pydata:latest commands: - python etl/parametrized.py {{ taskrun.value }} ``` this gives - `Missing variable: 'value' on 'python etl/parametrized.py {{ taskrun.value }}' at line 1` cc @loicmathieu
[ "core/src/main/java/io/kestra/core/runners/RunContext.java", "core/src/main/java/io/kestra/core/runners/Worker.java" ]
[ "core/src/main/java/io/kestra/core/runners/RunContext.java", "core/src/main/java/io/kestra/core/runners/Worker.java" ]
[ "core/src/test/java/io/kestra/core/tasks/flows/WorkingDirectoryTest.java", "core/src/test/resources/flows/valids/working-directory-taskrun.yml" ]
diff --git a/core/src/main/java/io/kestra/core/runners/RunContext.java b/core/src/main/java/io/kestra/core/runners/RunContext.java index 330aaeedf8..f849406dd1 100644 --- a/core/src/main/java/io/kestra/core/runners/RunContext.java +++ b/core/src/main/java/io/kestra/core/runners/RunContext.java @@ -426,6 +426,24 @@ public RunContext forWorker(ApplicationContext applicationContext, WorkerTrigger return forScheduler(workerTrigger.getTriggerContext(), workerTrigger.getTrigger()); } + public RunContext forWorkerDirectory(ApplicationContext applicationContext, WorkerTask workerTask) { + forWorker(applicationContext, workerTask); + + Map<String, Object> clone = new HashMap<>(this.variables); + + clone.put("workerTaskrun", clone.get("taskrun")); + if (clone.containsKey("parents")) { + clone.put("parents", clone.get("parents")); + } + if (clone.containsKey("parent")) { + clone.put("parent", clone.get("parent")); + } + + this.variables = ImmutableMap.copyOf(clone); + + return this; + } + public String render(String inline) throws IllegalVariableEvaluationException { return variableRenderer.render(inline, this.variables); } diff --git a/core/src/main/java/io/kestra/core/runners/Worker.java b/core/src/main/java/io/kestra/core/runners/Worker.java index dd2f5ba739..19315cab09 100644 --- a/core/src/main/java/io/kestra/core/runners/Worker.java +++ b/core/src/main/java/io/kestra/core/runners/Worker.java @@ -149,7 +149,7 @@ private void handleTask(WorkerTask workerTask) { if (workerTask.getTask() instanceof RunnableTask) { this.run(workerTask, true); } else if (workerTask.getTask() instanceof WorkingDirectory workingDirectory) { - RunContext runContext = workerTask.getRunContext().forWorker(applicationContext, workerTask); + RunContext runContext = workerTask.getRunContext().forWorkerDirectory(applicationContext, workerTask); try { workingDirectory.preExecuteTasks(runContext, workerTask.getTaskRun()); @@ -158,7 +158,6 @@ private void handleTask(WorkerTask workerTask) { if (Boolean.TRUE.equals(currentTask.getDisabled())) { continue; } - WorkerTask currentWorkerTask = workingDirectory.workerTask( workerTask.getTaskRun(), currentTask,
diff --git a/core/src/test/java/io/kestra/core/tasks/flows/WorkingDirectoryTest.java b/core/src/test/java/io/kestra/core/tasks/flows/WorkingDirectoryTest.java index 6aca4e1209..e2e00ac344 100644 --- a/core/src/test/java/io/kestra/core/tasks/flows/WorkingDirectoryTest.java +++ b/core/src/test/java/io/kestra/core/tasks/flows/WorkingDirectoryTest.java @@ -4,6 +4,7 @@ import io.kestra.core.models.executions.Execution; import io.kestra.core.models.flows.State; import io.kestra.core.runners.AbstractMemoryRunnerTest; +import io.kestra.core.runners.RunContextFactory; import io.kestra.core.runners.RunnerUtils; import io.kestra.core.storages.StorageInterface; import jakarta.inject.Inject; @@ -43,6 +44,11 @@ void cache() throws TimeoutException, IOException { suite.cache(runnerUtils); } + @Test + void taskrun() throws TimeoutException { + suite.taskRun(runnerUtils); + } + @Singleton public static class Suite { @Inject @@ -93,5 +99,14 @@ public void cache(RunnerUtils runnerUtils) throws TimeoutException, IOException assertThat(execution.getTaskRunList(), hasSize(2)); assertThat(execution.getState().getCurrent(), is(State.Type.FAILED)); } + + public void taskRun(RunnerUtils runnerUtils) throws TimeoutException { + Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "working-directory-taskrun"); + + assertThat(execution.getTaskRunList(), hasSize(6)); + assertThat(execution.getState().getCurrent(), is(State.Type.SUCCESS)); + assertThat(((String) execution.getTaskRunList().get(5).getOutputs().get("value")), containsString("{\"taskrun\":{\"value\":\"1\"}}")); + + } } } diff --git a/core/src/test/resources/flows/valids/working-directory-taskrun.yml b/core/src/test/resources/flows/valids/working-directory-taskrun.yml new file mode 100644 index 0000000000..8a1899dd91 --- /dev/null +++ b/core/src/test/resources/flows/valids/working-directory-taskrun.yml @@ -0,0 +1,23 @@ +id: working-directory-taskrun +namespace: io.kestra.tests + +tasks: + - id: parallel + type: io.kestra.core.tasks.flows.EachParallel + value: ["1"] + tasks: + - id: seq + type: io.kestra.core.tasks.flows.Sequential + tasks: + - id: workingDir + type: io.kestra.core.tasks.flows.WorkingDirectory + tasks: + - id: log-taskrun + type: io.kestra.core.tasks.debugs.Return + format: "{{ workerTaskrun }}" + - id: log-workerparents + type: io.kestra.core.tasks.debugs.Return + format: "{{ parents }}" + - id: log-workerparent + type: io.kestra.core.tasks.debugs.Return + format: "{{ parent }}" \ No newline at end of file
train
val
2023-10-12T21:13:07
"2023-07-25T09:56:20Z"
anna-geller
train
kestra-io/kestra/2326_2333
kestra-io/kestra
kestra-io/kestra/2326
kestra-io/kestra/2333
[ "keyword_pr_to_issue" ]
b7c7093b46da6075aa842889d2829b1385a545bb
8fa1444f9e6a438509a0edfc09ac3cacfdc17189
[]
[]
"2023-10-18T14:38:30Z"
[ "enhancement" ]
Validate that a WorkingDirectory task didn't contains any task with a workerGroup
### Feature description Validate that a WorkingDirectory task didn't contains any task with a workerGroup as otherwise the workerGroup will be ignored leading to possible confusion.
[ "core/src/main/java/io/kestra/core/validations/ValidationFactory.java" ]
[ "core/src/main/java/io/kestra/core/validations/ValidationFactory.java" ]
[ "core/src/test/java/io/kestra/core/validations/WorkingDirectoryTest.java" ]
diff --git a/core/src/main/java/io/kestra/core/validations/ValidationFactory.java b/core/src/main/java/io/kestra/core/validations/ValidationFactory.java index 724c9fc964..069a880240 100644 --- a/core/src/main/java/io/kestra/core/validations/ValidationFactory.java +++ b/core/src/main/java/io/kestra/core/validations/ValidationFactory.java @@ -176,6 +176,11 @@ ConstraintValidator<WorkingDirectoryTaskValidation, WorkingDirectory> workingDir return false; } + if (value.getTasks().stream().anyMatch(task -> task.getWorkerGroup() != null)) { + context.messageTemplate("Cannot set a Worker Group in any WorkingDirectory sub-tasks, it is only supported at the WorkingDirectory level"); + return false; + } + return true; }; }
diff --git a/core/src/test/java/io/kestra/core/validations/WorkingDirectoryTest.java b/core/src/test/java/io/kestra/core/validations/WorkingDirectoryTest.java new file mode 100644 index 0000000000..82c54a430b --- /dev/null +++ b/core/src/test/java/io/kestra/core/validations/WorkingDirectoryTest.java @@ -0,0 +1,88 @@ +package io.kestra.core.validations; + +import io.kestra.core.models.tasks.WorkerGroup; +import io.kestra.core.models.validations.ModelValidator; +import io.kestra.core.tasks.flows.Pause; +import io.kestra.core.tasks.flows.WorkingDirectory; +import io.kestra.core.tasks.log.Log; +import io.micronaut.test.extensions.junit5.annotation.MicronautTest; +import jakarta.inject.Inject; +import org.junit.jupiter.api.Test; + +import java.time.Duration; +import java.util.List; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.*; + +@MicronautTest +public class WorkingDirectoryTest { + @Inject + private ModelValidator modelValidator; + + @Test + void workingDirectoryValid() { + var workingDirectory = WorkingDirectory.builder() + .id("workingDir") + .type(WorkingDirectory.class.getName()) + .tasks( + List.of(Log.builder() + .id("log") + .type(Log.class.getName()) + .message("Hello World") + .build() + ) + ) + .build(); + + assertThat(modelValidator.isValid(workingDirectory).isPresent(), is(false)); + } + + @Test + void workingDirectoryInvalid() { + // empty list of tasks + var workingDirectory = WorkingDirectory.builder() + .id("workingDir") + .type(WorkingDirectory.class.getName()) + .build(); + + assertThat(modelValidator.isValid(workingDirectory).isPresent(), is(true)); + assertThat(modelValidator.isValid(workingDirectory).get().getMessage(), containsString("The tasks property cannot be empty")); + + // flowable task + workingDirectory = WorkingDirectory.builder() + .id("workingDir") + .type(WorkingDirectory.class.getName()) + .tasks( + List.of(Pause.builder() + .id("pause") + .type(Pause.class.getName()) + .delay(Duration.ofSeconds(1L)) + .build() + ) + ) + .build(); + + assertThat(modelValidator.isValid(workingDirectory).isPresent(), is(true)); + assertThat(modelValidator.isValid(workingDirectory).get().getMessage(), containsString("Only runnable tasks are allowed as children of a WorkingDirectory task")); + + // worker group at the subtasks level + workingDirectory = WorkingDirectory.builder() + .id("workingDir") + .type(WorkingDirectory.class.getName()) + .tasks( + List.of(Log.builder() + .id("log") + .type(Log.class.getName()) + .message("Hello World") + .workerGroup(new WorkerGroup("toto")) + .build() + ) + ) + .build(); + + assertThat(modelValidator.isValid(workingDirectory).isPresent(), is(true)); + assertThat(modelValidator.isValid(workingDirectory).get().getMessage(), containsString("Cannot set a Worker Group in any WorkingDirectory sub-tasks, it is only supported at the WorkingDirectory level")); + + } +}
test
val
2023-10-18T11:17:47
"2023-10-18T08:00:26Z"
loicmathieu
train
kestra-io/kestra/2330_2334
kestra-io/kestra
kestra-io/kestra/2330
kestra-io/kestra/2334
[ "keyword_pr_to_issue" ]
540337cf70c074690a6f6b6ff32599e483a3242a
523384a78b71fdbc125fe2f975b2d9478750ea59
[]
[]
"2023-10-18T15:35:36Z"
[ "enhancement" ]
Regression: bring "Edit flow" back to the main navigation bar
### Feature description It's a regression in developer productivity when the edit button is no longer available on the execution page. It is important to bring it back to the top navigation bar: ![image](https://github.com/kestra-io/kestra/assets/86264395/37b910fe-702f-4239-8362-2e218fc6b589)
[ "ui/src/components/executions/ExecutionRoot.vue", "ui/src/components/flows/FlowRoot.vue", "ui/src/components/layout/GlobalSearch.vue", "ui/src/components/layout/TopNavBar.vue" ]
[ "ui/src/components/executions/ExecutionRoot.vue", "ui/src/components/flows/FlowRoot.vue", "ui/src/components/layout/GlobalSearch.vue", "ui/src/components/layout/TopNavBar.vue" ]
[]
diff --git a/ui/src/components/executions/ExecutionRoot.vue b/ui/src/components/executions/ExecutionRoot.vue index d0d8d4bd67..3d187fffa8 100644 --- a/ui/src/components/executions/ExecutionRoot.vue +++ b/ui/src/components/executions/ExecutionRoot.vue @@ -2,42 +2,25 @@ <top-nav-bar :title="routeInfo?.title" :breadcrumb="routeInfo?.breadcrumb"> <template #additional-right v-if="canDelete || isAllowedTrigger || isAllowedEdit"> <ul> - <li> - <el-dropdown> - <el-button type="default"> - <DotsVertical title="" /> - {{ $t("actions") }} + <li v-if="isAllowedEdit"> + <a :href="`${finalApiUrl}/executions/${execution.id}`" target="_blank"> + <el-button :icon="Api"> + {{ $t('api') }} </el-button> - <template #dropdown> - <el-dropdown-menu class="m-dropdown-menu"> - <a class="el-dropdown-menu__item d-flex gap-2" :href="`${finalApiUrl}/executions/${execution.id}`" target="_blank"> - <Api /> {{ $t('api') }} - </a> - <el-dropdown-item - v-if="canDelete" - :icon="Delete" - size="large" - @click="deleteExecution" - > - {{ $t('delete') }} - </el-dropdown-item> - - <el-dropdown-item - v-if="isAllowedEdit" - :icon="Pencil" - size="large" - @click="editFlow" - > - {{ $t('edit flow') }} - </el-dropdown-item> - </el-dropdown-menu> - </template> - </el-dropdown> + </a> + </li> + <li v-if="canDelete"> + <el-button :icon="Delete" @click="deleteExecution"> + {{ $t('delete') }} + </el-button> + </li> + <li v-if="isAllowedEdit"> + <el-button :icon="Pencil" @click="editFlow"> + {{ $t("edit flow") }} + </el-button> </li> - <li> - <template v-if="isAllowedTrigger"> - <trigger-flow type="primary" :flow-id="$route.params.flowId" :namespace="$route.params.namespace" /> - </template> + <li v-if="isAllowedTrigger"> + <trigger-flow type="primary" :flow-id="$route.params.flowId" :namespace="$route.params.namespace" /> </li> </ul> </template> @@ -53,7 +36,6 @@ import Api from "vue-material-design-icons/Api.vue"; import Delete from "vue-material-design-icons/Delete.vue"; import Pencil from "vue-material-design-icons/Pencil.vue"; - import DotsVertical from "vue-material-design-icons/DotsVertical.vue"; </script> <script> diff --git a/ui/src/components/flows/FlowRoot.vue b/ui/src/components/flows/FlowRoot.vue index 8e1cf2a656..1091f9af1d 100644 --- a/ui/src/components/flows/FlowRoot.vue +++ b/ui/src/components/flows/FlowRoot.vue @@ -13,7 +13,7 @@ {{ $t("restore") }} </el-button> </li> - <li v-if="isAllowedEdit && !deleted && activeTabName !== 'editor'"> + <li v-if="isAllowedEdit && !deleted && activeTabName() !== 'editor'"> <el-button :icon="Pencil" @click="editFlow" :disabled="deleted"> {{ $t("edit flow") }} </el-button> diff --git a/ui/src/components/layout/GlobalSearch.vue b/ui/src/components/layout/GlobalSearch.vue index 43cb9a69fa..159a29d6d2 100644 --- a/ui/src/components/layout/GlobalSearch.vue +++ b/ui/src/components/layout/GlobalSearch.vue @@ -1,5 +1,5 @@ <template> - <el-dropdown trigger="click" popper-class="hide-arrow overflow-hidden separator-m-0 global-search-popper"> + <el-dropdown class="flex-shrink-0" trigger="click" popper-class="hide-arrow overflow-hidden separator-m-0 global-search-popper"> <search-field class="align-items-center" @search="search" :router="false" ref="search" placeholder="jump to..."> <template #prefix> <magnify /> diff --git a/ui/src/components/layout/TopNavBar.vue b/ui/src/components/layout/TopNavBar.vue index 6b36a11a56..be315d109d 100644 --- a/ui/src/components/layout/TopNavBar.vue +++ b/ui/src/components/layout/TopNavBar.vue @@ -14,7 +14,7 @@ </slot> </h1> </div> - <div class="d-flex side gap-2"> + <div class="d-flex side gap-2 flex-shrink-0"> <global-search /> <slot name="additional-right" /> <div class="d-flex fixed-buttons"> @@ -123,9 +123,9 @@ h1 { line-height: 1.6; - max-width: 40ch; flex-wrap: wrap; white-space: pre-wrap; + word-break: break-all; } .side {
null
val
val
2023-10-18T16:40:28
"2023-10-18T09:22:12Z"
anna-geller
train
kestra-io/kestra/2348_2362
kestra-io/kestra
kestra-io/kestra/2348
kestra-io/kestra/2362
[ "keyword_pr_to_issue" ]
8fa1444f9e6a438509a0edfc09ac3cacfdc17189
54dbd24368b94e0e125e62df4db909bd057d75ad
[]
[]
"2023-10-21T18:46:11Z"
[ "bug" ]
[UI] CTRL-E in the flow editor no longuer launch an execution
### Explain the bug [UI] CTRL-E in the flow editor no longuer launch an execution ### Environment Information - Kestra Version: 0.13 - Operating System and Java Version (if not using Kestra Docker image):
[ "ui/src/components/flows/TriggerFlow.vue", "ui/src/components/inputs/EditorView.vue", "ui/src/stores/flow.js" ]
[ "ui/src/components/flows/TriggerFlow.vue", "ui/src/components/inputs/EditorView.vue", "ui/src/stores/flow.js" ]
[]
diff --git a/ui/src/components/flows/TriggerFlow.vue b/ui/src/components/flows/TriggerFlow.vue index 99b504a939..02e60fc699 100644 --- a/ui/src/components/flows/TriggerFlow.vue +++ b/ui/src/components/flows/TriggerFlow.vue @@ -1,6 +1,6 @@ <template> <div class="trigger-flow-wrapper"> - <el-button class="edit-flow-trigger-button" :icon="icon.Flash" :disabled="disabled || flow?.deleted" :type="type" @click="onClick"> + <el-button class="edit-flow-trigger-button" :icon="icon.Flash" :disabled="isDisabled()" :type="type" @click="onClick"> {{ $t('execute') }} </el-button> <el-dialog v-if="isOpen" v-model="isOpen" destroy-on-close :append-to-body="true"> @@ -76,13 +76,15 @@ } this.isOpen = !this.isOpen }, - closeModal() { this.isOpen = false; + }, + isDisabled() { + return this.disabled || this.flow?.deleted; } }, computed: { - ...mapState("flow", ["flow"]), + ...mapState("flow", ["flow", "executeFlow"]), ...mapState("core", ["guidedProperties"]), }, watch: { @@ -93,6 +95,14 @@ } }, deep: true + }, + executeFlow: { + handler() { + if (this.executeFlow && !this.isDisabled()) { + this.$store.commit("flow/executeFlow", false); + this.onClick(); + } + } } } }; diff --git a/ui/src/components/inputs/EditorView.vue b/ui/src/components/inputs/EditorView.vue index 705d968b59..ff2b20668b 100644 --- a/ui/src/components/inputs/EditorView.vue +++ b/ui/src/components/inputs/EditorView.vue @@ -135,7 +135,6 @@ const isLoading = ref(false); const haveChange = ref(false) const flowYaml = ref("") - const triggerFlowDomElement = ref(null); const newTrigger = ref(null) const isNewTriggerOpen = ref(false) const newError = ref(null) @@ -547,10 +546,7 @@ }; const execute = (_) => { - if (!triggerFlowDomElement.value) { - return; - } - triggerFlowDomElement.value.onClick(); + store.commit("flow/executeFlow", true); }; const canDelete = () => { diff --git a/ui/src/stores/flow.js b/ui/src/stores/flow.js index 6cab48c209..102e9d5051 100644 --- a/ui/src/stores/flow.js +++ b/ui/src/stores/flow.js @@ -25,7 +25,8 @@ export default { taskError: undefined, metrics: [], aggregatedMetrics: undefined, - tasksWithMetrics: [] + tasksWithMetrics: [], + executeFlow: false }, actions: { @@ -334,6 +335,9 @@ export default { state.flow = {...flow} }, + executeFlow(state, value) { + state.executeFlow = value; + }, addTrigger(state, trigger) { let flow = state.flow;
null
train
val
2023-10-20T17:49:51
"2023-10-19T10:13:33Z"
loicmathieu
train
kestra-io/kestra/2232_2411
kestra-io/kestra
kestra-io/kestra/2232
kestra-io/kestra/2411
[ "keyword_pr_to_issue" ]
4f18b146a965c028b0ec3cae7aac206c71d9fbb2
690dcbd467f43e1115328ffe84d711414c17afa8
[ "related to https://github.com/kestra-io/kestra/issues/2383" ]
[]
"2023-10-30T15:12:35Z"
[ "bug", "frontend" ]
Different failed execution count on the Homepage dashboard
### Explain the bug For example, on the demo, when filtering on 7 days. On the homepage dashboard, execution count is 31147 ![image](https://github.com/kestra-io/kestra/assets/1819009/bb7692ee-6e48-4185-a43e-7fa0c52045f4) But the failed execution widget shows more than 10000 failed execution ![image](https://github.com/kestra-io/kestra/assets/1819009/90330409-cc2a-468e-b102-ca49319174ee) And same for the execution page when listing only FAILED execution ![image](https://github.com/kestra-io/kestra/assets/1819009/af964b77-17d0-44b9-8f68-83cbb1162645) ### Environment Information - Kestra Version: 0.13.0-SNAPSHOT - Operating System and Java Version (if not using Kestra Docker image):
[ "ui/src/components/home/Home.vue" ]
[ "ui/src/components/home/Home.vue" ]
[]
diff --git a/ui/src/components/home/Home.vue b/ui/src/components/home/Home.vue index 7d24d7e804..6e0aef1777 100644 --- a/ui/src/components/home/Home.vue +++ b/ui/src/components/home/Home.vue @@ -258,8 +258,8 @@ let sorted = data.sort((a, b) => { return new Date(b.date) - new Date(a.date); }); - this.today = sorted.shift(); - this.yesterday = sorted.shift(); + this.today = sorted.at(sorted.length - 1); + this.yesterday = sorted.length >= 2 ? sorted.at(sorted.length - 2) : {}; this.alls = this.mergeStats(sorted); this.dailyReady = true; });
null
val
val
2023-10-29T00:30:41
"2023-10-04T09:50:46Z"
loicmathieu
train
kestra-io/kestra/2381_2414
kestra-io/kestra
kestra-io/kestra/2381
kestra-io/kestra/2414
[ "keyword_pr_to_issue" ]
690dcbd467f43e1115328ffe84d711414c17afa8
b1e0fad6b431323c8c9d1bfd30e5044c77a9d34c
[]
[]
"2023-10-31T08:34:45Z"
[]
Load default namespace when starting the VS Code editor
Instead of a blank screen, we should load the default namespace: ![image](https://github.com/kestra-io/kestra/assets/86264395/ec3ab42a-dcbe-487a-8a85-541bc6bc487a) ![image](https://github.com/kestra-io/kestra/assets/86264395/1e2bff0b-7c34-4f65-a549-5b953c712ddf) this will be more encouraging and easier to start
[ "ui/public/vscode.html", "ui/src/components/flows/TriggerFlow.vue", "ui/src/components/namespace/Editor.vue", "ui/src/components/namespace/NamespaceSelect.vue", "ui/src/utils/submitTask.js" ]
[ "ui/public/init.js", "ui/public/vscode.html", "ui/src/components/flows/TriggerFlow.vue", "ui/src/components/namespace/Editor.vue", "ui/src/components/namespace/NamespaceSelect.vue", "ui/src/utils/submitTask.js" ]
[]
diff --git a/ui/public/init.js b/ui/public/init.js new file mode 100644 index 0000000000..0dec0bef22 --- /dev/null +++ b/ui/public/init.js @@ -0,0 +1,78 @@ +Object.keys(window.webPackagePaths).map(function (key) { + window.webPackagePaths[key] = `${window.location.origin}${KESTRA_UI_PATH}vscode-web/dist/node_modules/${key}/${window.webPackagePaths[key]}`; +}); + +require.config({ + baseUrl: `${window.location.origin}${KESTRA_UI_PATH}vscode-web/dist/out`, + recordStats: true, + trustedTypesPolicy: window.trustedTypes?.createPolicy("amdLoader", { + createScriptURL(value) { + return value; + } + }), + paths: window.webPackagePaths +}); + +// used to configure VSCode startup +window.product = { + productConfiguration: { + nameShort: "Kestra VSCode", + nameLong: "Kestra VSCode", + // configure the open sx marketplace + "extensionsGallery": { + "serviceUrl": "https://open-vsx.org/vscode/gallery", + "itemUrl": "https://open-vsx.org/vscode/item", + "resourceUrlTemplate": "https://openvsxorg.blob.core.windows.net/resources/{publisher}/{name}/{version}/{path}" + }, + }, + // scope the VSCode instance to Kestra File System Provider (defined in Kestra VSCode extension) + folderUri: { + scheme: "kestra", + path: "/" + queryParams["namespace"] + }, + commands: [ + { + id: "custom.postMessage", + handler: async (data) => { + window.parent.postMessage(data, "*") + } + } + ], + additionalBuiltinExtensions: [ + { + scheme: "https", + authority: "openvsxorg.blob.core.windows.net", + path: "/resources/PROxZIMA/sweetdracula/1.0.9/extension" + }, + { + scheme: window.location.protocol.replace(":", ""), + authority: window.location.host, + path: KESTRA_UI_PATH + "yamlExt" + }, + { + scheme: "https", + authority: "openvsxorg.blob.core.windows.net", + path: "/resources/kestra-io/kestra/0.1.4/extension" + } + ], + "linkProtectionTrustedDomains": [ + "https://open-vsx.org", + "https://openvsxorg.blob.core.windows.net" + ], + enabledExtensions: [ + // to handle dark theme + "proxzima.sweetdracula", + // to apply Kestra's flow validation schema + "redhat.vscode-yaml", + "kestra-io.kestra" + ], + configurationDefaults: { + "files.autoSave": "off", + "editor.fontSize": 12, + "workbench.colorTheme": THEME === "dark" ? "Sweet Dracula" : "Default Light Modern", + "workbench.startupEditor": "readme", + // "workbench.activityBar.visible": false, + // provide the Kestra root URL to extension + "kestra.api.url": KESTRA_API_URL + } +}; \ No newline at end of file diff --git a/ui/public/vscode.html b/ui/public/vscode.html index 05e20cfa10..bda5bfd2f8 100644 --- a/ui/public/vscode.html +++ b/ui/public/vscode.html @@ -25,76 +25,7 @@ <script src="./vscode-web/dist/out/vs/loader.js"></script> <script src="./vscode-web/dist/out/vs/webPackagePaths.js"></script> -<script> - Object.keys(window.webPackagePaths).map(function (key) { - window.webPackagePaths[key] = `${window.location.origin}${KESTRA_UI_PATH}vscode-web/dist/node_modules/${key}/${window.webPackagePaths[key]}`; - }); - - require.config({ - baseUrl: `${window.location.origin}${KESTRA_UI_PATH}vscode-web/dist/out`, - recordStats: true, - trustedTypesPolicy: window.trustedTypes?.createPolicy("amdLoader", { - createScriptURL(value) { - return value; - } - }), - paths: window.webPackagePaths - }); - - // used to configure VSCode startup - window.product = { - productConfiguration: { - nameShort: "Kestra VSCode", - nameLong: "Kestra VSCode", - // configure the open sx marketplace - "extensionsGallery": { - "serviceUrl": "https://open-vsx.org/vscode/gallery", - "itemUrl": "https://open-vsx.org/vscode/item", - "resourceUrlTemplate": "https://openvsxorg.blob.core.windows.net/resources/{publisher}/{name}/{version}/{path}" - }, - }, - // scope the VSCode instance to Kestra File System Provider (defined in Kestra VSCode extension) - folderUri: { - scheme: "kestra", - path: "/" + queryParams["namespace"] - }, - additionalBuiltinExtensions: [ - { - scheme: "https", - authority: "openvsxorg.blob.core.windows.net", - path: "/resources/PROxZIMA/sweetdracula/1.0.9/extension" - }, - { - scheme: window.location.protocol.replace(":", ""), - authority: window.location.host, - path: KESTRA_UI_PATH + "yamlExt" - }, - { - scheme: "https", - authority: "openvsxorg.blob.core.windows.net", - path: "/resources/kestra-io/kestra/0.1.2/extension" - }, - ], - "linkProtectionTrustedDomains": [ - "https://open-vsx.org", - "https://openvsxorg.blob.core.windows.net" - ], - enabledExtensions: [ - // to handle dark theme - "proxzima.sweetdracula", - // to apply Kestra's flow validation schema - "redhat.vscode-yaml", - "kestra-io.kestra" - ], - configurationDefaults: { - "files.autoSave": "off", - "editor.fontSize": 12, - "workbench.colorTheme": THEME === "dark" ? "Sweet Dracula" : "Default Light Modern", - // provide the Kestra root URL to extension - "kestra.api.url": KESTRA_API_URL - } - }; -</script> +<script src="./init.js"></script> <script src="./vscode-web/dist/out/vs/workbench/workbench.web.main.nls.js"></script> <script src="./vscode-web/dist/out/vs/workbench/workbench.web.main.js"></script> <script src="./vscode-web/dist/out/vs/code/browser/workbench/workbench.js"></script> diff --git a/ui/src/components/flows/TriggerFlow.vue b/ui/src/components/flows/TriggerFlow.vue index 02e60fc699..1616d13d40 100644 --- a/ui/src/components/flows/TriggerFlow.vue +++ b/ui/src/components/flows/TriggerFlow.vue @@ -103,6 +103,18 @@ this.onClick(); } } + }, + flowId: { + handler() { + if ((!this.flow || this.flow.id !== this.flowId) && this.flowId && this.namespace) { + this.$store + .dispatch("flow/loadFlow", { + id: this.flowId, + namespace: this.namespace, + allowDeleted: true + }); + } + } } } }; diff --git a/ui/src/components/namespace/Editor.vue b/ui/src/components/namespace/Editor.vue index e95578e052..714b4d7a93 100644 --- a/ui/src/components/namespace/Editor.vue +++ b/ui/src/components/namespace/Editor.vue @@ -1,10 +1,18 @@ <template> <top-nav-bar :title="routeInfo.title"> <template #additional-right> - <namespace-select class="fit-content" + <namespace-select + class="fit-content" data-type="flow" - :value="namespace" - @update:model-value="namespaceUpdate"/> + :value="namespace" + @update:model-value="namespaceUpdate" + allow-create + /> + <trigger-flow + :disabled="!flow" + :flow-id="flow" + :namespace="namespace" + /> </template> </top-nav-bar> <iframe @@ -13,6 +21,7 @@ v-if="namespace" class="vscode-editor" :src="vscodeIndexUrl" + ref="vscodeIde" /> <div v-else class="m-3 mw-100"> <el-alert type="info" :closable="false"> @@ -24,6 +33,7 @@ <script setup> import NamespaceSelect from "./NamespaceSelect.vue"; import TopNavBar from "../layout/TopNavBar.vue"; + import TriggerFlow from "../flows/TriggerFlow.vue"; </script> <script> @@ -40,8 +50,43 @@ namespace } }); + }, + handleTabsDirty(tabs) { + // Add tabs not saved + this.tabsNotSaved = this.tabsNotSaved.concat(tabs.dirty) + // Removed tabs closed + this.tabsNotSaved = this.tabsNotSaved.filter(e => !tabs.closed.includes(e)) + console.log(this.tabsNotSaved) + this.$store.dispatch("core/isUnsaved", this.tabsNotSaved.length > 0); + } + }, + data() { + return { + flow: null, + tabsNotSaved: [] } }, + created() { + const namespace = localStorage.getItem("defaultNamespace"); + if (namespace) { + this.namespaceUpdate(namespace); + } + }, + mounted() { + window.addEventListener("message", (event) => { + const message = event.data; + if (message.type === "kestra.tabFileChanged") { + const path = `/${this.namespace}/_flows/`; + if (message.filePath.path.startsWith(path)) { + this.flow = message.filePath.path.split(path)[1].replace(".yml", ""); + } else { + this.flow = null; + } + } else if (message.type === "kestra.tabsChanged") { + this.handleTabsDirty(message.tabs); + } + }); + }, computed: { routeInfo() { return { diff --git a/ui/src/components/namespace/NamespaceSelect.vue b/ui/src/components/namespace/NamespaceSelect.vue index 072d28180e..d090ccccb6 100644 --- a/ui/src/components/namespace/NamespaceSelect.vue +++ b/ui/src/components/namespace/NamespaceSelect.vue @@ -6,6 +6,7 @@ :placeholder="$t('Select namespace')" :persistent="false" filterable + :allow-create="allowCreate" > <el-option v-for="item in groupedNamespaces" @@ -29,6 +30,10 @@ value: { type: String, default: undefined + }, + allowCreate: { + type: Boolean, + default: false } }, emits: ["update:modelValue"], diff --git a/ui/src/utils/submitTask.js b/ui/src/utils/submitTask.js index 604512a71b..8d4f425ee4 100644 --- a/ui/src/utils/submitTask.js +++ b/ui/src/utils/submitTask.js @@ -38,7 +38,8 @@ export const executeTask = (submitor, flow, values, options) => { .then(response => { submitor.$store.commit("execution/setExecution", response.data) if (options.redirect) { - submitor.$router.push({name: "executions/update", params: {...{namespace: response.data.namespace, flowId: response.data.flowId, id: response.data.id}, ...{tab: "gantt"}}}) + const resolved = submitor.$router.resolve({name: "executions/update", params: {...{namespace: response.data.namespace, flowId: response.data.flowId, id: response.data.id}, ...{tab: "gantt"}}}) + window.open(resolved.href, "_blank") } return response.data;
null
train
val
2023-10-31T10:23:34
"2023-10-24T13:38:56Z"
anna-geller
train
kestra-io/kestra/2367_2414
kestra-io/kestra
kestra-io/kestra/2367
kestra-io/kestra/2414
[ "keyword_pr_to_issue" ]
690dcbd467f43e1115328ffe84d711414c17afa8
b1e0fad6b431323c8c9d1bfd30e5044c77a9d34c
[]
[]
"2023-10-31T08:34:45Z"
[ "enhancement" ]
Rename the `flows` Namespace Files directory to `_flows`
### Feature description This will: 1. Make it clear that this is a directory managed internally by kestra 2. Automatically pin that directory to the top naturally via naming 3. Make CI/CD easier, e.g., allowing to escape that directory when syncing namespace files via GitHub Actions or Terraform ![image](https://github.com/kestra-io/kestra/assets/86264395/8c16cdef-7c63-46d7-a3af-52a02f63b733)
[ "ui/public/vscode.html", "ui/src/components/flows/TriggerFlow.vue", "ui/src/components/namespace/Editor.vue", "ui/src/components/namespace/NamespaceSelect.vue", "ui/src/utils/submitTask.js" ]
[ "ui/public/init.js", "ui/public/vscode.html", "ui/src/components/flows/TriggerFlow.vue", "ui/src/components/namespace/Editor.vue", "ui/src/components/namespace/NamespaceSelect.vue", "ui/src/utils/submitTask.js" ]
[]
diff --git a/ui/public/init.js b/ui/public/init.js new file mode 100644 index 0000000000..0dec0bef22 --- /dev/null +++ b/ui/public/init.js @@ -0,0 +1,78 @@ +Object.keys(window.webPackagePaths).map(function (key) { + window.webPackagePaths[key] = `${window.location.origin}${KESTRA_UI_PATH}vscode-web/dist/node_modules/${key}/${window.webPackagePaths[key]}`; +}); + +require.config({ + baseUrl: `${window.location.origin}${KESTRA_UI_PATH}vscode-web/dist/out`, + recordStats: true, + trustedTypesPolicy: window.trustedTypes?.createPolicy("amdLoader", { + createScriptURL(value) { + return value; + } + }), + paths: window.webPackagePaths +}); + +// used to configure VSCode startup +window.product = { + productConfiguration: { + nameShort: "Kestra VSCode", + nameLong: "Kestra VSCode", + // configure the open sx marketplace + "extensionsGallery": { + "serviceUrl": "https://open-vsx.org/vscode/gallery", + "itemUrl": "https://open-vsx.org/vscode/item", + "resourceUrlTemplate": "https://openvsxorg.blob.core.windows.net/resources/{publisher}/{name}/{version}/{path}" + }, + }, + // scope the VSCode instance to Kestra File System Provider (defined in Kestra VSCode extension) + folderUri: { + scheme: "kestra", + path: "/" + queryParams["namespace"] + }, + commands: [ + { + id: "custom.postMessage", + handler: async (data) => { + window.parent.postMessage(data, "*") + } + } + ], + additionalBuiltinExtensions: [ + { + scheme: "https", + authority: "openvsxorg.blob.core.windows.net", + path: "/resources/PROxZIMA/sweetdracula/1.0.9/extension" + }, + { + scheme: window.location.protocol.replace(":", ""), + authority: window.location.host, + path: KESTRA_UI_PATH + "yamlExt" + }, + { + scheme: "https", + authority: "openvsxorg.blob.core.windows.net", + path: "/resources/kestra-io/kestra/0.1.4/extension" + } + ], + "linkProtectionTrustedDomains": [ + "https://open-vsx.org", + "https://openvsxorg.blob.core.windows.net" + ], + enabledExtensions: [ + // to handle dark theme + "proxzima.sweetdracula", + // to apply Kestra's flow validation schema + "redhat.vscode-yaml", + "kestra-io.kestra" + ], + configurationDefaults: { + "files.autoSave": "off", + "editor.fontSize": 12, + "workbench.colorTheme": THEME === "dark" ? "Sweet Dracula" : "Default Light Modern", + "workbench.startupEditor": "readme", + // "workbench.activityBar.visible": false, + // provide the Kestra root URL to extension + "kestra.api.url": KESTRA_API_URL + } +}; \ No newline at end of file diff --git a/ui/public/vscode.html b/ui/public/vscode.html index 05e20cfa10..bda5bfd2f8 100644 --- a/ui/public/vscode.html +++ b/ui/public/vscode.html @@ -25,76 +25,7 @@ <script src="./vscode-web/dist/out/vs/loader.js"></script> <script src="./vscode-web/dist/out/vs/webPackagePaths.js"></script> -<script> - Object.keys(window.webPackagePaths).map(function (key) { - window.webPackagePaths[key] = `${window.location.origin}${KESTRA_UI_PATH}vscode-web/dist/node_modules/${key}/${window.webPackagePaths[key]}`; - }); - - require.config({ - baseUrl: `${window.location.origin}${KESTRA_UI_PATH}vscode-web/dist/out`, - recordStats: true, - trustedTypesPolicy: window.trustedTypes?.createPolicy("amdLoader", { - createScriptURL(value) { - return value; - } - }), - paths: window.webPackagePaths - }); - - // used to configure VSCode startup - window.product = { - productConfiguration: { - nameShort: "Kestra VSCode", - nameLong: "Kestra VSCode", - // configure the open sx marketplace - "extensionsGallery": { - "serviceUrl": "https://open-vsx.org/vscode/gallery", - "itemUrl": "https://open-vsx.org/vscode/item", - "resourceUrlTemplate": "https://openvsxorg.blob.core.windows.net/resources/{publisher}/{name}/{version}/{path}" - }, - }, - // scope the VSCode instance to Kestra File System Provider (defined in Kestra VSCode extension) - folderUri: { - scheme: "kestra", - path: "/" + queryParams["namespace"] - }, - additionalBuiltinExtensions: [ - { - scheme: "https", - authority: "openvsxorg.blob.core.windows.net", - path: "/resources/PROxZIMA/sweetdracula/1.0.9/extension" - }, - { - scheme: window.location.protocol.replace(":", ""), - authority: window.location.host, - path: KESTRA_UI_PATH + "yamlExt" - }, - { - scheme: "https", - authority: "openvsxorg.blob.core.windows.net", - path: "/resources/kestra-io/kestra/0.1.2/extension" - }, - ], - "linkProtectionTrustedDomains": [ - "https://open-vsx.org", - "https://openvsxorg.blob.core.windows.net" - ], - enabledExtensions: [ - // to handle dark theme - "proxzima.sweetdracula", - // to apply Kestra's flow validation schema - "redhat.vscode-yaml", - "kestra-io.kestra" - ], - configurationDefaults: { - "files.autoSave": "off", - "editor.fontSize": 12, - "workbench.colorTheme": THEME === "dark" ? "Sweet Dracula" : "Default Light Modern", - // provide the Kestra root URL to extension - "kestra.api.url": KESTRA_API_URL - } - }; -</script> +<script src="./init.js"></script> <script src="./vscode-web/dist/out/vs/workbench/workbench.web.main.nls.js"></script> <script src="./vscode-web/dist/out/vs/workbench/workbench.web.main.js"></script> <script src="./vscode-web/dist/out/vs/code/browser/workbench/workbench.js"></script> diff --git a/ui/src/components/flows/TriggerFlow.vue b/ui/src/components/flows/TriggerFlow.vue index 02e60fc699..1616d13d40 100644 --- a/ui/src/components/flows/TriggerFlow.vue +++ b/ui/src/components/flows/TriggerFlow.vue @@ -103,6 +103,18 @@ this.onClick(); } } + }, + flowId: { + handler() { + if ((!this.flow || this.flow.id !== this.flowId) && this.flowId && this.namespace) { + this.$store + .dispatch("flow/loadFlow", { + id: this.flowId, + namespace: this.namespace, + allowDeleted: true + }); + } + } } } }; diff --git a/ui/src/components/namespace/Editor.vue b/ui/src/components/namespace/Editor.vue index e95578e052..714b4d7a93 100644 --- a/ui/src/components/namespace/Editor.vue +++ b/ui/src/components/namespace/Editor.vue @@ -1,10 +1,18 @@ <template> <top-nav-bar :title="routeInfo.title"> <template #additional-right> - <namespace-select class="fit-content" + <namespace-select + class="fit-content" data-type="flow" - :value="namespace" - @update:model-value="namespaceUpdate"/> + :value="namespace" + @update:model-value="namespaceUpdate" + allow-create + /> + <trigger-flow + :disabled="!flow" + :flow-id="flow" + :namespace="namespace" + /> </template> </top-nav-bar> <iframe @@ -13,6 +21,7 @@ v-if="namespace" class="vscode-editor" :src="vscodeIndexUrl" + ref="vscodeIde" /> <div v-else class="m-3 mw-100"> <el-alert type="info" :closable="false"> @@ -24,6 +33,7 @@ <script setup> import NamespaceSelect from "./NamespaceSelect.vue"; import TopNavBar from "../layout/TopNavBar.vue"; + import TriggerFlow from "../flows/TriggerFlow.vue"; </script> <script> @@ -40,8 +50,43 @@ namespace } }); + }, + handleTabsDirty(tabs) { + // Add tabs not saved + this.tabsNotSaved = this.tabsNotSaved.concat(tabs.dirty) + // Removed tabs closed + this.tabsNotSaved = this.tabsNotSaved.filter(e => !tabs.closed.includes(e)) + console.log(this.tabsNotSaved) + this.$store.dispatch("core/isUnsaved", this.tabsNotSaved.length > 0); + } + }, + data() { + return { + flow: null, + tabsNotSaved: [] } }, + created() { + const namespace = localStorage.getItem("defaultNamespace"); + if (namespace) { + this.namespaceUpdate(namespace); + } + }, + mounted() { + window.addEventListener("message", (event) => { + const message = event.data; + if (message.type === "kestra.tabFileChanged") { + const path = `/${this.namespace}/_flows/`; + if (message.filePath.path.startsWith(path)) { + this.flow = message.filePath.path.split(path)[1].replace(".yml", ""); + } else { + this.flow = null; + } + } else if (message.type === "kestra.tabsChanged") { + this.handleTabsDirty(message.tabs); + } + }); + }, computed: { routeInfo() { return { diff --git a/ui/src/components/namespace/NamespaceSelect.vue b/ui/src/components/namespace/NamespaceSelect.vue index 072d28180e..d090ccccb6 100644 --- a/ui/src/components/namespace/NamespaceSelect.vue +++ b/ui/src/components/namespace/NamespaceSelect.vue @@ -6,6 +6,7 @@ :placeholder="$t('Select namespace')" :persistent="false" filterable + :allow-create="allowCreate" > <el-option v-for="item in groupedNamespaces" @@ -29,6 +30,10 @@ value: { type: String, default: undefined + }, + allowCreate: { + type: Boolean, + default: false } }, emits: ["update:modelValue"], diff --git a/ui/src/utils/submitTask.js b/ui/src/utils/submitTask.js index 604512a71b..8d4f425ee4 100644 --- a/ui/src/utils/submitTask.js +++ b/ui/src/utils/submitTask.js @@ -38,7 +38,8 @@ export const executeTask = (submitor, flow, values, options) => { .then(response => { submitor.$store.commit("execution/setExecution", response.data) if (options.redirect) { - submitor.$router.push({name: "executions/update", params: {...{namespace: response.data.namespace, flowId: response.data.flowId, id: response.data.id}, ...{tab: "gantt"}}}) + const resolved = submitor.$router.resolve({name: "executions/update", params: {...{namespace: response.data.namespace, flowId: response.data.flowId, id: response.data.id}, ...{tab: "gantt"}}}) + window.open(resolved.href, "_blank") } return response.data;
null
val
val
2023-10-31T10:23:34
"2023-10-23T10:23:38Z"
anna-geller
train
kestra-io/kestra/2342_2414
kestra-io/kestra
kestra-io/kestra/2342
kestra-io/kestra/2414
[ "keyword_pr_to_issue" ]
690dcbd467f43e1115328ffe84d711414c17afa8
b1e0fad6b431323c8c9d1bfd30e5044c77a9d34c
[]
[]
"2023-10-31T08:34:45Z"
[]
Allow creating + saving flows from VS Code with full autocompletion (kestra flow schema is currently not preloaded)
Currently, fetching the flow schema requires manual intervention from the user. Fixing that is a priority in this issue. Then, we need to add an option to allow adding flow files directly to the `_flows` folder.
[ "ui/public/vscode.html", "ui/src/components/flows/TriggerFlow.vue", "ui/src/components/namespace/Editor.vue", "ui/src/components/namespace/NamespaceSelect.vue", "ui/src/utils/submitTask.js" ]
[ "ui/public/init.js", "ui/public/vscode.html", "ui/src/components/flows/TriggerFlow.vue", "ui/src/components/namespace/Editor.vue", "ui/src/components/namespace/NamespaceSelect.vue", "ui/src/utils/submitTask.js" ]
[]
diff --git a/ui/public/init.js b/ui/public/init.js new file mode 100644 index 0000000000..0dec0bef22 --- /dev/null +++ b/ui/public/init.js @@ -0,0 +1,78 @@ +Object.keys(window.webPackagePaths).map(function (key) { + window.webPackagePaths[key] = `${window.location.origin}${KESTRA_UI_PATH}vscode-web/dist/node_modules/${key}/${window.webPackagePaths[key]}`; +}); + +require.config({ + baseUrl: `${window.location.origin}${KESTRA_UI_PATH}vscode-web/dist/out`, + recordStats: true, + trustedTypesPolicy: window.trustedTypes?.createPolicy("amdLoader", { + createScriptURL(value) { + return value; + } + }), + paths: window.webPackagePaths +}); + +// used to configure VSCode startup +window.product = { + productConfiguration: { + nameShort: "Kestra VSCode", + nameLong: "Kestra VSCode", + // configure the open sx marketplace + "extensionsGallery": { + "serviceUrl": "https://open-vsx.org/vscode/gallery", + "itemUrl": "https://open-vsx.org/vscode/item", + "resourceUrlTemplate": "https://openvsxorg.blob.core.windows.net/resources/{publisher}/{name}/{version}/{path}" + }, + }, + // scope the VSCode instance to Kestra File System Provider (defined in Kestra VSCode extension) + folderUri: { + scheme: "kestra", + path: "/" + queryParams["namespace"] + }, + commands: [ + { + id: "custom.postMessage", + handler: async (data) => { + window.parent.postMessage(data, "*") + } + } + ], + additionalBuiltinExtensions: [ + { + scheme: "https", + authority: "openvsxorg.blob.core.windows.net", + path: "/resources/PROxZIMA/sweetdracula/1.0.9/extension" + }, + { + scheme: window.location.protocol.replace(":", ""), + authority: window.location.host, + path: KESTRA_UI_PATH + "yamlExt" + }, + { + scheme: "https", + authority: "openvsxorg.blob.core.windows.net", + path: "/resources/kestra-io/kestra/0.1.4/extension" + } + ], + "linkProtectionTrustedDomains": [ + "https://open-vsx.org", + "https://openvsxorg.blob.core.windows.net" + ], + enabledExtensions: [ + // to handle dark theme + "proxzima.sweetdracula", + // to apply Kestra's flow validation schema + "redhat.vscode-yaml", + "kestra-io.kestra" + ], + configurationDefaults: { + "files.autoSave": "off", + "editor.fontSize": 12, + "workbench.colorTheme": THEME === "dark" ? "Sweet Dracula" : "Default Light Modern", + "workbench.startupEditor": "readme", + // "workbench.activityBar.visible": false, + // provide the Kestra root URL to extension + "kestra.api.url": KESTRA_API_URL + } +}; \ No newline at end of file diff --git a/ui/public/vscode.html b/ui/public/vscode.html index 05e20cfa10..bda5bfd2f8 100644 --- a/ui/public/vscode.html +++ b/ui/public/vscode.html @@ -25,76 +25,7 @@ <script src="./vscode-web/dist/out/vs/loader.js"></script> <script src="./vscode-web/dist/out/vs/webPackagePaths.js"></script> -<script> - Object.keys(window.webPackagePaths).map(function (key) { - window.webPackagePaths[key] = `${window.location.origin}${KESTRA_UI_PATH}vscode-web/dist/node_modules/${key}/${window.webPackagePaths[key]}`; - }); - - require.config({ - baseUrl: `${window.location.origin}${KESTRA_UI_PATH}vscode-web/dist/out`, - recordStats: true, - trustedTypesPolicy: window.trustedTypes?.createPolicy("amdLoader", { - createScriptURL(value) { - return value; - } - }), - paths: window.webPackagePaths - }); - - // used to configure VSCode startup - window.product = { - productConfiguration: { - nameShort: "Kestra VSCode", - nameLong: "Kestra VSCode", - // configure the open sx marketplace - "extensionsGallery": { - "serviceUrl": "https://open-vsx.org/vscode/gallery", - "itemUrl": "https://open-vsx.org/vscode/item", - "resourceUrlTemplate": "https://openvsxorg.blob.core.windows.net/resources/{publisher}/{name}/{version}/{path}" - }, - }, - // scope the VSCode instance to Kestra File System Provider (defined in Kestra VSCode extension) - folderUri: { - scheme: "kestra", - path: "/" + queryParams["namespace"] - }, - additionalBuiltinExtensions: [ - { - scheme: "https", - authority: "openvsxorg.blob.core.windows.net", - path: "/resources/PROxZIMA/sweetdracula/1.0.9/extension" - }, - { - scheme: window.location.protocol.replace(":", ""), - authority: window.location.host, - path: KESTRA_UI_PATH + "yamlExt" - }, - { - scheme: "https", - authority: "openvsxorg.blob.core.windows.net", - path: "/resources/kestra-io/kestra/0.1.2/extension" - }, - ], - "linkProtectionTrustedDomains": [ - "https://open-vsx.org", - "https://openvsxorg.blob.core.windows.net" - ], - enabledExtensions: [ - // to handle dark theme - "proxzima.sweetdracula", - // to apply Kestra's flow validation schema - "redhat.vscode-yaml", - "kestra-io.kestra" - ], - configurationDefaults: { - "files.autoSave": "off", - "editor.fontSize": 12, - "workbench.colorTheme": THEME === "dark" ? "Sweet Dracula" : "Default Light Modern", - // provide the Kestra root URL to extension - "kestra.api.url": KESTRA_API_URL - } - }; -</script> +<script src="./init.js"></script> <script src="./vscode-web/dist/out/vs/workbench/workbench.web.main.nls.js"></script> <script src="./vscode-web/dist/out/vs/workbench/workbench.web.main.js"></script> <script src="./vscode-web/dist/out/vs/code/browser/workbench/workbench.js"></script> diff --git a/ui/src/components/flows/TriggerFlow.vue b/ui/src/components/flows/TriggerFlow.vue index 02e60fc699..1616d13d40 100644 --- a/ui/src/components/flows/TriggerFlow.vue +++ b/ui/src/components/flows/TriggerFlow.vue @@ -103,6 +103,18 @@ this.onClick(); } } + }, + flowId: { + handler() { + if ((!this.flow || this.flow.id !== this.flowId) && this.flowId && this.namespace) { + this.$store + .dispatch("flow/loadFlow", { + id: this.flowId, + namespace: this.namespace, + allowDeleted: true + }); + } + } } } }; diff --git a/ui/src/components/namespace/Editor.vue b/ui/src/components/namespace/Editor.vue index e95578e052..714b4d7a93 100644 --- a/ui/src/components/namespace/Editor.vue +++ b/ui/src/components/namespace/Editor.vue @@ -1,10 +1,18 @@ <template> <top-nav-bar :title="routeInfo.title"> <template #additional-right> - <namespace-select class="fit-content" + <namespace-select + class="fit-content" data-type="flow" - :value="namespace" - @update:model-value="namespaceUpdate"/> + :value="namespace" + @update:model-value="namespaceUpdate" + allow-create + /> + <trigger-flow + :disabled="!flow" + :flow-id="flow" + :namespace="namespace" + /> </template> </top-nav-bar> <iframe @@ -13,6 +21,7 @@ v-if="namespace" class="vscode-editor" :src="vscodeIndexUrl" + ref="vscodeIde" /> <div v-else class="m-3 mw-100"> <el-alert type="info" :closable="false"> @@ -24,6 +33,7 @@ <script setup> import NamespaceSelect from "./NamespaceSelect.vue"; import TopNavBar from "../layout/TopNavBar.vue"; + import TriggerFlow from "../flows/TriggerFlow.vue"; </script> <script> @@ -40,8 +50,43 @@ namespace } }); + }, + handleTabsDirty(tabs) { + // Add tabs not saved + this.tabsNotSaved = this.tabsNotSaved.concat(tabs.dirty) + // Removed tabs closed + this.tabsNotSaved = this.tabsNotSaved.filter(e => !tabs.closed.includes(e)) + console.log(this.tabsNotSaved) + this.$store.dispatch("core/isUnsaved", this.tabsNotSaved.length > 0); + } + }, + data() { + return { + flow: null, + tabsNotSaved: [] } }, + created() { + const namespace = localStorage.getItem("defaultNamespace"); + if (namespace) { + this.namespaceUpdate(namespace); + } + }, + mounted() { + window.addEventListener("message", (event) => { + const message = event.data; + if (message.type === "kestra.tabFileChanged") { + const path = `/${this.namespace}/_flows/`; + if (message.filePath.path.startsWith(path)) { + this.flow = message.filePath.path.split(path)[1].replace(".yml", ""); + } else { + this.flow = null; + } + } else if (message.type === "kestra.tabsChanged") { + this.handleTabsDirty(message.tabs); + } + }); + }, computed: { routeInfo() { return { diff --git a/ui/src/components/namespace/NamespaceSelect.vue b/ui/src/components/namespace/NamespaceSelect.vue index 072d28180e..d090ccccb6 100644 --- a/ui/src/components/namespace/NamespaceSelect.vue +++ b/ui/src/components/namespace/NamespaceSelect.vue @@ -6,6 +6,7 @@ :placeholder="$t('Select namespace')" :persistent="false" filterable + :allow-create="allowCreate" > <el-option v-for="item in groupedNamespaces" @@ -29,6 +30,10 @@ value: { type: String, default: undefined + }, + allowCreate: { + type: Boolean, + default: false } }, emits: ["update:modelValue"], diff --git a/ui/src/utils/submitTask.js b/ui/src/utils/submitTask.js index 604512a71b..8d4f425ee4 100644 --- a/ui/src/utils/submitTask.js +++ b/ui/src/utils/submitTask.js @@ -38,7 +38,8 @@ export const executeTask = (submitor, flow, values, options) => { .then(response => { submitor.$store.commit("execution/setExecution", response.data) if (options.redirect) { - submitor.$router.push({name: "executions/update", params: {...{namespace: response.data.namespace, flowId: response.data.flowId, id: response.data.id}, ...{tab: "gantt"}}}) + const resolved = submitor.$router.resolve({name: "executions/update", params: {...{namespace: response.data.namespace, flowId: response.data.flowId, id: response.data.id}, ...{tab: "gantt"}}}) + window.open(resolved.href, "_blank") } return response.data;
null
train
val
2023-10-31T10:23:34
"2023-10-18T16:11:43Z"
anna-geller
train
kestra-io/kestra/2374_2414
kestra-io/kestra
kestra-io/kestra/2374
kestra-io/kestra/2414
[ "keyword_pr_to_issue" ]
690dcbd467f43e1115328ffe84d711414c17afa8
b1e0fad6b431323c8c9d1bfd30e5044c77a9d34c
[]
[]
"2023-10-31T08:34:45Z"
[]
Warn about unsaved changes in Namespace Files
[ "ui/public/vscode.html", "ui/src/components/flows/TriggerFlow.vue", "ui/src/components/namespace/Editor.vue", "ui/src/components/namespace/NamespaceSelect.vue", "ui/src/utils/submitTask.js" ]
[ "ui/public/init.js", "ui/public/vscode.html", "ui/src/components/flows/TriggerFlow.vue", "ui/src/components/namespace/Editor.vue", "ui/src/components/namespace/NamespaceSelect.vue", "ui/src/utils/submitTask.js" ]
[]
diff --git a/ui/public/init.js b/ui/public/init.js new file mode 100644 index 0000000000..0dec0bef22 --- /dev/null +++ b/ui/public/init.js @@ -0,0 +1,78 @@ +Object.keys(window.webPackagePaths).map(function (key) { + window.webPackagePaths[key] = `${window.location.origin}${KESTRA_UI_PATH}vscode-web/dist/node_modules/${key}/${window.webPackagePaths[key]}`; +}); + +require.config({ + baseUrl: `${window.location.origin}${KESTRA_UI_PATH}vscode-web/dist/out`, + recordStats: true, + trustedTypesPolicy: window.trustedTypes?.createPolicy("amdLoader", { + createScriptURL(value) { + return value; + } + }), + paths: window.webPackagePaths +}); + +// used to configure VSCode startup +window.product = { + productConfiguration: { + nameShort: "Kestra VSCode", + nameLong: "Kestra VSCode", + // configure the open sx marketplace + "extensionsGallery": { + "serviceUrl": "https://open-vsx.org/vscode/gallery", + "itemUrl": "https://open-vsx.org/vscode/item", + "resourceUrlTemplate": "https://openvsxorg.blob.core.windows.net/resources/{publisher}/{name}/{version}/{path}" + }, + }, + // scope the VSCode instance to Kestra File System Provider (defined in Kestra VSCode extension) + folderUri: { + scheme: "kestra", + path: "/" + queryParams["namespace"] + }, + commands: [ + { + id: "custom.postMessage", + handler: async (data) => { + window.parent.postMessage(data, "*") + } + } + ], + additionalBuiltinExtensions: [ + { + scheme: "https", + authority: "openvsxorg.blob.core.windows.net", + path: "/resources/PROxZIMA/sweetdracula/1.0.9/extension" + }, + { + scheme: window.location.protocol.replace(":", ""), + authority: window.location.host, + path: KESTRA_UI_PATH + "yamlExt" + }, + { + scheme: "https", + authority: "openvsxorg.blob.core.windows.net", + path: "/resources/kestra-io/kestra/0.1.4/extension" + } + ], + "linkProtectionTrustedDomains": [ + "https://open-vsx.org", + "https://openvsxorg.blob.core.windows.net" + ], + enabledExtensions: [ + // to handle dark theme + "proxzima.sweetdracula", + // to apply Kestra's flow validation schema + "redhat.vscode-yaml", + "kestra-io.kestra" + ], + configurationDefaults: { + "files.autoSave": "off", + "editor.fontSize": 12, + "workbench.colorTheme": THEME === "dark" ? "Sweet Dracula" : "Default Light Modern", + "workbench.startupEditor": "readme", + // "workbench.activityBar.visible": false, + // provide the Kestra root URL to extension + "kestra.api.url": KESTRA_API_URL + } +}; \ No newline at end of file diff --git a/ui/public/vscode.html b/ui/public/vscode.html index 05e20cfa10..bda5bfd2f8 100644 --- a/ui/public/vscode.html +++ b/ui/public/vscode.html @@ -25,76 +25,7 @@ <script src="./vscode-web/dist/out/vs/loader.js"></script> <script src="./vscode-web/dist/out/vs/webPackagePaths.js"></script> -<script> - Object.keys(window.webPackagePaths).map(function (key) { - window.webPackagePaths[key] = `${window.location.origin}${KESTRA_UI_PATH}vscode-web/dist/node_modules/${key}/${window.webPackagePaths[key]}`; - }); - - require.config({ - baseUrl: `${window.location.origin}${KESTRA_UI_PATH}vscode-web/dist/out`, - recordStats: true, - trustedTypesPolicy: window.trustedTypes?.createPolicy("amdLoader", { - createScriptURL(value) { - return value; - } - }), - paths: window.webPackagePaths - }); - - // used to configure VSCode startup - window.product = { - productConfiguration: { - nameShort: "Kestra VSCode", - nameLong: "Kestra VSCode", - // configure the open sx marketplace - "extensionsGallery": { - "serviceUrl": "https://open-vsx.org/vscode/gallery", - "itemUrl": "https://open-vsx.org/vscode/item", - "resourceUrlTemplate": "https://openvsxorg.blob.core.windows.net/resources/{publisher}/{name}/{version}/{path}" - }, - }, - // scope the VSCode instance to Kestra File System Provider (defined in Kestra VSCode extension) - folderUri: { - scheme: "kestra", - path: "/" + queryParams["namespace"] - }, - additionalBuiltinExtensions: [ - { - scheme: "https", - authority: "openvsxorg.blob.core.windows.net", - path: "/resources/PROxZIMA/sweetdracula/1.0.9/extension" - }, - { - scheme: window.location.protocol.replace(":", ""), - authority: window.location.host, - path: KESTRA_UI_PATH + "yamlExt" - }, - { - scheme: "https", - authority: "openvsxorg.blob.core.windows.net", - path: "/resources/kestra-io/kestra/0.1.2/extension" - }, - ], - "linkProtectionTrustedDomains": [ - "https://open-vsx.org", - "https://openvsxorg.blob.core.windows.net" - ], - enabledExtensions: [ - // to handle dark theme - "proxzima.sweetdracula", - // to apply Kestra's flow validation schema - "redhat.vscode-yaml", - "kestra-io.kestra" - ], - configurationDefaults: { - "files.autoSave": "off", - "editor.fontSize": 12, - "workbench.colorTheme": THEME === "dark" ? "Sweet Dracula" : "Default Light Modern", - // provide the Kestra root URL to extension - "kestra.api.url": KESTRA_API_URL - } - }; -</script> +<script src="./init.js"></script> <script src="./vscode-web/dist/out/vs/workbench/workbench.web.main.nls.js"></script> <script src="./vscode-web/dist/out/vs/workbench/workbench.web.main.js"></script> <script src="./vscode-web/dist/out/vs/code/browser/workbench/workbench.js"></script> diff --git a/ui/src/components/flows/TriggerFlow.vue b/ui/src/components/flows/TriggerFlow.vue index 02e60fc699..1616d13d40 100644 --- a/ui/src/components/flows/TriggerFlow.vue +++ b/ui/src/components/flows/TriggerFlow.vue @@ -103,6 +103,18 @@ this.onClick(); } } + }, + flowId: { + handler() { + if ((!this.flow || this.flow.id !== this.flowId) && this.flowId && this.namespace) { + this.$store + .dispatch("flow/loadFlow", { + id: this.flowId, + namespace: this.namespace, + allowDeleted: true + }); + } + } } } }; diff --git a/ui/src/components/namespace/Editor.vue b/ui/src/components/namespace/Editor.vue index e95578e052..714b4d7a93 100644 --- a/ui/src/components/namespace/Editor.vue +++ b/ui/src/components/namespace/Editor.vue @@ -1,10 +1,18 @@ <template> <top-nav-bar :title="routeInfo.title"> <template #additional-right> - <namespace-select class="fit-content" + <namespace-select + class="fit-content" data-type="flow" - :value="namespace" - @update:model-value="namespaceUpdate"/> + :value="namespace" + @update:model-value="namespaceUpdate" + allow-create + /> + <trigger-flow + :disabled="!flow" + :flow-id="flow" + :namespace="namespace" + /> </template> </top-nav-bar> <iframe @@ -13,6 +21,7 @@ v-if="namespace" class="vscode-editor" :src="vscodeIndexUrl" + ref="vscodeIde" /> <div v-else class="m-3 mw-100"> <el-alert type="info" :closable="false"> @@ -24,6 +33,7 @@ <script setup> import NamespaceSelect from "./NamespaceSelect.vue"; import TopNavBar from "../layout/TopNavBar.vue"; + import TriggerFlow from "../flows/TriggerFlow.vue"; </script> <script> @@ -40,8 +50,43 @@ namespace } }); + }, + handleTabsDirty(tabs) { + // Add tabs not saved + this.tabsNotSaved = this.tabsNotSaved.concat(tabs.dirty) + // Removed tabs closed + this.tabsNotSaved = this.tabsNotSaved.filter(e => !tabs.closed.includes(e)) + console.log(this.tabsNotSaved) + this.$store.dispatch("core/isUnsaved", this.tabsNotSaved.length > 0); + } + }, + data() { + return { + flow: null, + tabsNotSaved: [] } }, + created() { + const namespace = localStorage.getItem("defaultNamespace"); + if (namespace) { + this.namespaceUpdate(namespace); + } + }, + mounted() { + window.addEventListener("message", (event) => { + const message = event.data; + if (message.type === "kestra.tabFileChanged") { + const path = `/${this.namespace}/_flows/`; + if (message.filePath.path.startsWith(path)) { + this.flow = message.filePath.path.split(path)[1].replace(".yml", ""); + } else { + this.flow = null; + } + } else if (message.type === "kestra.tabsChanged") { + this.handleTabsDirty(message.tabs); + } + }); + }, computed: { routeInfo() { return { diff --git a/ui/src/components/namespace/NamespaceSelect.vue b/ui/src/components/namespace/NamespaceSelect.vue index 072d28180e..d090ccccb6 100644 --- a/ui/src/components/namespace/NamespaceSelect.vue +++ b/ui/src/components/namespace/NamespaceSelect.vue @@ -6,6 +6,7 @@ :placeholder="$t('Select namespace')" :persistent="false" filterable + :allow-create="allowCreate" > <el-option v-for="item in groupedNamespaces" @@ -29,6 +30,10 @@ value: { type: String, default: undefined + }, + allowCreate: { + type: Boolean, + default: false } }, emits: ["update:modelValue"], diff --git a/ui/src/utils/submitTask.js b/ui/src/utils/submitTask.js index 604512a71b..8d4f425ee4 100644 --- a/ui/src/utils/submitTask.js +++ b/ui/src/utils/submitTask.js @@ -38,7 +38,8 @@ export const executeTask = (submitor, flow, values, options) => { .then(response => { submitor.$store.commit("execution/setExecution", response.data) if (options.redirect) { - submitor.$router.push({name: "executions/update", params: {...{namespace: response.data.namespace, flowId: response.data.flowId, id: response.data.id}, ...{tab: "gantt"}}}) + const resolved = submitor.$router.resolve({name: "executions/update", params: {...{namespace: response.data.namespace, flowId: response.data.flowId, id: response.data.id}, ...{tab: "gantt"}}}) + window.open(resolved.href, "_blank") } return response.data;
null
train
val
2023-10-31T10:23:34
"2023-10-23T16:15:03Z"
anna-geller
train
kestra-io/kestra/2357_2415
kestra-io/kestra
kestra-io/kestra/2357
kestra-io/kestra/2415
[ "keyword_pr_to_issue" ]
595e66663ef6e6f3931fc53a2c4532fc9fd76350
ba7f5061150bdf5f8c03478f58c0c1466867e405
[ "Hi,\r\nwe have very simple Python scripts, like for example parsing the date or creating an s3 bucket path from different variables and we are trying to do that in python script and run it as a PROCESS. The only thing that we are missing is the Kestra library on our runtime environment and we would expect that Kestra will have Kestra in it environment." ]
[]
"2023-10-31T09:06:30Z"
[ "enhancement" ]
Add the Python Kestra library to the Kestra full image
### Feature description The Kestra full image installs binaries (python3 python3-venv python-is-python3 nodejs npm curl zip unzip) and all plugins but not the Kestra library. User that wanted to use the Python tasks with the PROCESS runner will need to install it (or use a custom Kestra image). If possible, we should install the Kestra Python library inside the Kestra full image.
[ ".github/workflows/main.yml", "Dockerfile" ]
[ ".github/workflows/main.yml", "Dockerfile" ]
[]
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bd2ca58288..1ae79840ec 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -157,6 +157,7 @@ jobs: - name: "" plugins: "" packages: "" + python-libs: "" - name: "-full" plugins: >- io.kestra.plugin:plugin-airbyte:LATEST @@ -231,7 +232,8 @@ jobs: io.kestra.storage:storage-gcs:LATEST io.kestra.storage:storage-minio:LATEST io.kestra.storage:storage-s3:LATEST - packages: python3 python3-venv python-is-python3 nodejs npm curl zip unzip + packages: python3 python3-venv python-is-python3 python3-pip nodejs npm curl zip unzip + python-libs: kestra steps: - uses: actions/checkout@v4 @@ -293,6 +295,7 @@ jobs: build-args: | KESTRA_PLUGINS=${{ steps.vars.outputs.plugins }} APT_PACKAGES=${{ matrix.image.packages }} + PYTHON_LIBRARIES=${{ matrix.image.python-libs }} maven: name: Publish to Maven diff --git a/Dockerfile b/Dockerfile index dfdfdbacc7..d332ef30a7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,6 +2,7 @@ FROM eclipse-temurin:17-jre ARG KESTRA_PLUGINS="" ARG APT_PACKAGES="" +ARG PYTHON_LIBRARIES="" WORKDIR /app @@ -16,6 +17,7 @@ RUN apt-get update -y && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* /var/tmp/* /tmp/* && \ if [ -n "${KESTRA_PLUGINS}" ]; then /app/kestra plugins install ${KESTRA_PLUGINS} && rm -rf /tmp/*; fi && \ + if [ -n "${PYTHON_LIBRARIES}" ]; then pip install ${PYTHON_LIBRARIES}; fi && \ chown -R kestra:kestra /app USER kestra
null
train
val
2023-10-30T18:26:42
"2023-10-20T12:41:36Z"
loicmathieu
train
kestra-io/kestra/2245_2416
kestra-io/kestra
kestra-io/kestra/2245
kestra-io/kestra/2416
[ "keyword_pr_to_issue" ]
a570cc675b669b9b07a737b8379e0369ff6a542b
916a3b30b5924e52dfbfb2c428a2c00dfe527f9d
[ "You could add a `logLevel` on task and trigger that will limit the output of every log emitted by the task, by default, we will keep the `TRACE` level" ]
[]
"2023-10-31T13:49:33Z"
[ "enhancement" ]
Add `logLevel` Enum property on the core task
### Feature description Hi, Usually, all tasks are generating logs. These logs are collected by Kestra to be display in the UI. By default, this is the ideal behavior But sometimes we don't want that logs are collected for example when we have - huge log size (that use a lot of space in the Kestra DB for nothing and that are not readable in Kestra UI) - sensible information in the logs So it would be interesting if we should be able to disable the collect of the log by Kestra.
[ "core/src/main/java/io/kestra/core/models/executions/TaskRun.java", "core/src/main/java/io/kestra/core/models/tasks/Task.java", "core/src/main/java/io/kestra/core/models/triggers/AbstractTrigger.java", "core/src/main/java/io/kestra/core/runners/RunContext.java", "core/src/main/java/io/kestra/core/runners/RunContextLogger.java" ]
[ "core/src/main/java/io/kestra/core/models/executions/TaskRun.java", "core/src/main/java/io/kestra/core/models/tasks/Task.java", "core/src/main/java/io/kestra/core/models/triggers/AbstractTrigger.java", "core/src/main/java/io/kestra/core/runners/RunContext.java", "core/src/main/java/io/kestra/core/runners/RunContextLogger.java" ]
[ "core/src/test/java/io/kestra/core/runners/ExecutionServiceTest.java", "core/src/test/java/io/kestra/core/runners/RunContextTest.java", "core/src/test/java/io/kestra/core/serializers/YamlFlowParserTest.java", "core/src/test/resources/flows/valids/logs.yaml", "jdbc/src/test/java/io/kestra/jdbc/runner/JdbcRunnerTest.java", "webserver/src/test/java/io/kestra/webserver/controllers/PluginControllerTest.java" ]
diff --git a/core/src/main/java/io/kestra/core/models/executions/TaskRun.java b/core/src/main/java/io/kestra/core/models/executions/TaskRun.java index 43abe06476..5f61bdb787 100644 --- a/core/src/main/java/io/kestra/core/models/executions/TaskRun.java +++ b/core/src/main/java/io/kestra/core/models/executions/TaskRun.java @@ -9,6 +9,7 @@ import io.kestra.core.models.flows.State; import io.kestra.core.models.tasks.ResolvedTask; import io.kestra.core.utils.IdUtils; +import org.slf4j.event.Level; import java.util.ArrayList; import java.util.Collections; diff --git a/core/src/main/java/io/kestra/core/models/tasks/Task.java b/core/src/main/java/io/kestra/core/models/tasks/Task.java index fc64c825f7..a571cea4ec 100644 --- a/core/src/main/java/io/kestra/core/models/tasks/Task.java +++ b/core/src/main/java/io/kestra/core/models/tasks/Task.java @@ -13,6 +13,7 @@ import lombok.Getter; import lombok.NoArgsConstructor; import lombok.experimental.SuperBuilder; +import org.slf4j.event.Level; import java.time.Duration; import java.util.Optional; @@ -53,6 +54,8 @@ abstract public class Task { @Valid private WorkerGroup workerGroup; + private Level logLevel; + public Optional<Task> findById(String id) { if (this.getId().equals(id)) { return Optional.of(this); diff --git a/core/src/main/java/io/kestra/core/models/triggers/AbstractTrigger.java b/core/src/main/java/io/kestra/core/models/triggers/AbstractTrigger.java index caf232712f..b7c917b4de 100644 --- a/core/src/main/java/io/kestra/core/models/triggers/AbstractTrigger.java +++ b/core/src/main/java/io/kestra/core/models/triggers/AbstractTrigger.java @@ -11,6 +11,7 @@ import lombok.Getter; import lombok.NoArgsConstructor; import lombok.experimental.SuperBuilder; +import org.slf4j.event.Level; import java.util.List; import javax.validation.Valid; @@ -52,4 +53,6 @@ abstract public class AbstractTrigger { @Valid private WorkerGroup workerGroup; + + private Level minLogLevel; } diff --git a/core/src/main/java/io/kestra/core/runners/RunContext.java b/core/src/main/java/io/kestra/core/runners/RunContext.java index 51cf36ad28..5dbd5577de 100644 --- a/core/src/main/java/io/kestra/core/runners/RunContext.java +++ b/core/src/main/java/io/kestra/core/runners/RunContext.java @@ -83,7 +83,7 @@ public RunContext(ApplicationContext applicationContext, Flow flow, Execution ex public RunContext(ApplicationContext applicationContext, Flow flow, Task task, Execution execution, TaskRun taskRun) { this.initBean(applicationContext); this.initContext(flow, task, execution, taskRun); - this.initLogger(taskRun); + this.initLogger(taskRun, task); } /** @@ -136,13 +136,14 @@ private void initContext(Flow flow, Task task, Execution execution, TaskRun task } @SuppressWarnings("unchecked") - private void initLogger(TaskRun taskRun) { + private void initLogger(TaskRun taskRun, Task task) { this.runContextLogger = new RunContextLogger( applicationContext.findBean( QueueInterface.class, Qualifiers.byName(QueueFactoryInterface.WORKERTASKLOG_NAMED) ).orElseThrow(), - LogEntry.of(taskRun) + LogEntry.of(taskRun), + task.getLogLevel() ); } @@ -153,7 +154,8 @@ private void initLogger(Execution execution) { QueueInterface.class, Qualifiers.byName(QueueFactoryInterface.WORKERTASKLOG_NAMED) ).orElseThrow(), - LogEntry.of(execution) + LogEntry.of(execution), + null ); } @@ -164,7 +166,8 @@ private void initLogger(TriggerContext triggerContext, AbstractTrigger trigger) QueueInterface.class, Qualifiers.byName(QueueFactoryInterface.WORKERTASKLOG_NAMED) ).orElseThrow(), - LogEntry.of(triggerContext, trigger) + LogEntry.of(triggerContext, trigger), + trigger.getMinLogLevel() ); } @@ -175,7 +178,8 @@ private void initLogger(Flow flow, AbstractTrigger trigger) { QueueInterface.class, Qualifiers.byName(QueueFactoryInterface.WORKERTASKLOG_NAMED) ).orElseThrow(), - LogEntry.of(flow, trigger) + LogEntry.of(flow, trigger), + trigger.getMinLogLevel() ); } @@ -406,7 +410,7 @@ public RunContext forScheduler(TriggerContext triggerContext, AbstractTrigger tr public RunContext forWorker(ApplicationContext applicationContext, WorkerTask workerTask) { this.initBean(applicationContext); - this.initLogger(workerTask.getTaskRun()); + this.initLogger(workerTask.getTaskRun(), workerTask.getTask()); Map<String, Object> clone = new HashMap<>(this.variables); diff --git a/core/src/main/java/io/kestra/core/runners/RunContextLogger.java b/core/src/main/java/io/kestra/core/runners/RunContextLogger.java index 3c29b9f678..3cd4e497ee 100644 --- a/core/src/main/java/io/kestra/core/runners/RunContextLogger.java +++ b/core/src/main/java/io/kestra/core/runners/RunContextLogger.java @@ -26,13 +26,14 @@ public class RunContextLogger { private Logger logger; private QueueInterface<LogEntry> logQueue; private LogEntry logEntry; + private Level loglevel; @VisibleForTesting public RunContextLogger() { this.loggerName = "unit-test"; } - public RunContextLogger(QueueInterface<LogEntry> logQueue, LogEntry logEntry) { + public RunContextLogger(QueueInterface<LogEntry> logQueue, LogEntry logEntry, org.slf4j.event.Level loglevel) { if (logEntry.getExecutionId() != null) { this.loggerName = "flow." + logEntry.getFlowId() + "." + logEntry.getExecutionId() + (logEntry.getTaskRunId() != null ? "." + logEntry.getTaskRunId() : ""); } else { @@ -40,6 +41,7 @@ public RunContextLogger(QueueInterface<LogEntry> logQueue, LogEntry logEntry) { } this.logQueue = logQueue; this.logEntry = logEntry; + this.loglevel = loglevel == null ? Level.TRACE : Level.toLevel(loglevel.toString()); } private static List<LogEntry> logEntry(ILoggingEvent event, String message, org.slf4j.event.Level level, LogEntry logEntry) { @@ -138,7 +140,7 @@ public org.slf4j.Logger logger() { forwardAppender.start(); this.logger.addAppender(forwardAppender); - this.logger.setLevel(Level.TRACE); + this.logger.setLevel(this.loglevel); this.logger.setAdditive(true); }
diff --git a/core/src/test/java/io/kestra/core/runners/ExecutionServiceTest.java b/core/src/test/java/io/kestra/core/runners/ExecutionServiceTest.java index 8dae4c0cdb..7b541cfba2 100644 --- a/core/src/test/java/io/kestra/core/runners/ExecutionServiceTest.java +++ b/core/src/test/java/io/kestra/core/runners/ExecutionServiceTest.java @@ -128,7 +128,7 @@ void restartDynamic() throws Exception { @Test void replayFromBeginning() throws Exception { Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "logs"); - assertThat(execution.getTaskRunList(), hasSize(3)); + assertThat(execution.getTaskRunList(), hasSize(4)); assertThat(execution.getState().getCurrent(), is(State.Type.SUCCESS)); Execution restart = executionService.replay(execution, null, null); @@ -148,7 +148,7 @@ void replayFromBeginning() throws Exception { @Test void replaySimple() throws Exception { Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "logs"); - assertThat(execution.getTaskRunList(), hasSize(3)); + assertThat(execution.getTaskRunList(), hasSize(4)); assertThat(execution.getState().getCurrent(), is(State.Type.SUCCESS)); Execution restart = executionService.replay(execution, execution.getTaskRunList().get(1).getId(), null); diff --git a/core/src/test/java/io/kestra/core/runners/RunContextTest.java b/core/src/test/java/io/kestra/core/runners/RunContextTest.java index 3e8901ac26..076ed9b4a7 100644 --- a/core/src/test/java/io/kestra/core/runners/RunContextTest.java +++ b/core/src/test/java/io/kestra/core/runners/RunContextTest.java @@ -58,7 +58,7 @@ void logs() throws TimeoutException { Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "logs"); - assertThat(execution.getTaskRunList(), hasSize(3)); + assertThat(execution.getTaskRunList(), hasSize(4)); matchingLog = TestsUtils.awaitLog(logs, log -> Objects.equals(log.getTaskRunId(), execution.getTaskRunList().get(0).getId())); assertThat(matchingLog, notNullValue()); @@ -74,6 +74,9 @@ void logs() throws TimeoutException { assertThat(matchingLog, notNullValue()); assertThat(matchingLog.getLevel(), is(Level.ERROR)); assertThat(matchingLog.getMessage(), is("third logs")); + + matchingLog = TestsUtils.awaitLog(logs, log -> Objects.equals(log.getTaskRunId(), execution.getTaskRunList().get(3).getId())); + assertThat(matchingLog, nullValue()); } @Test diff --git a/core/src/test/java/io/kestra/core/serializers/YamlFlowParserTest.java b/core/src/test/java/io/kestra/core/serializers/YamlFlowParserTest.java index 2b5d36caa9..6e7f44ca2f 100644 --- a/core/src/test/java/io/kestra/core/serializers/YamlFlowParserTest.java +++ b/core/src/test/java/io/kestra/core/serializers/YamlFlowParserTest.java @@ -212,7 +212,7 @@ void invalidProperty() { () -> this.parse("flows/invalids/invalid-property.yaml") ); - assertThat(exception.getMessage(), is("Unrecognized field \"invalid\" (class io.kestra.core.tasks.debugs.Return), not marked as ignorable (8 known properties: \"timeout\", \"format\", \"retry\", \"type\", \"id\", \"description\", \"workerGroup\", \"disabled\"])")); + assertThat(exception.getMessage(), is("Unrecognized field \"invalid\" (class io.kestra.core.tasks.debugs.Return), not marked as ignorable (9 known properties: \"logLevel\", \"timeout\", \"format\", \"retry\", \"type\", \"id\", \"description\", \"workerGroup\", \"disabled\"])")); assertThat(exception.getConstraintViolations().size(), is(1)); assertThat(exception.getConstraintViolations().iterator().next().getPropertyPath().toString(), is("io.kestra.core.models.flows.Flow[\"tasks\"]->java.util.ArrayList[0]->io.kestra.core.tasks.debugs.Return[\"invalid\"]")); } diff --git a/core/src/test/resources/flows/valids/logs.yaml b/core/src/test/resources/flows/valids/logs.yaml index 139c3d5a9f..c14322e777 100644 --- a/core/src/test/resources/flows/valids/logs.yaml +++ b/core/src/test/resources/flows/valids/logs.yaml @@ -23,3 +23,8 @@ tasks: type: io.kestra.core.tasks.log.Log message: third {{flow.id}} level: ERROR +- id: t4 + type: io.kestra.core.tasks.log.Log + message: fourth {{task.id}} + level: TRACE + logLevel: INFO \ No newline at end of file diff --git a/jdbc/src/test/java/io/kestra/jdbc/runner/JdbcRunnerTest.java b/jdbc/src/test/java/io/kestra/jdbc/runner/JdbcRunnerTest.java index c31275faf4..ccdbd13d6a 100644 --- a/jdbc/src/test/java/io/kestra/jdbc/runner/JdbcRunnerTest.java +++ b/jdbc/src/test/java/io/kestra/jdbc/runner/JdbcRunnerTest.java @@ -102,7 +102,7 @@ void full() throws TimeoutException, QueueException { void logs() throws TimeoutException { Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "logs", null, null, Duration.ofSeconds(60)); - assertThat(execution.getTaskRunList(), hasSize(3)); + assertThat(execution.getTaskRunList(), hasSize(4)); } @Test diff --git a/webserver/src/test/java/io/kestra/webserver/controllers/PluginControllerTest.java b/webserver/src/test/java/io/kestra/webserver/controllers/PluginControllerTest.java index b325ed2780..d3fac39c0a 100644 --- a/webserver/src/test/java/io/kestra/webserver/controllers/PluginControllerTest.java +++ b/webserver/src/test/java/io/kestra/webserver/controllers/PluginControllerTest.java @@ -138,7 +138,7 @@ void taskWithBase() throws URISyntaxException { Map<String, Map<String, Object>> properties = (Map<String, Map<String, Object>>) doc.getSchema().getProperties().get("properties"); assertThat(doc.getMarkdown(), containsString("io.kestra.plugin.templates.ExampleTask")); - assertThat(properties.size(), is(11)); + assertThat(properties.size(), is(12)); assertThat(properties.get("id").size(), is(4)); assertThat(((Map<String, Object>) doc.getSchema().getOutputs().get("properties")).size(), is(1)); });
train
val
2023-11-03T09:33:04
"2023-10-06T14:20:20Z"
aurelienWls
train