-
Notifications
You must be signed in to change notification settings - Fork 66
fix (utils) : [CRW-8603] Use slice of string instead of apimachinery Set to merge events #1711
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
fix (utils) : [CRW-8603] Use slice of string instead of apimachinery Set to merge events #1711
Conversation
bb4d09e
to
eca2e36
Compare
…Set to merge events We were previously using apimachinery Set that is internally based on Map, an unordered data structure. Due to this we were losing the original insertion order defined in the devfile while merging it, List() call returns the elements in non-deterministic order, as it internally ranges over the map. Use string slice to preserve insertion order of all event types. Signed-off-by: Rohan Kumar <rohaan@redhat.com>
eca2e36
to
9923538
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: akurinnoy, Jdubrick, michael-valdron, rohanKanojia, thepetk The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Thanks a lot for the review! Is it possible to merge it? |
…Set to merge events (devfile#1711) We were previously using apimachinery Set that is internally based on Map, an unordered data structure. Due to this we were losing the original insertion order defined in the devfile while merging it, List() call returns the elements in non-deterministic order, as it internally ranges over the map. Use string slice to preserve insertion order of all event types. Signed-off-by: Rohan Kumar <rohaan@redhat.com>
Description of Changes
We were previously using apimachinery Set that is internally based on Map, an unordered data structure. Due to this we were losing the original insertion order defined in the devfile while merging it,
List()
call returns the elements in non-deterministic order, as it internally ranges over the map.Use string slice to preserve insertion order of all event types.
Related Issue(s)
https://issues.redhat.com/browse/CRW-8603
Acceptance Criteria
Testing and documentation do not need to be complete in order for this PR to be approved. However, tracking issues must be opened for missing testing/documentation.
New testing and documentation issues can be opened under
devfile/api/issues
.You can check the respective criteria below if either of the following is true:
If criteria is left unchecked please provide an explanation why.
Unit/Functional tests
QE Integration test
Documentation
Client Impact
Tests Performed
I have added unit tests that verify that insertion order is preserved.
Before these changes, for a devfile that contained postStart events in order like this:
After merging, this order was altered like this:
After making these changes, order is preserved (check unit test files)
How To Test
You can run unit tests that are added for this change.
Notes To Reviewer
This change is required for a fix in devworkspace operator for an issue where postStart event order is different than specified: https://issues.redhat.com/browse/CRW-8603
While debugging, I found that we're using MergeDevWorkspaceTemplateSpec and it seems to be changing the order of
postStart
events.