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

Fix deep copy and don't modify original state #919

Merged
merged 1 commit into from
Oct 10, 2019
Merged

Conversation

alenkacz
Copy link
Contributor

What this PR does / why we need it:
Fixes two issues:

  • we were using shallow copy and it was wrong because struct contains slices
  • we modified the original state in prepareKubernetesResources which worked exactly because the shallow copy was a wrong choice but it's not what we want to do

Copy link
Contributor

@zen-dog zen-dog left a comment

Choose a reason for hiding this comment

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

One nit, but otherwise 🚢

Comment on lines +147 to +150
if err == nil || newStatus == nil || newStatus.Status != v1alpha1.ErrorStatus || newStatus.Phases[0].Status != v1alpha1.ErrorStatus || newStatus.Phases[0].Steps[0].Status != v1alpha1.ErrorStatus {
t.Fatalf("Expecting to get an error with fatal error in status for error in using enhancer, got %w, %v", err, newStatus)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

wdyt:

Suggested change
if err == nil || newStatus == nil || newStatus.Status != v1alpha1.ErrorStatus || newStatus.Phases[0].Status != v1alpha1.ErrorStatus || newStatus.Phases[0].Steps[0].Status != v1alpha1.ErrorStatus {
t.Fatalf("Expecting to get an error with fatal error in status for error in using enhancer, got %w, %v", err, newStatus)
}
}
assert. NoError(t, err)
assert.Equal(t, newStatus.Phases[0].Status, v1alpha1.ErrorStatus, "Expected phase status to be an error")
assert.Equal(t, newStatus.Phases[0].Step[0].Status, v1alpha1.ErrorStatus, "Expected step status to be an error")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was trying to use pure go instead of asserts but I actually don't care here that much so ... sure :) we're using assert everywhere anyway

Copy link
Member

@kensipe kensipe left a comment

Choose a reason for hiding this comment

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

great work!

@kensipe kensipe merged commit 6827102 into master Oct 10, 2019
@kensipe kensipe deleted the av/deep-copu branch October 10, 2019 21:58
jbarrick-mesosphere pushed a commit that referenced this pull request Oct 17, 2019
* Introduce integration test for restart (#718)

This introduces and integration test that:
- creates instance
- waits for deploy on that instance is finished
- stops controller
- updates instance CRD in the meantime
- starts controller
- verifies update plan was run

This test was failing prior to the instance controller refactoring (the old controller logic was handling this wrong)

* Fix namespace handling for plan command (#925)

* Include CRDs in the -o yaml --dry-run (#923)

* go mod changes makes repo dirty.  this resolves that (#926)

* Fix deep copy and don't modify original state (#919)

* Fixes the release workflow for Docker images

* Attempt to fix 'TestCheckResourceIntegration' flaky test (#914)

* Do not use strategicmergepatch for CRDs (#936)

* Plan status should show last executed plan, not just active plan (#931)

* More consistent logging for install (#933)

* fixing repo merge by name bug (#938)

* Use built in isExists (#942)

* Make it possible to opt out of junit (#950)

* Maintainers is array, not object (#930)

* Handle already exists in flaky test (#941)

* Cleanup lastexecutedplan method to remove the flake (#949)

* Fix docs for instance name in install (#943)

* add namespace flag for kudo init (#903)

* Fix 'run_tests' script

* Use a shell script for E2E test commands

The script is similar to the one used for integration tests. This also
allows to not use JUnit output.

* Copy E2E test script into test container

* Fix permissions of E2E test script

* Distinguish between local and operator E2E tests

Tests in the 'test/e2e' folder are run as part of the E2E tests in addition
to the operator tests.
jbarrick-mesosphere added a commit that referenced this pull request Oct 17, 2019
fix make

docker privs

add go-junit-report

add docker CLI to test dockerfile

fix docker cli install

fix docker run command

fix docker

fix networking

remove CMD from dockerfile

E2E test additions (#958)

* Introduce integration test for restart (#718)

This introduces and integration test that:
- creates instance
- waits for deploy on that instance is finished
- stops controller
- updates instance CRD in the meantime
- starts controller
- verifies update plan was run

This test was failing prior to the instance controller refactoring (the old controller logic was handling this wrong)

* Fix namespace handling for plan command (#925)

* Include CRDs in the -o yaml --dry-run (#923)

* go mod changes makes repo dirty.  this resolves that (#926)

* Fix deep copy and don't modify original state (#919)

* Fixes the release workflow for Docker images

* Attempt to fix 'TestCheckResourceIntegration' flaky test (#914)

* Do not use strategicmergepatch for CRDs (#936)

* Plan status should show last executed plan, not just active plan (#931)

* More consistent logging for install (#933)

* fixing repo merge by name bug (#938)

* Use built in isExists (#942)

* Make it possible to opt out of junit (#950)

* Maintainers is array, not object (#930)

* Handle already exists in flaky test (#941)

* Cleanup lastexecutedplan method to remove the flake (#949)

* Fix docs for instance name in install (#943)

* add namespace flag for kudo init (#903)

* Fix 'run_tests' script

* Use a shell script for E2E test commands

The script is similar to the one used for integration tests. This also
allows to not use JUnit output.

* Copy E2E test script into test container

* Fix permissions of E2E test script

* Distinguish between local and operator E2E tests

Tests in the 'test/e2e' folder are run as part of the E2E tests in addition
to the operator tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants