From 6d89b7e16fcccab9296218c0e0daadea89730096 Mon Sep 17 00:00:00 2001 From: Lucian Petrut Date: Fri, 6 Dec 2024 15:56:16 +0200 Subject: [PATCH 1/5] Fix nightly job The runner labels used by the nightly job are not correctly evaluated. We'll fix this by switching to the newly added one-string node labels. --- .github/workflows/nightly-test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nightly-test.yaml b/.github/workflows/nightly-test.yaml index df51a662d..03758d03b 100644 --- a/.github/workflows/nightly-test.yaml +++ b/.github/workflows/nightly-test.yaml @@ -17,7 +17,7 @@ jobs: release: ["latest/edge"] fail-fast: false # TODO: remove once arm64 works - runs-on: ${{ matrix.arch == 'arm64' && ["self-hosted", "Linux", "ARM64", "jammy", "large"] || ["self-hosted", "Linux", "AMD64", "jammy", "large"] }} + runs-on: ${{ matrix.arch == 'arm64' && 'self-hosted-linux-arm64-jammy-large' || 'self-hosted-linux-amd64-jammy-large' }} steps: - name: Checking out repo From 593936a97dab7aa532cf3d9b65d60dd34244e606 Mon Sep 17 00:00:00 2001 From: Lucian Petrut Date: Fri, 6 Dec 2024 16:19:53 +0200 Subject: [PATCH 2/5] Apply Docker iptables workaround --- .github/workflows/nightly-test.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/nightly-test.yaml b/.github/workflows/nightly-test.yaml index 03758d03b..98089d932 100644 --- a/.github/workflows/nightly-test.yaml +++ b/.github/workflows/nightly-test.yaml @@ -30,6 +30,8 @@ jobs: sudo lxd init --auto sudo usermod --append --groups lxd $USER sg lxd -c 'lxc version' + sudo iptables -I DOCKER-USER -i lxdbr0 -j ACCEPT + sudo iptables -I DOCKER-USER -o lxdbr0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT - name: Create build directory run: mkdir -p build - name: Install ${{ matrix.release }} k8s snap From 244335eed046c3592c22fb5361570043beafa201 Mon Sep 17 00:00:00 2001 From: Lucian Petrut Date: Mon, 9 Dec 2024 11:44:37 +0000 Subject: [PATCH 3/5] Fix test_node_cleanup_new_containerd_path test The containerd base dir setting is currently ignored when joining nodes. The reason is that yaml parser ignores a struct field which is marked as private. Making it public fixes the issue. At the same time, the test expects the default containerd folders to be missing when configured to use a different base dir. However, the tests are currently placing the registry settings in /etc/containerd. We also get an empty /run/containerd folder. For now, we'll update the test to ignore these folders. There's also an os.path.join call that doesn't produce the expected result if the last element is an absolute path, we'll need to remove a slash when constructing the paths. --- src/k8s/pkg/k8sd/api/cluster_join.go | 6 +++--- tests/integration/tests/test_cleanup.py | 17 ++++++++++++++--- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/k8s/pkg/k8sd/api/cluster_join.go b/src/k8s/pkg/k8sd/api/cluster_join.go index ba9421ddb..769ad8999 100644 --- a/src/k8s/pkg/k8sd/api/cluster_join.go +++ b/src/k8s/pkg/k8sd/api/cluster_join.go @@ -37,16 +37,16 @@ func (e *Endpoints) postClusterJoin(s state.State, r *http.Request) response.Res joinConfig := struct { // We only care about this field from the entire join config. - containerdBaseDir string `yaml:"containerd-base-dir,omitempty"` + ContainerdBaseDir string `yaml:"containerd-base-dir,omitempty"` }{} if err := yaml.Unmarshal([]byte(req.Config), &joinConfig); err != nil { return response.BadRequest(fmt.Errorf("failed to parse request config: %w", err)) } - if joinConfig.containerdBaseDir != "" { + if joinConfig.ContainerdBaseDir != "" { // append k8s-containerd to the given base dir, so we don't flood it with our own folders. - e.provider.Snap().SetContainerdBaseDir(filepath.Join(joinConfig.containerdBaseDir, "k8s-containerd")) + e.provider.Snap().SetContainerdBaseDir(filepath.Join(joinConfig.ContainerdBaseDir, "k8s-containerd")) } config := map[string]string{} diff --git a/tests/integration/tests/test_cleanup.py b/tests/integration/tests/test_cleanup.py index 6dab6ccf7..ac9ba9a3d 100644 --- a/tests/integration/tests/test_cleanup.py +++ b/tests/integration/tests/test_cleanup.py @@ -64,15 +64,26 @@ def test_node_cleanup_new_containerd_path(instances: List[harness.Instance]): boostrap_config = yaml.safe_load(containerd_path_bootstrap_config) new_containerd_paths = [ - os.path.join(boostrap_config["containerd-base-dir"], "k8s-containerd", p) + os.path.join(boostrap_config["containerd-base-dir"], "k8s-containerd", p.lstrip("/")) for p in CONTAINERD_PATHS ] + + # We expect containerd to use our custom paths instead of the default ones. + # However, the test fixture places registry configuration in /etc/containerd + # and /run/containerd gets created but isn't actually used (requires further + # investigation). + exp_missing_paths = [ + "/etc/containerd/config.toml", + "/run/containerd/containerd.sock", + "/var/lib/containerd", + ] + for instance in instances: # Check that the containerd-related folders are not in the default locations. process = instance.exec( - ["ls", *CONTAINERD_PATHS], capture_output=True, text=True, check=False + ["ls", *exp_missing_paths], capture_output=True, text=True, check=False ) - for path in CONTAINERD_PATHS: + for path in exp_missing_paths: assert ( f"cannot access '{path}': No such file or directory" in process.stderr ) From 72d17d31f02e819e0c0eca55fe93a7c52dc16e7f Mon Sep 17 00:00:00 2001 From: Lucian Petrut Date: Mon, 9 Dec 2024 14:53:08 +0000 Subject: [PATCH 4/5] Fix linter errors --- tests/integration/tests/test_cleanup.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/integration/tests/test_cleanup.py b/tests/integration/tests/test_cleanup.py index ac9ba9a3d..245a2f623 100644 --- a/tests/integration/tests/test_cleanup.py +++ b/tests/integration/tests/test_cleanup.py @@ -64,7 +64,9 @@ def test_node_cleanup_new_containerd_path(instances: List[harness.Instance]): boostrap_config = yaml.safe_load(containerd_path_bootstrap_config) new_containerd_paths = [ - os.path.join(boostrap_config["containerd-base-dir"], "k8s-containerd", p.lstrip("/")) + os.path.join( + boostrap_config["containerd-base-dir"], "k8s-containerd", p.lstrip("/") + ) for p in CONTAINERD_PATHS ] From 66221db93e168b43d4a415b9ac73a33599369545 Mon Sep 17 00:00:00 2001 From: Lucian Petrut Date: Tue, 10 Dec 2024 08:16:33 +0000 Subject: [PATCH 5/5] Run all tests for backports or when there are test changes We're adding a few checks to the integration tests workflow. We'll use the "weekly" tag in case of backports (targeting the release-* branches) and whenever there are test changes. --- .github/workflows/integration.yaml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/integration.yaml b/.github/workflows/integration.yaml index 4c35e84a5..3a72d8963 100644 --- a/.github/workflows/integration.yaml +++ b/.github/workflows/integration.yaml @@ -107,7 +107,17 @@ jobs: TEST_VERSION_UPGRADE_MIN_RELEASE: "1.31" TEST_MIRROR_LIST: '[{"name": "ghcr.io", "port": 5000, "remote": "https://ghcr.io", "username": "${{ github.actor }}", "password": "${{ secrets.GITHUB_TOKEN }}"}, {"name": "docker.io", "port": 5001, "remote": "https://registry-1.docker.io", "username": "", "password": ""}, {"name": "rocks.canonical.com", "port": 5002, "remote": "https://rocks.canonical.com/cdk"}]' run: | - cd tests/integration && sg lxd -c 'tox -e integration -- --tags pull_request' + tags="pull_request" + # Run all tests if there are test changes. In case of a PR, we'll + # get a merge commit that includes all changes. + if git diff HEAD HEAD~1 --name-only | grep "tests/"; then + tags="weekly" + fi + # Run all tests on backports. + if echo ${{ github.base_ref }} | grep "release-"; then + tags="weekly" + fi + cd tests/integration && sg lxd -c 'tox -e integration -- --tags $tags' - name: Prepare inspection reports if: failure() run: |