Skip to content
This repository was archived by the owner on Jul 11, 2023. It is now read-only.

remove unused code paths #4758

Merged
merged 1 commit into from
May 25, 2022
Merged

Conversation

steeling
Copy link
Contributor

@steeling steeling commented May 24, 2022

Remove dead code.

This PR additionally removed unreachable code paths in pkg/envoy/sds/response.go. By stripping out these unreachable code paths, it became apparent that we could further collapse several functions into one.

Copy link
Member

@shashankram shashankram left a comment

Choose a reason for hiding this comment

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

This change seems to be doing more than simply removing dead code. Did you mean to include this refactor, and if yes could you update the commit title and description. Also, note that the CI is failing on this change.

@steeling
Copy link
Contributor Author

This change seems to be doing more than simply removing dead code. Did you mean to include this refactor, and if yes could you update the commit title and description. Also, note that the CI is failing on this change.

Updated comment

Signed-off-by: Sean Teeling <[email protected]>
@codecov-commenter
Copy link

codecov-commenter commented May 25, 2022

Codecov Report

Merging #4758 (bc6f81f) into main (ecc4e67) will decrease coverage by 0.02%.
The diff coverage is 60.00%.

@@            Coverage Diff             @@
##             main    #4758      +/-   ##
==========================================
- Coverage   68.96%   68.94%   -0.03%     
==========================================
  Files         227      226       -1     
  Lines       16454    16374      -80     
==========================================
- Hits        11348    11289      -59     
+ Misses       5054     5033      -21     
  Partials       52       52              
Flag Coverage Δ
unittests 68.94% <60.00%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/catalog/outbound_traffic_policies.go 94.47% <ø> (-0.20%) ⬇️
pkg/envoy/sds/response.go 87.23% <60.00%> (+9.85%) ⬆️
pkg/messaging/workqueue.go 89.28% <0.00%> (-10.72%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ecc4e67...bc6f81f. Read the comment docs.

@nojnhuh
Copy link
Contributor

nojnhuh commented May 25, 2022

@steeling Could you explain in a bit more detail why these code paths are unreachable? That's not immediately obvious to me.

@steeling
Copy link
Contributor Author

@steeling Could you explain in a bit more detail why these code paths are unreachable? That's not immediately obvious to me.

Sure thing!

The changed method is in getRootCert, which is only called in getSDSSecrets, and only in the case where the type is RootCert for inbound or outbound.

Now getServiceIdentitiesFromCert is only called in getRootCert, but it occurs after line154, which returns early if it is an Inbound cert, leaving only the case for outbound.

Yet getServiceIdentitiesFromCert, has a case for Inbound, which is unreachable.

After removing that case, the function is brought down to a few lines, and is better placed directly within getRootCert

Copy link
Contributor

@nojnhuh nojnhuh left a comment

Choose a reason for hiding this comment

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

Thanks, that makes sense!

@nojnhuh nojnhuh merged commit 27ab5a7 into openservicemesh:main May 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants