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

Add ability for control servers to broadcast to hubs via gRPC #40

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

evanphx
Copy link
Contributor

@evanphx evanphx commented Dec 9, 2020

These changes add a gRPC server within the hubs that is accessed from the control instances. The control instances are aware of the hubs and their addresses from consul, and use a internal authentication token to control access.

Copy link
Contributor

@krantzinator krantzinator left a comment

Choose a reason for hiding this comment

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

This was fun to read, so that's a good sign 😄
Just a take-it-or-leave-it nit and a question for my own understanding.

pkg/control/broadcast.go Outdated Show resolved Hide resolved
return pb.NewHubServicesClient(cc), nil
}

g.mu.Lock()
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need to use both RLock and Lock here in sequence? I guess this relates to your comment about there being a race condition -- does the race condition require we use a Lock on our second check instead of an RLock (is there a difference in behavior that contributes to a race condition), or is the reasoning "we need to do a Write, but first we have to check that Read didn't flake out on us previously, and that check has to be within the same Lock as the eventual write-action"?

Copy link

Choose a reason for hiding this comment

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

I think of it like a table lock in SQL. RLock locks all threads from reading, then sets the current target. Such that everyone behind this current Dial call has to wait to read until it is done. Only then can hypothetically the next person in line read the value, or not to see that it was changed by the person ahead of them. But this is in the weeds for me.

Copy link
Contributor

@mitchellh mitchellh left a comment

Choose a reason for hiding this comment

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

Code looks good. As a disclaimer, I didn't dive too deep into fully understanding the logic, but I don't see anything that stands out to me. Generally speaking I feel like there could be more comments and in particular every exported function should probably be commented.

pkg/control/broadcast.go Outdated Show resolved Hide resolved
@evanphx
Copy link
Contributor Author

evanphx commented Dec 10, 2020

@mitchellh I'll take another pass at the comments. I've been working on having more of those docs on the first pass but missed some.

@trilom
Copy link

trilom commented Jan 12, 2021

This project in many ways is the last link I needed. This PR is another last link to keep that chain in a gRPC ring, thank you for your work here.

@hashicorp-cla
Copy link

hashicorp-cla commented Mar 12, 2022

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants