Skip to content

Commit cf41cec

Browse files
authored
cmd/{k8s-operator,containerboot},k8s-operator: remove support for proxies below capver 95. (tailscale#13986)
Updates tailscale#13984 Signed-off-by: Irbe Krumina <[email protected]>
1 parent e38522c commit cf41cec

File tree

5 files changed

+9
-48
lines changed

5 files changed

+9
-48
lines changed

cmd/containerboot/main.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ import (
102102
"net/netip"
103103
"os"
104104
"os/signal"
105-
"path"
106105
"path/filepath"
107106
"slices"
108107
"strings"
@@ -731,16 +730,16 @@ func tailscaledConfigFilePath() string {
731730
}
732731
cv, err := kubeutils.CapVerFromFileName(e.Name())
733732
if err != nil {
734-
log.Printf("skipping file %q in tailscaled config directory %q: %v", e.Name(), dir, err)
735733
continue
736734
}
737735
if cv > maxCompatVer && cv <= tailcfg.CurrentCapabilityVersion {
738736
maxCompatVer = cv
739737
}
740738
}
741739
if maxCompatVer == -1 {
742-
log.Fatalf("no tailscaled config file found in %q for current capability version %q", dir, tailcfg.CurrentCapabilityVersion)
740+
log.Fatalf("no tailscaled config file found in %q for current capability version %d", dir, tailcfg.CurrentCapabilityVersion)
743741
}
744-
log.Printf("Using tailscaled config file %q for capability version %q", maxCompatVer, tailcfg.CurrentCapabilityVersion)
745-
return path.Join(dir, kubeutils.TailscaledConfigFileName(maxCompatVer))
742+
filePath := filepath.Join(dir, kubeutils.TailscaledConfigFileName(maxCompatVer))
743+
log.Printf("Using tailscaled config file %q to match current capability version %d", filePath, tailcfg.CurrentCapabilityVersion)
744+
return filePath
746745
}

cmd/k8s-operator/operator_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,7 +1388,7 @@ func TestTailscaledConfigfileHash(t *testing.T) {
13881388
parentType: "svc",
13891389
hostname: "default-test",
13901390
clusterTargetIP: "10.20.30.40",
1391-
confFileHash: "362360188dac62bca8013c8134929fed8efd84b1f410c00873d14a05709b5647",
1391+
confFileHash: "a67b5ad3ff605531c822327e8f1a23dd0846e1075b722c13402f7d5d0ba32ba2",
13921392
app: kubetypes.AppIngressProxy,
13931393
}
13941394
expectEqual(t, fc, expectedSTS(t, fc, o), nil)
@@ -1399,7 +1399,7 @@ func TestTailscaledConfigfileHash(t *testing.T) {
13991399
mak.Set(&svc.Annotations, AnnotationHostname, "another-test")
14001400
})
14011401
o.hostname = "another-test"
1402-
o.confFileHash = "20db57cfabc3fc6490f6bb1dc85994e61d255cdfa2a56abb0141736e59f263ef"
1402+
o.confFileHash = "888a993ebee20ad6be99623b45015339de117946850cf1252bede0b570e04293"
14031403
expectReconciled(t, sr, "default", "test")
14041404
expectEqual(t, fc, expectedSTS(t, fc, o), nil)
14051405
}

cmd/k8s-operator/sts.go

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -521,11 +521,6 @@ func (a *tailscaleSTSReconciler) reconcileSTS(ctx context.Context, logger *zap.S
521521
Name: "TS_KUBE_SECRET",
522522
Value: proxySecret,
523523
},
524-
corev1.EnvVar{
525-
// Old tailscaled config key is still used for backwards compatibility.
526-
Name: "EXPERIMENTAL_TS_CONFIGFILE_PATH",
527-
Value: "/etc/tsconfig/tailscaled",
528-
},
529524
corev1.EnvVar{
530525
// New style is in the form of cap-<capability-version>.hujson.
531526
Name: "TS_EXPERIMENTAL_VERSIONED_CONFIG_DIR",
@@ -789,15 +784,9 @@ func readAuthKey(secret *corev1.Secret, key string) (*string, error) {
789784
return origConf.AuthKey, nil
790785
}
791786

792-
// tailscaledConfig takes a proxy config, a newly generated auth key if
793-
// generated and a Secret with the previous proxy state and auth key and
794-
// returns tailscaled configuration and a hash of that configuration.
795-
//
796-
// As of 2024-05-09 it also returns legacy tailscaled config without the
797-
// later added NoStatefulFilter field to support proxies older than cap95.
798-
// TODO (irbekrm): remove the legacy config once we no longer need to support
799-
// versions older than cap94,
800-
// https://tailscale.com/kb/1236/kubernetes-operator#operator-and-proxies
787+
// tailscaledConfig takes a proxy config, a newly generated auth key if generated and a Secret with the previous proxy
788+
// state and auth key and returns tailscaled config files for currently supported proxy versions and a hash of that
789+
// configuration.
801790
func tailscaledConfig(stsC *tailscaleSTSConfig, newAuthkey string, oldSecret *corev1.Secret) (tailscaledConfigs, error) {
802791
conf := &ipn.ConfigVAlpha{
803792
Version: "alpha0",
@@ -846,10 +835,6 @@ func tailscaledConfig(stsC *tailscaleSTSConfig, newAuthkey string, oldSecret *co
846835
// AppConnector config option is only understood by clients of capver 107 and newer.
847836
conf.AppConnector = nil
848837
capVerConfigs[95] = *conf
849-
850-
// StatefulFiltering is only understood by clients of capver 95 and newer.
851-
conf.NoStatefulFiltering.Clear()
852-
capVerConfigs[94] = *conf
853838
return capVerConfigs, nil
854839
}
855840

cmd/k8s-operator/testutils_test.go

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ func expectedSTS(t *testing.T, cl client.Client, opts configOpts) *appsv1.Statef
7171
{Name: "TS_USERSPACE", Value: "false"},
7272
{Name: "POD_IP", ValueFrom: &corev1.EnvVarSource{FieldRef: &corev1.ObjectFieldSelector{APIVersion: "", FieldPath: "status.podIP"}, ResourceFieldRef: nil, ConfigMapKeyRef: nil, SecretKeyRef: nil}},
7373
{Name: "TS_KUBE_SECRET", Value: opts.secretName},
74-
{Name: "EXPERIMENTAL_TS_CONFIGFILE_PATH", Value: "/etc/tsconfig/tailscaled"},
7574
{Name: "TS_EXPERIMENTAL_VERSIONED_CONFIG_DIR", Value: "/etc/tsconfig"},
7675
},
7776
SecurityContext: &corev1.SecurityContext{
@@ -230,7 +229,6 @@ func expectedSTSUserspace(t *testing.T, cl client.Client, opts configOpts) *apps
230229
{Name: "TS_USERSPACE", Value: "true"},
231230
{Name: "POD_IP", ValueFrom: &corev1.EnvVarSource{FieldRef: &corev1.ObjectFieldSelector{APIVersion: "", FieldPath: "status.podIP"}, ResourceFieldRef: nil, ConfigMapKeyRef: nil, SecretKeyRef: nil}},
232231
{Name: "TS_KUBE_SECRET", Value: opts.secretName},
233-
{Name: "EXPERIMENTAL_TS_CONFIGFILE_PATH", Value: "/etc/tsconfig/tailscaled"},
234232
{Name: "TS_EXPERIMENTAL_VERSIONED_CONFIG_DIR", Value: "/etc/tsconfig"},
235233
{Name: "TS_SERVE_CONFIG", Value: "/etc/tailscaled/serve-config"},
236234
{Name: "TS_INTERNAL_APP", Value: opts.app},
@@ -404,12 +402,6 @@ func expectedSecret(t *testing.T, cl client.Client, opts configOpts) *corev1.Sec
404402
if err != nil {
405403
t.Fatalf("error marshalling tailscaled config")
406404
}
407-
conf.NoStatefulFiltering.Clear()
408-
b, err := json.Marshal(conf)
409-
if err != nil {
410-
t.Fatalf("error marshalling tailscaled config")
411-
}
412-
mak.Set(&s.StringData, "tailscaled", string(b))
413405
mak.Set(&s.StringData, "cap-95.hujson", string(bn))
414406
mak.Set(&s.StringData, "cap-107.hujson", string(bnn))
415407
labels := map[string]string{
@@ -662,18 +654,6 @@ func removeTargetPortsFromSvc(svc *corev1.Service) {
662654
func removeAuthKeyIfExistsModifier(t *testing.T) func(s *corev1.Secret) {
663655
return func(secret *corev1.Secret) {
664656
t.Helper()
665-
if len(secret.StringData["tailscaled"]) != 0 {
666-
conf := &ipn.ConfigVAlpha{}
667-
if err := json.Unmarshal([]byte(secret.StringData["tailscaled"]), conf); err != nil {
668-
t.Fatalf("error unmarshalling 'tailscaled' contents: %v", err)
669-
}
670-
conf.AuthKey = nil
671-
b, err := json.Marshal(conf)
672-
if err != nil {
673-
t.Fatalf("error marshalling updated 'tailscaled' config: %v", err)
674-
}
675-
mak.Set(&secret.StringData, "tailscaled", string(b))
676-
}
677657
if len(secret.StringData["cap-95.hujson"]) != 0 {
678658
conf := &ipn.ConfigVAlpha{}
679659
if err := json.Unmarshal([]byte(secret.StringData["cap-95.hujson"]), conf); err != nil {

k8s-operator/utils.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ type Records struct {
3232
// TailscaledConfigFileName returns a tailscaled config file name in
3333
// format expected by containerboot for the given CapVer.
3434
func TailscaledConfigFileName(cap tailcfg.CapabilityVersion) string {
35-
if cap < 95 {
36-
return "tailscaled"
37-
}
3835
return fmt.Sprintf("cap-%v.hujson", cap)
3936
}
4037

0 commit comments

Comments
 (0)