Skip to content

Allow sidecar server to reload TLS certificates#607

Open
pierDipi wants to merge 3 commits intollm-d:mainfrom
pierDipi:sidecar-auto-reload-certs
Open

Allow sidecar server to reload TLS certificates#607
pierDipi wants to merge 3 commits intollm-d:mainfrom
pierDipi:sidecar-auto-reload-certs

Conversation

@pierDipi
Copy link
Member

Enables TLS certificates to be rotated without restarting sidecar and vLLM deployments.

Enables TLS certificates to be rotated without restarting
sidecar and vLLM deployments.

Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
@pierDipi
Copy link
Member Author

/cc @shmuelk @elevran

@github-actions github-actions bot requested review from elevran and shmuelk February 13, 2026 08:34
@shmuelk
Copy link
Collaborator

shmuelk commented Feb 19, 2026

/lgtm
/approve

@github-actions github-actions bot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 19, 2026
github-actions[bot]
github-actions bot previously approved these changes Feb 19, 2026
@pierDipi
Copy link
Member Author

@elevran @shmuelk can we merge this PR?

Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR moves TLS certificate handling into the sidecar proxy server and adds support for reloading TLS certificates from disk so sidecar/vLLM deployments can rotate certs without restarts.

Changes:

  • Add Config.CertPath and Config.SecureServing, and remove passing a *tls.Certificate into Server.Start().
  • Configure http.Server.TLSConfig to use GetCertificate, optionally backed by a cert reloader when CertPath is set.
  • Update sidecar main and proxy tests to use the new config-driven TLS setup.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
cmd/pd-sidecar/main.go Moves TLS config inputs into proxy.Config and updates Start() call signature.
pkg/sidecar/proxy/proxy.go Extends Config with TLS fields and updates Start()/data-parallel startup signatures.
pkg/sidecar/proxy/proxy_helpers.go Implements TLS cert loading/self-signed fallback and hooks in cert reloading via GetCertificate.
pkg/sidecar/proxy/data_parallel.go Updates data-parallel startup path to no longer pass a cert into startHTTP().
pkg/sidecar/proxy/proxy_test.go Updates tests to enable TLS via config rather than injecting a cert.
pkg/sidecar/proxy/data_parallel_test.go Updates test call sites for the new startDataParallel() signature.
pkg/sidecar/proxy/connector_test.go Updates Start() call sites for the new signature.
pkg/sidecar/proxy/connector_nixlv2_test.go Updates Start() call sites for the new signature.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

clone.setConnector()

return clone.startHTTP(ctx, cert)
return clone.startHTTP(ctx)
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

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

Data-parallel clone servers call startHTTP(), which now derives TLS settings (and connector selection) from s.config, but Clone() does not copy the config field. As a result, cloned servers will run with zero-value config (e.g., SecureServing false / CertPath empty), so TLS cert reloading (and potentially connector behavior) won’t apply to the data-parallel proxy ports. Consider copying config (and any other required fields) in Clone(), or explicitly setting clone.config = s.config before calling clone.startHTTP().

Copilot uses AI. Check for mistakes.
Comment on lines +45 to +51
tempCert, err = tls.LoadX509KeyPair(s.config.CertPath+"/tls.crt", s.config.CertPath+"/tls.key")
} else {
tempCert, err = CreateSelfSignedTLSCertificate()
}
if err != nil {
return fmt.Errorf("failed to create TLS certificate: %w", err)
}
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

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

The error message "failed to create TLS certificate" is used for both loading a keypair from CertPath and generating a self-signed cert. It would be more actionable to distinguish these cases (e.g., include the cert/key filenames when LoadX509KeyPair fails, and a separate message for self-signed generation failure).

Suggested change
tempCert, err = tls.LoadX509KeyPair(s.config.CertPath+"/tls.crt", s.config.CertPath+"/tls.key")
} else {
tempCert, err = CreateSelfSignedTLSCertificate()
}
if err != nil {
return fmt.Errorf("failed to create TLS certificate: %w", err)
}
certFile := s.config.CertPath + "/tls.crt"
keyFile := s.config.CertPath + "/tls.key"
tempCert, err = tls.LoadX509KeyPair(certFile, keyFile)
if err != nil {
return fmt.Errorf("failed to load TLS key pair from cert %q and key %q: %w", certFile, keyFile, err)
}
} else {
tempCert, err = CreateSelfSignedTLSCertificate()
if err != nil {
return fmt.Errorf("failed to generate self-signed TLS certificate: %w", err)
}
}

Copilot uses AI. Check for mistakes.
Comment on lines +59 to +63
if s.config.CertPath != "" {
reloader, err := common.NewCertReloader(ctx, s.config.CertPath, cert)
if err != nil {
return fmt.Errorf("failed to start reloader: %w", err)
}
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

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

TLS certificate reloading via common.NewCertReloader is newly introduced but doesn’t appear to be covered by tests. Adding an integration/unit test that starts the server with CertPath pointing to a temp dir, rotates tls.crt/tls.key, and verifies a new TLS handshake presents the updated cert would help prevent regressions.

Copilot uses AI. Check for mistakes.
Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm "Looks good to me", indicates that a PR is ready to be merged.

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

3 participants