From a0e2b549425eb32ac322f667c3f0087c1bae6824 Mon Sep 17 00:00:00 2001 From: Lucian Petrut Date: Thu, 23 Jan 2025 10:20:55 +0000 Subject: [PATCH 1/4] Enable cluster-config.load-balancer.l2-mode by default We'll change the defalt value of cluster-config.load-balancer.l2-mode, enabling it by default. --- docs/src/_parts/bootstrap_config.md | 2 +- src/k8s/pkg/k8sd/types/cluster_config_defaults.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/src/_parts/bootstrap_config.md b/docs/src/_parts/bootstrap_config.md index 2c07c061a..516206ed0 100644 --- a/docs/src/_parts/bootstrap_config.md +++ b/docs/src/_parts/bootstrap_config.md @@ -93,7 +93,7 @@ Sets the CIDRs used for assigning IP addresses to Kubernetes services with type **Type:** `bool`
Determines if L2 mode should be enabled. -If omitted defaults to `false`. +If omitted defaults to `true`. ### cluster-config.load-balancer.l2-interfaces **Type:** `[]string`
diff --git a/src/k8s/pkg/k8sd/types/cluster_config_defaults.go b/src/k8s/pkg/k8sd/types/cluster_config_defaults.go index c0ef17de3..18c02dadf 100644 --- a/src/k8s/pkg/k8sd/types/cluster_config_defaults.go +++ b/src/k8s/pkg/k8sd/types/cluster_config_defaults.go @@ -61,7 +61,7 @@ func (c *ClusterConfig) SetDefaults() { c.LoadBalancer.CIDRs = utils.Pointer([]string{}) } if c.LoadBalancer.L2Mode == nil { - c.LoadBalancer.L2Mode = utils.Pointer(false) + c.LoadBalancer.L2Mode = utils.Pointer(true) } if c.LoadBalancer.L2Interfaces == nil { c.LoadBalancer.L2Interfaces = utils.Pointer([]string{}) From 23f3fda809b9367c92464e4742a96e2743c60a48 Mon Sep 17 00:00:00 2001 From: Lucian Petrut Date: Thu, 23 Jan 2025 13:49:21 +0000 Subject: [PATCH 2/4] Bump k8s-snap-api version --- src/k8s/go.mod | 2 +- src/k8s/go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/k8s/go.mod b/src/k8s/go.mod index 3d4bb6801..6de14bec7 100644 --- a/src/k8s/go.mod +++ b/src/k8s/go.mod @@ -7,7 +7,7 @@ toolchain go1.23.4 require ( dario.cat/mergo v1.0.0 github.com/canonical/go-dqlite/v2 v2.0.0 - github.com/canonical/k8s-snap-api v1.0.15 + github.com/canonical/k8s-snap-api v1.0.16 github.com/canonical/lxd v0.0.0-20250113143058-52441d41dab7 github.com/canonical/microcluster/v2 v2.1.1-0.20250115174915-f2320c71e720 github.com/go-logr/logr v1.4.2 diff --git a/src/k8s/go.sum b/src/k8s/go.sum index 8fb146da3..3f1bad015 100644 --- a/src/k8s/go.sum +++ b/src/k8s/go.sum @@ -53,8 +53,8 @@ github.com/bugsnag/panicwrap v0.0.0-20151223152923-e2c28503fcd0 h1:nvj0OLI3YqYXe github.com/bugsnag/panicwrap v0.0.0-20151223152923-e2c28503fcd0/go.mod h1:D/8v3kj0zr8ZAKg1AQ6crr+5VwKN5eIywRkfhyM/+dE= github.com/canonical/go-dqlite/v2 v2.0.0 h1:RNFcFVhHMh70muKKErbW35rSzqmAFswheHdAgxW0Ddw= github.com/canonical/go-dqlite/v2 v2.0.0/go.mod h1:IaIC8u4Z1UmPjuAqPzA2r83YMaMHRLoKZdHKI5uHCJI= -github.com/canonical/k8s-snap-api v1.0.15 h1:uhEJiEhrK93tJAly+quuAayanMhT/5vpePlG+xxVCPA= -github.com/canonical/k8s-snap-api v1.0.15/go.mod h1:LDPoIYCeYnfgOFrwVPJ/4edGU264w7BB7g0GsVi36AY= +github.com/canonical/k8s-snap-api v1.0.16 h1:j1VPvWimgRt3P5uRtD2ZCPGalSFvU5AJ/Jbz60QMoBs= +github.com/canonical/k8s-snap-api v1.0.16/go.mod h1:LDPoIYCeYnfgOFrwVPJ/4edGU264w7BB7g0GsVi36AY= github.com/canonical/lxd v0.0.0-20250113143058-52441d41dab7 h1:lZCOt9/1KowNdnWXjfA1/51Uj7+R0fKtByos9EVrYn4= github.com/canonical/lxd v0.0.0-20250113143058-52441d41dab7/go.mod h1:4Ssm3YxIz8wyazciTLDR9V0aR2GPlGIHb+S0182T5pA= github.com/canonical/microcluster/v2 v2.1.1-0.20250115174915-f2320c71e720 h1:LLegPoZ5bY/PGx3x1xtzggy2xvQvZ5sCw6jlQJ3BRFg= From dda135aa6b941398b86b4e128cf76a6caa14fb30 Mon Sep 17 00:00:00 2001 From: Lucian Petrut Date: Thu, 23 Jan 2025 14:07:42 +0000 Subject: [PATCH 3/4] Update unit test --- src/k8s/pkg/k8sd/types/cluster_config_defaults_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k8s/pkg/k8sd/types/cluster_config_defaults_test.go b/src/k8s/pkg/k8sd/types/cluster_config_defaults_test.go index ae8b8581c..d95beb6c7 100644 --- a/src/k8s/pkg/k8sd/types/cluster_config_defaults_test.go +++ b/src/k8s/pkg/k8sd/types/cluster_config_defaults_test.go @@ -43,7 +43,7 @@ func TestSetDefaults(t *testing.T) { LoadBalancer: types.LoadBalancer{ Enabled: utils.Pointer(false), CIDRs: utils.Pointer([]string{}), - L2Mode: utils.Pointer(false), + L2Mode: utils.Pointer(true), L2Interfaces: utils.Pointer([]string{}), BGPMode: utils.Pointer(false), BGPLocalASN: utils.Pointer(0), From 2325127fef9c6a0aff93cbeb1458a62721e2cadb Mon Sep 17 00:00:00 2001 From: Lucian Petrut Date: Thu, 23 Jan 2025 15:36:42 +0000 Subject: [PATCH 4/4] Update test_smoke * update expected l2 mode * bump the timeout --- tests/integration/tests/test_smoke.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integration/tests/test_smoke.py b/tests/integration/tests/test_smoke.py index b7128e261..a38515fb5 100644 --- a/tests/integration/tests/test_smoke.py +++ b/tests/integration/tests/test_smoke.py @@ -20,7 +20,7 @@ r"network:\s*enabled", r"dns:\s*enabled at (\d{1,3}(?:\.\d{1,3}){3})", r"ingress:\s*enabled", - r"load-balancer:\s*enabled, Unknown mode", + r"load-balancer:\s*enabled, L2 mode", r"local-storage:\s*enabled at /var/snap/k8s/common/rawfile-storage", r"gateway\s*enabled", ] @@ -145,6 +145,6 @@ def status_output_matches(p: subprocess.CompletedProcess) -> bool: return True LOG.info("Verifying the output of `k8s status`") - util.stubbornly(retries=10, delay_s=10).on(instance).until( + util.stubbornly(retries=15, delay_s=10).on(instance).until( condition=status_output_matches, ).exec(["k8s", "status", "--wait-ready"])