-
Notifications
You must be signed in to change notification settings - Fork 52
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
Removal of caching for service networks #391
Conversation
Pull Request Test Coverage Report for Build 6126663228
💛 - Coveralls |
…ding nil checks for result
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can address comments in following PR. The deleteServiceNetwork function that return string stands out.
if snInfo == nil { | ||
return fmt.Errorf("Service network %s for account %s not found", snName, m.cloud.Config().AccountId) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should look again into returning nil as not found later. We may find that there is no code that tolerates "not found" result. That will save us from doing double error checking - for err and for nil.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. Currently there were only two places, but as I do more resource types I'll see which pattern makes more sense.
|
||
// TODO need to check if service network is referenced by gateway in other namespace | ||
gwList := &gateway_api.GatewayList{} | ||
s.Client.List(context.TODO(), gwList) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: use context from function argument - ctx, not context.TODO()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a straight refactor-to-method, but happy to update when I see these.
|
||
err := s.serviceNetworkManager.Delete(ctx, resServiceNetwork.Spec.Name) | ||
if err != nil { | ||
return LATTICE_RETRY |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: return or log original error. For example:
return fmt.Errorf("%w: %w", RetryErr, err)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was also a straight copy/paste/new method refactor, so for now I'll just add a log line. I'm hesitant to change too much of the flow logic at once.
@@ -117,7 +81,39 @@ func (s *serviceNetworkSynthesizer) synthesizeTriggeredGateways(ctx context.Cont | |||
} else { | |||
return nil | |||
} | |||
} | |||
|
|||
func (s *serviceNetworkSynthesizer) deleteServiceNetwork(ctx context.Context, resServiceNetwork *latticemodel.ServiceNetwork) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should return error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't disagree, but I was trying to minimize logic changes in the refactor. Previously, this code only set a return string.
What type of PR is this?
cleanup
Which issue does this PR fix:
n/a
What does this PR do / Why do we need it:
This is the first of what will be several refactors to eliminate the local
LatticeDataStore
cache. Currently, use of the data store results in inconsistent behaviour across the codebase and encourages side-effect programming as many decisions are made based on the presence of or state of the data in the cache rather than using the Lattice APIs as the source of truth. Longer term, this approach should reduce the surface area for consistency bugs or race conditions.This PR eliminates use of the data store for service network operations, instead calling the VPC Lattice API directly. This increases call volume to the
ListServiceNetworks
API, but centralizes this logic in a way that should be more reliably cacheable in future.Additional changes include minor refactoring for readability, typos, or consistency in naming.
Testing done on this change:
Unit tests added and some modified or removed as appropriate.
Ran e2e tests.
Automation added to e2e:
No new e2e tests
Will this PR introduce any new dependencies?:
No
Will this break upgrades or downgrades. Has updating a running cluster been tested?:
n/a
Does this PR introduce any user-facing change?:
No
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.