mirror of
https://github.com/tailscale/tailscale.git
synced 2025-05-21 01:38:32 +00:00
cmd/k8s-operator: don't set deprecated configfile hash on new proxies (#14817)
Fixes the configfile reload logic- if the tailscale capver can not yet be determined because the device info is not yet written to the state Secret, don't assume that the proxy is pre-110. Updates tailscale/tailscale#13032 Signed-off-by: Irbe Krumina <irbe@tailscale.com>
This commit is contained in:
parent
b406f209c3
commit
52f88f782a
@ -1339,71 +1339,6 @@ func TestProxyFirewallMode(t *testing.T) {
|
|||||||
expectEqual(t, fc, expectedSTS(t, fc, o), removeHashAnnotation, removeResourceReqs)
|
expectEqual(t, fc, expectedSTS(t, fc, o), removeHashAnnotation, removeResourceReqs)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTailscaledConfigfileHash(t *testing.T) {
|
|
||||||
fc := fake.NewFakeClient()
|
|
||||||
ft := &fakeTSClient{}
|
|
||||||
zl, err := zap.NewDevelopment()
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
clock := tstest.NewClock(tstest.ClockOpts{})
|
|
||||||
sr := &ServiceReconciler{
|
|
||||||
Client: fc,
|
|
||||||
ssr: &tailscaleSTSReconciler{
|
|
||||||
Client: fc,
|
|
||||||
tsClient: ft,
|
|
||||||
defaultTags: []string{"tag:k8s"},
|
|
||||||
operatorNamespace: "operator-ns",
|
|
||||||
proxyImage: "tailscale/tailscale",
|
|
||||||
},
|
|
||||||
logger: zl.Sugar(),
|
|
||||||
clock: clock,
|
|
||||||
isDefaultLoadBalancer: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a service that we should manage, and check that the initial round
|
|
||||||
// of objects looks right.
|
|
||||||
mustCreate(t, fc, &corev1.Service{
|
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
|
||||||
Name: "test",
|
|
||||||
Namespace: "default",
|
|
||||||
// The apiserver is supposed to set the UID, but the fake client
|
|
||||||
// doesn't. So, set it explicitly because other code later depends
|
|
||||||
// on it being set.
|
|
||||||
UID: types.UID("1234-UID"),
|
|
||||||
},
|
|
||||||
Spec: corev1.ServiceSpec{
|
|
||||||
ClusterIP: "10.20.30.40",
|
|
||||||
Type: corev1.ServiceTypeLoadBalancer,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
expectReconciled(t, sr, "default", "test")
|
|
||||||
expectReconciled(t, sr, "default", "test")
|
|
||||||
|
|
||||||
fullName, shortName := findGenName(t, fc, "default", "test", "svc")
|
|
||||||
o := configOpts{
|
|
||||||
stsName: shortName,
|
|
||||||
secretName: fullName,
|
|
||||||
namespace: "default",
|
|
||||||
parentType: "svc",
|
|
||||||
hostname: "default-test",
|
|
||||||
clusterTargetIP: "10.20.30.40",
|
|
||||||
confFileHash: "848bff4b5ba83ac999e6984c8464e597156daba961ae045e7dbaef606d54ab5e",
|
|
||||||
app: kubetypes.AppIngressProxy,
|
|
||||||
}
|
|
||||||
expectEqual(t, fc, expectedSTS(t, fc, o), removeResourceReqs)
|
|
||||||
|
|
||||||
// 2. Hostname gets changed, configfile is updated and a new hash value
|
|
||||||
// is produced.
|
|
||||||
mustUpdate(t, fc, "default", "test", func(svc *corev1.Service) {
|
|
||||||
mak.Set(&svc.Annotations, AnnotationHostname, "another-test")
|
|
||||||
})
|
|
||||||
o.hostname = "another-test"
|
|
||||||
o.confFileHash = "d4cc13f09f55f4f6775689004f9a466723325b84d2b590692796bfe22aeaa389"
|
|
||||||
expectReconciled(t, sr, "default", "test")
|
|
||||||
expectEqual(t, fc, expectedSTS(t, fc, o), removeResourceReqs)
|
|
||||||
}
|
|
||||||
func Test_isMagicDNSName(t *testing.T) {
|
func Test_isMagicDNSName(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
in string
|
in string
|
||||||
|
@ -697,7 +697,7 @@ func (a *tailscaleSTSReconciler) reconcileSTS(ctx context.Context, logger *zap.S
|
|||||||
// being created, there is no need for a restart.
|
// being created, there is no need for a restart.
|
||||||
// TODO(irbekrm): remove this in 1.84.
|
// TODO(irbekrm): remove this in 1.84.
|
||||||
hash := tsConfigHash
|
hash := tsConfigHash
|
||||||
if dev != nil && dev.capver >= 110 {
|
if dev == nil || dev.capver >= 110 {
|
||||||
hash = s.Spec.Template.GetAnnotations()[podAnnotationLastSetConfigFileHash]
|
hash = s.Spec.Template.GetAnnotations()[podAnnotationLastSetConfigFileHash]
|
||||||
}
|
}
|
||||||
s.Spec = ss.Spec
|
s.Spec = ss.Spec
|
||||||
|
Loading…
x
Reference in New Issue
Block a user