This is an automated email from the ASF dual-hosted git repository.
mfordjody pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-kubernetes.git
The following commit(s) were added to refs/heads/master by this push:
new b6eeba8d Update ci infra (#940)
b6eeba8d is described below
commit b6eeba8d838f51bf23f5f1a35e7c1e6eac78b30a
Author: mfordjody <[email protected]>
AuthorDate: Sat Jul 11 16:25:12 2026 +0800
Update ci infra (#940)
* Refine telemetry hierarchy and observability
* Update ci infra
---
Makefile => .github/dependabot.yml | 39 +++---
.github/workflows/ci.yml | 147 +++++++++++---------
.github/workflows/release.yaml | 154 ++++++++-------------
.github/workflows/security.yml | 66 +++++++++
.golangci.yml | 69 +++++++++
Makefile | 106 ++++++++++++++
cli/cmd/analyze.go | 2 +-
cli/cmd/create.go | 3 +-
cli/cmd/image.go | 2 +-
cli/cmd/multicluster.go | 2 +-
cli/cmd/portforward.go | 2 +-
cli/cmd/repo.go | 2 +-
cli/pkg/hub/client.go | 4 +-
cli/pkg/hub/pusher/pusher.go | 11 +-
cli/pkg/hub/ssh/agent.go | 1 -
cli/pkg/hub/ssh/agent_windows.go | 1 -
cli/pkg/sdk/client.go | 4 +-
cli/pkg/sdk/repositories.go | 4 +-
cli/pkg/validate/validate.go | 2 +-
cli/pkg/version/version.go | 3 +-
dubbod/discovery/cmd/app/grpc_outbound.go | 2 +-
dubbod/discovery/cmd/app/grpc_outbound_test.go | 8 +-
.../pkg/bootstrap/proxyless_grpc_controller.go | 5 +-
dubbod/discovery/pkg/bootstrap/server.go | 4 +-
.../config/kube/gateway/deployment_controller.go | 2 +-
.../config/kube/gateway/gatewayclass_collection.go | 9 +-
.../pkg/config/kube/gateway/referencegrants.go | 2 +-
.../k8sleaderelection/leaderelection.go | 2 +-
dubbod/discovery/pkg/model/destinationrule.go | 14 +-
dubbod/discovery/pkg/model/push_context.go | 8 +-
dubbod/discovery/pkg/networking/core/configgen.go | 1 -
dubbod/discovery/pkg/networking/grpcgen/cds.go | 2 +-
.../discovery/pkg/networking/grpcgen/cds_test.go | 2 +-
dubbod/discovery/pkg/networking/grpcgen/lds.go | 7 +-
dubbod/discovery/pkg/networking/grpcgen/rds.go | 2 +-
.../discovery/pkg/networking/grpcgen/rds_test.go | 4 +-
dubbod/discovery/pkg/server/instance.go | 1 +
.../serviceregistry/kube/controller/controller.go | 2 +-
.../kube/controller/endpointslice.go | 10 +-
.../pkg/serviceregistry/kube/controller/pod.go | 2 +-
dubbod/discovery/pkg/status/resource.go | 2 +-
dubbod/discovery/pkg/xds/ads.go | 13 +-
dubbod/discovery/pkg/xds/cds.go | 4 +-
dubbod/discovery/pkg/xds/discovery.go | 14 +-
.../pkg/xds/endpoints/endpoint_builder.go | 8 +-
.../pkg/xds/endpoints/endpoint_builder_test.go | 2 +-
dubbod/discovery/pkg/xds/xdsgen.go | 7 +-
dubbod/security/pkg/nodeagent/cache/secretcache.go | 4 +-
dubbod/security/pkg/server/ca/server.go | 2 +-
operator/cmd/cluster/manifest.go | 16 +--
operator/pkg/helm/helm.go | 3 +
operator/pkg/install/installer.go | 5 +-
operator/pkg/render/manifest.go | 3 +
pkg/bootstrap/config.go | 2 +-
pkg/config/mesh/meshwatcher/mesh.go | 2 +-
pkg/config/schema/codegen/collections.go | 5 +-
pkg/env/var.go | 2 +-
pkg/file/fadvise_unspecified.go | 1 -
pkg/kube/inject/inject.go | 4 +-
pkg/kube/inject/webhook.go | 4 +-
pkg/kube/kclient/client.go | 17 +--
pkg/kube/krt/files/files.go | 2 +-
pkg/log/klog_interceptor.go | 1 -
pkg/model/proxy.go | 2 +-
pkg/slices/slices.go | 2 +-
pkg/spiffe/spiffe.go | 6 +-
pkg/webhooks/webhookpatch.go | 4 +-
67 files changed, 520 insertions(+), 330 deletions(-)
diff --git a/Makefile b/.github/dependabot.yml
similarity index 58%
copy from Makefile
copy to .github/dependabot.yml
index f5189ed6..a7b9b64e 100644
--- a/Makefile
+++ b/.github/dependabot.yml
@@ -13,23 +13,24 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-.PHONY: build-dubboctl
-build-dubboctl:
- CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build \
- -ldflags "-X
github.com/apache/dubbo-kubernetes/pkg/version.gitTag=$(GIT_VERSION)" \
- -o bin/dubboctl cli/main.go
+version: 2
+updates:
+ - package-ecosystem: gomod
+ directory: /
+ schedule:
+ interval: weekly
+ open-pull-requests-limit: 5
+ groups:
+ golang-x:
+ patterns:
+ - "golang.org/x/*"
+ kubernetes:
+ patterns:
+ - "k8s.io/*"
+ - "sigs.k8s.io/*"
-.PHONY: build-dubbod
-build-dubbod:
- CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build \
- -o bin/dubbod dubbod/discovery/cmd/main.go
-
-.PHONY: build-dubbo-cni
-build-dubbo-cni:
- CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build \
- -o bin/dubbo-cni cni/main.go
-
-.PHONY: clone-sample
-clone-sample:
- mkdir -p bin
- cp -r samples bin/samples
+ - package-ecosystem: github-actions
+ directory: /
+ schedule:
+ interval: weekly
+ open-pull-requests-limit: 5
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 09733d4b..f84da827 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -26,13 +26,21 @@ on:
- main
workflow_dispatch:
+permissions:
+ contents: read
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.event.pull_request.number ||
github.ref }}
+ cancel-in-progress: ${{ github.event_name == 'pull_request' }}
+
env:
- GO_VERSION: '1.25'
+ GOLANGCI_LINT_VERSION: v2.6.2
jobs:
- unit-test:
- name: Go Unit Tests
+ lint:
+ name: Lint
runs-on: ubuntu-latest
+ timeout-minutes: 20
if: github.repository == 'apache/dubbo-kubernetes'
steps:
- name: Checkout code
@@ -44,35 +52,18 @@ jobs:
go-version-file: go.mod
cache-dependency-path: go.sum
- - name: Download dependencies
- run: go mod download
-
- - name: Verify dependencies
- run: go mod verify
-
- - name: Run unit tests
- run: |
- go test ./... -gcflags=-l -coverprofile=coverage.txt
-covermode=atomic -v
-
- - name: Upload test coverage
- if: always()
- uses: actions/upload-artifact@v4
+ - name: Run golangci-lint
+ uses: golangci/golangci-lint-action@v8
with:
- name: test-coverage
- path: "**/coverage.txt"
- retention-days: 7
+ version: ${{ env.GOLANGCI_LINT_VERSION }}
- - name: Upload coverage to Codecov
- uses: codecov/codecov-action@v4
- with:
- file: ./coverage.txt
- flags: unittests
- name: codecov-umbrella
- fail_ci_if_error: false
+ - name: Run shellcheck
+ run: make lint-shell
- lint:
- name: Go Lint
+ check:
+ name: Check Repo Hygiene
runs-on: ubuntu-latest
+ timeout-minutes: 15
if: github.repository == 'apache/dubbo-kubernetes'
steps:
- name: Checkout code
@@ -84,24 +75,22 @@ jobs:
go-version-file: go.mod
cache-dependency-path: go.sum
- - name: Download dependencies
- run: go mod download
-
- - name: Run go fmt check
+ - name: Verify dependencies
run: |
- if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then
- echo "The following files need formatting:"
- gofmt -s -d .
- exit 1
- fi
+ go mod download
+ go mod verify
- build:
- name: Go Build
+ - name: Check go.mod/go.sum are tidy
+ run: make check-tidy
+
+ - name: Check License Header
+ uses: apache/skywalking-eyes/[email protected]
+
+ unit-test:
+ name: Unit Tests
runs-on: ubuntu-latest
+ timeout-minutes: 30
if: github.repository == 'apache/dubbo-kubernetes'
- strategy:
- matrix:
- os: [ubuntu-latest]
steps:
- name: Checkout code
uses: actions/checkout@v4
@@ -112,44 +101,72 @@ jobs:
go-version-file: go.mod
cache-dependency-path: go.sum
- - name: Download dependencies
- run: go mod download
+ - name: Run unit tests with race detector and coverage
+ run: make test-coverage
- - name: Build
- run: go build ./...
+ - name: Upload test coverage
+ if: always()
+ uses: actions/upload-artifact@v4
+ with:
+ name: test-coverage
+ path: coverage.txt
+ retention-days: 7
+
+ - name: Upload coverage to Codecov
+ uses: codecov/codecov-action@v4
+ with:
+ file: ./coverage.txt
+ flags: unittests
+ name: codecov-umbrella
+ fail_ci_if_error: false
- license-check:
- name: License Header Check
+ build:
+ name: Build (${{ matrix.goos }}/${{ matrix.goarch }})
runs-on: ubuntu-latest
+ timeout-minutes: 20
if: github.repository == 'apache/dubbo-kubernetes'
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - goos: linux
+ goarch: amd64
+ - goos: linux
+ goarch: arm64
+ - goos: darwin
+ goarch: amd64
+ - goos: darwin
+ goarch: arm64
steps:
- name: Checkout code
uses: actions/checkout@v4
- - name: Check License Header
- uses: apache/skywalking-eyes/header@main
+ - name: Set up Go
+ uses: actions/setup-go@v5
+ with:
+ go-version-file: go.mod
+ cache-dependency-path: go.sum
+
+ - name: Build all binaries
+ run: make build GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }}
+
+ - name: Compile tests (vet whole tree)
+ if: matrix.goos == 'linux' && matrix.goarch == 'amd64'
+ run: go build ./...
- helm-lint:
- name: Helm Lint
+ helm:
+ name: Helm Charts
runs-on: ubuntu-latest
+ timeout-minutes: 15
if: github.repository == 'apache/dubbo-kubernetes'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Helm
- uses: azure/setup-helm@v1
+ uses: azure/setup-helm@v4
with:
- version: '3.13.0'
-
- - name: Lint base chart
- run: helm lint manifests/charts/base
-
- - name: Lint dubbod chart
- run: helm lint manifests/charts/dubbod
-
- - name: Validate base chart template rendering
- run: helm template test-release manifests/charts/base --debug
+ version: 'v3.16.4'
- - name: Validate dubbod chart template rendering
- run: helm template test-release manifests/charts/dubbod --debug
+ - name: Lint and render charts
+ run: make lint-helm
diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml
index 11b083e8..6807e38c 100644
--- a/.github/workflows/release.yaml
+++ b/.github/workflows/release.yaml
@@ -27,53 +27,32 @@ jobs:
create_release:
name: Create Release
runs-on: ubuntu-latest
- outputs:
- upload_url: ${{ steps.create_release.outputs.upload_url }}
-
+ timeout-minutes: 10
steps:
- - name: Check if Release Exists
- id: check
- uses: actions/github-script@v7
- with:
- result-encoding: string
- script: |
- const tag = context.ref.replace('refs/tags/', '');
- try {
- await github.rest.repos.getReleaseByTag({
- owner: context.repo.owner,
- repo: context.repo.repo,
- tag: tag,
- });
- return "exists";
- } catch (e) {
- if (e.status === 404) return "not_found";
- throw e;
- }
+ - name: Checkout code
+ uses: actions/checkout@v4
- - name: Create GitHub Release
- id: create_release
- if: steps.check.outputs.result == 'not_found'
- uses: actions/create-release@v1
+ - name: Create GitHub Release if missing
env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- with:
- tag_name: ${{ github.ref_name }}
- release_name: "${{ github.ref_name }}"
- body: |
- Refine the delta xDS framework.
- Added timeout features for traffic management.
- Added circuit-breaking capabilities for traffic management.
- Added egress capability.
- Refine and supplement observability features.
- Enhance KRT-related capabilities.
- draft: false
- prerelease: true
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ TAG: ${{ github.ref_name }}
+ run: |
+ if gh release view "${TAG}" >/dev/null 2>&1; then
+ echo "Release ${TAG} already exists, skipping creation."
+ else
+ gh release create "${TAG}" \
+ --title "${TAG}" \
+ --prerelease \
+ --generate-notes
+ fi
build_and_upload:
name: Build and Upload Binaries
needs: create_release
runs-on: ubuntu-latest
+ timeout-minutes: 30
strategy:
+ fail-fast: false
matrix:
goos: [linux, darwin, windows]
goarch: [386, amd64, arm64]
@@ -91,95 +70,80 @@ jobs:
uses: actions/setup-go@v5
with:
go-version-file: go.mod
+ cache-dependency-path: go.sum
- name: Download dependencies
run: go mod download
- - name: Dubboctl Build binary
+ - name: Build dubboctl and samples
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
GIT_VERSION: ${{ github.ref_name }}
run: |
mkdir -p build/dubboctl
- make build-dubboctl GOOS=${GOOS} GOARCH=${GOARCH}
GIT_VERSION=${GIT_VERSION}
- cp README.md LICENSE build/dubboctl/
- mv bin/dubboctl* build/dubboctl/
- ls -ln build/dubboctl/
-
- - name: Dubbo Build binary
- env:
- GOOS: ${{ matrix.goos }}
- GOARCH: ${{ matrix.goarch }}
- GIT_VERSION: ${{ github.ref_name }}
- run: |
- mkdir -p build/dubboctl
- make build-dubboctl GOOS=${GOOS} GOARCH=${GOARCH}
GIT_VERSION=${GIT_VERSION}
- make clone-sample GOOS=${GOOS} GOARCH=${GOARCH}
GIT_VERSION=${GIT_VERSION}
+ make build-dubboctl GOOS="${GOOS}" GOARCH="${GOARCH}"
GIT_VERSION="${GIT_VERSION}"
+ make clone-sample
cp README.md LICENSE build/
+ cp README.md LICENSE build/dubboctl/
mv bin/dubboctl* build/dubboctl/
mv bin/samples/ build/
ls -ln build/dubboctl/ ; ls -ln build/
- - name: Dubboctl Rename windows
+ - name: Rename windows binary
if: matrix.goos == 'windows'
run: |
cp build/dubboctl/dubboctl build/dubboctl/dubboctl.exe
- - name: dubboctl Package files
+ - name: Package dubboctl
id: package_ctl
run: |
VERSION=${GITHUB_REF#refs/tags/}
- FILENAME=dubboctl-${VERSION}-${{ matrix.goos }}-${{ matrix.goarch }}
- DIRNAME=dubboctl-${VERSION}
- mkdir -p ${DIRNAME}/bin
- cp build/dubboctl/dubboctl ${DIRNAME}/bin
- ls -ln ${DIRNAME}/bin
- cp build/dubboctl/README.md build/dubboctl/LICENSE ${DIRNAME}
- ls -Rlh ${DIRNAME}
+ FILENAME="dubboctl-${VERSION}-${{ matrix.goos }}-${{ matrix.goarch
}}"
+ DIRNAME="dubboctl-${VERSION}"
+ mkdir -p "${DIRNAME}/bin"
+ cp build/dubboctl/dubboctl "${DIRNAME}/bin"
+ cp build/dubboctl/README.md build/dubboctl/LICENSE "${DIRNAME}"
+ ls -Rlh "${DIRNAME}"
if [ "${{ matrix.goos }}" = "windows" ]; then
- zip -r ${FILENAME}.zip ${DIRNAME}/bin
- echo "name=${FILENAME}.zip" >> $GITHUB_OUTPUT
+ zip -r "${FILENAME}.zip" "${DIRNAME}/bin"
+ echo "name=${FILENAME}.zip" >> "$GITHUB_OUTPUT"
else
- tar -czvf ${FILENAME}.tar.gz ${DIRNAME}
- echo "name=${FILENAME}.tar.gz" >> $GITHUB_OUTPUT
+ tar -czvf "${FILENAME}.tar.gz" "${DIRNAME}"
+ echo "name=${FILENAME}.tar.gz" >> "$GITHUB_OUTPUT"
fi
- - name: dubbo Package files
+ - name: Package dubbo distribution
id: package_dubbo
run: |
VERSION=${GITHUB_REF#refs/tags/}
- FILENAME=dubbo-${VERSION}-${{ matrix.goos }}-${{ matrix.goarch }}
- DIRNAME=dubbo-${VERSION}
- mkdir -p ${DIRNAME}/bin
- cp build/dubboctl/dubboctl ${DIRNAME}/bin/
- cp build/README.md build/LICENSE ${DIRNAME}
- cp -r build/samples ${DIRNAME}
- ls -Rlh ${DIRNAME}
+ FILENAME="dubbo-${VERSION}-${{ matrix.goos }}-${{ matrix.goarch }}"
+ DIRNAME="dubbo-${VERSION}"
+ mkdir -p "${DIRNAME}/bin"
+ cp build/dubboctl/dubboctl "${DIRNAME}/bin/"
+ cp build/README.md build/LICENSE "${DIRNAME}"
+ cp -r build/samples "${DIRNAME}"
+ ls -Rlh "${DIRNAME}"
if [ "${{ matrix.goos }}" = "windows" ]; then
- zip -r ${FILENAME}.zip ${DIRNAME}
- echo "name=${FILENAME}.zip" >> $GITHUB_OUTPUT
+ zip -r "${FILENAME}.zip" "${DIRNAME}"
+ echo "name=${FILENAME}.zip" >> "$GITHUB_OUTPUT"
else
- tar -czvf ${FILENAME}.tar.gz ${DIRNAME}
- echo "name=${FILENAME}.tar.gz" >> $GITHUB_OUTPUT
+ tar -czvf "${FILENAME}.tar.gz" "${DIRNAME}"
+ echo "name=${FILENAME}.tar.gz" >> "$GITHUB_OUTPUT"
fi
- - name: Upload Dubboctl Release Asset
- uses: actions/upload-release-asset@v1
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- with:
- upload_url: ${{ needs.create_release.outputs.upload_url }}
- asset_path: ${{ steps.package_ctl.outputs.name }}
- asset_name: ${{ steps.package_ctl.outputs.name }}
- asset_content_type: application/octet-stream
+ - name: Generate checksums
+ run: |
+ sha256sum "${{ steps.package_ctl.outputs.name }}" > "${{
steps.package_ctl.outputs.name }}.sha256"
+ sha256sum "${{ steps.package_dubbo.outputs.name }}" > "${{
steps.package_dubbo.outputs.name }}.sha256"
- - name: Upload Dubbo Release Asset
- uses: actions/upload-release-asset@v1
+ - name: Upload release assets
env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- with:
- upload_url: ${{ needs.create_release.outputs.upload_url }}
- asset_path: ${{ steps.package_dubbo.outputs.name }}
- asset_name: ${{ steps.package_dubbo.outputs.name }}
- asset_content_type: application/octet-stream
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ TAG: ${{ github.ref_name }}
+ run: |
+ gh release upload "${TAG}" --clobber \
+ "${{ steps.package_ctl.outputs.name }}" \
+ "${{ steps.package_ctl.outputs.name }}.sha256" \
+ "${{ steps.package_dubbo.outputs.name }}" \
+ "${{ steps.package_dubbo.outputs.name }}.sha256"
diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml
new file mode 100644
index 00000000..d10bf81c
--- /dev/null
+++ b/.github/workflows/security.yml
@@ -0,0 +1,66 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+name: Security Scan
+
+on:
+ push:
+ branches:
+ - master
+ - main
+ paths:
+ - 'go.mod'
+ - 'go.sum'
+ - '**.go'
+ pull_request:
+ branches:
+ - master
+ - main
+ paths:
+ - 'go.mod'
+ - 'go.sum'
+ schedule:
+ # Weekly scan so newly disclosed vulnerabilities are caught even
+ # without code changes.
+ - cron: '0 3 * * 1'
+ workflow_dispatch:
+
+permissions:
+ contents: read
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.event.pull_request.number ||
github.ref }}
+ cancel-in-progress: ${{ github.event_name == 'pull_request' }}
+
+jobs:
+ govulncheck:
+ name: govulncheck
+ runs-on: ubuntu-latest
+ timeout-minutes: 20
+ if: github.repository == 'apache/dubbo-kubernetes'
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v4
+
+ - name: Set up Go
+ uses: actions/setup-go@v5
+ with:
+ go-version-file: go.mod
+ cache-dependency-path: go.sum
+
+ - name: Run govulncheck
+ run: |
+ go install golang.org/x/vuln/cmd/govulncheck@latest
+ govulncheck ./...
diff --git a/.golangci.yml b/.golangci.yml
new file mode 100644
index 00000000..acec8a90
--- /dev/null
+++ b/.golangci.yml
@@ -0,0 +1,69 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+version: "2"
+
+run:
+ timeout: 15m
+ build-tags: []
+
+linters:
+ # Start from an explicit allowlist so CI stays deterministic across
+ # golangci-lint upgrades; broaden the set incrementally as the codebase
+ # is cleaned up (errcheck and gosec are the next candidates).
+ default: none
+ enable:
+ - govet
+ - staticcheck
+ - ineffassign
+ - misspell
+ - unconvert
+ - copyloopvar
+ settings:
+ misspell:
+ locale: US
+ staticcheck:
+ checks:
+ # golangci-lint's default set (all minus the noisy style checks below),
+ # plus SA1019 (use of deprecated APIs) temporarily excluded; migrating
+ # off deprecated grpc/protobuf APIs is tracked as separate work.
+ - all
+ - -ST1000
+ - -ST1003
+ - -ST1016
+ - -ST1020
+ - -ST1021
+ - -ST1022
+ - -SA1019
+ exclusions:
+ generated: lax
+ paths:
+ - ".*\\.pb\\.go$"
+ - ".*\\.gen\\.go$"
+
+formatters:
+ enable:
+ - gofmt
+ settings:
+ gofmt:
+ simplify: true
+ exclusions:
+ paths:
+ - ".*\\.pb\\.go$"
+ - ".*\\.gen\\.go$"
+
+issues:
+ max-issues-per-linter: 0
+ max-same-issues: 0
diff --git a/Makefile b/Makefile
index f5189ed6..14af9508 100644
--- a/Makefile
+++ b/Makefile
@@ -13,6 +13,23 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+GOOS ?= $(shell go env GOOS)
+GOARCH ?= $(shell go env GOARCH)
+GIT_VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null ||
echo unknown)
+
+GOLANGCI_LINT_VERSION ?= v2.6.2
+GOTESTFLAGS ?= -race
+
+.PHONY: default
+default: build
+
+# ------------------------------------------------------------------------
+# Build
+# ------------------------------------------------------------------------
+
+.PHONY: build
+build: build-dubboctl build-dubbod build-dubbo-cni
+
.PHONY: build-dubboctl
build-dubboctl:
CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build \
@@ -33,3 +50,92 @@ build-dubbo-cni:
clone-sample:
mkdir -p bin
cp -r samples bin/samples
+
+# ------------------------------------------------------------------------
+# Test
+# ------------------------------------------------------------------------
+
+.PHONY: test
+test:
+ go test $(GOTESTFLAGS) ./...
+
+.PHONY: test-coverage
+test-coverage:
+ go test $(GOTESTFLAGS) -coverprofile=coverage.txt -covermode=atomic
./...
+
+# ------------------------------------------------------------------------
+# Lint / format
+# ------------------------------------------------------------------------
+
+.PHONY: lint
+lint: lint-go lint-shell
+
+.PHONY: lint-go
+lint-go:
+ @if ! command -v golangci-lint >/dev/null 2>&1; then \
+ echo "golangci-lint not found; install $(GOLANGCI_LINT_VERSION)
from https://golangci-lint.run/welcome/install/"; \
+ exit 1; \
+ fi
+ golangci-lint run ./...
+
+.PHONY: lint-shell
+lint-shell:
+ @if command -v shellcheck >/dev/null 2>&1; then \
+ find . -name '*.sh' -not -path './vendor/*' -not -path
'./bin/*' -print0 | xargs -0 -r shellcheck; \
+ else \
+ echo "shellcheck not found, skipping shell lint"; \
+ fi
+
+.PHONY: fmt
+fmt:
+ gofmt -s -w .
+
+.PHONY: check-fmt
+check-fmt:
+ @out="$$(gofmt -s -l .)"; \
+ if [ -n "$$out" ]; then \
+ echo "The following files need 'gofmt -s':"; \
+ echo "$$out"; \
+ exit 1; \
+ fi
+
+# ------------------------------------------------------------------------
+# Hygiene gates (CI runs these; they must leave the tree clean)
+# ------------------------------------------------------------------------
+
+.PHONY: tidy
+tidy:
+ go mod tidy
+
+.PHONY: check-clean-repo
+check-clean-repo:
+ @if [ -n "$$(git status --porcelain)" ]; then \
+ echo "The working tree is dirty after running
generators/tidy:"; \
+ git status --porcelain; \
+ git diff; \
+ exit 1; \
+ fi
+
+.PHONY: check-tidy
+check-tidy: tidy check-clean-repo
+
+# ------------------------------------------------------------------------
+# Helm
+# ------------------------------------------------------------------------
+
+CHARTS := manifests/charts/base manifests/charts/dubbod
+
+.PHONY: lint-helm
+lint-helm:
+ @for chart in $(CHARTS); do \
+ helm lint $$chart || exit 1; \
+ helm template test-release $$chart >/dev/null || exit 1; \
+ done
+
+# ------------------------------------------------------------------------
+# Misc
+# ------------------------------------------------------------------------
+
+.PHONY: clean
+clean:
+ rm -rf bin coverage.txt
diff --git a/cli/cmd/analyze.go b/cli/cmd/analyze.go
index aa977355..0c214bf9 100644
--- a/cli/cmd/analyze.go
+++ b/cli/cmd/analyze.go
@@ -143,7 +143,7 @@ func analyzeHTTPRoutes(ctx context.Context, client
kube.CLIClient, namespace str
if ref.Port != nil {
portFound := false
for _, p := range svc.Spec.Ports {
- if p.Port == int32(*ref.Port) {
+ if p.Port == *ref.Port {
portFound = true
break
}
diff --git a/cli/cmd/create.go b/cli/cmd/create.go
index 4e792fd2..e995a5fd 100644
--- a/cli/cmd/create.go
+++ b/cli/cmd/create.go
@@ -122,8 +122,7 @@ type createConfig struct {
// accessing things like the current valid templates list, and uses the
// current value of the config at time of prompting.
func newCreateConfig(_ *cobra.Command, _ []string, _ ClientFactory) (cc
createConfig, err error) {
- var absolutePath string
- absolutePath = cwd()
+ absolutePath := cwd()
cc = createConfig{
DirName: viper.GetString("dirname"),
diff --git a/cli/cmd/image.go b/cli/cmd/image.go
index 103911df..7627e381 100644
--- a/cli/cmd/image.go
+++ b/cli/cmd/image.go
@@ -389,7 +389,7 @@ func (d *deployConfig) deployPrompt(dc2 *dubbo.DubboConfig)
(*deployConfig, erro
}
}
- buildconfig, err := d.hubConfig.hubPrompt(dc2)
+ buildconfig, err := d.hubPrompt(dc2)
if err != nil {
return d, err
}
diff --git a/cli/cmd/multicluster.go b/cli/cmd/multicluster.go
index 1d3766b1..b75381b8 100644
--- a/cli/cmd/multicluster.go
+++ b/cli/cmd/multicluster.go
@@ -247,7 +247,7 @@ func buildEastWestGatewayManifest(args eastWestGatewayArgs)
(*gatewayv1.Gateway,
Listeners: []gatewayv1.Listener{{
Name:
gatewayv1.SectionName("http-eastwest"),
Protocol: gatewayv1.HTTPProtocolType,
- Port: gatewayv1.PortNumber(args.port),
+ Port: args.port,
AllowedRoutes: &gatewayv1.AllowedRoutes{
Namespaces: &gatewayv1.RouteNamespaces{
From:
ptrGatewayFrom(gatewayv1.NamespacesFromAll),
diff --git a/cli/cmd/portforward.go b/cli/cmd/portforward.go
index 62f41be1..c0b1d23e 100644
--- a/cli/cmd/portforward.go
+++ b/cli/cmd/portforward.go
@@ -34,7 +34,7 @@ import (
)
// forwardToService port-forwards a local port to a running pod backing the
-// given service and blocks until the context is cancelled or an interrupt is
+// given service and blocks until the context is canceled or an interrupt is
// received.
func forwardToService(ctx context.Context, client kube.CLIClient, out
io.Writer, namespace, serviceName string, localPort, podPort int) error {
pod, err := podForService(ctx, client, namespace, serviceName)
diff --git a/cli/cmd/repo.go b/cli/cmd/repo.go
index 33442c67..000544ea 100644
--- a/cli/cmd/repo.go
+++ b/cli/cmd/repo.go
@@ -85,7 +85,7 @@ func runAdd(cmd *cobra.Command, args []string, clientFactory
ClientFactory) (err
// Preconditions
// If not confirming/prompting, assert the args were both provided.
if len(args) != 2 {
- return fmt.Errorf("Usage: dubboctl repo add [<name>] [<url>]")
+ return fmt.Errorf("usage: dubboctl repo add [<name>] [<url>]")
}
// Extract Params
diff --git a/cli/pkg/hub/client.go b/cli/pkg/hub/client.go
index b237bd58..f56ccd1f 100644
--- a/cli/pkg/hub/client.go
+++ b/cli/pkg/hub/client.go
@@ -36,7 +36,7 @@ import (
"github.com/docker/go-connections/tlsconfig"
)
-var NoDockerAPIError = errors.New("docker API not available")
+var ErrNoDockerAPI = errors.New("docker API not available")
func NewClient(defaultHost string) (dockerClient client.CommonAPIClient,
dockerHostInRemote string, err error) {
var u *url.URL
@@ -60,7 +60,7 @@ func NewClient(defaultHost string) (dockerClient
client.CommonAPIClient, dockerH
}
if dockerHost == "" {
- return nil, "", NoDockerAPIError
+ return nil, "", ErrNoDockerAPI
}
dockerHostInRemote = dockerHost
diff --git a/cli/pkg/hub/pusher/pusher.go b/cli/pkg/hub/pusher/pusher.go
index 72b7a1fa..6fef2343 100644
--- a/cli/pkg/hub/pusher/pusher.go
+++ b/cli/pkg/hub/pusher/pusher.go
@@ -80,12 +80,10 @@ func NewPusher(opts ...Opt) *Pusher {
}
func (p *Pusher) Push(ctx context.Context, dc *dubbo.DubboConfig) (digest
string, err error) {
- var output io.Writer
-
- output = os.Stderr
+ var output io.Writer = os.Stderr
if dc.Image == "" {
- return "", errors.New("Function has no associated image. Has
it been built?")
+ return "", errors.New("function has no associated image; has it
been built?")
}
registry, err := getRegistry(dc.Image)
@@ -122,10 +120,7 @@ func (p *Pusher) daemonPush(ctx context.Context, dc
*dubbo.DubboConfig, credenti
}
defer cli.Close()
- ac := authConfig{
- Username: credentials.Username,
- Password: credentials.Password,
- }
+ ac := authConfig(credentials)
b, err := json.Marshal(&ac)
if err != nil {
diff --git a/cli/pkg/hub/ssh/agent.go b/cli/pkg/hub/ssh/agent.go
index 2f13e7e7..bbfced03 100644
--- a/cli/pkg/hub/ssh/agent.go
+++ b/cli/pkg/hub/ssh/agent.go
@@ -1,5 +1,4 @@
//go:build !windows
-// +build !windows
//
// Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/cli/pkg/hub/ssh/agent_windows.go b/cli/pkg/hub/ssh/agent_windows.go
index d11655eb..d295dc8b 100644
--- a/cli/pkg/hub/ssh/agent_windows.go
+++ b/cli/pkg/hub/ssh/agent_windows.go
@@ -1,5 +1,4 @@
//go:build windows
-// +build windows
//
// Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/cli/pkg/sdk/client.go b/cli/pkg/sdk/client.go
index bf71df95..76997300 100644
--- a/cli/pkg/sdk/client.go
+++ b/cli/pkg/sdk/client.go
@@ -223,9 +223,7 @@ func (c *Client) Deploy(ctx context.Context, dc
*dubbo.DubboConfig, opts ...Depl
dc.Deploy.Namespace = result.Namespace
- if result.Status == Deployed {
- // TODO
- }
+ // TODO: handle result.Status == Deployed
return dc, nil
}
diff --git a/cli/pkg/sdk/repositories.go b/cli/pkg/sdk/repositories.go
index 9e5b7467..67e8f68a 100644
--- a/cli/pkg/sdk/repositories.go
+++ b/cli/pkg/sdk/repositories.go
@@ -75,7 +75,7 @@ func (r *Repositories) All() (repos []Repository, err error) {
func (r *Repositories) Add(name, url string) (string, error) {
if r.path == "" {
- return "", fmt.Errorf("repository %v not added.", name)
+ return "", fmt.Errorf("repository %v not added", name)
}
repo, err := NewRepository(name, url)
@@ -97,7 +97,7 @@ func (r *Repositories) Add(name, url string) (string, error) {
func (r *Repositories) Remove(name string) error {
if r.path == "" {
- return fmt.Errorf("repository %v not removed.", name)
+ return fmt.Errorf("repository %v not removed", name)
}
if name == "" {
return errors.New("name is required")
diff --git a/cli/pkg/validate/validate.go b/cli/pkg/validate/validate.go
index f1aeecf5..4e97f575 100644
--- a/cli/pkg/validate/validate.go
+++ b/cli/pkg/validate/validate.go
@@ -37,7 +37,7 @@ import (
)
var (
- errFiles = errors.New(`error: you must specify resources by -f.`)
+ errFiles = errors.New(`error: you must specify resources by -f`)
validFields = map[string]struct{}{
"apiVersion": {},
"kind": {},
diff --git a/cli/pkg/version/version.go b/cli/pkg/version/version.go
index b1009283..ce20dc79 100644
--- a/cli/pkg/version/version.go
+++ b/cli/pkg/version/version.go
@@ -25,8 +25,7 @@ import (
)
func NewVersionCommand() *cobra.Command {
- var versionCmd *cobra.Command
- versionCmd = version.CobraCommandWithOptions()
+ versionCmd := version.CobraCommandWithOptions()
versionCmd.Flags().VisitAll(func(flag *pflag.Flag) {
if flag.Name == "short" {
err := flag.Value.Set("true")
diff --git a/dubbod/discovery/cmd/app/grpc_outbound.go
b/dubbod/discovery/cmd/app/grpc_outbound.go
index 2974b95d..61e1e905 100644
--- a/dubbod/discovery/cmd/app/grpc_outbound.go
+++ b/dubbod/discovery/cmd/app/grpc_outbound.go
@@ -133,7 +133,7 @@ func newGRPCOutboundCommand() *cobra.Command {
host, port, hostErr := autoDiscoverServiceTarget(os.Environ(),
namespace, domainSuffix)
opts := &grpcOutboundOptions{
host: firstNonEmpty(os.Getenv("DUBBO_SERVICE_HOST"),
host),
- port: firstIntFromEnv(int(port),
"DUBBO_SERVICE_PORT"),
+ port: firstIntFromEnv(port, "DUBBO_SERVICE_PORT"),
path: firstNonEmpty(os.Getenv("REQUEST_PATH"), "/"),
xdsAddress: firstNonEmpty(os.Getenv("XDS_ADDRESS"),
"dubbod.dubbo-system.svc:26010"),
bootstrapPath: os.Getenv("GRPC_XDS_BOOTSTRAP"),
diff --git a/dubbod/discovery/cmd/app/grpc_outbound_test.go
b/dubbod/discovery/cmd/app/grpc_outbound_test.go
index 4bf5d64e..0a001f30 100644
--- a/dubbod/discovery/cmd/app/grpc_outbound_test.go
+++ b/dubbod/discovery/cmd/app/grpc_outbound_test.go
@@ -170,7 +170,7 @@ func TestRunSampleRequestsUsesUpdatedSnapshotOnSameStream(t
*testing.T) {
host: initial.Host,
port: initial.Port,
route: map[string]uint32{initial.Destinations[0].Cluster:
1},
- endpoints:
map[string][]xdsEndpoint{initial.Destinations[0].Cluster:
[]xdsEndpoint{v1Endpoint}},
+ endpoints:
map[string][]xdsEndpoint{initial.Destinations[0].Cluster: {v1Endpoint}},
}
oldStdout := os.Stdout
@@ -192,7 +192,7 @@ func TestRunSampleRequestsUsesUpdatedSnapshotOnSameStream(t
*testing.T) {
time.Sleep(50 * time.Millisecond)
client.mu.Lock()
client.route = map[string]uint32{updated.Destinations[0].Cluster: 1}
- client.endpoints =
map[string][]xdsEndpoint{updated.Destinations[0].Cluster:
[]xdsEndpoint{v2Endpoint}}
+ client.endpoints =
map[string][]xdsEndpoint{updated.Destinations[0].Cluster: {v2Endpoint}}
client.mu.Unlock()
output, readErr := io.ReadAll(readPipe)
@@ -238,7 +238,7 @@ func TestRunSampleRequestsUsesRequestPathAndHeaders(t
*testing.T) {
path: "/reviews",
requestHeaders: http.Header{"End-User":
[]string{"terminal-user"}},
route:
map[string]uint32{snapshot.Destinations[0].Cluster: 1},
- endpoints:
map[string][]xdsEndpoint{snapshot.Destinations[0].Cluster:
[]xdsEndpoint{endpoint}},
+ endpoints:
map[string][]xdsEndpoint{snapshot.Destinations[0].Cluster: {endpoint}},
}
if err := runSampleRequests(context.Background(), client, snapshot, 1,
0, time.Second); err != nil {
@@ -272,7 +272,7 @@ func TestRunSampleRequestsUsesRouteTimeout(t *testing.T) {
path: "/",
route:
map[string]uint32{snapshot.Destinations[0].Cluster: 100},
routeTimeout: time.Millisecond,
- endpoints:
map[string][]xdsEndpoint{snapshot.Destinations[0].Cluster:
[]xdsEndpoint{endpoint}},
+ endpoints:
map[string][]xdsEndpoint{snapshot.Destinations[0].Cluster: {endpoint}},
}
err := runSampleRequests(context.Background(), client, snapshot, 1, 0,
time.Second)
diff --git a/dubbod/discovery/pkg/bootstrap/proxyless_grpc_controller.go
b/dubbod/discovery/pkg/bootstrap/proxyless_grpc_controller.go
index 3c76dae4..ad98f61b 100644
--- a/dubbod/discovery/pkg/bootstrap/proxyless_grpc_controller.go
+++ b/dubbod/discovery/pkg/bootstrap/proxyless_grpc_controller.go
@@ -48,7 +48,9 @@ import (
"github.com/apache/dubbo-kubernetes/dubbod/security/pkg/pki/ca"
pkiutil
"github.com/apache/dubbo-kubernetes/dubbod/security/pkg/pki/util"
caserver
"github.com/apache/dubbo-kubernetes/dubbod/security/pkg/server/ca"
+ meshv1alpha1 "github.com/kdubbo/api/mesh/v1alpha1"
networking "github.com/kdubbo/api/networking/v1alpha3"
+ "google.golang.org/protobuf/proto"
corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -538,8 +540,7 @@ func (c *proxylessGRPCWorkloadController)
buildWorkloadContext(pod *corev1.Pod)
clusterID := podEnvValue(pod, "DUBBO_META_CLUSTER_ID",
constants.DefaultClusterName)
discoveryAddress := podEnvValue(pod, inject.ProxylessXDSAddressEnvName,
proxyConfig.GetDiscoveryAddress())
caAddress := podEnvValue(pod, "CA_ADDRESS", discoveryAddress)
- proxyConfigCopy := *proxyConfig
- proxyConfig = &proxyConfigCopy
+ proxyConfig = proto.Clone(proxyConfig).(*meshv1alpha1.ProxyConfig)
proxyConfig.DiscoveryAddress = discoveryAddress
nodeID := strings.Join([]string{
diff --git a/dubbod/discovery/pkg/bootstrap/server.go
b/dubbod/discovery/pkg/bootstrap/server.go
index 710cc1ca..6aeb521b 100644
--- a/dubbod/discovery/pkg/bootstrap/server.go
+++ b/dubbod/discovery/pkg/bootstrap/server.go
@@ -807,9 +807,9 @@ func (s *Server) initSDSServer() {
if !features.EnableXDSIdentityCheck {
// Make sure we have security
log.Warnf("skipping Kubernetes credential reader;
DUBBO_ENABLE_XDS_IDENTITY_CHECK must be set to true for this feature.")
- } else {
- // TODO ConfigUpdated Multicluster get secret and configmap
+ return
}
+ // TODO ConfigUpdated Multicluster get secret and configmap
}
// isK8SSigning returns whether K8S (as a RA) is used to sign certs instead of
private keys known by Dubbod
diff --git a/dubbod/discovery/pkg/config/kube/gateway/deployment_controller.go
b/dubbod/discovery/pkg/config/kube/gateway/deployment_controller.go
index a6ced2d6..da8a04e6 100644
--- a/dubbod/discovery/pkg/config/kube/gateway/deployment_controller.go
+++ b/dubbod/discovery/pkg/config/kube/gateway/deployment_controller.go
@@ -1156,7 +1156,7 @@ func parentRefMatchesHTTPListener(parentRef
gateway.ParentReference, gw *gateway
if parentRef.SectionName != nil && *parentRef.SectionName !=
listener.Name {
continue
}
- if parentRef.Port != nil && int32(*parentRef.Port) !=
listener.Port {
+ if parentRef.Port != nil && *parentRef.Port != listener.Port {
continue
}
return true
diff --git
a/dubbod/discovery/pkg/config/kube/gateway/gatewayclass_collection.go
b/dubbod/discovery/pkg/config/kube/gateway/gatewayclass_collection.go
index a03c415e..eb9cbfa7 100644
--- a/dubbod/discovery/pkg/config/kube/gateway/gatewayclass_collection.go
+++ b/dubbod/discovery/pkg/config/kube/gateway/gatewayclass_collection.go
@@ -18,13 +18,12 @@ package gateway
import (
"github.com/apache/dubbo-kubernetes/pkg/kube/krt"
- gateway "sigs.k8s.io/gateway-api/apis/v1"
gatewayv1 "sigs.k8s.io/gateway-api/apis/v1"
)
type GatewayClass struct {
Name string
- Controller gateway.GatewayController
+ Controller gatewayv1.GatewayController
}
func (g GatewayClass) ResourceName() string {
@@ -39,11 +38,11 @@ func getKnownControllerNames() []string {
return names
}
-func GatewayClassesCollection(gatewayClasses
krt.Collection[*gateway.GatewayClass], opts krt.OptionsBuilder) (
- krt.StatusCollection[*gateway.GatewayClass,
gatewayv1.GatewayClassStatus],
+func GatewayClassesCollection(gatewayClasses
krt.Collection[*gatewayv1.GatewayClass], opts krt.OptionsBuilder) (
+ krt.StatusCollection[*gatewayv1.GatewayClass,
gatewayv1.GatewayClassStatus],
krt.Collection[GatewayClass],
) {
- return krt.NewStatusCollection(gatewayClasses, func(ctx
krt.HandlerContext, obj *gateway.GatewayClass) (*gatewayv1.GatewayClassStatus,
*GatewayClass) {
+ return krt.NewStatusCollection(gatewayClasses, func(ctx
krt.HandlerContext, obj *gatewayv1.GatewayClass)
(*gatewayv1.GatewayClassStatus, *GatewayClass) {
log.Infof("Processing GatewayClass %s with controller name %q",
obj.Name, obj.Spec.ControllerName)
// Log all known controller names for debugging
for k := range classInfos {
diff --git a/dubbod/discovery/pkg/config/kube/gateway/referencegrants.go
b/dubbod/discovery/pkg/config/kube/gateway/referencegrants.go
index e71d46e8..01b205bb 100644
--- a/dubbod/discovery/pkg/config/kube/gateway/referencegrants.go
+++ b/dubbod/discovery/pkg/config/kube/gateway/referencegrants.go
@@ -84,7 +84,7 @@ func ReferenceGrantsCollection(
}
fromRef := Reference{
Kind: fromKind,
- Namespace: gatewayv1.Namespace(from.Namespace),
+ Namespace: from.Namespace,
}
for _, to := range obj.Spec.To {
toKind := normalizeReference(&to.Group,
&to.Kind, config.GroupVersionKind{})
diff --git
a/dubbod/discovery/pkg/leaderelection/k8sleaderelection/leaderelection.go
b/dubbod/discovery/pkg/leaderelection/k8sleaderelection/leaderelection.go
index 643a16f5..decbd0a3 100644
--- a/dubbod/discovery/pkg/leaderelection/k8sleaderelection/leaderelection.go
+++ b/dubbod/discovery/pkg/leaderelection/k8sleaderelection/leaderelection.go
@@ -164,7 +164,7 @@ func (le *LeaderElector) renew(ctx context.Context) {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
wait.Until(func() {
- // Check if context is already cancelled before starting renewal
+ // Check if context is already canceled before starting renewal
select {
case <-ctx.Done():
return
diff --git a/dubbod/discovery/pkg/model/destinationrule.go
b/dubbod/discovery/pkg/model/destinationrule.go
index a153106c..2713f030 100644
--- a/dubbod/discovery/pkg/model/destinationrule.go
+++ b/dubbod/discovery/pkg/model/destinationrule.go
@@ -17,12 +17,12 @@
package model
import (
- networking "github.com/kdubbo/api/networking/v1alpha3"
"github.com/apache/dubbo-kubernetes/dubbod/discovery/pkg/features"
"github.com/apache/dubbo-kubernetes/pkg/config"
"github.com/apache/dubbo-kubernetes/pkg/config/host"
"github.com/apache/dubbo-kubernetes/pkg/config/visibility"
"github.com/apache/dubbo-kubernetes/pkg/util/sets"
+ networking "github.com/kdubbo/api/networking/v1alpha3"
"k8s.io/apimachinery/pkg/types"
)
@@ -44,13 +44,11 @@ func (ps *PushContext) mergeDestinationRule(p
*consolidatedSubRules, subRuleConf
appendSeparately := true
for _, mdr := range mdrList {
if features.EnableEnhancedDestinationRuleMerge {
- if exportToSet.Equals(mdr.exportTo) {
- appendSeparately = false
- } else if len(mdr.exportTo) > 0 &&
exportToSet.SupersetOf(mdr.exportTo) {
- // If the new exportTo is superset of
existing, merge and also append as a standalone one
- appendSeparately = true
- } else {
- // can not merge with existing one,
append as a standalone one
+ // Merge when exportTo matches or the new
exportTo is a superset of the
+ // existing one; otherwise append as a
standalone entry.
+ canMerge := exportToSet.Equals(mdr.exportTo) ||
+ (len(mdr.exportTo) > 0 &&
exportToSet.SupersetOf(mdr.exportTo))
+ if !canMerge {
appendSeparately = true
continue
}
diff --git a/dubbod/discovery/pkg/model/push_context.go
b/dubbod/discovery/pkg/model/push_context.go
index 8bceeb98..88725024 100644
--- a/dubbod/discovery/pkg/model/push_context.go
+++ b/dubbod/discovery/pkg/model/push_context.go
@@ -461,7 +461,7 @@ func resolveServiceAliases(allServices []*Service,
configsUpdated sets.Set[Confi
Hostname: s.Hostname,
Namespace: s.Attributes.Namespace,
}
- rawAlias[nh] =
host.Name(s.Attributes.K8sAttributes.ExternalName)
+ rawAlias[nh] = host.Name(s.Attributes.ExternalName)
}
unnamespacedRawAlias := make(map[host.Name]host.Name, len(rawAlias))
@@ -558,7 +558,7 @@ func (ps *PushContext) initServiceRegistry(env
*Environment, configsUpdate sets.
ps.ServiceIndex.HostnameAndNamespace[s.Hostname] =
map[string]*Service{}
}
if existing :=
ps.ServiceIndex.HostnameAndNamespace[s.Hostname][s.Attributes.Namespace];
existing != nil &&
- !(existing.Attributes.ServiceRegistry !=
provider.Kubernetes && s.Attributes.ServiceRegistry == provider.Kubernetes) {
+ (existing.Attributes.ServiceRegistry ==
provider.Kubernetes || s.Attributes.ServiceRegistry != provider.Kubernetes) {
log.Debugf("Service %s/%s from registry %s ignored by
%s/%s/%s", s.Attributes.Namespace, s.Hostname, s.Attributes.ServiceRegistry,
existing.Attributes.ServiceRegistry,
existing.Attributes.Namespace, existing.Hostname)
} else {
@@ -958,9 +958,7 @@ func (ps *PushContext) setDestinationRules(configs
[]config.Config) {
rule := configs[i].Spec.(*networking.DestinationRule)
rule.Host = string(ResolveShortnameToFQDN(rule.Host,
configs[i].Meta))
- var exportToSet sets.Set[visibility.Instance]
-
- exportToSet =
sets.NewWithLength[visibility.Instance](len(rule.ExportTo))
+ exportToSet :=
sets.NewWithLength[visibility.Instance](len(rule.ExportTo))
for _, e := range rule.ExportTo {
exportToSet.Insert(visibility.Instance(e))
}
diff --git a/dubbod/discovery/pkg/networking/core/configgen.go
b/dubbod/discovery/pkg/networking/core/configgen.go
index 28cfdea4..61baa216 100644
--- a/dubbod/discovery/pkg/networking/core/configgen.go
+++ b/dubbod/discovery/pkg/networking/core/configgen.go
@@ -36,5 +36,4 @@ func NewConfigGenerator(cache model.XdsCache)
*ConfigGeneratorImpl {
}
func (configgen *ConfigGeneratorImpl) serviceRouteIndexChanged(_
*serviceRouteIndex.MeshConfig) {
- return
}
diff --git a/dubbod/discovery/pkg/networking/grpcgen/cds.go
b/dubbod/discovery/pkg/networking/grpcgen/cds.go
index 44cb0054..cfb7e3ef 100644
--- a/dubbod/discovery/pkg/networking/grpcgen/cds.go
+++ b/dubbod/discovery/pkg/networking/grpcgen/cds.go
@@ -419,7 +419,7 @@ func (b *clusterBuilder) applyBackendTLSPolicy(c
*cluster.Cluster) {
if c == nil || c.TransportSocket != nil || b.svc == nil || b.push ==
nil {
return
}
- if b.svc.Resolution != model.Alias ||
b.svc.Attributes.K8sAttributes.ExternalName == "" {
+ if b.svc.Resolution != model.Alias || b.svc.Attributes.ExternalName ==
"" {
return
}
settings, found :=
b.push.BackendTLSForService(b.svc.Attributes.Namespace, b.svc.Attributes.Name)
diff --git a/dubbod/discovery/pkg/networking/grpcgen/cds_test.go
b/dubbod/discovery/pkg/networking/grpcgen/cds_test.go
index 996b5398..14b72f12 100644
--- a/dubbod/discovery/pkg/networking/grpcgen/cds_test.go
+++ b/dubbod/discovery/pkg/networking/grpcgen/cds_test.go
@@ -31,7 +31,7 @@ func
TestBuildClustersExternalNameBackendTLSPolicyUsesSimpleTLS(t *testing.T) {
hostName := "httpbin-egress.app.svc.cluster.local"
service := newRDSTestService("httpbin-egress", "app", hostName, 443)
service.Resolution = model.Alias
- service.Attributes.K8sAttributes.ExternalName = "httpbin.org"
+ service.Attributes.ExternalName = "httpbin.org"
push := newRDSTestPushContext(t, []config.Config{
newBackendTLSPolicyConfig("httpbin-tls", "app",
"httpbin-egress", "httpbin.org"),
}, []*model.Service{service})
diff --git a/dubbod/discovery/pkg/networking/grpcgen/lds.go
b/dubbod/discovery/pkg/networking/grpcgen/lds.go
index ff903026..0eb4a6cc 100644
--- a/dubbod/discovery/pkg/networking/grpcgen/lds.go
+++ b/dubbod/discovery/pkg/networking/grpcgen/lds.go
@@ -36,6 +36,7 @@ import (
listener "github.com/kdubbo/xds-api/listener/v1"
route "github.com/kdubbo/xds-api/route/v1"
discovery "github.com/kdubbo/xds-api/service/discovery/v1"
+ "google.golang.org/protobuf/proto"
wrapperspb "google.golang.org/protobuf/types/known/wrapperspb"
)
@@ -373,11 +374,7 @@ func cloneInboundFilterChain(in *listener.FilterChain)
*listener.FilterChain {
if in == nil {
return &listener.FilterChain{}
}
- out := *in
- if len(in.Filters) > 0 {
- out.Filters = append([]*listener.Filter(nil), in.Filters...)
- }
- return &out
+ return proto.Clone(in).(*listener.FilterChain)
}
func logInboundMTLSMode(name string, mode model.MutualTLSMode,
filterChainCount int) {
diff --git a/dubbod/discovery/pkg/networking/grpcgen/rds.go
b/dubbod/discovery/pkg/networking/grpcgen/rds.go
index 249ab63a..796137c7 100644
--- a/dubbod/discovery/pkg/networking/grpcgen/rds.go
+++ b/dubbod/discovery/pkg/networking/grpcgen/rds.go
@@ -534,7 +534,7 @@ func httpRouteReferencesService(hrSpec
*sigsk8siogatewayapiapisv1.HTTPRouteSpec,
if refNamespace != svc.Attributes.Namespace ||
string(parentRef.Name) != svc.Attributes.Name {
continue
}
- if parentRef.Port != nil && int32(*parentRef.Port) !=
int32(port) {
+ if parentRef.Port != nil && *parentRef.Port != int32(port) {
continue
}
if parentRef.SectionName != nil {
diff --git a/dubbod/discovery/pkg/networking/grpcgen/rds_test.go
b/dubbod/discovery/pkg/networking/grpcgen/rds_test.go
index 7b28cc3c..83d43946 100644
--- a/dubbod/discovery/pkg/networking/grpcgen/rds_test.go
+++ b/dubbod/discovery/pkg/networking/grpcgen/rds_test.go
@@ -159,7 +159,7 @@ func newRDSTestPushContext(t *testing.T, configs
[]config.Config, services []*mo
}
func newWildcardHTTPRouteConfig(backendName, backendNamespace string,
backendPort int32) config.Config {
- port := gatewayv1.PortNumber(backendPort)
+ port := backendPort
weight := int32(1)
return config.Config{
Meta: config.Meta{
@@ -197,7 +197,7 @@ func newWildcardHTTPRouteConfig(backendName,
backendNamespace string, backendPor
func newServiceAttachedHTTPRouteConfig(name, namespace, parentName string,
parentPort int32) config.Config {
group := gatewayv1.Group("")
kind := gatewayv1.Kind("Service")
- port := gatewayv1.PortNumber(parentPort)
+ port := parentPort
weight := int32(100)
pathType := gatewayv1.PathMatchPathPrefix
pathValue := "/"
diff --git a/dubbod/discovery/pkg/server/instance.go
b/dubbod/discovery/pkg/server/instance.go
index 04933209..43b29b05 100644
--- a/dubbod/discovery/pkg/server/instance.go
+++ b/dubbod/discovery/pkg/server/instance.go
@@ -84,6 +84,7 @@ func (i *instance) Start(stop <-chan struct{}) error {
case next := <-i.components:
t0 := time.Now()
if err := next.task(stop); err != nil {
+ log.Warnf("post-start task failed: %v",
err)
}
runtime := time.Since(t0)
if runtime > time.Second {
diff --git a/dubbod/discovery/pkg/serviceregistry/kube/controller/controller.go
b/dubbod/discovery/pkg/serviceregistry/kube/controller/controller.go
index 5cea8d07..1db2150b 100644
--- a/dubbod/discovery/pkg/serviceregistry/kube/controller/controller.go
+++ b/dubbod/discovery/pkg/serviceregistry/kube/controller/controller.go
@@ -277,7 +277,7 @@ func (c *Controller) GetProxyServiceTargets(proxy
*model.Proxy) []model.ServiceT
if kubeSvc != nil {
// Find the matching ServicePort in Kubernetes
Service
for _, kubePort := range kubeSvc.Spec.Ports {
- if kubePort.Name == port.Name &&
int32(kubePort.Port) == int32(port.Port) {
+ if kubePort.Name == port.Name &&
kubePort.Port == int32(port.Port) {
// Resolve targetPort from
ServicePort.TargetPort
if kubePort.TargetPort.Type ==
intstr.Int {
// TargetPort is a
number
diff --git
a/dubbod/discovery/pkg/serviceregistry/kube/controller/endpointslice.go
b/dubbod/discovery/pkg/serviceregistry/kube/controller/endpointslice.go
index 86885e24..17e8fa35 100644
--- a/dubbod/discovery/pkg/serviceregistry/kube/controller/endpointslice.go
+++ b/dubbod/discovery/pkg/serviceregistry/kube/controller/endpointslice.go
@@ -245,7 +245,7 @@ func (esc *endpointSliceController)
updateEndpointCacheForSlice(hostName host.Na
matched := false
for _, kubePort := range
kubeSvc.Spec.Ports {
// Try matching by port number
(service port or targetPort)
- portMatches :=
int32(kubePort.Port) == epSlicePortNum
+ portMatches := kubePort.Port ==
epSlicePortNum
// Also try matching by
targetPort
var kubeTargetPort int32
@@ -272,7 +272,7 @@ func (esc *endpointSliceController)
updateEndpointCacheForSlice(hostName host.Na
if (portMatches ||
targetPortMatches) && (epSlicePortName == "" || nameMatches) {
// Found matching
ServicePort
- servicePortNum =
int32(kubePort.Port)
+ servicePortNum =
kubePort.Port
portName = kubePort.Name
// Resolve targetPortNum
@@ -312,9 +312,9 @@ func (esc *endpointSliceController)
updateEndpointCacheForSlice(hostName host.Na
// If we can't match by
Service, try to find ServicePort by port number only
// This handles cases where
EndpointSlice.Port.Name doesn't match but port number does
for _, kubePort := range
kubeSvc.Spec.Ports {
- if int32(kubePort.Port)
== epSlicePortNum {
+ if kubePort.Port ==
epSlicePortNum {
// Found by
port number, use Service.Port.Name
- servicePortNum
= int32(kubePort.Port)
+ servicePortNum
= kubePort.Port
portName =
kubePort.Name
// Resolve
targetPortNum
if
kubePort.TargetPort.Type == intstr.Int {
@@ -355,7 +355,7 @@ func (esc *endpointSliceController)
updateEndpointCacheForSlice(hostName host.Na
} else {
// If
EndpointSlice.Port.Name is also empty, try to get port name from Service by
port number
for _, kubePort
:= range kubeSvc.Spec.Ports {
- if
int32(kubePort.Port) == epSlicePortNum {
+ if
kubePort.Port == epSlicePortNum {
portName = kubePort.Name
log.Debugf("updateEndpointCacheForSlice: resolved portName='%s' from Service by
port number %d", portName, epSlicePortNum)
break
diff --git a/dubbod/discovery/pkg/serviceregistry/kube/controller/pod.go
b/dubbod/discovery/pkg/serviceregistry/kube/controller/pod.go
index 24fc8e7b..fcb61d42 100644
--- a/dubbod/discovery/pkg/serviceregistry/kube/controller/pod.go
+++ b/dubbod/discovery/pkg/serviceregistry/kube/controller/pod.go
@@ -134,7 +134,7 @@ func (pc *PodCache) onEvent(old, pod *v1.Pod, ev
model.Event) error {
if !pc.deleteIP(ip, key) {
return nil
}
- ev = model.EventDelete
+ // TODO: emit model.EventDelete once
notifyWorkloadHandlers is implemented.
} else if shouldPodBeInEndpoints(pod) && IsPodReady(pod) {
labelUpdated := pc.labelFilter(old, pod)
pc.addPod(pod, ip, key, labelUpdated)
diff --git a/dubbod/discovery/pkg/status/resource.go
b/dubbod/discovery/pkg/status/resource.go
index 17697561..2ea41998 100644
--- a/dubbod/discovery/pkg/status/resource.go
+++ b/dubbod/discovery/pkg/status/resource.go
@@ -34,7 +34,7 @@ type Resource struct {
}
func (r Resource) String() string {
- return strings.Join([]string{r.Group, r.Version,
r.GroupVersionResource.Resource, r.Namespace, r.Name, r.Generation}, "/")
+ return strings.Join([]string{r.Group, r.Version, r.Resource,
r.Namespace, r.Name, r.Generation}, "/")
}
func (r *Resource) ToModelKey() string {
diff --git a/dubbod/discovery/pkg/xds/ads.go b/dubbod/discovery/pkg/xds/ads.go
index 1e2727a1..0edaf45d 100644
--- a/dubbod/discovery/pkg/xds/ads.go
+++ b/dubbod/discovery/pkg/xds/ads.go
@@ -256,20 +256,11 @@ func (s *DiscoveryServer) computeProxyState(proxy
*model.Proxy, request *model.P
proxy.SetServiceTargets(s.Env.ServiceDiscovery)
}
- recomputeLabels := request == nil || request.IsProxyUpdate()
- if recomputeLabels {
- }
+ // TODO: recompute proxy labels when request == nil or
request.IsProxyUpdate().
push := proxy.LastPushContext
- if request == nil {
- } else {
+ if request != nil {
push = request.Push
- if request.Forced {
- }
- for conf := range request.ConfigsUpdated {
- switch conf.Kind {
- }
- }
}
proxy.LastPushContext = push
diff --git a/dubbod/discovery/pkg/xds/cds.go b/dubbod/discovery/pkg/xds/cds.go
index ef04bb81..84749ea7 100644
--- a/dubbod/discovery/pkg/xds/cds.go
+++ b/dubbod/discovery/pkg/xds/cds.go
@@ -40,7 +40,7 @@ func cdsNeedsPush(req *model.PushRequest, proxy *model.Proxy)
(*model.PushReques
}
func (c CdsGenerator) Generate(proxy *model.Proxy, w *model.WatchedResource,
req *model.PushRequest) (model.Resources, model.XdsLogDetails, error) {
- req, needsPush := cdsNeedsPush(req, proxy)
+ _, needsPush := cdsNeedsPush(req, proxy)
if !needsPush {
return nil, model.DefaultXdsLogDetails, nil
}
@@ -51,7 +51,7 @@ func (c CdsGenerator) Generate(proxy *model.Proxy, w
*model.WatchedResource, req
func (c CdsGenerator) GenerateDeltas(proxy *model.Proxy, req
*model.PushRequest,
w *model.WatchedResource,
) (model.Resources, model.DeletedResources, model.XdsLogDetails, bool, error) {
- req, needsPush := cdsNeedsPush(req, proxy)
+ _, needsPush := cdsNeedsPush(req, proxy)
if !needsPush {
return nil, nil, model.DefaultXdsLogDetails, false, nil
}
diff --git a/dubbod/discovery/pkg/xds/discovery.go
b/dubbod/discovery/pkg/xds/discovery.go
index 0a2ee9fd..21a5cdfc 100644
--- a/dubbod/discovery/pkg/xds/discovery.go
+++ b/dubbod/discovery/pkg/xds/discovery.go
@@ -382,7 +382,7 @@ func (s *DiscoveryServer) ConfigUpdate(req
*model.PushRequest) {
s.InboundUpdates.Inc()
// Record inbound update metrics
- if req.ConfigsUpdated != nil && len(req.ConfigsUpdated) > 0 {
+ if len(req.ConfigsUpdated) > 0 {
recordInboundConfigUpdate()
}
@@ -448,7 +448,8 @@ func (s *DiscoveryServer) EDSUpdate(shard model.ShardKey,
serviceName string, na
// 1. Endpoints become available (from empty to non-empty)
// 2. Endpoints become unavailable (from non-empty to empty)
// 3. Endpoint health status changes
- if pushType == model.IncrementalPush || pushType == model.FullPush {
+ switch pushType {
+ case model.IncrementalPush, model.FullPush:
log.Debugf("service %s/%s triggering %v push [endpoints=%d]",
namespace, serviceName, pushType, len(dubboEndpoints))
// Record EDS update metric
@@ -459,7 +460,7 @@ func (s *DiscoveryServer) EDSUpdate(shard model.ShardKey,
serviceName string, na
ConfigsUpdated: sets.New(model.ConfigKey{Kind:
kind.Service, Name: serviceName, Namespace: namespace}),
Reason:
model.NewReasonStats(model.EndpointUpdate),
})
- } else if pushType == model.NoPush {
+ case model.NoPush:
// Even when UpdateServiceEndpoints returns NoPush, we may
still need to push
// This happens when:
// 1. All old endpoints were unhealthy and new endpoints are
also unhealthy (health status didn't change)
@@ -521,12 +522,11 @@ func reasonsUpdated(req *model.PushRequest) string {
reason0Cnt, reason1Cnt, idx int
)
for r, cnt := range req.Reason {
- if idx == 0 {
+ switch idx {
+ case 0:
reason0, reason0Cnt = r, cnt
- } else if idx == 1 {
+ case 1:
reason1, reason1Cnt = r, cnt
- } else {
- break
}
idx++
}
diff --git a/dubbod/discovery/pkg/xds/endpoints/endpoint_builder.go
b/dubbod/discovery/pkg/xds/endpoints/endpoint_builder.go
index 6ba24d46..97b41a28 100644
--- a/dubbod/discovery/pkg/xds/endpoints/endpoint_builder.go
+++ b/dubbod/discovery/pkg/xds/endpoints/endpoint_builder.go
@@ -96,7 +96,7 @@ func (b *EndpointBuilder)
BuildClusterLoadAssignmentWithGateways(endpointIndex *
if svcPort == nil {
return buildEmptyClusterLoadAssignment(b.clusterName)
}
- if externalName := b.service.Attributes.K8sAttributes.ExternalName;
externalName != "" {
+ if externalName := b.service.Attributes.ExternalName; externalName !=
"" {
return buildDNSClusterLoadAssignment(b.clusterName,
externalName, uint32(svcPort.Port))
}
@@ -197,13 +197,11 @@ func (b *EndpointBuilder)
BuildClusterLoadAssignmentWithGateways(endpointIndex *
}
if len(lbEndpoints) == 0 {
- logLevel := log.Debugf
// For proxyless gRPC, log empty endpoints at INFO level to
help diagnose connection issues
// This helps identify when endpoints are not available vs when
they're filtered out
+ logLevel := log.Infof // If no endpoints exist at all, this is
informational
if totalEndpoints > 0 {
logLevel = log.Warnf // If endpoints exist but were
filtered, this is a warning
- } else {
- logLevel = log.Infof // If no endpoints exist at all,
this is informational
}
logLevel("no endpoints found for cluster %s (hostname=%s,
port=%d, svcPort.Name='%s', svcPort.Port=%d, totalEndpoints=%d,
filteredCount=%d, portNameMismatch=%d, unhealthy=%d, buildFailed=%d)",
b.clusterName, b.hostname, b.port, svcPort.Name,
svcPort.Port, totalEndpoints, filteredCount, portNameMismatchCount,
unhealthyCount, buildFailedCount)
@@ -295,8 +293,6 @@ func (b *EndpointBuilder) buildLbEndpointForCluster(ep
*model.DubboEndpoint, end
healthStatus = core.HealthStatus_DRAINING
case model.Terminating:
healthStatus = core.HealthStatus_UNHEALTHY
- default:
- healthStatus = core.HealthStatus_HEALTHY
}
return &endpoint.LbEndpoint{
diff --git a/dubbod/discovery/pkg/xds/endpoints/endpoint_builder_test.go
b/dubbod/discovery/pkg/xds/endpoints/endpoint_builder_test.go
index fff6528c..c60e3f42 100644
--- a/dubbod/discovery/pkg/xds/endpoints/endpoint_builder_test.go
+++ b/dubbod/discovery/pkg/xds/endpoints/endpoint_builder_test.go
@@ -42,7 +42,7 @@ func TestBuildClusterLoadAssignmentUsesExternalNameDNS(t
*testing.T) {
hostname := host.Name("httpbin-egress.app.svc.cluster.local")
svc := newEndpointTestService("httpbin-egress", "app",
string(hostname), 443)
svc.Resolution = model.Alias
- svc.Attributes.K8sAttributes.ExternalName = "httpbin.org"
+ svc.Attributes.ExternalName = "httpbin.org"
push := newEndpointTestPushContext(t, nil, []*model.Service{svc})
index := model.NewEndpointIndex(model.DisabledCache{})
diff --git a/dubbod/discovery/pkg/xds/xdsgen.go
b/dubbod/discovery/pkg/xds/xdsgen.go
index ab9588cc..c10a14e4 100644
--- a/dubbod/discovery/pkg/xds/xdsgen.go
+++ b/dubbod/discovery/pkg/xds/xdsgen.go
@@ -95,7 +95,8 @@ func (s *DiscoveryServer) pushXds(con *Connection, w
*model.WatchedResource, req
// Initial wildcard request - need to extract resource
names from parent resources
// For CDS: extract cluster names from LDS
// For EDS: extract cluster names from CDS
- if w.TypeUrl == v1.ClusterType {
+ switch w.TypeUrl {
+ case v1.ClusterType:
// Extract cluster names from LDS response
ldsWatched :=
con.proxy.GetWatchedResource(v1.ListenerType)
if ldsWatched != nil && ldsWatched.NonceSent !=
"" {
@@ -125,7 +126,7 @@ func (s *DiscoveryServer) pushXds(con *Connection, w
*model.WatchedResource, req
}
}
}
- } else if w.TypeUrl == v1.EndpointType {
+ case v1.EndpointType:
// Extract cluster names from CDS response
cdsWatched :=
con.proxy.GetWatchedResource(v1.ClusterType)
if cdsWatched != nil && cdsWatched.NonceSent !=
"" {
@@ -153,7 +154,7 @@ func (s *DiscoveryServer) pushXds(con *Connection, w
*model.WatchedResource, req
}
}
}
- } else if w.TypeUrl == v1.RouteType {
+ case v1.RouteType:
// Extract route names from LDS response for
RDS wildcard requests
// RDS is not a wildcard type, so when client
sends empty ResourceNames,
// we need to extract route names from LDS
listeners that reference RDS
diff --git a/dubbod/security/pkg/nodeagent/cache/secretcache.go
b/dubbod/security/pkg/nodeagent/cache/secretcache.go
index 766d6aa3..9ac0e153 100644
--- a/dubbod/security/pkg/nodeagent/cache/secretcache.go
+++ b/dubbod/security/pkg/nodeagent/cache/secretcache.go
@@ -348,7 +348,7 @@ func (sc *SecretManagerClient) registerSecret(item
security.SecretItem) {
// In case `UpdateConfigTrustBundle` called, it will resign
workload cert.
// Check if this is a stale scheduled rotating task.
if cached := sc.cache.GetWorkload(); cached != nil {
- if cached.CreatedTime == item.CreatedTime {
+ if cached.CreatedTime.Equal(item.CreatedTime) {
cacheLog.Debugf("Rotating certificate,
resource=%s", item.ResourceName)
sc.cache.SetWorkload(nil)
sc.OnSecretUpdate(item.ResourceName)
@@ -638,7 +638,7 @@ func (sc *SecretManagerClient) handleFileWatch() {
return
}
// We only care about updates that change the file
content
- if !(isWrite(event) || isRemove(event) ||
isCreate(event)) {
+ if !isWrite(event) && !isRemove(event) &&
!isCreate(event) {
continue
}
sc.certMutex.RLock()
diff --git a/dubbod/security/pkg/server/ca/server.go
b/dubbod/security/pkg/server/ca/server.go
index 7e374ffb..e9347112 100644
--- a/dubbod/security/pkg/server/ca/server.go
+++ b/dubbod/security/pkg/server/ca/server.go
@@ -21,11 +21,11 @@ import (
"github.com/apache/dubbo-kubernetes/pkg/log"
"time"
- pb "github.com/kdubbo/api/security/v1alpha3"
"github.com/apache/dubbo-kubernetes/dubbod/security/pkg/pki/ca"
caerror
"github.com/apache/dubbo-kubernetes/dubbod/security/pkg/pki/error"
"github.com/apache/dubbo-kubernetes/dubbod/security/pkg/pki/util"
"github.com/apache/dubbo-kubernetes/pkg/security"
+ pb "github.com/kdubbo/api/security/v1alpha3"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
diff --git a/operator/cmd/cluster/manifest.go b/operator/cmd/cluster/manifest.go
index bcba34ca..76092698 100644
--- a/operator/cmd/cluster/manifest.go
+++ b/operator/cmd/cluster/manifest.go
@@ -137,31 +137,31 @@ func sortManifests(raw []manifest.ManifestSet) []string {
func objectKindOrder(m manifest.Manifest) int {
o := m.Unstructured
gk := o.GroupVersionKind().Group + "/" + o.GroupVersionKind().Kind
- switch {
+ switch gk {
// Create CRDs asap - both because they are slow and because we will
likely create instances of them soon
- case gk == "apiextensions.k8s.io/CustomResourceDefinition":
+ case "apiextensions.k8s.io/CustomResourceDefinition":
return -1000
// We need to create ServiceAccounts, Roles before we bind them
with a RoleBinding
- case gk == "/ServiceAccount" || gk ==
"rbac.authorization.k8s.io/ClusterRole":
+ case "/ServiceAccount", "rbac.authorization.k8s.io/ClusterRole":
return 1
- case gk == "rbac.authorization.k8s.io/ClusterRoleBinding":
+ case "rbac.authorization.k8s.io/ClusterRoleBinding":
return 2
// Pods might need configmap or secrets - avoid backoff by
creating them first
- case gk == "/ConfigMap" || gk == "/Secrets":
+ case "/ConfigMap", "/Secrets":
return 100
// Create the pods after we've created other things they might
be waiting for
- case gk == "extensions/Deployment" || gk == "apps/Deployment":
+ case "extensions/Deployment", "apps/Deployment":
return 1000
// Autoscalers typically act on a deployment
- case gk == "autoscaling/HorizontalPodAutoscaler":
+ case "autoscaling/HorizontalPodAutoscaler":
return 1001
// Create services late - after pods have been started
- case gk == "/Service":
+ case "/Service":
return 10000
default:
diff --git a/operator/pkg/helm/helm.go b/operator/pkg/helm/helm.go
index ecf093f8..d2708f15 100644
--- a/operator/pkg/helm/helm.go
+++ b/operator/pkg/helm/helm.go
@@ -54,6 +54,9 @@ func Render(namespace string, directory string, dop
values.Map) ([]manifest.Mani
path := pathJoin("charts", directory)
f := manifests.BuiltinDir("")
chrt, err := loadChart(f, path)
+ if err != nil {
+ return nil, nil, fmt.Errorf("load chart: %v", err)
+ }
output, warnings, err := renderChart(namespace, val, chrt)
if err != nil {
return nil, nil, fmt.Errorf("render chart: %v", err)
diff --git a/operator/pkg/install/installer.go
b/operator/pkg/install/installer.go
index f4986b6e..6eb75eb4 100644
--- a/operator/pkg/install/installer.go
+++ b/operator/pkg/install/installer.go
@@ -86,7 +86,7 @@ func (i Installer) install(manifests []manifest.ManifestSet)
error {
})...)
dependencyWaitCh := dependenciesChannels()
for _, mfs := range manifests {
- mfs := mfs
+
c := mfs.Components
m := mfs.Manifests
disabledComponents.Delete(c)
@@ -220,7 +220,8 @@ func (i Installer) prune(manifests []manifest.ManifestSet)
error {
if err != nil {
return err
}
- objs, err := dc.List(context.Background(), metav1.ListOptions{
+ // Pruning is best-effort: resources we cannot list are skipped
below.
+ objs, _ := dc.List(context.Background(), metav1.ListOptions{
LabelSelector: selector.String(),
})
if objs == nil {
diff --git a/operator/pkg/render/manifest.go b/operator/pkg/render/manifest.go
index 08d1815b..a5e66fef 100644
--- a/operator/pkg/render/manifest.go
+++ b/operator/pkg/render/manifest.go
@@ -64,6 +64,9 @@ func MergeInputs(filenames []string, flags []string)
(values.Map, error) {
} else {
b, err = os.ReadFile(strings.TrimSpace(fn))
}
+ if err != nil {
+ return nil, err
+ }
if err := checkDops(string(b)); err != nil {
return nil, fmt.Errorf("checkDops err:%v", err)
diff --git a/pkg/bootstrap/config.go b/pkg/bootstrap/config.go
index 924d20a9..8ed542e2 100644
--- a/pkg/bootstrap/config.go
+++ b/pkg/bootstrap/config.go
@@ -24,10 +24,10 @@ import (
"strconv"
"strings"
- meshAPI "github.com/kdubbo/api/mesh/v1alpha1"
"github.com/apache/dubbo-kubernetes/pkg/config/constants"
"github.com/apache/dubbo-kubernetes/pkg/model"
"github.com/apache/dubbo-kubernetes/pkg/security"
+ meshAPI "github.com/kdubbo/api/mesh/v1alpha1"
core "github.com/kdubbo/xds-api/core/v1"
dubbolog "github.com/apache/dubbo-kubernetes/pkg/log"
diff --git a/pkg/config/mesh/meshwatcher/mesh.go
b/pkg/config/mesh/meshwatcher/mesh.go
index 3769cc09..1f43fc7c 100644
--- a/pkg/config/mesh/meshwatcher/mesh.go
+++ b/pkg/config/mesh/meshwatcher/mesh.go
@@ -42,7 +42,7 @@ type WatcherCollection interface {
func (a adapter) Mesh() *meshv1alpha1.MeshConfig {
// Just get the value; we know there is always one set due to the way
the collection is setup.
- v := a.Singleton.Get()
+ v := a.Get()
return v.MeshConfig
}
diff --git a/pkg/config/schema/codegen/collections.go
b/pkg/config/schema/codegen/collections.go
index 9ac0a865..a0d956b1 100644
--- a/pkg/config/schema/codegen/collections.go
+++ b/pkg/config/schema/codegen/collections.go
@@ -199,10 +199,7 @@ func toImport(p string) string {
}
func toDubboImport(protoPackage string, version string) string {
- aliasPackage := protoPackage
- if strings.Contains(aliasPackage, "github.com/kdubbo/api") {
- aliasPackage = strings.Replace(aliasPackage,
"github.com/kdubbo/api", "github.com/apache/dubbo-kubernetes/api", 1)
- }
+ aliasPackage := strings.Replace(protoPackage, "github.com/kdubbo/api",
"github.com/apache/dubbo-kubernetes/api", 1)
p := strings.Split(aliasPackage, "/")
base := strings.Join(p[:len(p)-1], "")
dmp := strings.ReplaceAll(strings.ReplaceAll(base, ".", ""), "-", "") +
version
diff --git a/pkg/env/var.go b/pkg/env/var.go
index a359d7dd..0c3d63b4 100644
--- a/pkg/env/var.go
+++ b/pkg/env/var.go
@@ -368,7 +368,7 @@ func (v GenericVar[T]) IsSet() bool {
}
func (v GenericVar[T]) GetName() string {
- return v.Var.Name
+ return v.Name
}
// specializedVar represents a var that can Get/Lookup
diff --git a/pkg/file/fadvise_unspecified.go b/pkg/file/fadvise_unspecified.go
index a4bdfe37..40635dba 100644
--- a/pkg/file/fadvise_unspecified.go
+++ b/pkg/file/fadvise_unspecified.go
@@ -1,5 +1,4 @@
//go:build !linux
-// +build !linux
//
// Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/pkg/kube/inject/inject.go b/pkg/kube/inject/inject.go
index 14a587f0..9f51516d 100644
--- a/pkg/kube/inject/inject.go
+++ b/pkg/kube/inject/inject.go
@@ -396,8 +396,8 @@ func injectRequired(ignored []string, config *Config,
podSpec *corev1.PodSpec, m
func injectionStatus(pod *corev1.Pod) *InjectionStatus {
var statusBytes []byte
- if pod.ObjectMeta.Annotations != nil {
- if value, ok :=
pod.ObjectMeta.Annotations[annotation.OrgApacheDubboProxylessStatus.Name]; ok {
+ if pod.Annotations != nil {
+ if value, ok :=
pod.Annotations[annotation.OrgApacheDubboProxylessStatus.Name]; ok {
statusBytes = []byte(value)
}
}
diff --git a/pkg/kube/inject/webhook.go b/pkg/kube/inject/webhook.go
index d31f9dd8..540c20e2 100644
--- a/pkg/kube/inject/webhook.go
+++ b/pkg/kube/inject/webhook.go
@@ -259,8 +259,8 @@ func (wh *Webhook) injectPod(ar *kube.AdmissionReview, path
string) *kube.Admiss
pod.ManagedFields = nil
podName := potentialPodName(pod.ObjectMeta)
- if pod.ObjectMeta.Namespace == "" {
- pod.ObjectMeta.Namespace = req.Namespace
+ if pod.Namespace == "" {
+ pod.Namespace = req.Namespace
}
log = log.WithLabels("pod", pod.Namespace+"/"+podName)
diff --git a/pkg/kube/kclient/client.go b/pkg/kube/kclient/client.go
index ea642b7f..4cd8115d 100644
--- a/pkg/kube/kclient/client.go
+++ b/pkg/kube/kclient/client.go
@@ -295,7 +295,7 @@ func (n *informerClient[T]) AddEventHandler(h
cache.ResourceEventHandler) cache.
fh := cache.FilteringResourceEventHandler{
FilterFunc: func(obj interface{}) bool {
var nameStr, nsStr string
- if objWithNs, ok := any(obj).(interface {
+ if objWithNs, ok := obj.(interface {
GetNamespace() string
GetName() string
}); ok {
@@ -319,7 +319,7 @@ func (n *informerClient[T]) AddEventHandler(h
cache.ResourceEventHandler) cache.
Handler: cache.ResourceEventHandlerFuncs{
AddFunc: func(obj interface{}) {
var nameStr, nsStr string
- if objWithNs, ok := any(obj).(interface {
+ if objWithNs, ok := obj.(interface {
GetNamespace() string
GetName() string
}); ok {
@@ -331,7 +331,7 @@ func (n *informerClient[T]) AddEventHandler(h
cache.ResourceEventHandler) cache.
},
UpdateFunc: func(oldObj, newObj interface{}) {
var nameStr, nsStr string
- if objWithNs, ok := any(newObj).(interface {
+ if objWithNs, ok := newObj.(interface {
GetNamespace() string
GetName() string
}); ok {
@@ -343,7 +343,7 @@ func (n *informerClient[T]) AddEventHandler(h
cache.ResourceEventHandler) cache.
},
DeleteFunc: func(obj interface{}) {
var nameStr, nsStr string
- if objWithNs, ok := any(obj).(interface {
+ if objWithNs, ok := obj.(interface {
GetNamespace() string
GetName() string
}); ok {
@@ -367,13 +367,12 @@ func (n *informerClient[T]) AddEventHandler(h
cache.ResourceEventHandler) cache.
func (n *informerClient[T]) Index(name string, extract func(o T) []string)
RawIndexer {
if _, ok := n.informer.GetIndexer().GetIndexers()[name]; !ok {
- if err := n.informer.AddIndexers(map[string]cache.IndexFunc{
+ _ = n.informer.AddIndexers(map[string]cache.IndexFunc{
name: func(obj any) ([]string, error) {
t := controllers.Extract[T](obj)
return extract(t), nil
},
- }); err != nil {
- }
+ })
}
ret := internalIndex{
key: name,
@@ -445,9 +444,7 @@ func (a neverReady) HasSynced() bool {
}
func (i internalIndex) Lookup(key string) []any {
- res, err := i.indexer.ByIndex(i.key, key)
- if err != nil {
- }
+ res, _ := i.indexer.ByIndex(i.key, key)
if i.filter != nil {
return slices.FilterInPlace(res, i.filter)
}
diff --git a/pkg/kube/krt/files/files.go b/pkg/kube/krt/files/files.go
index 343824ec..d3345c61 100644
--- a/pkg/kube/krt/files/files.go
+++ b/pkg/kube/krt/files/files.go
@@ -190,7 +190,7 @@ func (m recursiveWatcher) watchRecursive(path string) error
{
return err
}
if fi.IsDir() {
- if err = m.Watcher.Add(walkPath); err != nil {
+ if err = m.Add(walkPath); err != nil {
return err
}
}
diff --git a/pkg/log/klog_interceptor.go b/pkg/log/klog_interceptor.go
index 1bcfef49..c5ac72ec 100644
--- a/pkg/log/klog_interceptor.go
+++ b/pkg/log/klog_interceptor.go
@@ -1,5 +1,4 @@
//go:build !noklog
-// +build !noklog
//
// Licensed to the Apache Software Foundation (ASF) under one or more
diff --git a/pkg/model/proxy.go b/pkg/model/proxy.go
index 6c98cc06..d3032aee 100644
--- a/pkg/model/proxy.go
+++ b/pkg/model/proxy.go
@@ -23,9 +23,9 @@ import (
core "github.com/kdubbo/xds-api/core/v1"
"strconv"
- meshv1alpha1 "github.com/kdubbo/api/mesh/v1alpha1"
networkutil
"github.com/apache/dubbo-kubernetes/dubbod/discovery/pkg/util/network"
"github.com/apache/dubbo-kubernetes/pkg/util/protomarshal"
+ meshv1alpha1 "github.com/kdubbo/api/mesh/v1alpha1"
)
type (
diff --git a/pkg/slices/slices.go b/pkg/slices/slices.go
index d9698d87..e2b3b60f 100644
--- a/pkg/slices/slices.go
+++ b/pkg/slices/slices.go
@@ -250,7 +250,7 @@ func MapFilter[E any, O any](s []E, f func(E) *O) []O {
func Reference[E any](s []E) []*E {
res := make([]*E, 0, len(s))
for _, v := range s {
- v := v
+
res = append(res, &v)
}
return res
diff --git a/pkg/spiffe/spiffe.go b/pkg/spiffe/spiffe.go
index 327d1d1f..7da58660 100644
--- a/pkg/spiffe/spiffe.go
+++ b/pkg/spiffe/spiffe.go
@@ -297,7 +297,7 @@ func (v *PeerCertVerifier) VerifyPeerCert(rawCerts
[][]byte, _ [][]*x509.Certifi
}
func sanitizeTrustDomain(td string) string {
- return strings.Replace(td, "@", ".", -1)
+ return strings.ReplaceAll(td, "@", ".")
}
func genSpiffeURI(td, ns, serviceAccount string) (string, error) {
@@ -310,8 +310,6 @@ func genSpiffeURI(td, ns, serviceAccount string) (string,
error) {
}
func MustGenSpiffeURI(meshCfg *meshv1alpha1.MeshConfig, ns, serviceAccount
string) string {
- uri, err := genSpiffeURI(meshCfg.GetTrustDomain(), ns, serviceAccount)
- if err != nil {
- }
+ uri, _ := genSpiffeURI(meshCfg.GetTrustDomain(), ns, serviceAccount)
return uri
}
diff --git a/pkg/webhooks/webhookpatch.go b/pkg/webhooks/webhookpatch.go
index b02ef982..d1fb0b8e 100644
--- a/pkg/webhooks/webhookpatch.go
+++ b/pkg/webhooks/webhookpatch.go
@@ -143,8 +143,8 @@ func (w *WebhookCertPatcher)
patchMutatingWebhookConfig(webhookConfigName string
}
if updated {
- _, err := w.webhooks.Update(config)
- if err != nil {
+ if _, err := w.webhooks.Update(config); err != nil {
+ return err
}
}