diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 89d9f05..81b12e3 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/ @@ -18,13 +33,8 @@ 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 == '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 @@ -40,11 +50,12 @@ 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 + export IMG_TAG=${IMG_TAG//\//-} echo "IMG_TAG=${IMG_TAG}" >> $GITHUB_OUTPUT 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: | @@ -71,7 +82,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 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: 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))