From a4d508a2e504912c778f01be5dbd0dba4f1af351 Mon Sep 17 00:00:00 2001 From: Seer Date: Mon, 26 Aug 2024 14:03:56 +0800 Subject: [PATCH] chore: updated suite test configs --- .github/workflows/dev.yaml | 4 +- .gitignore | 1 + Dockerfile | 11 +- Makefile | 153 +++++++++--------- ...atabases.spotahome.com_redisfailovers.yaml | 38 ++++- ...atabases.spotahome.com_redissentinels.yaml | 9 +- .../crd/bases/middleware.alauda.io_redis.yaml | 34 +++- .../redis.kun_distributedredisclusters.yaml | 51 ++++-- ...redis.middleware.alauda.io_redisusers.yaml | 2 +- config/rbac/role.yaml | 60 +++++-- ...distributedrediscluster_controller_test.go | 3 +- internal/controller/cluster/suite_test.go | 10 -- internal/controller/databases/suite_test.go | 10 -- internal/controller/middleware/suite_test.go | 2 +- pkg/kubernetes/clientset/clientset.go | 6 +- pkg/kubernetes/clientset/mocks/client_set.go | 6 +- pkg/kubernetes/clientset/namespaces.go | 31 ++-- pkg/kubernetes/kubernetes.go | 2 +- pkg/redis/node_test.go | 5 + 19 files changed, 261 insertions(+), 177 deletions(-) diff --git a/.github/workflows/dev.yaml b/.github/workflows/dev.yaml index 98faaf5..28aa7ab 100644 --- a/.github/workflows/dev.yaml +++ b/.github/workflows/dev.yaml @@ -18,10 +18,10 @@ jobs: go mod download - name: Run Unit tests run: | - go test -race -covermode atomic -coverprofile=covprofile ./... + make test - name: Install goveralls run: go install github.com/mattn/goveralls@latest - name: Send coverage env: COVERALLS_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} - run: goveralls -coverprofile=covprofile -service=github + run: goveralls -coverprofile=coverage.txt -service=github diff --git a/.gitignore b/.gitignore index 78fb8ca..015ac0a 100644 --- a/.gitignore +++ b/.gitignore @@ -28,6 +28,7 @@ bin/ .DS_Store .vscode/* +default.etcd/ coverage.txt bundle/* bundle.Dockerfile diff --git a/Dockerfile b/Dockerfile index 529e7c2..ca6c50d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,18 +2,19 @@ FROM golang:1.22-alpine as builder WORKDIR /workspace -# Dependencies are cached unless we change go.mod or go.sum -COPY go.mod go.mod -COPY go.sum go.sum -RUN GOPROXY=https://goproxy.io,direct go mod download - # Copy the go source +COPY version version COPY api/ api/ COPY cmd/ cmd/ COPY internal/ internal/ COPY pkg/ pkg/ COPY tools/ tools/ +COPY Makefile Makefile +# Dependencies are cached unless we change go.mod or go.sum +COPY go.mod go.mod +COPY go.sum go.sum +RUN GOPROXY=https://goproxy.io,direct go mod download RUN CGO_ENABLED=0 go build -a -tags timetzdata -buildmode=pie -ldflags '-extldflags "-Wl,-z,relro,-z,now"' -a -o manager cmd/main.go RUN CGO_ENABLED=0 go build -a -tags timetzdata -buildmode=pie -ldflags '-extldflags "-Wl,-z,relro,-z,now"' -a -o redis-tools cmd/redis-tools/main.go diff --git a/Makefile b/Makefile index 35f2614..6f1942c 100644 --- a/Makefile +++ b/Makefile @@ -48,14 +48,10 @@ ifeq ($(USE_IMAGE_DIGESTS), true) BUNDLE_GEN_FLAGS += --use-image-digests endif -# Set the Operator SDK version to use. By default, what is installed on the system is used. -# This is useful for CI or a project to utilize a specific version of the operator-sdk toolkit. -OPERATOR_SDK_VERSION ?= v1.32.0 - # Image URL to use all building/pushing image targets IMG ?= $(REGISTRY)/$(GROUP)/redis-operator:v$(VERSION) # ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary. -ENVTEST_K8S_VERSION = 1.26.0 +ENVTEST_K8S_VERSION = 1.30.0 # Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) ifeq (,$(shell go env GOBIN)) @@ -109,7 +105,21 @@ vet: ## Run go vet against code. .PHONY: test test: manifests generate fmt vet envtest ## Run tests. - KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test ./... -coverprofile cover.out + KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test $$(go list ./... | grep -vE "/e2e|/mocks") -covermode atomic -coverprofile=coverage.txt + go tool cover -func=coverage.txt | tail -n1 | awk '{print "Total test coverage: " $$3}' + +# Utilize Kind or modify the e2e tests to load the image locally, enabling compatibility with other vendors. +.PHONY: test-e2e # Run the e2e tests against a Kind k8s instance that is spun up. +test-e2e: + go test ./test/e2e/ -v -ginkgo.v + +.PHONY: lint +lint: golangci-lint ## Run golangci-lint linter + $(GOLANGCI_LINT) run + +.PHONY: lint-fix +lint-fix: golangci-lint ## Run golangci-lint linter and perform fixes + $(GOLANGCI_LINT) run --fix ##@ Build @@ -150,6 +160,27 @@ docker-buildx: test ## Build and push docker image for the manager for cross-pla - docker buildx rm project-v3-builder rm Dockerfile.cross +.PHONY: build-installer +build-installer: manifests generate kustomize ## Generate a consolidated YAML with CRDs and deployment. + mkdir -p dist + cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG} + $(KUSTOMIZE) build config/default > dist/install.yaml + +.PHONY: bundle +bundle: manifests kustomize operator-sdk ## Generate bundle manifests and metadata, then validate generated files. + @cd config/manager && $(KUSTOMIZE) edit set image redis-operator=$(IMG) + $(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle $(BUNDLE_GEN_FLAGS) + @sed -i 's#__CURRENT_VERSION__#$(VERSION)#g' ./bundle/manifests/redis-operator.clusterserviceversion.yaml + $(OPERATOR_SDK) bundle validate ./bundle + +.PHONY: bundle-build +bundle-build: ## Build the bundle image. + docker build -f bundle.Dockerfile -t $(BUNDLE_IMG) . + +.PHONY: bundle-push +bundle-push: ## Push the bundle image. + $(MAKE) docker-push IMG=$(BUNDLE_IMG) + ##@ Deployment ifndef ignore-not-found @@ -170,10 +201,10 @@ deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in $(KUSTOMIZE) build config/default | kubectl apply -f - .PHONY: undeploy -undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion. +undeploy: kustomize ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion. $(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f - -##@ Build Dependencies +##@ Dependencies ## Location to install dependencies to LOCALBIN ?= $(shell pwd)/bin @@ -182,33 +213,39 @@ $(LOCALBIN): ## Tool Binaries KUBECTL ?= kubectl -KUSTOMIZE ?= $(LOCALBIN)/kustomize -CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen -ENVTEST ?= $(LOCALBIN)/setup-envtest +KUSTOMIZE ?= $(LOCALBIN)/kustomize-$(KUSTOMIZE_VERSION) +CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen-$(CONTROLLER_TOOLS_VERSION) +ENVTEST ?= $(LOCALBIN)/setup-envtest-$(ENVTEST_VERSION) +GOLANGCI_LINT = $(LOCALBIN)/golangci-lint-$(GOLANGCI_LINT_VERSION) ## Tool Versions -KUSTOMIZE_VERSION ?= v5.0.1 -CONTROLLER_TOOLS_VERSION ?= v0.16.0 +KUSTOMIZE_VERSION ?= v5.4.1 +CONTROLLER_TOOLS_VERSION ?= v0.15.0 +ENVTEST_VERSION ?= release-0.18 +GOLANGCI_LINT_VERSION ?= v1.57.2 +# Set the Operator SDK version to use. By default, what is installed on the system is used. +# This is useful for CI or a project to utilize a specific version of the operator-sdk toolkit. +OPERATOR_SDK_VERSION ?= v1.36.1 .PHONY: kustomize -kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary. If wrong version is installed, it will be removed before downloading. +kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary. $(KUSTOMIZE): $(LOCALBIN) - @if test -x $(LOCALBIN)/kustomize && ! $(LOCALBIN)/kustomize version | grep -q $(KUSTOMIZE_VERSION); then \ - echo "$(LOCALBIN)/kustomize version is not expected $(KUSTOMIZE_VERSION). Removing it before installing."; \ - rm -rf $(LOCALBIN)/kustomize; \ - fi - test -s $(LOCALBIN)/kustomize || GOBIN=$(LOCALBIN) GO111MODULE=on go install sigs.k8s.io/kustomize/kustomize/v5@$(KUSTOMIZE_VERSION) + $(call go-install-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/v5,$(KUSTOMIZE_VERSION)) .PHONY: controller-gen -controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary. If wrong version is installed, it will be overwritten. +controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary. $(CONTROLLER_GEN): $(LOCALBIN) - test -s $(LOCALBIN)/controller-gen && $(LOCALBIN)/controller-gen --version | grep -q $(CONTROLLER_TOOLS_VERSION) || \ - GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION) + $(call go-install-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen,$(CONTROLLER_TOOLS_VERSION)) .PHONY: envtest -envtest: $(ENVTEST) ## Download envtest-setup locally if necessary. +envtest: $(ENVTEST) ## Download setup-envtest locally if necessary. $(ENVTEST): $(LOCALBIN) - test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest + $(call go-install-tool,$(ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest,$(ENVTEST_VERSION)) + +.PHONY: golangci-lint +golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary. +$(GOLANGCI_LINT): $(LOCALBIN) + $(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint,${GOLANGCI_LINT_VERSION}) .PHONY: operator-sdk OPERATOR_SDK ?= $(LOCALBIN)/operator-sdk @@ -227,58 +264,16 @@ OPERATOR_SDK = $(shell which operator-sdk) endif endif -.PHONY: bundle -bundle: manifests kustomize operator-sdk ## Generate bundle manifests and metadata, then validate generated files. - @cd config/manager && $(KUSTOMIZE) edit set image redis-operator=$(IMG) - $(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle $(BUNDLE_GEN_FLAGS) - @sed -i 's#__CURRENT_VERSION__#$(VERSION)#g' ./bundle/manifests/redis-operator.clusterserviceversion.yaml - $(OPERATOR_SDK) bundle validate ./bundle - -.PHONY: bundle-build -bundle-build: ## Build the bundle image. - docker build -f bundle.Dockerfile -t $(BUNDLE_IMG) . - -.PHONY: bundle-push -bundle-push: ## Push the bundle image. - $(MAKE) docker-push IMG=$(BUNDLE_IMG) - -.PHONY: opm -OPM = ./bin/opm -opm: ## Download opm locally if necessary. -ifeq (,$(wildcard $(OPM))) -ifeq (,$(shell which opm 2>/dev/null)) - @{ \ - set -e ;\ - mkdir -p $(dir $(OPM)) ;\ - OS=$(shell go env GOOS) && ARCH=$(shell go env GOARCH) && \ - curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.23.0/$${OS}-$${ARCH}-opm ;\ - chmod +x $(OPM) ;\ - } -else -OPM = $(shell which opm) -endif -endif - -# A comma-separated list of bundle images (e.g. make catalog-build BUNDLE_IMGS=example.com/operator-bundle:v0.1.0,example.com/operator-bundle:v0.2.0). -# These images MUST exist in a registry and be pull-able. -BUNDLE_IMGS ?= $(BUNDLE_IMG) - -# The image tag given to the resulting catalog image (e.g. make catalog-build CATALOG_IMG=example.com/operator-catalog:v0.2.0). -CATALOG_IMG ?= $(IMAGE_TAG_BASE)-catalog:v$(VERSION) - -# Set CATALOG_BASE_IMG to an existing catalog image tag to add $BUNDLE_IMGS to that image. -ifneq ($(origin CATALOG_BASE_IMG), undefined) -FROM_INDEX_OPT := --from-index $(CATALOG_BASE_IMG) -endif - -# Build a catalog image by adding bundle images to an empty catalog using the operator package manager tool, 'opm'. -# This recipe invokes 'opm' in 'semver' bundle add mode. For more information on add modes, see: -# https://github.com/operator-framework/community-operators/blob/7f1438c/docs/packaging-operator.md#updating-your-existing-operator -.PHONY: catalog-build -catalog-build: opm ## Build a catalog image. - $(OPM) index add --container-tool docker --mode semver --tag $(CATALOG_IMG) --bundles $(BUNDLE_IMGS) $(FROM_INDEX_OPT) - -# Push the catalog image. -.PHONY: catalog-push -catalog-push: ## Push a catalog image. - $(MAKE) docker-push IMG=$(CATALOG_IMG) +# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist +# $1 - target path with name of binary (ideally with version) +# $2 - package url which can be installed +# $3 - specific version of package +define go-install-tool +@[ -f $(1) ] || { \ +set -e; \ +package=$(2)@$(3) ;\ +echo "Downloading $${package}" ;\ +GOBIN=$(LOCALBIN) go install $${package} ;\ +mv "$$(echo "$(1)" | sed "s/-$(3)$$//")" $(1) ;\ +} +endef diff --git a/config/crd/bases/databases.spotahome.com_redisfailovers.yaml b/config/crd/bases/databases.spotahome.com_redisfailovers.yaml index 51b935f..296ae78 100644 --- a/config/crd/bases/databases.spotahome.com_redisfailovers.yaml +++ b/config/crd/bases/databases.spotahome.com_redisfailovers.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.0 + controller-gen.kubebuilder.io/version: v0.15.0 name: redisfailovers.databases.spotahome.com spec: group: databases.spotahome.com @@ -74,6 +74,7 @@ spec: description: EnableActiveRedis enable active-active model for Redis type: boolean labelWhitelist: + description: 'TODO: remove this field in 3.20, which not used' items: type: string type: array @@ -927,9 +928,11 @@ spec: Claims lists the names of resources, defined in spec.resourceClaims, that are used by this container. + This is an alpha field and requires enabling the DynamicResourceAllocation feature gate. + This field is immutable. It can only be set for containers. items: description: ResourceClaim references one entry in PodSpec.ResourceClaims. @@ -992,6 +995,7 @@ spec: type: integer description: |- NodePortMap defines the map of the nodeport for redis sentinel only + TODO: deprecated this field with NodePortSequence in 3.22 Reversed for 3.14 backward compatibility type: object dataStorageNodePortSequence: @@ -1039,6 +1043,7 @@ spec: description: |- Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid? type: string type: object x-kubernetes-map-type: atomic @@ -1063,9 +1068,11 @@ spec: Claims lists the names of resources, defined in spec.resourceClaims, that are used by this container. + This is an alpha field and requires enabling the DynamicResourceAllocation feature gate. + This field is immutable. It can only be set for containers. items: description: ResourceClaim references one entry in PodSpec.ResourceClaims. @@ -1133,10 +1140,12 @@ spec: Some volume types allow the Kubelet to change the ownership of that volume to be owned by the pod: + 1. The owning GID will be the FSGroup 2. The setgid bit is set (new files created in the volume will be owned by FSGroup) 3. The permission bits are OR'd with rw-rw---- + If unset, the Kubelet will not modify the ownership and permissions of any volume. Note that this field cannot be set when spec.os.name is windows. format: int64 @@ -1223,6 +1232,7 @@ spec: type indicates which kind of seccomp profile will be applied. Valid options are: + Localhost - a profile defined in a file on the node should be used. RuntimeDefault - the container runtime default profile should be used. Unconfined - no profile should be applied. @@ -1460,9 +1470,11 @@ spec: Claims lists the names of resources, defined in spec.resourceClaims, that are used by this container. + This is an alpha field and requires enabling the DynamicResourceAllocation feature gate. + This field is immutable. It can only be set for containers. items: description: ResourceClaim references one entry @@ -1596,7 +1608,7 @@ spec: names such as \"example.com/my-custom-resource\"\nApart from above values - keys that are unprefixed or have kubernetes.io prefix are considered\nreserved - and hence may not be used.\n\nClaimResourceStatus + and hence may not be used.\n\n\nClaimResourceStatus can be in any of following states:\n\t- ControllerResizeInProgress:\n\t\tState set when resize controller starts resizing the volume in control-plane.\n\t- ControllerResizeFailed:\n\t\tState @@ -1617,14 +1629,14 @@ spec: = \"NodeResizeInProgress\"\n - pvc.status.allocatedResourceStatus['storage'] = \"NodeResizeFailed\"\nWhen this field is not set, it means that no resize operation is in progress - for the given PVC.\n\nA controller that receives + for the given PVC.\n\n\nA controller that receives PVC update with previously unknown resourceName or ClaimResourceStatus\nshould ignore the update for the purpose it was designed. For example - a controller that\nonly is responsible for resizing capacity of the volume, should ignore PVC updates that change other valid\nresources associated with - PVC.\n\nThis is an alpha field and requires enabling + PVC.\n\n\nThis is an alpha field and requires enabling RecoverVolumeExpansionFailure feature." type: object x-kubernetes-map-type: granular @@ -1644,7 +1656,7 @@ spec: names such as \"example.com/my-custom-resource\"\nApart from above values - keys that are unprefixed or have kubernetes.io prefix are considered\nreserved - and hence may not be used.\n\nCapacity reported + and hence may not be used.\n\n\nCapacity reported here may be larger than the actual capacity when a volume expansion operation\nis requested.\nFor storage quota, the larger value from allocatedResources @@ -1654,13 +1666,13 @@ spec: request is lowered, allocatedResources is only\nlowered if there are no expansion operations in progress and if the actual volume capacity\nis equal or lower - than the requested capacity.\n\nA controller that + than the requested capacity.\n\n\nA controller that receives PVC update with previously unknown resourceName\nshould ignore the update for the purpose it was designed. For example - a controller that\nonly is responsible for resizing capacity of the volume, should ignore PVC updates that change other valid\nresources associated - with PVC.\n\nThis is an alpha field and requires + with PVC.\n\n\nThis is an alpha field and requires enabling RecoverVolumeExpansionFailure feature." type: object capacity: @@ -2572,6 +2584,7 @@ spec: type: integer description: |- NodePortMap defines the map of the nodeport for redis sentinel only + TODO: deprecated this field with NodePortSequence in 3.22 Reversed for 3.14 backward compatibility type: object dataStorageNodePortSequence: @@ -2624,6 +2637,7 @@ spec: description: |- Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid? type: string type: object x-kubernetes-map-type: atomic @@ -2668,9 +2682,11 @@ spec: Claims lists the names of resources, defined in spec.resourceClaims, that are used by this container. + This is an alpha field and requires enabling the DynamicResourceAllocation feature gate. + This field is immutable. It can only be set for containers. items: description: ResourceClaim references one entry in PodSpec.ResourceClaims. @@ -2725,10 +2741,12 @@ spec: Some volume types allow the Kubelet to change the ownership of that volume to be owned by the pod: + 1. The owning GID will be the FSGroup 2. The setgid bit is set (new files created in the volume will be owned by FSGroup) 3. The permission bits are OR'd with rw-rw---- + If unset, the Kubelet will not modify the ownership and permissions of any volume. Note that this field cannot be set when spec.os.name is windows. format: int64 @@ -2815,6 +2833,7 @@ spec: type indicates which kind of seccomp profile will be applied. Valid options are: + Localhost - a profile defined in a file on the node should be used. RuntimeDefault - the container runtime default profile should be used. Unconfined - no profile should be applied. @@ -2989,6 +3008,7 @@ spec: the event) or if no container name is specified "spec.containers[2]" (container with index 2 in this pod). This syntax is chosen only to have some well-defined way of referencing a part of an object. + TODO: this design is not final and this field is subject to change in the future. type: string kind: description: |- @@ -3154,7 +3174,9 @@ spec: description: TLSSecret the tls secret type: string version: - description: Version + description: |- + Version + TODO: remove this field in 3.20, which not used type: string type: object type: object diff --git a/config/crd/bases/databases.spotahome.com_redissentinels.yaml b/config/crd/bases/databases.spotahome.com_redissentinels.yaml index f159a34..e3c0cf2 100644 --- a/config/crd/bases/databases.spotahome.com_redissentinels.yaml +++ b/config/crd/bases/databases.spotahome.com_redissentinels.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.0 + controller-gen.kubebuilder.io/version: v0.15.0 name: redissentinels.databases.spotahome.com spec: group: databases.spotahome.com @@ -861,6 +861,7 @@ spec: type: integer description: |- NodePortMap defines the map of the nodeport for redis sentinel only + TODO: deprecated this field with NodePortSequence in 3.22 Reversed for 3.14 backward compatibility type: object dataStorageNodePortSequence: @@ -912,6 +913,7 @@ spec: description: |- Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid? type: string type: object x-kubernetes-map-type: atomic @@ -940,9 +942,11 @@ spec: Claims lists the names of resources, defined in spec.resourceClaims, that are used by this container. + This is an alpha field and requires enabling the DynamicResourceAllocation feature gate. + This field is immutable. It can only be set for containers. items: description: ResourceClaim references one entry in PodSpec.ResourceClaims. @@ -997,10 +1001,12 @@ spec: Some volume types allow the Kubelet to change the ownership of that volume to be owned by the pod: + 1. The owning GID will be the FSGroup 2. The setgid bit is set (new files created in the volume will be owned by FSGroup) 3. The permission bits are OR'd with rw-rw---- + If unset, the Kubelet will not modify the ownership and permissions of any volume. Note that this field cannot be set when spec.os.name is windows. format: int64 @@ -1087,6 +1093,7 @@ spec: type indicates which kind of seccomp profile will be applied. Valid options are: + Localhost - a profile defined in a file on the node should be used. RuntimeDefault - the container runtime default profile should be used. Unconfined - no profile should be applied. diff --git a/config/crd/bases/middleware.alauda.io_redis.yaml b/config/crd/bases/middleware.alauda.io_redis.yaml index c66a97b..f89d435 100644 --- a/config/crd/bases/middleware.alauda.io_redis.yaml +++ b/config/crd/bases/middleware.alauda.io_redis.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.0 + controller-gen.kubebuilder.io/version: v0.15.0 name: redis.middleware.alauda.io spec: group: middleware.alauda.io @@ -930,9 +930,11 @@ spec: Claims lists the names of resources, defined in spec.resourceClaims, that are used by this container. + This is an alpha field and requires enabling the DynamicResourceAllocation feature gate. + This field is immutable. It can only be set for containers. items: description: ResourceClaim references one entry in PodSpec.ResourceClaims. @@ -995,6 +997,7 @@ spec: type: integer description: |- NodePortMap defines the map of the nodeport for redis sentinel only + TODO: deprecated this field with NodePortSequence in 3.22 Reversed for 3.14 backward compatibility type: object dataStorageNodePortSequence: @@ -1003,7 +1006,9 @@ spec: NodePortSequence defines the sequence of the nodeport for redis cluster only type: string enableNodePort: - description: EnableNodePort defines if the nodeport is enabled + description: |- + EnableNodePort defines if the nodeport is enabled + TODO: remove this field in 3.22 type: boolean type: description: ServiceType defines the type of the all related service @@ -1082,6 +1087,7 @@ spec: Not all objects are required to be scoped to a namespace - the value of this field for those objects will be empty. + Must be a DNS_LABEL. Cannot be updated. More info: http://kubernetes.io/docs/user-guide/namespaces @@ -1141,6 +1147,7 @@ spec: clients must ensure that clusterIPs[0] and clusterIP have the same value. + This field may hold a maximum of two entries (dual-stack IPs, in either order). These IPs must correspond to the values of the ipFamilies field. Both clusterIPs and ipFamilies are governed by the ipFamilyPolicy field. @@ -1219,6 +1226,7 @@ spec: NodePort, and LoadBalancer, and does apply to "headless" services. This field will be wiped when updating a Service to type ExternalName. + This field may hold a maximum of two entries (dual-stack families, in either order). These families must correspond to the values of the clusterIPs field, if specified. Both clusterIPs and ipFamilies are @@ -1288,14 +1296,17 @@ spec: This field follows standard Kubernetes label syntax. Valid values are either: + * Un-prefixed protocol names - reserved for IANA standard service names (as per RFC-6335 and https://www.iana.org/assignments/service-names). + * Kubernetes-defined prefixed names: * 'kubernetes.io/h2c' - HTTP/2 over cleartext as described in https://www.rfc-editor.org/rfc/rfc7540 * 'kubernetes.io/ws' - WebSocket over cleartext as described in https://www.rfc-editor.org/rfc/rfc6455 * 'kubernetes.io/wss' - WebSocket over TLS as described in https://www.rfc-editor.org/rfc/rfc6455 + * Other protocols should use implementation-defined prefixed names such as mycompany.com/my-custom-protocol. type: string @@ -1326,9 +1337,7 @@ spec: format: int32 type: integer protocol: - allOf: - - default: TCP - - default: TCP + default: TCP description: |- The IP protocol for this port. Supports "TCP", "UDP", and "SCTP". Default is TCP. @@ -2261,9 +2270,11 @@ spec: Claims lists the names of resources, defined in spec.resourceClaims, that are used by this container. + This is an alpha field and requires enabling the DynamicResourceAllocation feature gate. + This field is immutable. It can only be set for containers. items: description: ResourceClaim references one entry in PodSpec.ResourceClaims. @@ -2413,9 +2424,11 @@ spec: Claims lists the names of resources, defined in spec.resourceClaims, that are used by this container. + This is an alpha field and requires enabling the DynamicResourceAllocation feature gate. + This field is immutable. It can only be set for containers. items: description: ResourceClaim references one entry in PodSpec.ResourceClaims. @@ -2480,10 +2493,12 @@ spec: Some volume types allow the Kubelet to change the ownership of that volume to be owned by the pod: + 1. The owning GID will be the FSGroup 2. The setgid bit is set (new files created in the volume will be owned by FSGroup) 3. The permission bits are OR'd with rw-rw---- + If unset, the Kubelet will not modify the ownership and permissions of any volume. Note that this field cannot be set when spec.os.name is windows. format: int64 @@ -2570,6 +2585,7 @@ spec: type indicates which kind of seccomp profile will be applied. Valid options are: + Localhost - a profile defined in a file on the node should be used. RuntimeDefault - the container runtime default profile should be used. Unconfined - no profile should be applied. @@ -3454,6 +3470,7 @@ spec: type: integer description: |- NodePortMap defines the map of the nodeport for redis sentinel only + TODO: deprecated this field with NodePortSequence in 3.22 Reversed for 3.14 backward compatibility type: object dataStorageNodePortSequence: @@ -3506,6 +3523,7 @@ spec: description: |- Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid? type: string type: object x-kubernetes-map-type: atomic @@ -3550,9 +3568,11 @@ spec: Claims lists the names of resources, defined in spec.resourceClaims, that are used by this container. + This is an alpha field and requires enabling the DynamicResourceAllocation feature gate. + This field is immutable. It can only be set for containers. items: description: ResourceClaim references one entry in PodSpec.ResourceClaims. @@ -3607,10 +3627,12 @@ spec: Some volume types allow the Kubelet to change the ownership of that volume to be owned by the pod: + 1. The owning GID will be the FSGroup 2. The setgid bit is set (new files created in the volume will be owned by FSGroup) 3. The permission bits are OR'd with rw-rw---- + If unset, the Kubelet will not modify the ownership and permissions of any volume. Note that this field cannot be set when spec.os.name is windows. format: int64 @@ -3697,6 +3719,7 @@ spec: type indicates which kind of seccomp profile will be applied. Valid options are: + Localhost - a profile defined in a file on the node should be used. RuntimeDefault - the container runtime default profile should be used. Unconfined - no profile should be applied. @@ -3987,6 +4010,7 @@ spec: the event) or if no container name is specified "spec.containers[2]" (container with index 2 in this pod). This syntax is chosen only to have some well-defined way of referencing a part of an object. + TODO: this design is not final and this field is subject to change in the future. type: string kind: description: |- diff --git a/config/crd/bases/redis.kun_distributedredisclusters.yaml b/config/crd/bases/redis.kun_distributedredisclusters.yaml index 31f84bb..eb11def 100644 --- a/config/crd/bases/redis.kun_distributedredisclusters.yaml +++ b/config/crd/bases/redis.kun_distributedredisclusters.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.0 + controller-gen.kubebuilder.io/version: v0.15.0 name: distributedredisclusters.redis.kun spec: group: redis.kun @@ -67,7 +67,9 @@ spec: DistributedRedisCluster properties: affinity: - description: Affinity + description: |- + Affinity + TODO: remove in 3.20 properties: nodeAffinity: description: Describes node affinity scheduling rules for the @@ -904,6 +906,7 @@ spec: description: |- Use this map to setup redis service. Most of the settings is key-value format. + For client-output-buffer-limit and rename, the values is split by group. type: object containerSecurityContext: @@ -1033,6 +1036,7 @@ spec: type indicates which kind of seccomp profile will be applied. Valid options are: + Localhost - a profile defined in a file on the node should be used. RuntimeDefault - the container runtime default profile should be used. Unconfined - no profile should be applied. @@ -1080,7 +1084,9 @@ spec: description: EnableTLS type: boolean env: - description: Env is the environment variables + description: |- + Env is the environment variables + TODO: remove in 3.20 items: description: EnvVar represents an environment variable present in a Container. @@ -1114,6 +1120,7 @@ spec: description: |- Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid? type: string optional: description: Specify whether the ConfigMap or its key @@ -1175,6 +1182,7 @@ spec: description: |- Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid? type: string optional: description: Specify whether the Secret or its key must @@ -1190,7 +1198,9 @@ spec: type: object type: array expose: - description: Expose config for service access + description: |- + Expose config for service access + TODO: should rename Expose to Access properties: accessPort: description: AccessPort defines the lb access nodeport @@ -1208,6 +1218,7 @@ spec: type: integer description: |- NodePortMap defines the map of the nodeport for redis sentinel only + TODO: deprecated this field with NodePortSequence in 3.22 Reversed for 3.14 backward compatibility type: object dataStorageNodePortSequence: @@ -1242,7 +1253,9 @@ spec: description: Image is the Redis image type: string imagePullPolicy: - description: ImagePullPolicy is the Redis image pull policy + description: |- + ImagePullPolicy is the Redis image pull policy + TODO: reset the default value to IfNotPresent in 3.20 type: string imagePullSecrets: items: @@ -1254,6 +1267,7 @@ spec: description: |- Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid? type: string type: object x-kubernetes-map-type: atomic @@ -1267,7 +1281,9 @@ spec: minimum: 3 type: integer monitor: - description: Monitor + description: |- + Monitor + TODO: added an global button to controller wether to enable monitor properties: args: description: |- @@ -1320,6 +1336,7 @@ spec: description: |- Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid? type: string optional: description: Specify whether the ConfigMap or its @@ -1382,6 +1399,7 @@ spec: description: |- Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid? type: string optional: description: Specify whether the Secret or its key @@ -1403,7 +1421,7 @@ spec: a container image type: string prometheus: - description: "PrometheusSpec\n\n\tthis struct must be Deprecated, + description: "PrometheusSpec\n\n\n\tthis struct must be Deprecated, only port is used." properties: interval: @@ -1435,9 +1453,11 @@ spec: Claims lists the names of resources, defined in spec.resourceClaims, that are used by this container. + This is an alpha field and requires enabling the DynamicResourceAllocation feature gate. + This field is immutable. It can only be set for containers. items: description: ResourceClaim references one entry in PodSpec.ResourceClaims. @@ -1609,6 +1629,7 @@ spec: type indicates which kind of seccomp profile will be applied. Valid options are: + Localhost - a profile defined in a file on the node should be used. RuntimeDefault - the container runtime default profile should be used. Unconfined - no profile should be applied. @@ -1664,12 +1685,14 @@ spec: description: |- Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid? type: string type: object x-kubernetes-map-type: atomic requiredAntiAffinity: - description: Set RequiredAntiAffinity to force the master-slave node - anti-affinity. + description: |- + Set RequiredAntiAffinity to force the master-slave node anti-affinity. + TODO: remove in 3.20 type: boolean resources: description: ResourceRequirements describes the compute resource requirements. @@ -1679,9 +1702,11 @@ spec: Claims lists the names of resources, defined in spec.resourceClaims, that are used by this container. + This is an alpha field and requires enabling the DynamicResourceAllocation feature gate. + This field is immutable. It can only be set for containers. items: description: ResourceClaim references one entry in PodSpec.ResourceClaims. @@ -1748,10 +1773,12 @@ spec: Some volume types allow the Kubelet to change the ownership of that volume to be owned by the pod: + 1. The owning GID will be the FSGroup 2. The setgid bit is set (new files created in the volume will be owned by FSGroup) 3. The permission bits are OR'd with rw-rw---- + If unset, the Kubelet will not modify the ownership and permissions of any volume. Note that this field cannot be set when spec.os.name is windows. format: int64 @@ -1838,6 +1865,7 @@ spec: type indicates which kind of seccomp profile will be applied. Valid options are: + Localhost - a profile defined in a file on the node should be used. RuntimeDefault - the container runtime default profile should be used. Unconfined - no profile should be applied. @@ -1986,7 +2014,9 @@ spec: type: string type: object serviceName: - description: ServiceName is the service name + description: |- + ServiceName is the service name + TODO: remove in 3.20, this should not changed or specified type: string shards: description: |- @@ -2086,6 +2116,7 @@ spec: the event) or if no container name is specified "spec.containers[2]" (container with index 2 in this pod). This syntax is chosen only to have some well-defined way of referencing a part of an object. + TODO: this design is not final and this field is subject to change in the future. type: string kind: description: |- diff --git a/config/crd/bases/redis.middleware.alauda.io_redisusers.yaml b/config/crd/bases/redis.middleware.alauda.io_redisusers.yaml index c38eed0..6c5e8bf 100644 --- a/config/crd/bases/redis.middleware.alauda.io_redisusers.yaml +++ b/config/crd/bases/redis.middleware.alauda.io_redisusers.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.16.0 + controller-gen.kubebuilder.io/version: v0.15.0 name: redisusers.redis.middleware.alauda.io spec: group: redis.middleware.alauda.io diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index cd7594c..1a2989f 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -8,13 +8,17 @@ rules: - '*' resources: - configmaps + - configmaps/finalizers - endpoints + - persistentvolumeclaims + - persistentvolumeclaims/finalizers - pods - pods/exec + - secrets + - secrets/finalizers - services - services/finalizers verbs: - - '*' - create - delete - deletecollection @@ -26,20 +30,14 @@ rules: - apiGroups: - '*' resources: - - configmaps/finalizers - - persistentvolumeclaims - - persistentvolumeclaims/finalizers - - secrets - - secrets/finalizers + - configmaps + - endpoints + - pods + - pods/exec + - services + - services/finalizers verbs: - - create - - delete - - deletecollection - - get - - list - - patch - - update - - watch + - '*' - apiGroups: - '*' resources: @@ -143,7 +141,6 @@ rules: - databases.spotahome.com resources: - redisfailovers - - redissentinels verbs: - create - delete @@ -156,13 +153,37 @@ rules: - databases.spotahome.com resources: - redisfailovers/finalizers - - redissentinels/finalizers verbs: - update - apiGroups: - databases.spotahome.com resources: - redisfailovers/status + verbs: + - get + - patch + - update +- apiGroups: + - databases.spotahome.com + resources: + - redissentinels + verbs: + - create + - delete + - get + - list + - patch + - update + - watch +- apiGroups: + - databases.spotahome.com + resources: + - redissentinels/finalizers + verbs: + - update +- apiGroups: + - databases.spotahome.com + resources: - redissentinels/status verbs: - get @@ -235,6 +256,12 @@ rules: - patch - update - watch +- apiGroups: + - redis.kun + resources: + - '*' + verbs: + - '*' - apiGroups: - redis.kun resources: @@ -262,7 +289,6 @@ rules: - patch - update - apiGroups: - - redis.kun - redis.middleware.alauda.io resources: - '*' diff --git a/internal/controller/cluster/distributedrediscluster_controller_test.go b/internal/controller/cluster/distributedrediscluster_controller_test.go index 7317b8a..d520d4a 100644 --- a/internal/controller/cluster/distributedrediscluster_controller_test.go +++ b/internal/controller/cluster/distributedrediscluster_controller_test.go @@ -62,7 +62,7 @@ var _ = Describe("DistributedRedisClusterReconciler", func() { Namespace: namespace, }, Spec: rediskunv1alpha1.DistributedRedisClusterSpec{ - Image: "redis:6.0.20", + Image: "redis:6.0", MasterSize: 3, ClusterReplicas: 1, Config: map[string]string{ @@ -95,6 +95,7 @@ var _ = Describe("DistributedRedisClusterReconciler", func() { By("Cleanup the specific resource instance Cron") Expect(k8sClient.Delete(ctx, resource)).To(Succeed()) }) + It("should successfully reconcile the resource", func() { By("Reconciling the created resource") diff --git a/internal/controller/cluster/suite_test.go b/internal/controller/cluster/suite_test.go index 56e4b5e..1708cdc 100644 --- a/internal/controller/cluster/suite_test.go +++ b/internal/controller/cluster/suite_test.go @@ -17,9 +17,7 @@ limitations under the License. package cluster import ( - "fmt" "path/filepath" - "runtime" "testing" . "github.com/onsi/ginkgo/v2" @@ -56,14 +54,6 @@ var _ = BeforeSuite(func() { testEnv = &envtest.Environment{ CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "config", "crd", "bases")}, ErrorIfCRDPathMissing: true, - - // The BinaryAssetsDirectory is only required if you want to run the tests directly - // without call the makefile target test. If not informed it will look for the - // default path defined in controller-runtime which is /usr/local/kubebuilder/. - // Note that you must have the required binaries setup under the bin directory to perform - // the tests directly. When we run make test it will be setup and used automatically. - BinaryAssetsDirectory: filepath.Join("..", "..", "bin", "k8s", - fmt.Sprintf("1.29.0-%s-%s", runtime.GOOS, runtime.GOARCH)), } var err error diff --git a/internal/controller/databases/suite_test.go b/internal/controller/databases/suite_test.go index fa8efc6..bef68bf 100644 --- a/internal/controller/databases/suite_test.go +++ b/internal/controller/databases/suite_test.go @@ -17,9 +17,7 @@ limitations under the License. package databases import ( - "fmt" "path/filepath" - "runtime" "testing" . "github.com/onsi/ginkgo/v2" @@ -56,14 +54,6 @@ var _ = BeforeSuite(func() { testEnv = &envtest.Environment{ CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "config", "crd", "bases")}, ErrorIfCRDPathMissing: true, - - // The BinaryAssetsDirectory is only required if you want to run the tests directly - // without call the makefile target test. If not informed it will look for the - // default path defined in controller-runtime which is /usr/local/kubebuilder/. - // Note that you must have the required binaries setup under the bin directory to perform - // the tests directly. When we run make test it will be setup and used automatically. - BinaryAssetsDirectory: filepath.Join("..", "..", "..", "bin", "k8s", - fmt.Sprintf("1.30.0-%s-%s", runtime.GOOS, runtime.GOARCH)), } var err error diff --git a/internal/controller/middleware/suite_test.go b/internal/controller/middleware/suite_test.go index 3bf02af..5bff69e 100644 --- a/internal/controller/middleware/suite_test.go +++ b/internal/controller/middleware/suite_test.go @@ -53,7 +53,7 @@ var _ = BeforeSuite(func() { By("bootstrapping test environment") testEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")}, + CRDDirectoryPaths: []string{filepath.Join("..", "..", "..", "config", "crd", "bases")}, ErrorIfCRDPathMissing: true, } diff --git a/pkg/kubernetes/clientset/clientset.go b/pkg/kubernetes/clientset/clientset.go index 6a4a17b..85a46a9 100644 --- a/pkg/kubernetes/clientset/clientset.go +++ b/pkg/kubernetes/clientset/clientset.go @@ -29,7 +29,7 @@ type ClientSet interface { CronJob Deployment Job - NameSpaces + Namespaces Pod PodDisruptionBudget PVC @@ -54,7 +54,7 @@ type clientSet struct { CronJob Deployment Job - NameSpaces + Namespaces Pod PodDisruptionBudget PVC @@ -92,7 +92,7 @@ func NewWithConfig(kubecli client.Client, restConfig *rest.Config, logger logr.L CronJob: NewCronJob(kubecli, logger), Deployment: NewDeployment(kubecli, logger), Job: NewJob(kubecli, logger), - NameSpaces: NewNameSpaces(logger), + Namespaces: NewNamespaces(kubecli, logger), Pod: NewPod(kubecli, restConfig, logger), PodDisruptionBudget: NewPodDisruptionBudget(kubecli, logger), PVC: NewPVCService(kubecli, logger), diff --git a/pkg/kubernetes/clientset/mocks/client_set.go b/pkg/kubernetes/clientset/mocks/client_set.go index 3da6bfe..1ff9976 100644 --- a/pkg/kubernetes/clientset/mocks/client_set.go +++ b/pkg/kubernetes/clientset/mocks/client_set.go @@ -1386,12 +1386,12 @@ func (_m *ClientSet) GetJob(ctx context.Context, namespace string, name string) return r0, r1 } -// GetNameSpace provides a mock function with given fields: ctx, namespace -func (_m *ClientSet) GetNameSpace(ctx context.Context, namespace string) (*corev1.Namespace, error) { +// GetNamespace provides a mock function with given fields: ctx, namespace +func (_m *ClientSet) GetNamespace(ctx context.Context, namespace string) (*corev1.Namespace, error) { ret := _m.Called(ctx, namespace) if len(ret) == 0 { - panic("no return value specified for GetNameSpace") + panic("no return value specified for GetNamespace") } var r0 *corev1.Namespace diff --git a/pkg/kubernetes/clientset/namespaces.go b/pkg/kubernetes/clientset/namespaces.go index c868c22..d88c27f 100644 --- a/pkg/kubernetes/clientset/namespaces.go +++ b/pkg/kubernetes/clientset/namespaces.go @@ -23,40 +23,31 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/client/config" ) -// NameSpaces the client that knows how to interact with kubernetes to manage them -type NameSpaces interface { - // GetNameSpace get namespace info form kubernetes - GetNameSpace(ctx context.Context, namespace string) (*corev1.Namespace, error) +// Namespaces the client that knows how to interact with kubernetes to manage them +type Namespaces interface { + // GetNamespace get namespace info form kubernetes + GetNamespace(ctx context.Context, namespace string) (*corev1.Namespace, error) } // NameSpacesOption is the NameSpaces client implementation using API calls to kubernetes. -type NameSpacesOption struct { +type NamespacesOption struct { client client.Client logger logr.Logger } -// NewNameSpaces returns a new NameSpaces client. -func NewNameSpaces(logger logr.Logger) NameSpaces { - logger = logger.WithValues("service", "k8s.namespaces") - cfg, err := config.GetConfig() - if err != nil { - panic(err) - } - kubeClient, err := client.New(cfg, client.Options{}) - if err != nil { - panic(err) - } - return &NameSpacesOption{ +// NewNameSpaces returns a new Namespaces client. +func NewNamespaces(kubeClient client.Client, logger logr.Logger) *NamespacesOption { + logger = logger.WithValues("service", "k8s.namespace") + return &NamespacesOption{ client: kubeClient, logger: logger, } } -// GetNameSpace implement the NameSpaces.Interface -func (n *NameSpacesOption) GetNameSpace(ctx context.Context, namespace string) (*corev1.Namespace, error) { +// GetNameSpace implement the Namespaces.Interface +func (n *NamespacesOption) GetNamespace(ctx context.Context, namespace string) (*corev1.Namespace, error) { nm := &corev1.Namespace{} err := n.client.Get(ctx, types.NamespacedName{ Name: namespace, diff --git a/pkg/kubernetes/kubernetes.go b/pkg/kubernetes/kubernetes.go index 5d7469e..272dbfc 100644 --- a/pkg/kubernetes/kubernetes.go +++ b/pkg/kubernetes/kubernetes.go @@ -28,7 +28,7 @@ type ClientSet interface { clientset.CronJob clientset.Deployment clientset.Job - clientset.NameSpaces + clientset.Namespaces clientset.Pod clientset.PodDisruptionBudget clientset.PVC diff --git a/pkg/redis/node_test.go b/pkg/redis/node_test.go index b27f31c..63db5e9 100644 --- a/pkg/redis/node_test.go +++ b/pkg/redis/node_test.go @@ -38,11 +38,16 @@ func TestParseNodeFromClusterNode(t *testing.T) { Id: "33b1262d41a4d9c27a78eef522c84999b064ce7f", Addr: "", RawFlag: "myself,master", + BusPort: "16379", + AuxFields: ClusterNodeAuxFields{raw: ":6379@16379"}, + Role: "master", MasterId: "", PingSend: 0, PongRecv: 0, Epoch: 0, LinkState: "connected", + slots: []string{}, + rawInfo: "33b1262d41a4d9c27a78eef522c84999b064ce7f :6379@16379 myself,master - 0 0 0 connected", }, wantErr: false, },