Skip to content

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

Merged
merged 1 commit into from
May 7, 2025

Conversation

rohanKanojia
Copy link
Contributor

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:

  • There is a separate tracking issue opened and that issue is linked in this PR.
  • Testing/documentation updates are contained within this PR.

If criteria is left unchecked please provide an explanation why.

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:

    - "event-one"
    - "event-two"
    - "event-three"

After merging, this order was altered like this:

    - "event-one"
    - "event-three"
    - "event-two"
    - "init-che-code-command"

After making these changes, order is preserved (check unit test files)

   - "event-one"
    - "event-two"
    - "event-three"
    - "init-che-code-command"

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.

@rohanKanojia rohanKanojia marked this pull request as ready for review May 6, 2025 09:14
@rohanKanojia rohanKanojia requested review from AObuchow, dkwon17 and a team as code owners May 6, 2025 09:14
…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>
Copy link
Member

@michael-valdron michael-valdron left a comment

Choose a reason for hiding this comment

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

/lgtm

Built successfully and testing passed:
Screenshot From 2025-05-06 15-57-00
Screenshot From 2025-05-06 15-51-19
Screenshot From 2025-05-06 15-54-48

Copy link
Contributor

@thepetk thepetk left a comment

Choose a reason for hiding this comment

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

/lgtm

Copy link

openshift-ci bot commented May 7, 2025

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@rohanKanojia
Copy link
Contributor Author

Thanks a lot for the review! Is it possible to merge it?

@michael-valdron michael-valdron merged commit 3024466 into devfile:main May 7, 2025
8 checks passed
@rohanKanojia rohanKanojia deleted the pr/issue-crw-8603 branch May 8, 2025 03:59
michael-valdron pushed a commit to michael-valdron/devfile-api that referenced this pull request May 14, 2025
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants