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

fix(kuma-cp): don't let CA requests for other meshes block generation (backport #6282) #6284

Merged
merged 1 commit into from
Mar 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions api/mesh/v1alpha1/mesh.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions api/mesh/v1alpha1/mesh.proto
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ message CertificateAuthorityBackend {
// RootChain defines settings related to CA root certificate chain.
message RootChain {
// Timeout on request for to CA for root certificate chain.
// If not specified, defaults to 10s.
google.protobuf.Duration requestTimeout = 1;
}

Expand Down
2 changes: 2 additions & 0 deletions docs/generated/resources/other_mesh.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
- `requestTimeout` (optional)

Timeout on request for to CA for root certificate chain.
If not specified, defaults to 10s.

- `tracing` (optional)

Expand Down Expand Up @@ -250,6 +251,7 @@
- `requestTimeout` (optional)

Timeout on request for to CA for root certificate chain.
If not specified, defaults to 10s.
## Networking

- `outbound` (optional)
Expand Down
12 changes: 7 additions & 5 deletions pkg/xds/secrets/ca_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,20 @@ type meshCaProvider struct {
latencyMetrics *prometheus.SummaryVec
}

// Get retrieves the root CA for a given backend with a default timeout of 10
// seconds.
func (s *meshCaProvider) Get(ctx context.Context, mesh *core_mesh.MeshResource) (*core_xds.CaSecret, []string, error) {
backend := mesh.GetEnabledCertificateAuthorityBackend()
if backend == nil {
return nil, nil, errors.New("CA backend is nil")
}

timeout := backend.GetRootChain().GetRequestTimeout()
if timeout != nil {
var cancel context.CancelFunc
ctx, cancel = context.WithTimeout(ctx, timeout.AsDuration())
defer cancel()
timeout := 10 * time.Second
if backendTimeout := backend.GetRootChain().GetRequestTimeout(); backendTimeout != nil {
timeout = backendTimeout.AsDuration()
}
ctx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()

caManager, exist := s.caManagers[backend.Type]
if !exist {
Expand Down