Files
tailscale/kube/localclient/fake-client.go
chaosinthecrd b5fa6773ce cmd/containerboot,kube/{certs,health,localclient}: serve /livez and /readyz
Proxies only serve /healthz, which reports whether the node has a tailnet IP,
so it can't back a liveness or readiness probe. When TS_ENABLE_HEALTH_CHECK is
set, containerboot now also serves /livez, which fails only when tailscaled
stops answering LocalAPI, and /readyz, which passes once the node has tailnet
IPs and, with TS_SERVE_CONFIG set, has applied the serve config and has a cert
for each HTTPS-only Tailscale Service it advertises. Certs are checked through
the read-only cert-status endpoint so the probe never triggers issuance. An
expired or unreadable cert counts as present, as failing readiness on it would
stop a StatefulSet rollout before it reaches the replica that renews certs.

Updates tailscale/corp#38175

Signed-off-by: chaosinthecrd <[email protected]>
2026-11-19 13:17:44 +00:00

75 lines
1.9 KiB
Go

// Copyright (c) Tailscale Inc & contributors
// SPDX-License-Identifier: BSD-3-Clause
package localclient
import (
"context"
"fmt"
"tailscale.com/ipn"
"tailscale.com/tailcfg"
)
type FakeLocalClient struct {
FakeIPNBusWatcher
SetServeCalled bool
EditPrefsCalls []*ipn.MaskedPrefs
GetPrefsResult *ipn.Prefs
CertDomainsResult []string
// CertStatusResults maps a domain to the cert status the fake returns.
// Domains absent from the map are reported as missing.
CertStatusResults map[string]*tailcfg.C2NTLSCertInfo
}
func (m *FakeLocalClient) SetServeConfig(ctx context.Context, cfg *ipn.ServeConfig) error {
m.SetServeCalled = true
return nil
}
func (m *FakeLocalClient) EditPrefs(ctx context.Context, mp *ipn.MaskedPrefs) (*ipn.Prefs, error) {
m.EditPrefsCalls = append(m.EditPrefsCalls, mp)
if m.GetPrefsResult == nil {
return &ipn.Prefs{}, nil
}
return m.GetPrefsResult, nil
}
func (m *FakeLocalClient) GetPrefs(ctx context.Context) (*ipn.Prefs, error) {
if m.GetPrefsResult == nil {
return &ipn.Prefs{}, nil
}
return m.GetPrefsResult, nil
}
func (f *FakeLocalClient) WatchIPNBus(ctx context.Context, mask ipn.NotifyWatchOpt) (IPNBusWatcher, error) {
return &f.FakeIPNBusWatcher, nil
}
func (f *FakeLocalClient) CertPair(ctx context.Context, domain string) ([]byte, []byte, error) {
return nil, nil, fmt.Errorf("CertPair not implemented")
}
func (f *FakeLocalClient) CertStatus(ctx context.Context, domain string) (*tailcfg.C2NTLSCertInfo, error) {
if info, ok := f.CertStatusResults[domain]; ok {
return info, nil
}
return &tailcfg.C2NTLSCertInfo{Missing: true, Error: "no certificate"}, nil
}
func (f *FakeLocalClient) CertDomains(ctx context.Context) ([]string, error) {
return f.CertDomainsResult, nil
}
type FakeIPNBusWatcher struct {
NotifyChan chan ipn.Notify
}
func (f *FakeIPNBusWatcher) Close() error {
return nil
}
func (f *FakeIPNBusWatcher) Next() (ipn.Notify, error) {
return <-f.NotifyChan, nil
}