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

SYSENG-1822: panic when faking ResourceWithTag #419

Merged
merged 8 commits into from
Nov 25, 2024

Conversation

DrPsychick
Copy link
Contributor

@DrPsychick DrPsychick commented Nov 6, 2024

Description

Update: after digging deeper, it turns out that only the use of ResourceWithTag directly with the mock was an issue. To use tags in mock data, create Resource which has tags instead.

ResourceWithTag expects the identifier of a resource that is to be tagged. The tag itself has its own identifier which is returned in the response from the Engine.

This fixes the issue that a ResourceWithTag using the same identifier as a Resource will overwrite each other in mock data.

Additionally, this fixes two small issues with integration tests not passing.

Checklist

  • added release notes to Unreleased section in CHANGELOG.md, if user facing change

References

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Copy link

codeclimate bot commented Nov 6, 2024

Code Climate has analyzed commit 9dffea8 and detected 0 issues on this pull request.

View more on Code Climate.

@DrPsychick DrPsychick added integration_tests Used to approve the run of integration tests! bug Something isn't working labels Nov 6, 2024
@89Q12 89Q12 added integration_tests Used to approve the run of integration tests! and removed integration_tests Used to approve the run of integration tests! labels Nov 6, 2024
@DrPsychick DrPsychick added integration_tests Used to approve the run of integration tests! and removed integration_tests Used to approve the run of integration tests! labels Nov 7, 2024
@nachtjasmin nachtjasmin self-requested a review November 20, 2024 12:34
pkg/apis/lbaas/v1/e2e_connection_test.go Show resolved Hide resolved
pkg/vlan/integration_test.go Show resolved Hide resolved
@@ -91,7 +90,7 @@ func (rwt ResourceWithTag) EndpointURL(ctx context.Context) (*url.URL, error) {
return nil, fmt.Errorf("%w: ResourceWithTag only support Create and Destroy operations", api.ErrOperationNotSupported)
}

return url.Parse(fmt.Sprintf("/api/core/v1/resource.json/%v/tags/%v", rwt.Identifier, rwt.Tag))
return url.Parse(fmt.Sprintf("/api/core/v1/resource.json/%v/tags/%v", rwt.ResourceIdentifier, rwt.Tag))
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ This would break all existing usages for this resource!

The ticket you've created says:

When using the mock, this causes a resource object to be replaced in the mock data with the ResourceWithTag object because they have the same identifier.

It's clear that this is a problem inside the implementation of the mock, not of the actual API. There are two solutions to this problem:

  1. Either provide a way that sets the ResourceIdentifier in a backwards compatible way for existing users or
  2. fix the wrong behavior in the mock itself.

My preference would be option 2, but I'm fine with option 1 as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We agreed on adjusting the code so it is backwards compatible, using Identifier when no ResourceIdentifier is available.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for that feedback, I additionally found an issue with the tests and fixed it as well.

@DrPsychick DrPsychick force-pushed the SYSENG-1822-fix-ResourceWithTag branch from 9fa980b to 632101a Compare November 21, 2024 12:40
@DrPsychick DrPsychick changed the title SYSENG-1822: fix ResourceWithTag Identifier usage SYSENG-1822: panic when faking ResourceWithTag Nov 21, 2024
Copy link
Contributor

@nachtjasmin nachtjasmin left a comment

Choose a reason for hiding this comment

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

One minor suggestion but then we're ready to merge this! Thanks a lot!!

pkg/api/mock/mock_api_implementation.go Outdated Show resolved Hide resolved
@nachtjasmin nachtjasmin enabled auto-merge (squash) November 22, 2024 11:19
DrPsychick and others added 8 commits November 25, 2024 16:16
ResourceWithTag expects the identifier of a resource that is to be tagged. The tag itself has its own identifier which is returned in the response from the Engine.
Increase timeout for eventually to make lbaas tests pass.
Move DeferCleanup into BeforeAll for vlan e2e test.
Support using ResourceWithTag as before with 'Identifier.' Cover it with tests. Cover ListTags with a simple test.
Remove ListTags test as it is unrelated to this change.
Reverts commit e937d73. The source of the issue was faking ResourceWithTag instead of setting tags or tagging a resource.
@DrPsychick DrPsychick force-pushed the SYSENG-1822-fix-ResourceWithTag branch from 459fcf8 to 9dffea8 Compare November 25, 2024 15:16
@nachtjasmin nachtjasmin merged commit 46a1c40 into main Nov 25, 2024
9 checks passed
@nachtjasmin nachtjasmin deleted the SYSENG-1822-fix-ResourceWithTag branch November 25, 2024 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working integration_tests Used to approve the run of integration tests!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants