CASMCMS-9623: session-completion: When processing tenant sessions, only consider components they own #561
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
CASMCMS-9623
Prior to this PR, the
session-completionoperator works as follows:For each running BOS session (call it
S):sessionfield has the name of sessionS.staged_state.sessionfield has the name of sessionSScomplete.This runs into problems in cases where two running sessions have the same name (which is permitted due to tenancy namespacing). The effect is that in such cases, none of these same-named sessions will be marked complete until ALL of them are ready to be marked complete.
This PR modifies the operator so it behaves like everywhere else in BOS regarding components and tenancy. Specifically, it adds a new step in between steps 1 and 2 above:
1.5. If S is on behalf of a tenant, query TAPMS for all components owned by that tenant, and intersect that with the list from step 1.
This completely solves the case for multiple running sessions with the same name PROVIDED THAT all of them are on behalf of tenants. If one of them is untenanted, then there are still problems. However, those issues are not limited to just this operator, and the situation is trickier. See CASMCMS-9622 for details.
This PR also refactors the operator slightly, mainly for ease of readability.
Testing
I tested this on mug. The test scenario was as follows:
First, I ran this test on mug without my fix applied. As expected, in step 5, neither session had been marked completed, but both had been marked completed in step 8.
I then tested with my fix applied. This time, in step 5, the session whose only component had been marked disabled was marked complete, and the other was still running. And in step 8, they both had been marked complete. This is the correct behavior.