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

Aggregate ServiceExport conflict conditions #1624

Merged
merged 3 commits into from
Aug 29, 2024

Conversation

tpantelis
Copy link
Contributor

@tpantelis tpantelis commented Aug 22, 2024

It's possible there could be more than one concurrent conflict however the MCS API only defines one conflict type so a second conflict would overwrite the first. We could define our own conflict types but the MCS spec does specifically reference the ServiceExportConflict type, defined as "Conflict", in the conflict resolution section. It doesn't mention what the behavior should be if there's more than one conflict.

To represent multiple conflicts, we can still use the ServiceExportConflict type but aggregate the differing condition reasons and messages. For the Reason field, join multiple reasons separated by a comma and, for the Message field, join with a new line. When a particular conflict is resolved, remove its reason and message. When there's no more conflicts, ie Reason is empty, set the condition Status to False.

See individual commits for details.

@submariner-bot
Copy link
Contributor

🤖 Created branch: z_pr1624/tpantelis/conflict_condition
🚀 Full E2E won't run until the "ready-to-test" label is applied. I will add it automatically once the PR has 2 approvals, or you can add it manually.

Changed UpdateStatusConditions and RemoveStatusCondition
public to facilitate.

Signed-off-by: Tom Pantelis <[email protected]>
It's possible there could be more than one concurrent conflict
however the MCS API only defines one conflict type so a second
conflict would overwrite the first. We could define our own
conflict types but the MCS spec does specifically reference the
ServiceExportConflict type, defined as "Conflict", in the conflict
resolution section. It doesn't mention what the behavior should
be if there's more than one conflict.

To represent multiple conflicts, We can still use the
ServiceExportConflict type but aggregate the differing condition
reasons and messages. For the Reason field, join multiple reasons
separated by a comma and, for the Message field, join with a new line.
When a particular conflict is resolved, remove it's reason and message.
When there's no more conflicts, ie Reason is empty, set the condition
Status to False.

Signed-off-by: Tom Pantelis <[email protected]>
This was used to remove the Conflict condition when the conflict
was resolved but we now update the the condition as there can be
multiple conflicts. In general, the pattern is to update the
condition status rather than removing a condition.

Signed-off-by: Tom Pantelis <[email protected]>
index := goslices.Index(reasons, *from.Reason)
if index >= 0 {
if from.Status == corev1.ConditionTrue {
if index < len(messages) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When will this be true? Message is already present but not at end? Means this code is updating the message for this reason in case it changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

index should always be < len(messages) b/c it's size mirrors reason. This is just a sanity check.

If you're referring to if from.Status == corev1.ConditionTrue, yes, if the reason already exists but the message changed.

@submariner-bot submariner-bot added the ready-to-test When a PR is ready for full E2E testing label Aug 29, 2024
@tpantelis tpantelis merged commit 3844280 into submariner-io:devel Aug 29, 2024
26 checks passed
@submariner-bot
Copy link
Contributor

🤖 Closed branches: [z_pr1624/tpantelis/conflict_condition]

@tpantelis tpantelis deleted the conflict_condition branch August 30, 2024 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-test When a PR is ready for full E2E testing
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants