spring-attic / spring-cloud-task-app-starters-composed-task-runner

Task Starter for executing composed tasks
Apache License 2.0
14 stars 20 forks source link

Miss parent-execution-id when launched by schedules on k8s #105

Open WeekiXu opened 4 years ago

WeekiXu commented 4 years ago

composedtask started by schedules on k8s do not have the param executionid.

and parent-execution-id comes from the executionid param when start the composedtaskrunner.

composedtaskrunner images: springcloudtask/composedtaskrunner-task:2.1.3.RELEASE params in k8s container

--spring.datasource.username=xxxx
--spring.datasource.url=jdbc:mysql://mysql:3306/server
--spring.datasource.driverClassName=com.mysql.jdbc.Driver
--dataflowServerUri=http://scdf-server:80
--spring.cloud.task.name=task-debug-1
--graph=task-debug-1-task-debug && task-debug-1-task-debug3
--spring.datasource.password=xxxx

can we add a TaskListener in ComposedTaskRunnerStepFactory to set executionid generated by SimpleTaskLauncher when SpringBoot startup

    @Autowired
    private TaskProperties taskProperties;

    @BeforeTask
    public void beforeComposedTask(
        TaskExecution taskExecution) {
        if (taskProperties.getExecutionid() == null) {
            taskProperties.setExecutionid(taskExecution.getExecutionId());
        }
    }
WeekiXu commented 4 years ago

I set executionid to taskProperties in ComposedTaskRunnerConfiguration, it works. but failed in 2 tests ComposedTaskRunnerConfigurationNoPropertiesTests and ComposedTaskRunnerConfigurationWithPropertiesTests

   @BeforeTask
    public void beforeComposedTask(
        TaskExecution taskExecution) {
        if (taskProperties.getExecutionid() == null
            && taskExecution.getExecutionId() > 0) {
            taskProperties.setExecutionid(taskExecution.getExecutionId());
            logger.info(
                "set executionid to taskProperties from taskExecution.getExecutionId()");
        }
    }
sabbyanandan commented 4 years ago

Hi. @WeekiXu. Thanks for attempting to use and extend the available options. We will review it on our side to see what and if anything is missing.