mirror of
https://github.com/tailscale/tailscale.git
synced 2026-12-01 22:22:34 -08:00
* cmd/containerboot: guard kubeClient against nil dereference (#14357) A method on kc was called unconditionally, even if was not initialized, leading to a nil pointer dereference when TS_SERVE_CONFIG was set outside Kubernetes. Add a guard symmetric with other uses of the kubeClient. Signed-off-by: Bjorn Neergaard <[email protected]> (cherry picked from commit8b1d01161b) * cmd/containerboot: don't attempt to write kube Secret in non-kube environments (#14358) Signed-off-by: Irbe Krumina <[email protected]> (cherry picked from commit0cc071f154) * cmd/containerboot: don't attempt to patch a Secret field without permissions (#14365) Signed-off-by: Irbe Krumina <[email protected]> (cherry picked from commit6e552f66a0) Updates tailscale/tailscale#14354
This commit is contained in:
1 parent
3e3d5d8c68
commit
6e0f168db0
4 files changed
+10
-4
No files matched your search
@@ -24,6 +24,7 @@ import (
|
||||
type kubeClient struct {
|
||||
kubeclient.Client
|
||||
stateSecret string
|
||||
canPatch bool // whether the client has permissions to patch Kubernetes Secrets
|
||||
}
|
||||
|
||||
func newKubeClient(root string, stateSecret string) (*kubeClient, error) {
|
||||
|
||||
@@ -331,8 +331,10 @@ authLoop:
|
||||
if err := client.SetServeConfig(ctx, new(ipn.ServeConfig)); err != nil {
|
||||
log.Fatalf("failed to unset serve config: %v", err)
|
||||
}
|
||||
if err := kc.storeHTTPSEndpoint(ctx, ""); err != nil {
|
||||
log.Fatalf("failed to update HTTPS endpoint in tailscale state: %v", err)
|
||||
if hasKubeStateStore(cfg) {
|
||||
if err := kc.storeHTTPSEndpoint(ctx, ""); err != nil {
|
||||
log.Fatalf("failed to update HTTPS endpoint in tailscale state: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -72,8 +72,10 @@ func watchServeConfigChanges(ctx context.Context, path string, cdChanged <-chan
|
||||
if err := updateServeConfig(ctx, sc, certDomain, lc); err != nil {
|
||||
log.Fatalf("serve proxy: error updating serve config: %v", err)
|
||||
}
|
||||
if err := kc.storeHTTPSEndpoint(ctx, certDomain); err != nil {
|
||||
log.Fatalf("serve proxy: error storing HTTPS endpoint: %v", err)
|
||||
if kc != nil && kc.canPatch {
|
||||
if err := kc.storeHTTPSEndpoint(ctx, certDomain); err != nil {
|
||||
log.Fatalf("serve proxy: error storing HTTPS endpoint: %v", err)
|
||||
}
|
||||
}
|
||||
prevServeConfig = sc
|
||||
}
|
||||
|
||||
@@ -214,6 +214,7 @@ func (cfg *settings) setupKube(ctx context.Context, kc *kubeClient) error {
|
||||
return fmt.Errorf("some Kubernetes permissions are missing, please check your RBAC configuration: %v", err)
|
||||
}
|
||||
cfg.KubernetesCanPatch = canPatch
|
||||
kc.canPatch = canPatch
|
||||
|
||||
s, err := kc.GetSecret(ctx, cfg.KubeSecret)
|
||||
if err != nil {
|
||||
|
||||
Reference in new issue
Block a user