From a14f597d18ed9ccf0ae9f9736caa9954c6045071 Mon Sep 17 00:00:00 2001 From: Nitya Dhanushkodi Date: Wed, 16 Nov 2022 17:34:05 -0800 Subject: [PATCH] default to dataplane being supported when checking version annotation (#1731) --- .../endpoints/consul_client_health_checks.go | 4 ++- .../consul_client_health_checks_test.go | 25 ++++++++++--------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/control-plane/connect-inject/controllers/endpoints/consul_client_health_checks.go b/control-plane/connect-inject/controllers/endpoints/consul_client_health_checks.go index 0ab1b9f79f..f54fb71d11 100644 --- a/control-plane/connect-inject/controllers/endpoints/consul_client_health_checks.go +++ b/control-plane/connect-inject/controllers/endpoints/consul_client_health_checks.go @@ -19,7 +19,9 @@ func isConsulDataplaneSupported(pod corev1.Pod) bool { if anno, ok := pod.Annotations[constants.AnnotationConsulK8sVersion]; ok { consulK8sVersion, err := version.NewVersion(anno) if err != nil { - return false + // Only consul-k8s v1.0.0+ (including pre-release versions) have the version annotation. So it would be + // reasonable to default to supporting dataplane even if the version is malformed or invalid. + return true } consulDPSupportedVersion, err := version.NewVersion(minSupportedConsulDataplaneVersion) if err != nil { diff --git a/control-plane/connect-inject/controllers/endpoints/consul_client_health_checks_test.go b/control-plane/connect-inject/controllers/endpoints/consul_client_health_checks_test.go index da42a2fa4c..189587106d 100644 --- a/control-plane/connect-inject/controllers/endpoints/consul_client_health_checks_test.go +++ b/control-plane/connect-inject/controllers/endpoints/consul_client_health_checks_test.go @@ -18,18 +18,19 @@ func TestIsConsulDataplaneSupported(t *testing.T) { versions := map[string]struct { expIsConsulDataplaneSupported bool }{ - "": {false}, - "v1.0.0": {true}, - "1.0.0": {true}, - "v0.49.0": {false}, - "0.49.0-beta2": {false}, - "0.49.2": {false}, - "v1.0.0-beta1": {true}, - "v1.0.0-beta3": {true}, - "v1.1.0-beta1": {true}, - "v1.0.0-dev": {true}, - "v1.0.0-dev+abcdef": {true}, - "invalid": {false}, + "": {false}, + "v1.0.0": {true}, + "1.0.0": {true}, + "v0.49.0": {false}, + "0.49.0-beta2": {false}, + "0.49.2": {false}, + "v1.0.0-beta1": {true}, + "v1.0.0-beta3": {true}, + "v1.1.0-beta1": {true}, + "v1.0.0-dev": {true}, + "v1.0.0-dev (abcdef)": {true}, + "v1.0.0-dev+abcdef": {true}, + "invalid": {true}, } for version, c := range versions {