From af9d52c202e030f85d14fb65ca4d24ea7a5ad939 Mon Sep 17 00:00:00 2001 From: Simon Bengtsson Date: Thu, 4 Sep 2025 11:11:34 +0200 Subject: [PATCH 1/6] Improve workflows --- .github/workflows/build.yml | 15 +++++++++++++++ .github/workflows/lint.yml | 14 ++++++++++++++ .github/workflows/test-chart.yml | 29 ++++++++++++++++++++++++++--- .github/workflows/test-e2e.yml | 14 ++++++++++++++ .github/workflows/test.yml | 14 ++++++++++++++ 5 files changed, 83 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 89d9f05..f15209c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,6 +2,21 @@ name: Build on: push: + paths-ignore: + - '.gitignore' + - 'CODEOWNERS' + - 'LICENSE' + - '*.md' + - '*.adoc' + - '*.txt' + pull_request: + paths-ignore: + - '.gitignore' + - 'CODEOWNERS' + - 'LICENSE' + - '*.md' + - '*.adoc' + - '*.txt' env: IMG_REGISTRY: ghcr.io/slyngdk/ diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 7e78e55..5faae6e 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -2,7 +2,21 @@ name: Lint on: push: + paths-ignore: + - '.gitignore' + - 'CODEOWNERS' + - 'LICENSE' + - '*.md' + - '*.adoc' + - '*.txt' pull_request: + paths-ignore: + - '.gitignore' + - 'CODEOWNERS' + - 'LICENSE' + - '*.md' + - '*.adoc' + - '*.txt' jobs: golangci-lint: diff --git a/.github/workflows/test-chart.yml b/.github/workflows/test-chart.yml index 4674510..22e1ab3 100644 --- a/.github/workflows/test-chart.yml +++ b/.github/workflows/test-chart.yml @@ -2,7 +2,28 @@ name: Test Chart on: push: + paths-ignore: + - '.gitignore' + - 'CODEOWNERS' + - 'LICENSE' + - '*.md' + - '*.adoc' + - '*.txt' pull_request: + paths-ignore: + - '.gitignore' + - 'CODEOWNERS' + - 'LICENSE' + - '*.md' + - '*.adoc' + - '*.txt' + +env: + IMG_REGISTRY: ghcr.io/slyngdk/ + IMG_NAME_CONTROLLER: nodedrain-controller + IMG_NAME_EXAM_PLUGIN: nodedrain-example-plugin + IMG_TAG: test-chart + KIND_CLUSTER_NAME: nodedrain-test-chart jobs: test-chart: @@ -26,13 +47,15 @@ jobs: run: kind version - name: Create kind cluster - run: kind create cluster + run: | + kind delete cluster + kind create cluster - name: Prepare nodedrain run: | go mod tidy - make docker-build IMG_NAME_CONTROLLER=nodedrain IMG_TAG=v0.1.0 - kind load docker-image IMG_NAME_CONTROLLER=nodedrain IMG_TAG=v0.1.0 + make docker-build + kind load docker-image ${IMG_REGISTRY}${IMG_NAME_CONTROLLER}:${IMG_TAG} - name: Install Helm run: | diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index 68fd1ed..135c773 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -2,7 +2,21 @@ name: E2E Tests on: push: + paths-ignore: + - '.gitignore' + - 'CODEOWNERS' + - 'LICENSE' + - '*.md' + - '*.adoc' + - '*.txt' pull_request: + paths-ignore: + - '.gitignore' + - 'CODEOWNERS' + - 'LICENSE' + - '*.md' + - '*.adoc' + - '*.txt' jobs: test-e2e: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 67dcfed..90d2c6e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,7 +2,21 @@ name: Tests on: push: + paths-ignore: + - '.gitignore' + - 'CODEOWNERS' + - 'LICENSE' + - '*.md' + - '*.adoc' + - '*.txt' pull_request: + paths-ignore: + - '.gitignore' + - 'CODEOWNERS' + - 'LICENSE' + - '*.md' + - '*.adoc' + - '*.txt' jobs: test: From 5bc5672c5423c09fd91627b258557afbbfaa1385 Mon Sep 17 00:00:00 2001 From: Simon Bengtsson Date: Mon, 8 Sep 2025 22:50:50 +0200 Subject: [PATCH 2/6] Improve workflows --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f15209c..e83fe46 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -55,7 +55,7 @@ jobs: elif [[ "${{ github.ref_type }}" == "tag" && "${{ github.ref_name }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then export IMG_TAG=$(echo -n "${{ github.ref_name }}" | sed 's/^v//g') fi - echo "IMG_TAG=${IMG_TAG}" >> $GITHUB_OUTPUT + echo "IMG_TAG=${IMG_TAG//\//-}" >> $GITHUB_OUTPUT make docker-build - name: Push image From d780c0fd074b6c0c82f16f683d8d2bba3eb11062 Mon Sep 17 00:00:00 2001 From: Simon Bengtsson Date: Mon, 8 Sep 2025 22:51:08 +0200 Subject: [PATCH 3/6] Fix lint --- internal/controller/node_controller.go | 1 + internal/utils/reboot-manager.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/controller/node_controller.go b/internal/controller/node_controller.go index 0c206f3..226dd22 100644 --- a/internal/controller/node_controller.go +++ b/internal/controller/node_controller.go @@ -147,6 +147,7 @@ func (r *nodeReconciler) SetupWithManager(mgr ctrl.Manager) error { // // For more details, check Reconcile and its Result here: // - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.19.0/pkg/reconcile +// nolint:gocyclo func (r *nodeReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { l := r.l.With(zap.String("node.name", req.Name)) l.Debug("node reconcile") diff --git a/internal/utils/reboot-manager.go b/internal/utils/reboot-manager.go index a2a1a8b..ede6b6e 100644 --- a/internal/utils/reboot-manager.go +++ b/internal/utils/reboot-manager.go @@ -202,7 +202,7 @@ func (r *RebootManager) IsNodeRebooted(ctx context.Context, kubeNode *corev1.Nod if config.GetConfig().ContainerNode { r.l.Info("Node was not rebooted, because running on containers", zap.String("node.name", kubeNode.Name)) pod := r.rebootRequiredPod(kubeNode.Name) - pod.ObjectMeta.GenerateName = "reboot-required-remove-" + pod.GenerateName = "reboot-required-remove-" pod.Spec.Containers[0].Command = []string{"rm", "-f", "/host/var/run/reboot-required"} pod.Spec.Containers[0].VolumeMounts[0].ReadOnly = false pod.Spec.SecurityContext.RunAsUser = PtrTo(int64(0)) From 2ff78d3a8dbcc68a3191372c7ce6df3be3e0be92 Mon Sep 17 00:00:00 2001 From: Simon Bengtsson Date: Mon, 8 Sep 2025 22:54:48 +0200 Subject: [PATCH 4/6] Improve workflows --- .github/workflows/build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e83fe46..a8f7f48 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -55,7 +55,8 @@ jobs: elif [[ "${{ github.ref_type }}" == "tag" && "${{ github.ref_name }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then export IMG_TAG=$(echo -n "${{ github.ref_name }}" | sed 's/^v//g') fi - echo "IMG_TAG=${IMG_TAG//\//-}" >> $GITHUB_OUTPUT + export IMG_TAG=${IMG_TAG//\//-} + echo "IMG_TAG=${IMG_TAG}" >> $GITHUB_OUTPUT make docker-build - name: Push image From c407730761bb047cf55550f5400e2183d0242b3d Mon Sep 17 00:00:00 2001 From: Simon Bengtsson Date: Mon, 8 Sep 2025 23:08:55 +0200 Subject: [PATCH 5/6] Improve workflows --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a8f7f48..d901f21 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -39,7 +39,7 @@ jobs: go-version-file: go.mod - name: Login to GitHub Container Registry - if: github.ref == 'refs/heads/main' || (github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/v')) + if: github.ref_protected uses: docker/login-action@v3 with: registry: ghcr.io @@ -60,7 +60,7 @@ jobs: make docker-build - name: Push image - if: github.ref == 'refs/heads/main' || (github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/v')) + if: github.ref_protected env: IMG_TAG: ${{ steps.build_image.outputs.IMG_TAG }} run: | @@ -87,7 +87,7 @@ jobs: run: helm version - name: Login to GitHub Container Registry - if: github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/v') + if: github.ref_protected uses: docker/login-action@v3 with: registry: ghcr.io From f88941d258ce938ed961b4eb203f970f4d2552fe Mon Sep 17 00:00:00 2001 From: Simon Bengtsson Date: Mon, 8 Sep 2025 23:13:25 +0200 Subject: [PATCH 6/6] Improve workflows --- .github/workflows/build.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d901f21..81b12e3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -33,11 +33,6 @@ jobs: - name: Checkout code uses: actions/checkout@v2 - - name: Setup Go - uses: actions/setup-go@v5 - with: - go-version-file: go.mod - - name: Login to GitHub Container Registry if: github.ref_protected uses: docker/login-action@v3