From aa71986f8fe55d35e7b63fc19e0e2678ebce0cc3 Mon Sep 17 00:00:00 2001 From: ysicing Date: Fri, 1 Sep 2023 13:10:19 +0800 Subject: [PATCH] feat(precheck): change devops check change devops check Signed-off-by: ysicing --- .github/runner.yml | 11 +++++++++++ .github/workflows/test.yml | 3 +-- internal/pkg/util/preflight/checks.go | 13 +++++++------ internal/pkg/util/preflight/checks_linux.go | 13 +++++++------ 4 files changed, 26 insertions(+), 14 deletions(-) create mode 100644 .github/runner.yml diff --git a/.github/runner.yml b/.github/runner.yml new file mode 100644 index 00000000..087226e0 --- /dev/null +++ b/.github/runner.yml @@ -0,0 +1,11 @@ +apiVersion: actions.summerwind.dev/v1alpha1 +kind: RunnerDeployment +metadata: + name: quickon-cli-runner +spec: + replicas: 1 + template: + spec: + repository: easysoft/quickon_cli + labels: + - quickon-cli-runner diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fee4ea42..3d5af46d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -31,8 +31,7 @@ jobs: build: name: "build" timeout-minutes: 20 - # runs-on: ubuntu-latest - runs-on: self-hosted + runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 diff --git a/internal/pkg/util/preflight/checks.go b/internal/pkg/util/preflight/checks.go index 703a96e5..b5d32be2 100644 --- a/internal/pkg/util/preflight/checks.go +++ b/internal/pkg/util/preflight/checks.go @@ -681,17 +681,18 @@ func (ncc NumCPUCheck) Check() error { log := log.GetInstance() log.Debug("validating number of CPUs") numCPU := runtime.NumCPU() + if numCPU < ncc.NumCPU { + return errors.Errorf("the number of available CPUs %d is less than the required %d", numCPU, ncc.NumCPU) + } if ncc.Devops { if numCPU < ncc.NumCPU*2 { - return errors.Errorf("the number of available CPUs %d is less than the required %d", numCPU, ncc.NumCPU*2) + log.Warnf("the number of available CPUs %d is greater than the required %d", numCPU, ncc.NumCPU*2) + return nil } log.Donef("the number of available CPUs %d is greater than the required %d", numCPU, ncc.NumCPU*2) - return nil - } - if numCPU < ncc.NumCPU { - return errors.Errorf("the number of available CPUs %d is less than the required %d", numCPU, ncc.NumCPU) + } else { + log.Donef("the number of available CPUs %d is greater than the required %d", numCPU, ncc.NumCPU) } - log.Donef("the number of available CPUs %d is greater than the required %d", numCPU, ncc.NumCPU) return nil } diff --git a/internal/pkg/util/preflight/checks_linux.go b/internal/pkg/util/preflight/checks_linux.go index 5d38e2c8..58068938 100644 --- a/internal/pkg/util/preflight/checks_linux.go +++ b/internal/pkg/util/preflight/checks_linux.go @@ -38,16 +38,17 @@ func (mc MemCheck) Check() error { // Totalram holds the total usable memory. Unit holds the size of a memory unit in bytes. Multiply them and convert to MB actual := uint64(info.Totalram) * uint64(info.Unit) / 1024 / 1024 + if actual < mc.Mem { + return errors.Errorf("the system RAM (%d MB) is less than the minimum %d MB", actual, mc.Mem) + } if mc.Devops { if actual < mc.Mem*2 { - return errors.Errorf("the system RAM (%d MB) is less than the minimum %d MB", actual, mc.Mem*2) + log.Warnf("the system RAM (%d MB) is less than the minimum %d MB", actual, mc.Mem*2) + return nil } log.Donef("the system RAM (%d MB) is greater than the minimum %d MB", actual, mc.Mem*2) - return nil - } - if actual < mc.Mem { - return errors.Errorf("the system RAM (%d MB) is less than the minimum %d MB", actual, mc.Mem) + } else { + log.Donef("the system RAM (%d MB) is greater than the minimum %d MB", actual, mc.Mem) } - log.Donef("the system RAM (%d MB) is greater than the minimum %d MB", actual, mc.Mem) return nil }