kestra-io / kestra

Infinitely scalable, event-driven, language-agnostic orchestration and scheduling platform to manage millions of workflows declaratively in code.
https://kestra.io
Apache License 2.0
7.04k stars 412 forks source link

Overriding the `kestra.tasks.defaults` config property doesn't work #2797

Open yuri1969 opened 6 months ago

yuri1969 commented 6 months ago

Explain the bug

As the docs state, a non-forced task defaults should be applied only when the task itself does not define such property.

This doesn't seem to apply on the io.kestra.plugin.scripts.shell.Commands's runner property.


Snippet of config file which defaults the runner type to PROCESS for the each shell.Commands task:

kestra:
  tasks:
    defaults:
      - type: "io.kestra.plugin.scripts.shell.Commands"
        values:
          runner: PROCESS

Flow overriding the cluster default runner type to DOCKER:

id: hello-world-from-docker
namespace: company.team

tasks:
  - id: use-docker
    type: io.kestra.plugin.scripts.shell.Commands
    runner: DOCKER # Use the Docker runner
    commands:
      - echo "Hello from Docker!"

Executing such flow still results in a local call - not using Docker.

It seems this issue might be related to #2364.

Environment Information

brian-mulier-p commented 4 months ago

I guess it's the same issue as https://github.com/kestra-io/kestra/issues/2364 See https://kestra-io.slack.com/archives/C04HTFM3VL6/p1709724906043089 but there is 2 issues to tackle:

TLDR: It's a hard subject with some major reworks which won't be tackled this release

loicmathieu commented 2 months ago

The issue is indeed tricky: task properties having a default value (like runner or pullPolicy using @Builder.Default in the Java code) cannot be set in a flow if there is a taskDefaults defined in the Kestra configuration file with a different value that the initial property.

It's also the case with taskDefaults defined at the flow level, for ex:

id: hello-world-from-docker
namespace: company.team

taskDefaults:
  - type: io.kestra.plugin.scripts.shell.Commands
    values:
      runner: PROCESS

tasks:
  - id: use-docker
    type: io.kestra.plugin.scripts.shell.Commands
    runner: DOCKER # Use the Docker runner
    commands:
      - echo "Hello from Docker!"

We will soon switch to serialization including NON_NULL but it's only the beginning of the story, it will not fully fix the issue.

loicmathieu commented 2 months ago

Same root cause as https://github.com/kestra-io/kestra/issues/2260