Skip to content

Allow sidecar server to reload TLS certificates#607

Merged
elevran merged 3 commits intollm-d:mainfrom
pierDipi:sidecar-auto-reload-certs
Mar 4, 2026
Merged

Allow sidecar server to reload TLS certificates#607
elevran merged 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.

@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?

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.

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.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I like Copilot's suggestion.

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)
}
}

Copy link
Member Author

Choose a reason for hiding this comment

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

I can do this improvement but the current logic follows the existing logic and the returned error contains the context of the failure

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.
@pierDipi pierDipi force-pushed the sidecar-auto-reload-certs branch from 6262305 to 1d5dbfa Compare March 2, 2026 07:27
@github-actions
Copy link

github-actions bot commented Mar 2, 2026

🚨 Unsigned commits detected! Please sign your commits.

For instructions on how to set up GPG/SSH signing and verify your commits, please see GitHub Documentation.

@pierDipi pierDipi force-pushed the sidecar-auto-reload-certs branch from 1d5dbfa to cd2c0ea Compare March 2, 2026 07:29
pierDipi added 2 commits March 2, 2026 08:31
Enables TLS certificates to be rotated without restarting
sidecar and vLLM deployments.

Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
@pierDipi pierDipi force-pushed the sidecar-auto-reload-certs branch from cd2c0ea to 3a6c935 Compare March 2, 2026 07:31
@pierDipi
Copy link
Member Author

pierDipi commented Mar 2, 2026

/cc @shmuelk @elevran @nirrozenbaum

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
Collaborator

Choose a reason for hiding this comment

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

I like Copilot's suggestion.

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)
}
}

Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
@pierDipi pierDipi requested a review from shmuelk March 3, 2026 08:20
@elevran
Copy link
Collaborator

elevran commented Mar 3, 2026

@shmuelk - can you please clear the Requested changes via the GH UI once this is good to merge from your point of view?

@elevran elevran added this to the v0.6 milestone Mar 3, 2026
@elevran
Copy link
Collaborator

elevran commented Mar 3, 2026

@pierDipi will cherry-pick into 0.6.0-RC2 if it's ready in time.

@elevran elevran merged commit c910eeb into llm-d:main Mar 4, 2026
8 checks passed
@github-project-automation github-project-automation bot moved this from In review to Done in llm-d-inference-scheduler Mar 4, 2026
@pierDipi pierDipi deleted the sidecar-auto-reload-certs branch March 4, 2026 12:49
elevran pushed a commit that referenced this pull request Mar 4, 2026
* Allow sidecar server to reload TLS certificates

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

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

* Pass certPath to reloader

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

* Improvements

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

---------

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: Done

Development

Successfully merging this pull request may close these issues.

4 participants