Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task table prefix is not resolved correctly in CTR #5854

Open
klopfdreh opened this issue Jun 27, 2024 · 1 comment
Open

Task table prefix is not resolved correctly in CTR #5854

klopfdreh opened this issue Jun 27, 2024 · 1 comment
Assignees
Milestone

Comments

@klopfdreh
Copy link
Contributor

Description:
Currently we are receiving a lot of warnings when starting a composed task. During our migration we found out that the lookup of the table prefix is broken as the relax binding rules of spring are resolving the property TABLEPREFIX to tableprefix instead of tablePrefix

See:

{"timestamp":"2024-06-27T10:17:41.283+0200","level":"WARN","thread":"main","logger":"org.springframework.cloud.dataflow.composedtaskrunner.ComposedTaskRunnerConfiguration","message":"Cannot find app.s3-uploader-app.spring.cloud.task.tablePrefix in {...., app.s3-uploader-app.spring.cloud.task.tableprefix=BOOT3_TASK_,....}

Release versions:
2.11.2

Custom apps:
N/A

Steps to reproduce:
Just launch a task with the new CTR

Screenshots:
N/A

Additional context:
N/A

Solution:

Replace code:

logger.debug("addTaskExplorer:{}", taskName);
String propertyName = String.format("app.%s.spring.cloud.task.tablePrefix", taskName);
String prefix = properties.getComposedTaskAppProperties().get(propertyName);
if (prefix == null) {
	prefix = env.getProperty(propertyName);
}
if (prefix != null) {
	TaskExecutionDaoFactoryBean factoryBean = new MultiSchemaTaskExecutionDaoFactoryBean(dataSource, prefix);
	logger.debug("taskExplorerContainer:adding:{}:{}", taskName, prefix);
	explorers.put(taskName, new SimpleTaskExplorer(factoryBean));
} else {
	logger.warn("Cannot find {} in {} ", propertyName, properties.getComposedTaskAppProperties());
}

With:

logger.debug("addTaskExplorer:{}", taskName);

List<String> propertyNames = Stream.of("app.%s.spring.cloud.task.tablePrefix",
        "app.%s.spring.cloud.task.table-prefix",
        "app.%s.spring.cloud.task.tableprefix")
    .map(propertyName -> String.format(propertyName, taskName)).toList();

String prefix = propertyNames.stream()
    .map(propertyName -> {
        String prefixOfComposedTaskProperties = properties.getComposedTaskAppProperties().get(propertyName);
        return prefixOfComposedTaskProperties == null ? env.getProperty(propertyName) : prefixOfComposedTaskProperties;
    })
    .filter(Objects::nonNull)
    .findFirst().orElse(null);

if (prefix != null) {
	TaskExecutionDaoFactoryBean factoryBean = new MultiSchemaTaskExecutionDaoFactoryBean(dataSource, prefix);
	logger.debug("taskExplorerContainer:adding:{}:{}", taskName, prefix);
	explorers.put(taskName, new SimpleTaskExplorer(factoryBean));
} else {
	logger.warn("Cannot find {} in {} ", propertyNames, properties.getComposedTaskAppProperties());
}

in the CTR. You might need to downport it if you don't want to use Java 17. 😁

@github-actions github-actions bot added the status/need-triage Team needs to triage and take a first look label Jun 27, 2024
@cppwfs cppwfs removed the status/need-triage Team needs to triage and take a first look label Jul 1, 2024
@cppwfs cppwfs added this to the 2.11.4 milestone Jul 1, 2024
@cppwfs cppwfs self-assigned this Jul 1, 2024
@cppwfs cppwfs modified the milestones: 2.11.4, 2.11.5 Jul 12, 2024
@onobc
Copy link
Contributor

onobc commented Aug 1, 2024

TODO Close once we decide if it is to port forward to 3.0.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants