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

Keep track of changes to the upstreams for a service within a batch on the Agent. #309

Merged
merged 9 commits into from
Jun 13, 2019

Conversation

baconmania
Copy link
Contributor

No description provided.

Optional<BaragonService> oldService;

if (maybeRequest.isPresent()) {
oldService = getOldService(maybeRequest.get());
Copy link
Member

Choose a reason for hiding this comment

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

should we also save the old service instead of having to look it up again in processRequest?

serviceId = request.getLoadBalancerService().getServiceId();
existingUpstreamsForThisService = existingUpstreams.get(serviceId);
if (existingUpstreamsForThisService == null || existingUpstreamsForThisService.isEmpty()) {
existingUpstreamsForThisService = new ArrayList<>(stateDatastore.getUpstreams(serviceId));
Copy link
Member

Choose a reason for hiding this comment

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

why are we resetting from the state datastore here? If it's empty wouldn't we assume that it's because we already looked it up and it was empty earlier?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is mostly to cover the case where we had an exception grabbing the upstreams the first time, for whatever reason: https://github.com/HubSpot/Baragon/pull/309/files/c8b670ab071ebc5d957307fdb5e8373560e21452#diff-2829d66da65c086b8c7d4fbb094196d3R100

Although I suppose we could just throw a RuntimeException there instead, which is what we do elsewhere in the code when try/catching around stateDatastore.getUpstreams().

@baconmania baconmania added the qa label Jun 12, 2019
@baconmania baconmania merged commit 044bc5c into master Jun 13, 2019
@baconmania baconmania deleted the track-upstream-changes-in-agent branch June 13, 2019 20:10
@baconmania baconmania added this to the 0.9.0 milestone Jun 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants