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

Improve logic used to detect changes in Deployment resource #46

Merged

Conversation

jgwest
Copy link
Member

@jgwest jgwest commented Mar 7, 2024

What does this PR do / why we need it:

  • Deployment changes

    • Update the logic used to detect Deployment changes. See comment on 'normalizeDeployment' for details. TL;DR: to normalize a Deployment for comparison, we create a new Deployment struct, and copy in only the fields we care about (from the un-normalized Deployment).
    • Unit tests for these changes
  • Related E2E test changes:

    • Move operator e2e test logic into shell script
    • Operator E2E tests should fail if the operator itself has unexpected ERROR log entries: added a check for this
    • Ability to set SKIP_RUN_STEP to skip starting operator in upstream rollouts test
    • Improve logic of 'waitAndGetE2EFileContents' to now check last 50 lines, rather than last 1 line

Have you updated the necessary documentation?

  • Documentation update is required by this PR, and has been updated.

Which issue(s) this PR fixes:
Fixes #47

How to test changes / Special notes to the reviewer:

@jgwest jgwest marked this pull request as draft March 7, 2024 23:59
@jgwest jgwest force-pushed the improve-deployment-update-logic-mar-2024 branch from 6285ada to f82834e Compare March 11, 2024 14:35
@jgwest jgwest changed the title Draft: Improve logic used to detect changes in Deployment resource Improve logic used to detect changes in Deployment resource Mar 11, 2024
@jgwest jgwest marked this pull request as ready for review March 11, 2024 14:53
Copy link
Collaborator

@jopit jopit left a comment

Choose a reason for hiding this comment

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

Looks good, just a few minor things.

- name: Run tests
run: |
set -o pipefail
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think removing the set -o pipefail will mean that even if the tests fail, the tee command will succeed and so the overall command will have a zero exit status and therefore the failure won't be reflected in the status of the github action (i.e. the action will be seen as successful)

return appsv1.Deployment{}, fmt.Errorf("incorrect volume mounts")
}

// String slices need to be converted to nil, because reflect.DeepEqual(nil, []string{}) is false, despite being functionally the same, here.
Copy link
Collaborator

Choose a reason for hiding this comment

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

The code is actually ensuring that any nil string slice is converted to an empty string slice, so the comment probably should be changed to say something like

// Nil string slices need to be converted to empty string slices, because  reflect.DeepEqual(nil, []string{}) is false, despite being functionally the same, here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch!

By("ensuring the reconcileRolloutsDeployment will detect and revert the change")
{
By("calling reconcileRolloutsDeployment to create a default Deployment")
reconciledDepl := appsv1.Deployment{
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not a big deal, but it might make things a bit easier to understand if reconciledDepl was called expectedDepl instead.

for _, line := range fileLines[lineIndexStart:] {
// example: DONE 6 runs, 144 tests, 6 skipped, 47 failures in 2279.668s
if strings.HasPrefix(line, "DONE ") || time.Now().After(expireTime) {
fmt.Println("E2E tests file is complete:", line)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe it would be better to have a separate message for when we're exiting due to a timeout?

@jgwest jgwest force-pushed the improve-deployment-update-logic-mar-2024 branch from 0d317f8 to 4221242 Compare March 13, 2024 06:49
@jgwest
Copy link
Member Author

jgwest commented Mar 13, 2024

👍 to all review comments, and all addressed. Thanks @jopit!

@jgwest jgwest merged commit 0100dce into argoproj-labs:main Mar 13, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants