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

Add a programmer friendly code to Persistent Task Assignments (#53711) #110013

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nmesot
Copy link

@nmesot nmesot commented Jun 20, 2024

When a task can not be assigned, the ptask framework is able to message back a reason in form of a string. This feature also started to be used for successful assignments, for example in the task that ads a health node.

Callers might need to interpret an assignment failure to e.g. return a HTTP status code. A string is hard to interpret and therefore not suitable.

Therefore, the Assignment can now take a programmer friendly code. It is still possible to provide a freetext String, as some context dependent information (e.g. nodeId) can not be stored in an Enum. Because some tasks provided multiple reasons for being unable to assign (all concatenated in a string), it is possible to provide multiple codes.

This commit also adapted the serialization and deserialization methods for backwards compatibility.

Closes #53711

@elasticsearchmachine elasticsearchmachine added needs:triage Requires assignment of a team area label v8.15.0 external-contributor Pull request authored by a developer outside the Elasticsearch team labels Jun 20, 2024
@kingherc kingherc added :Distributed/Task Management Issues for anything around the Tasks API - both persistent and node level. Team:Distributed Meta label for distributed team labels Jun 21, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-distributed (Team:Distributed)

@elasticsearchmachine elasticsearchmachine removed the needs:triage Requires assignment of a team area label label Jun 21, 2024
@nmesot nmesot marked this pull request as draft July 7, 2024 18:33
@nmesot
Copy link
Author

nmesot commented Jul 7, 2024

One test failed once after 10 runs, I will update this PR after I figure out why

@nmesot nmesot force-pushed the feat/improve-persistent-task branch from 6cd602c to 825e643 Compare July 11, 2024 11:02
…c#53711)

When a task can not be assigned, the ptask framework is able to message back a reason in form of a string. This feature is also used for successful assignments, for example in the task that ads a health node.

Callers might need to interpret an assignment failure to e.g. return a HTTP status code. A string is hard to interpret and therefore not suitable.

Therefore, the Assignment can now take a programmer friendly code. It is still possible to provide a freetext String, as some context dependent information (e.g. nodeId) can not be stored in an Enum. Because some tasks provided multiple reasons for being unable to assign (all concatenated in a string), it is possible to provide multiple codes.

This commit also adapted the serialization and deserialization methods for backwards compatibility.

Closes elastic#53711
@nmesot nmesot force-pushed the feat/improve-persistent-task branch from 825e643 to 1925187 Compare July 11, 2024 16:15
@nmesot nmesot marked this pull request as ready for review July 11, 2024 16:50
@nmesot
Copy link
Author

nmesot commented Jul 11, 2024

I managed to fix the broken test, PR is ready for review. Pinging @elastic/es-distributed (Team:Distributed)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Distributed/Task Management Issues for anything around the Tasks API - both persistent and node level. external-contributor Pull request authored by a developer outside the Elasticsearch team Team:Distributed Meta label for distributed team v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve reason for PersistentTasksCustomMetaData.Assignment
4 participants