From e7253ae5a0f4fa8ef480bd22f9b42fcc5fa106f8 Mon Sep 17 00:00:00 2001 From: Jack Francis Date: Mon, 20 Oct 2025 14:46:51 -0700 Subject: [PATCH 1/4] ci: dedicated UT jobs for CA and VPA --- .github/workflows/ca-test.yaml | 41 ++++++++++++++ .github/workflows/{ci.yaml => verify.yaml} | 8 +-- .github/workflows/vpa-test.yaml | 42 ++++++++++++++ hack/for-go-proj.sh | 66 ++++++++-------------- 4 files changed, 107 insertions(+), 50 deletions(-) create mode 100644 .github/workflows/ca-test.yaml rename .github/workflows/{ci.yaml => verify.yaml} (85%) create mode 100644 .github/workflows/vpa-test.yaml diff --git a/.github/workflows/ca-test.yaml b/.github/workflows/ca-test.yaml new file mode 100644 index 00000000000..665888981f3 --- /dev/null +++ b/.github/workflows/ca-test.yaml @@ -0,0 +1,41 @@ +name: Tests + +on: + push: + paths: + - 'cluster-autoscaler/**' + pull_request: + paths: + - 'cluster-autoscaler/**' + +env: + GOPATH: ${{ github.workspace }}/go + +permissions: + contents: read + checks: write + +jobs: + cluster-autoscaler-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4.2.2 + with: + path: ${{ env.GOPATH }}/src/k8s.io/autoscaler + + - name: Set up Go + uses: actions/setup-go@v5.5.0 + with: + go-version: '1.24.0' + cache-dependency-path: | + ${{ env.GOPATH}}/src/k8s.io/autoscaler/cluster-autoscaler/go.sum + + - name: Apt-get + run: sudo apt-get install libseccomp-dev -qq + + - name: Test + working-directory: ${{ env.GOPATH }}/src/k8s.io/autoscaler + run: hack/for-go-proj.sh cluster-autoscaler + env: + GO111MODULE: auto + PROJECT_NAMES: "" diff --git a/.github/workflows/ci.yaml b/.github/workflows/verify.yaml similarity index 85% rename from .github/workflows/ci.yaml rename to .github/workflows/verify.yaml index 2f709884cb1..e7cb4a107a9 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/verify.yaml @@ -12,7 +12,7 @@ permissions: checks: write jobs: - test-and-verify: + verify: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4.2.2 @@ -42,9 +42,3 @@ jobs: run: hack/verify-all.sh -v env: GO111MODULE: auto - - - name: Test - working-directory: ${{ env.GOPATH }}/src/k8s.io/autoscaler - run: hack/for-go-proj.sh test - env: - GO111MODULE: auto diff --git a/.github/workflows/vpa-test.yaml b/.github/workflows/vpa-test.yaml new file mode 100644 index 00000000000..a8b9f2cdfb2 --- /dev/null +++ b/.github/workflows/vpa-test.yaml @@ -0,0 +1,42 @@ +name: Tests + +on: + push: + paths: + - 'vertical-pod-autoscaler/**' + pull_request: + paths: + - 'vertical-pod-autoscaler/**' + +env: + GOPATH: ${{ github.workspace }}/go + +permissions: + contents: read + checks: write + +jobs: + vertical-pod-autoscaler-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4.2.2 + with: + path: ${{ env.GOPATH }}/src/k8s.io/autoscaler + + - name: Set up Go + uses: actions/setup-go@v5.5.0 + with: + go-version: '1.24.0' + cache-dependency-path: | + ${{ env.GOPATH}}/src/k8s.io/autoscaler/vertical-pod-autoscaler/go.sum + ${{ env.GOPATH}}/src/k8s.io/autoscaler/vertical-pod-autoscaler/e2e/go.sum + + - name: Apt-get + run: sudo apt-get install libseccomp-dev -qq + + - name: Test + working-directory: ${{ env.GOPATH }}/src/k8s.io/autoscaler + run: hack/for-go-proj.sh vertical-pod-autoscaler + env: + GO111MODULE: auto + PROJECT_NAMES: "" diff --git a/hack/for-go-proj.sh b/hack/for-go-proj.sh index eaaff6d71b8..318b0f495c1 100755 --- a/hack/for-go-proj.sh +++ b/hack/for-go-proj.sh @@ -19,58 +19,38 @@ set -o pipefail set -o nounset CONTRIB_ROOT="$(dirname ${BASH_SOURCE})/.." -PROJECT_NAMES=(addon-resizer vertical-pod-autoscaler) if [[ $# -ne 1 ]]; then - echo "missing subcommand: [build|install|test]" + echo "missing subcommand: [cluster-autoscaler|vertical-pod-autoscaler|addon-resizer]" exit 1 fi -CMD="${1}" - -case "${CMD}" in - "build") - ;; - "install") +PROJECT="${1}" + +case "${PROJECT}" in + "cluster-autoscaler") + pushd ${CONTRIB_ROOT}/cluster-autoscaler/ + # TODO: #8127 - Use default analyzers set by `go test` to include `printf` analyzer. + # Default analyzers that go test runs according to https://github.com/golang/go/blob/52624e533fe52329da5ba6ebb9c37712048168e0/src/cmd/go/internal/test/test.go#L649 + # This doesn't include the `printf` analyzer until cluster-autoscaler libraries are updated. + ANALYZERS="atomic,bool,buildtags,directive,errorsas,ifaceassert,nilfunc,slog,stringintconv,tests" + go test -count=1 ./... -vet="${ANALYZERS}" + popd ;; - "test") + "vertical-pod-autoscaler") + pushd ${CONTRIB_ROOT}/vertical-pod-autoscaler + go test -count=1 -race $(go list ./... | grep -v /vendor/ | grep -v vertical-pod-autoscaler/e2e | grep -v cluster-autoscaler/apis) + popd + pushd ${CONTRIB_ROOT}/vertical-pod-autoscaler/e2e + go test -run=None ./... + popd ;; + "addon-resizer") + pushd ${CONTRIB_ROOT}/addon-resizer + godep go test -race $(go list ./... | grep -v /vendor/ | grep -v vertical-pod-autoscaler/e2e) + popd *) echo "invalid subcommand: ${CMD}" exit 1 ;; esac - -for project_name in ${PROJECT_NAMES[*]}; do - ( - export GO111MODULE=auto - project=${CONTRIB_ROOT}/${project_name} - echo "${CMD}ing ${project}" - cd "${project}" - case "${CMD}" in - "test") - if [[ -n $(find . -name "Godeps.json") ]]; then - godep go test -race $(go list ./... | grep -v /vendor/ | grep -v vertical-pod-autoscaler/e2e) - else - go test -count=1 -race $(go list ./... | grep -v /vendor/ | grep -v vertical-pod-autoscaler/e2e | grep -v cluster-autoscaler/apis) - fi - ;; - *) - godep go "${CMD}" ./... - ;; - esac - ) -done; - -if [ "${CMD}" = "build" ] || [ "${CMD}" == "test" ]; then - pushd ${CONTRIB_ROOT}/vertical-pod-autoscaler/e2e - go test -run=None ./... - popd - pushd ${CONTRIB_ROOT}/cluster-autoscaler/ - # TODO: #8127 - Use default analyzers set by `go test` to include `printf` analyzer. - # Default analyzers that go test runs according to https://github.com/golang/go/blob/52624e533fe52329da5ba6ebb9c37712048168e0/src/cmd/go/internal/test/test.go#L649 - # This doesn't include the `printf` analyzer until cluster-autoscaler libraries are updated. - ANALYZERS="atomic,bool,buildtags,directive,errorsas,ifaceassert,nilfunc,slog,stringintconv,tests" - go test -count=1 ./... -vet="${ANALYZERS}" - popd -fi From bbb190615ddea5e50a40a9b5422f53d8fc8fd0c2 Mon Sep 17 00:00:00 2001 From: Jack Francis Date: Mon, 20 Oct 2025 14:59:05 -0700 Subject: [PATCH 2/4] changes to ca and vpa to trigger tests --- .github/workflows/ca-test.yaml | 2 +- .github/workflows/verify.yaml | 2 +- .github/workflows/vpa-test.yaml | 2 +- cluster-autoscaler/README.md | 2 +- vertical-pod-autoscaler/README.md | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ca-test.yaml b/.github/workflows/ca-test.yaml index 665888981f3..3d3b892af9c 100644 --- a/.github/workflows/ca-test.yaml +++ b/.github/workflows/ca-test.yaml @@ -1,4 +1,4 @@ -name: Tests +name: Cluster Autoscaler Tests on: push: diff --git a/.github/workflows/verify.yaml b/.github/workflows/verify.yaml index e7cb4a107a9..2dbd70a2631 100644 --- a/.github/workflows/verify.yaml +++ b/.github/workflows/verify.yaml @@ -1,4 +1,4 @@ -name: Tests +name: Verify Go on: - push diff --git a/.github/workflows/vpa-test.yaml b/.github/workflows/vpa-test.yaml index a8b9f2cdfb2..ce1f628ba60 100644 --- a/.github/workflows/vpa-test.yaml +++ b/.github/workflows/vpa-test.yaml @@ -1,4 +1,4 @@ -name: Tests +name: VPA Tests on: push: diff --git a/cluster-autoscaler/README.md b/cluster-autoscaler/README.md index 4b2ec2c3031..234600393e5 100644 --- a/cluster-autoscaler/README.md +++ b/cluster-autoscaler/README.md @@ -4,7 +4,7 @@ # Introduction Cluster Autoscaler is a tool that automatically adjusts the size of the Kubernetes cluster when one of the following conditions is true: -* there are pods that failed to run in the cluster due to insufficient +* there are pods that failed to be scheduled in the cluster due to insufficient resources. * there are nodes in the cluster that have been underutilized for an extended period of time and their pods can be placed on other existing nodes. diff --git a/vertical-pod-autoscaler/README.md b/vertical-pod-autoscaler/README.md index f119b405c79..d20219c709b 100644 --- a/vertical-pod-autoscaler/README.md +++ b/vertical-pod-autoscaler/README.md @@ -14,7 +14,7 @@ Vertical Pod Autoscaler (VPA) frees users from the necessity of setting up-to-date resource requests for the containers in their pods. When configured, it will set the requests automatically based on usage and thus -allow proper scheduling onto nodes so that appropriate resource amount is +allow proper scheduling onto nodes so that appropriate resource overhead is available for each pod. It will also maintain ratios between requests and limits that were specified in initial containers configuration. From ea18cc8d6a23a4cda36073d8d676baef7c5ba6a7 Mon Sep 17 00:00:00 2001 From: Jack Francis Date: Mon, 20 Oct 2025 15:14:31 -0700 Subject: [PATCH 3/4] missing ;; --- hack/for-go-proj.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/hack/for-go-proj.sh b/hack/for-go-proj.sh index 318b0f495c1..d82cbfd9741 100755 --- a/hack/for-go-proj.sh +++ b/hack/for-go-proj.sh @@ -49,6 +49,7 @@ case "${PROJECT}" in pushd ${CONTRIB_ROOT}/addon-resizer godep go test -race $(go list ./... | grep -v /vendor/ | grep -v vertical-pod-autoscaler/e2e) popd + ;; *) echo "invalid subcommand: ${CMD}" exit 1 From adcd6bc950788a1cd26a57fcc1616b9c83573e1a Mon Sep 17 00:00:00 2001 From: Jack Francis Date: Fri, 31 Oct 2025 08:52:23 -0700 Subject: [PATCH 4/4] rename test configs to Cluster Autoscaler and Vertical Pod Autoscaler --- .github/workflows/ca-test.yaml | 5 +++-- .github/workflows/vpa-golangci-lint.yaml | 6 +++--- .github/workflows/vpa-test.yaml | 5 +++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ca-test.yaml b/.github/workflows/ca-test.yaml index 3d3b892af9c..964f773bcb3 100644 --- a/.github/workflows/ca-test.yaml +++ b/.github/workflows/ca-test.yaml @@ -1,4 +1,4 @@ -name: Cluster Autoscaler Tests +name: Cluster Autoscaler on: push: @@ -16,7 +16,8 @@ permissions: checks: write jobs: - cluster-autoscaler-test: + test: + name: Run unit tests runs-on: ubuntu-latest steps: - uses: actions/checkout@v4.2.2 diff --git a/.github/workflows/vpa-golangci-lint.yaml b/.github/workflows/vpa-golangci-lint.yaml index 15a26992514..21a9daa6b7c 100644 --- a/.github/workflows/vpa-golangci-lint.yaml +++ b/.github/workflows/vpa-golangci-lint.yaml @@ -1,4 +1,4 @@ -name: Lint +name: Vertical Pod Autoscaler on: push: @@ -15,8 +15,8 @@ permissions: contents: read jobs: - golangci: - name: golangci-lint - VPA + lint: + name: Run golangci-lint runs-on: ubuntu-latest steps: - uses: actions/checkout@v5 diff --git a/.github/workflows/vpa-test.yaml b/.github/workflows/vpa-test.yaml index ce1f628ba60..15c198bd83f 100644 --- a/.github/workflows/vpa-test.yaml +++ b/.github/workflows/vpa-test.yaml @@ -1,4 +1,4 @@ -name: VPA Tests +name: Vertical Pod Autoscaler on: push: @@ -16,7 +16,8 @@ permissions: checks: write jobs: - vertical-pod-autoscaler-test: + test: + name: Run unit tests runs-on: ubuntu-latest steps: - uses: actions/checkout@v4.2.2