-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Setup intermediate_pki_path on secondary #8001
Setup intermediate_pki_path on secondary #8001
Conversation
Make sure to mount vault backend for intermediate_pki_path on secondary dc.
@@ -231,7 +244,22 @@ func (v *VaultProvider) SetIntermediate(intermediatePEM, rootPEM string) error { | |||
|
|||
// ActiveIntermediate returns the current intermediate certificate. | |||
func (v *VaultProvider) ActiveIntermediate() (string, error) { | |||
return v.getCA(v.config.IntermediatePKIPath) | |||
if err := v.setupIntermediatePKIPath(); err != 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.
Not sure it is the best way to make sure everything is setup in here, but I didn't find a better place. Using setupIntermediatePKIPathDone
as a guard to make sure the setup is only done once.
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.
LGTM
} | ||
} | ||
v.setupIntermediatePKIPathDone = true |
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.
Does this need a mutex or is it only accessed by a single goroutine?
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.
There are two different flows.
The leader in the primary dc calls this the first time in initializeRootCA
while holding caProviderReconfigurationLock
:
consul/agent/consul/leader_connect.go
Lines 262 to 266 in ad7fb3a
// Also create the intermediate CA, which is the one that actually signs leaf certs | |
interPEM, err := provider.GenerateIntermediate() | |
if err != nil { | |
return fmt.Errorf("error generating intermediate cert: %v", err) | |
} |
The leader in a secondary dc calls this the first time in initializeSecondaryCA
while holding caProviderReconfigurationLock
:
consul/agent/consul/leader_connect.go
Lines 346 to 349 in ad7fb3a
activeIntermediate, err := provider.ActiveIntermediate() | |
if err != nil { | |
return err | |
} |
An error will prevent the initialization to move on and and it will be retried later. I think this is safe to do. However I considered using atomic
just to make sure we don't shoot our foot in case the other code changes.
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.
Sounds good.
Make sure to mount vault backend for intermediate_pki_path on secondary dc.
Make sure to mount vault backend for intermediate_pki_path on secondary dc.
Hi @i0rek Would it be possible to bring this in for beta3? cc @mikemorris |
Make sure to mount vault backend for intermediate_pki_path on secondary
dc.