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

Updates TransformXXX Functions in k8s pkg #26244

Merged
merged 1 commit into from Jun 27, 2023

Conversation

danehans
Copy link
Contributor

@danehans danehans commented Jun 15, 2023

Updates TransformXXX functions to not return an error if the provided and returned objects are the same type. Instead, the provided object is returned without any transformations.

Fixes: #26240

@danehans danehans requested a review from a team as a code owner June 15, 2023 00:09
@maintainer-s-little-helper maintainer-s-little-helper bot added the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Jun 15, 2023
@danehans
Copy link
Contributor Author

@odinuge since you commented in #25604, PTAL.

@tommyp1ckles tommyp1ckles added the kind/bug This is a bug in the Cilium logic. label Jun 15, 2023
Copy link
Member

@odinuge odinuge left a comment

Choose a reason for hiding this comment

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

Thanks! The code looks good to me!

Outside the scope of this PR; I think at some point it would be more useful to extraxct the godoc for these functions to a common description, so we avoid having it duplicated that much; given its so easy to miss one and get inconsistent comments - given they ~all implement the same thing, just for different types.

@joestringer joestringer added the release-note/misc This PR makes changes that have no direct user impact. label Jun 15, 2023
@maintainer-s-little-helper maintainer-s-little-helper bot removed the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Jun 15, 2023
@joestringer joestringer added the release-blocker/1.14 This issue will prevent the release of the next version of Cilium. label Jun 20, 2023
Copy link
Member

@giorio94 giorio94 left a comment

Choose a reason for hiding this comment

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

Thanks! /lgtm

@giorio94
Copy link
Member

Outside the scope of this PR; I think at some point it would be more useful to extraxct the godoc for these functions to a common description, so we avoid having it duplicated that much; given its so easy to miss one and get inconsistent comments - given they ~all implement the same thing, just for different types.

One step further might be to leverage generics to extract all the common logic, having only a single function as parameter which takes care of the actual conversion from the source to the destination type. This would reduce the overall code duplication and ensure consistency across all implementations. Related: #26367

@danehans
Copy link
Contributor Author

danehans commented Jun 21, 2023

@giorio94 thanks for the heads-up regarding #26367. Based on my comment, we may be able to close this PR and have #26367 fix #26240.

@giorio94
Copy link
Member

@giorio94 thanks for the heads-up regarding #26367. Based on my comment, we may be able to close this PR and have #26367 fix #26240.

The two PRs are currently addressing two separate aspects (this one tackles the transformation functions which do an actual type transformation, while #26367 the ones which don't mutate the object type).

@danehans
Copy link
Contributor Author

@giorio94 thanks for the clarification. I noticed the TransformToGeneric() func in #26367 and thought it was using generics for all transformation funcs. Back to your #26244 (comment), should I update this PR to use generics? Since #26240 is expected to be a release blocker, IMO it's better for this PR to introduce minimal changes and tackle the transition to generics in a separate PR that is merged after the release. Thoughts?

@giorio94
Copy link
Member

Back to your #26244 (comment), should I update this PR to use generics? Since #26240 is expected to be a release blocker, IMO it's better for this PR to introduce minimal changes and tackle the transition to generics in a separate PR that is merged after the release. Thoughts?

Yeah, I agree that it is better to drive this fix to completion and tackle more invasive refactorings in a followup.

@joestringer joestringer added release-note/bug This PR fixes an issue in a previous release of Cilium. and removed release-note/misc This PR makes changes that have no direct user impact. labels Jun 22, 2023
@joestringer
Copy link
Member

I re-ran K8sUpstreamNetConformance tests. From the sheer number of tests that failed, I don't quite understand whether some of the test failures could be related to the PR or the workflow is just a bit broken sometimes. :(

@tommyp1ckles
Copy link
Contributor

tommyp1ckles commented Jun 23, 2023

@danehans These changes look very reasonable to me, however I am still a bit confused as to how this situation might arise?

In the only usage of this transform function in the operator, the k8s client service interface returns a *v1.Service type.

@tommyp1ckles
Copy link
Contributor

/test

@danehans
Copy link
Contributor Author

@tommyp1ckles thanks for the review. I agree that TransformToK8sService() should only receive a k8s Service. However, this PR makes TransformToK8sService() and other transform functions backward compatible prior to the changes introduced by #25604. I also believe this PR follows the updated guidance for using TransformFunc. I can revert the TransformToK8sService() changes, especially since it's not being used as a TransformFunc, but I think it's safer to keep it as-is at this point of the release cycle and reassess after the release. Thoughts?

@danehans
Copy link
Contributor Author

@joestringer thanks for rerunning the K8sUpstreamNetConformance test. It's now passing but now the ConformanceEKS test is failing due to:

Error reading Cilium logs: error getting cilium-agent logs for kube-system/cilium-zxm7g: Get "https://192.168.116.242:10250/containerLogs/kube-system/cilium-zxm7g/cilium-agent?sinceTime=2023-06-23T06%3A13%3A12Z&timestamps=true": dial tcp 192.168.116.242:10250: i/o timeout
[=] Test [all-entities-deny]

I don't believe the ConformanceEKS test failures are related to this PR. Are you able to rerun this test?

Copy link
Contributor

@tommyp1ckles tommyp1ckles left a comment

Choose a reason for hiding this comment

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

@danehans Thanks for the clarification, lgtm

@joestringer
Copy link
Member

/test

@joestringer
Copy link
Member

I tried retriggering tests to kick off the gateway-conformance jobs, but I think actually the PR needs to be rebased against the latest main branch. @danehans could you rebase and retrigger the tests?

Updates TransformXXX functions to not return an error
if the provided object is the same type that is being
transformed to. Instead, the provided object is returned
without any transformations.

Signed-off-by: Daneyon Hansen <daneyon.hansen@solo.io>
@joestringer
Copy link
Member

/test

@joestringer joestringer merged commit c7f6fa5 into cilium:main Jun 27, 2023
65 checks passed
@maintainer-s-little-helper maintainer-s-little-helper bot added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Jun 27, 2023
@danehans danehans deleted the issue_26240 branch September 12, 2023 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug This is a bug in the Cilium logic. ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-blocker/1.14 This issue will prevent the release of the next version of Cilium. release-note/bug This PR fixes an issue in a previous release of Cilium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

K8s TransformXXX() Funcs Should Return SlimXXX Objects
5 participants