From 7f453bdf05849537539f49e026bcc1e15fc67f39 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Thu, 29 Oct 2020 20:00:50 -0700 Subject: [PATCH 1/2] Create go.yml --- .github/workflows/go.yml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/go.yml diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 0000000..1c5b486 --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,36 @@ +name: Go + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + + build: + name: Build + runs-on: ubuntu-latest + steps: + + - name: Set up Go 1.x + uses: actions/setup-go@v2 + with: + go-version: ^1.13 + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Get dependencies + run: | + go get -v -t -d ./... + if [ -f Gopkg.toml ]; then + curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh + dep ensure + fi + + - name: Build + run: go build -v . + + - name: Test + run: go test -v . From 0bcbcd1d0bb482c400b512059aec380b8d21169f Mon Sep 17 00:00:00 2001 From: Howard Lau Date: Fri, 30 Oct 2020 05:15:18 +0000 Subject: [PATCH 2/2] Add verify codegen and manifests Signed-off-by: Howard Lau --- .github/workflows/verify.yml | 35 +++++++++++++++++++ api/v1/seaweed_types.go | 10 +++--- api/v1/zz_generated.deepcopy.go | 2 +- .../bases/seaweed.seaweedfs.com_seaweeds.yaml | 18 ++++++++++ controllers/controller_master_statefulset.go | 2 +- hack/verify-codegen.sh | 32 +++++++++++++++++ hack/verify-manifests.sh | 32 +++++++++++++++++ 7 files changed, 124 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/verify.yml create mode 100755 hack/verify-codegen.sh create mode 100755 hack/verify-manifests.sh diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml new file mode 100644 index 0000000..16e69b0 --- /dev/null +++ b/.github/workflows/verify.yml @@ -0,0 +1,35 @@ +name: Verify + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + verify: + name: Verify + runs-on: ubuntu-latest + steps: + + - name: Set up Go 1.x + uses: actions/setup-go@v2 + with: + go-version: ^1.13 + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Get dependencies + run: | + go get -v -t -d ./... + if [ -f Gopkg.toml ]; then + curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh + dep ensure + fi + + - name: Verify Codegen + run: hack/verify-codegen.sh + + - name: Verify Manifests + run: hack/verify-manifests.sh \ No newline at end of file diff --git a/api/v1/seaweed_types.go b/api/v1/seaweed_types.go index 338725d..36c2921 100644 --- a/api/v1/seaweed_types.go +++ b/api/v1/seaweed_types.go @@ -122,11 +122,11 @@ type MasterSpec struct { // Config in raw toml string Config *string `json:"config,omitempty"` - VolumePreallocate *bool `json:"volumePreallocate,omitempty"` - VolumeSizeLimitMB *int32 `json:"volumeSizeLimitMB,omitempty"` - GarbageThreshold *float64 `json:"garbageThreshold,omitempty"` - PulseSeconds *int32 `json:"pulseSeconds,omitempty"` - DefaultReplication *string `json:"defaultReplication,omitempty"` + VolumePreallocate *bool `json:"volumePreallocate,omitempty"` + VolumeSizeLimitMB *int32 `json:"volumeSizeLimitMB,omitempty"` + GarbageThreshold *string `json:"garbageThreshold,omitempty"` + PulseSeconds *int32 `json:"pulseSeconds,omitempty"` + DefaultReplication *string `json:"defaultReplication,omitempty"` } // VolumeSpec is the spec for volume servers diff --git a/api/v1/zz_generated.deepcopy.go b/api/v1/zz_generated.deepcopy.go index 43ae982..af0b627 100644 --- a/api/v1/zz_generated.deepcopy.go +++ b/api/v1/zz_generated.deepcopy.go @@ -176,7 +176,7 @@ func (in *MasterSpec) DeepCopyInto(out *MasterSpec) { } if in.GarbageThreshold != nil { in, out := &in.GarbageThreshold, &out.GarbageThreshold - *out = new(float64) + *out = new(string) **out = **in } if in.PulseSeconds != nil { diff --git a/config/crd/bases/seaweed.seaweedfs.com_seaweeds.yaml b/config/crd/bases/seaweed.seaweedfs.com_seaweeds.yaml index 46ba57d..f93aa1b 100644 --- a/config/crd/bases/seaweed.seaweedfs.com_seaweeds.yaml +++ b/config/crd/bases/seaweed.seaweedfs.com_seaweeds.yaml @@ -3525,6 +3525,9 @@ spec: description: Annotations of the component. Merged into the cluster-level annotations if non-empty type: object + config: + description: Config in raw toml string + type: string env: description: List of environment variables to set in the container, like v1.Container.Env. Note that following env names cannot be @@ -6715,6 +6718,11 @@ spec: description: Annotations of the component. Merged into the cluster-level annotations if non-empty type: object + config: + description: Config in raw toml string + type: string + defaultReplication: + type: string env: description: List of environment variables to set in the container, like v1.Container.Env. Note that following env names cannot be @@ -6824,6 +6832,8 @@ spec: - name type: object type: array + garbageThreshold: + type: string hostNetwork: description: Whether Hostnetwork of the component is enabled. Override the cluster-level setting if present @@ -6866,6 +6876,9 @@ spec: description: PriorityClassName of the component. Override the cluster-level one if present type: string + pulseSeconds: + format: int32 + type: integer replicas: description: The desired ready replicas format: int32 @@ -6968,6 +6981,11 @@ spec: description: Version of the component. Override the cluster-level version if non-empty type: string + volumePreallocate: + type: boolean + volumeSizeLimitMB: + format: int32 + type: integer required: - replicas type: object diff --git a/controllers/controller_master_statefulset.go b/controllers/controller_master_statefulset.go index d571055..a419f9f 100644 --- a/controllers/controller_master_statefulset.go +++ b/controllers/controller_master_statefulset.go @@ -24,7 +24,7 @@ func buildMasterStartupScript(m *seaweedv1.Seaweed) string { } if spec.GarbageThreshold != nil { - command = append(command, fmt.Sprintf("-garbageThreshold=%f", *spec.GarbageThreshold)) + command = append(command, fmt.Sprintf("-garbageThreshold=%s", *spec.GarbageThreshold)) } if spec.PulseSeconds != nil { diff --git a/hack/verify-codegen.sh b/hack/verify-codegen.sh new file mode 100755 index 0000000..96f1b7d --- /dev/null +++ b/hack/verify-codegen.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +set -o errexit +set -o nounset +set -o pipefail +ROOT=$(unset CDPATH && cd $(dirname "${BASH_SOURCE[0]}")/.. && pwd) + +DIFFROOT="${ROOT}/api" +TMP_DIFFROOT="${ROOT}/_tmp/api" +_tmp="${ROOT}/_tmp" + +cleanup() { + rm -rf "${_tmp}" +} +trap "cleanup" EXIT SIGINT + +cleanup + +mkdir -p "${TMP_DIFFROOT}" +cp -a "${DIFFROOT}"/* "${TMP_DIFFROOT}" + +make generate +echo "diffing ${DIFFROOT} against freshly generated codegen" +ret=0 +diff -Naupr "${DIFFROOT}" "${TMP_DIFFROOT}" || ret=$? +cp -a "${TMP_DIFFROOT}"/* "${DIFFROOT}" +if [[ $ret -eq 0 ]]; then + echo "${DIFFROOT} up to date." +else + echo "${DIFFROOT} is out of date. Please run make generate" + exit 1 +fi diff --git a/hack/verify-manifests.sh b/hack/verify-manifests.sh new file mode 100755 index 0000000..57d01ff --- /dev/null +++ b/hack/verify-manifests.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +set -o errexit +set -o nounset +set -o pipefail +ROOT=$(unset CDPATH && cd $(dirname "${BASH_SOURCE[0]}")/.. && pwd) + +DIFFROOT="${ROOT}/config" +TMP_DIFFROOT="${ROOT}/_tmp/config" +_tmp="${ROOT}/_tmp" + +cleanup() { + rm -rf "${_tmp}" +} +trap "cleanup" EXIT SIGINT + +cleanup + +mkdir -p "${TMP_DIFFROOT}" +cp -a "${DIFFROOT}"/* "${TMP_DIFFROOT}" + +make manifests +echo "diffing ${DIFFROOT} against freshly generated manifests" +ret=0 +diff -Naupr "${DIFFROOT}" "${TMP_DIFFROOT}" || ret=$? +cp -a "${TMP_DIFFROOT}"/* "${DIFFROOT}" +if [[ $ret -eq 0 ]]; then + echo "${DIFFROOT} up to date." +else + echo "${DIFFROOT} is out of date. Please run make manifests" + exit 1 +fi