diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 83830fcb9d..f1e9eb3b41 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -13,7 +13,7 @@ permissions: read-all env: # Common versions - GO_VERSION: '1.19' + GO_VERSION: '1.20' GOLANGCI_VERSION: 'v1.55.2' DOCKER_BUILDX_VERSION: 'v0.4.2' diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index b0de241f2b..67b5f74dd4 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -13,7 +13,7 @@ name: "CodeQL" on: push: - branches: [ "master", "release-*" ] + branches: [ "master", "release-*"] pull_request: # The branches below must be a subset of the branches above branches: [ "master" ] diff --git a/.github/workflows/e2e-1.18.yaml b/.github/workflows/e2e-1.18.yaml index e3c2e180aa..07c6327ca8 100644 --- a/.github/workflows/e2e-1.18.yaml +++ b/.github/workflows/e2e-1.18.yaml @@ -13,7 +13,7 @@ permissions: read-all env: # Common versions - GO_VERSION: '1.19' + GO_VERSION: '1.20' KIND_VERSION: 'v0.14.0' KIND_IMAGE: 'kindest/node:v1.18.20' KIND_CLUSTER_NAME: 'ci-testing' diff --git a/.github/workflows/e2e-1.20-EphemeralJob.yaml b/.github/workflows/e2e-1.20-EphemeralJob.yaml index 59205d00cc..db323b0954 100644 --- a/.github/workflows/e2e-1.20-EphemeralJob.yaml +++ b/.github/workflows/e2e-1.20-EphemeralJob.yaml @@ -13,7 +13,7 @@ permissions: read-all env: # Common versions - GO_VERSION: '1.19' + GO_VERSION: '1.20' KIND_VERSION: 'v0.14.0' KIND_IMAGE: 'kindest/node:v1.20.15' KIND_CLUSTER_NAME: 'ci-testing' diff --git a/.github/workflows/e2e-1.24.yaml b/.github/workflows/e2e-1.24.yaml index 24728b7414..2c53b4bb6d 100644 --- a/.github/workflows/e2e-1.24.yaml +++ b/.github/workflows/e2e-1.24.yaml @@ -13,7 +13,7 @@ permissions: read-all env: # Common versions - GO_VERSION: '1.19' + GO_VERSION: '1.20' KIND_ACTION_VERSION: 'v1.3.0' KIND_VERSION: 'v0.14.0' KIND_IMAGE: 'kindest/node:v1.24.6' diff --git a/.github/workflows/e2e-1.26.yaml b/.github/workflows/e2e-1.26.yaml index d4ded24bcc..c8b55b18fa 100644 --- a/.github/workflows/e2e-1.26.yaml +++ b/.github/workflows/e2e-1.26.yaml @@ -13,7 +13,7 @@ permissions: read-all env: # Common versions - GO_VERSION: '1.19' + GO_VERSION: '1.20' KIND_VERSION: 'v0.18.0' KIND_IMAGE: 'kindest/node:v1.26.3' KIND_CLUSTER_NAME: 'ci-testing' diff --git a/.github/workflows/e2e-1.28.yaml b/.github/workflows/e2e-1.28.yaml new file mode 100644 index 0000000000..5d5c6e30e1 --- /dev/null +++ b/.github/workflows/e2e-1.28.yaml @@ -0,0 +1,603 @@ +name: E2E-1.28 + +on: + push: + branches: + - master + - release-* + pull_request: {} + workflow_dispatch: {} + +# Declare default permissions as read only. +permissions: read-all + +env: + # Common versions + GO_VERSION: '1.20' + KIND_VERSION: 'v0.22.0' + KIND_IMAGE: 'kindest/node:v1.28.7' + KIND_CLUSTER_NAME: 'ci-testing' + +jobs: + + astatefulset: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v3 + with: + submodules: true + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: ${{ env.GO_VERSION }} + - name: Setup Kind Cluster + uses: helm/kind-action@v1.9.0 + with: + node_image: ${{ env.KIND_IMAGE }} + cluster_name: ${{ env.KIND_CLUSTER_NAME }} + config: ./test/kind-conf-none-fg.yaml + version: ${{ env.KIND_VERSION }} + - name: Build image + run: | + export IMAGE="openkruise/kruise-manager:e2e-${GITHUB_RUN_ID}" + docker build --pull --no-cache . -t $IMAGE + kind load docker-image --name=${KIND_CLUSTER_NAME} $IMAGE || { echo >&2 "kind not installed or error loading image: $IMAGE"; exit 1; } + - name: Install Kruise + run: | + set -ex + kubectl cluster-info + IMG=openkruise/kruise-manager:e2e-${GITHUB_RUN_ID} ./scripts/deploy_kind.sh + NODES=$(kubectl get node | wc -l) + for ((i=1;i<10;i++)); + do + set +e + PODS=$(kubectl get pod -n kruise-system | grep '1/1' | wc -l) + set -e + if [ "$PODS" -eq "$NODES" ]; then + break + fi + sleep 3 + done + set +e + PODS=$(kubectl get pod -n kruise-system | grep '1/1' | wc -l) + kubectl get node -o yaml + kubectl get all -n kruise-system -o yaml + kubectl get pod -n kruise-system --no-headers | grep daemon | awk '{print $1}' | xargs kubectl logs -n kruise-system + kubectl get pod -n kruise-system --no-headers | grep daemon | awk '{print $1}' | xargs kubectl logs -n kruise-system --previous=true + set -e + if [ "$PODS" -eq "$NODES" ]; then + echo "Wait for kruise-manager and kruise-daemon ready successfully" + else + echo "Timeout to wait for kruise-manager and kruise-daemon ready" + exit 1 + fi + - name: Run E2E Tests + run: | + export KUBECONFIG=/home/runner/.kube/config + make ginkgo + set +e + ./bin/ginkgo -timeout 60m -v --focus='\[apps\] StatefulSet' test/e2e + retVal=$? + restartCount=$(kubectl get pod -n kruise-system -l control-plane=controller-manager --no-headers | awk '{print $4}') + if [ "${restartCount}" -eq "0" ];then + echo "Kruise-manager has not restarted" + else + kubectl get pod -n kruise-system -l control-plane=controller-manager --no-headers + echo "Kruise-manager has restarted, abort!!!" + kubectl get pod -n kruise-system --no-headers -l control-plane=controller-manager | awk '{print $1}' | xargs kubectl logs -p -n kruise-system + exit 1 + fi + if [ "$retVal" -ne 0 ];then + echo "test fail, dump kruise-manager logs" + while read pod; do + kubectl logs -n kruise-system $pod + done < <(kubectl get pods -n kruise-system -l control-plane=controller-manager --no-headers | awk '{print $1}') + echo "test fail, dump kruise-daemon logs" + while read pod; do + kubectl logs -n kruise-system $pod + done < <(kubectl get pods -n kruise-system -l control-plane=daemon --no-headers | awk '{print $1}') + fi + exit $retVal + + pullimages-containerrecreate: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v3 + with: + submodules: true + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: ${{ env.GO_VERSION }} + - name: Setup Kind Cluster + uses: helm/kind-action@v1.9.0 + with: + node_image: ${{ env.KIND_IMAGE }} + cluster_name: ${{ env.KIND_CLUSTER_NAME }} + config: ./test/kind-conf-none-fg.yaml + version: ${{ env.KIND_VERSION }} + - name: Build image + run: | + export IMAGE="openkruise/kruise-manager:e2e-${GITHUB_RUN_ID}" + docker build --pull --no-cache . -t $IMAGE + kind load docker-image --name=${KIND_CLUSTER_NAME} $IMAGE || { echo >&2 "kind not installed or error loading image: $IMAGE"; exit 1; } + - name: Install Kruise + run: | + set -ex + kubectl cluster-info + IMG=openkruise/kruise-manager:e2e-${GITHUB_RUN_ID} ./scripts/deploy_kind.sh + NODES=$(kubectl get node | wc -l) + for ((i=1;i<10;i++)); + do + set +e + PODS=$(kubectl get pod -n kruise-system | grep '1/1' | wc -l) + set -e + if [ "$PODS" -eq "$NODES" ]; then + break + fi + sleep 3 + done + set +e + PODS=$(kubectl get pod -n kruise-system | grep '1/1' | wc -l) + kubectl get node -o yaml + kubectl get all -n kruise-system -o yaml + kubectl get pod -n kruise-system --no-headers | grep daemon | awk '{print $1}' | xargs kubectl logs -n kruise-system + kubectl get pod -n kruise-system --no-headers | grep daemon | awk '{print $1}' | xargs kubectl logs -n kruise-system --previous=true + set -e + if [ "$PODS" -eq "$NODES" ]; then + echo "Wait for kruise-manager and kruise-daemon ready successfully" + else + echo "Timeout to wait for kruise-manager and kruise-daemon ready" + exit 1 + fi + - name: Run E2E Tests + run: | + export KUBECONFIG=/home/runner/.kube/config + make ginkgo + set +e + ./bin/ginkgo -timeout 60m -v --focus='\[apps\] (PullImage|ContainerRecreateRequest|PullImages)' test/e2e + retVal=$? + restartCount=$(kubectl get pod -n kruise-system -l control-plane=controller-manager --no-headers | awk '{print $4}') + if [ "${restartCount}" -eq "0" ];then + echo "Kruise-manager has not restarted" + else + kubectl get pod -n kruise-system -l control-plane=controller-manager --no-headers + echo "Kruise-manager has restarted, abort!!!" + kubectl get pod -n kruise-system --no-headers -l control-plane=controller-manager | awk '{print $1}' | xargs kubectl logs -p -n kruise-system + exit 1 + fi + kubectl get pods -n kruise-system -l control-plane=daemon -o=jsonpath="{range .items[*]}{.metadata.namespace}{\"\t\"}{.metadata.name}{\"\n\"}{end}" | while read ns name; + do + restartCount=$(kubectl get pod -n ${ns} ${name} --no-headers | awk '{print $4}') + if [ "${restartCount}" -eq "0" ];then + echo "Kruise-daemon has not restarted" + else + kubectl get pods -n ${ns} -l control-plane=daemon --no-headers + echo "Kruise-daemon has restarted, abort!!!" + kubectl logs -p -n ${ns} ${name} + exit 1 + fi + done + if [ "$retVal" -ne 0 ];then + echo "test fail, dump kruise-manager logs" + while read pod; do + kubectl logs -n kruise-system $pod + done < <(kubectl get pods -n kruise-system -l control-plane=controller-manager --no-headers | awk '{print $1}') + echo "test fail, dump kruise-daemon logs" + while read pod; do + kubectl logs -n kruise-system $pod + done < <(kubectl get pods -n kruise-system -l control-plane=daemon --no-headers | awk '{print $1}') + fi + + exit $retVal + + advanced-daemonset: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v3 + with: + submodules: true + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: ${{ env.GO_VERSION }} + - name: Setup Kind Cluster + uses: helm/kind-action@v1.9.0 + with: + node_image: ${{ env.KIND_IMAGE }} + cluster_name: ${{ env.KIND_CLUSTER_NAME }} + config: ./test/kind-conf-none-fg.yaml + version: ${{ env.KIND_VERSION }} + - name: Build image + run: | + export IMAGE="openkruise/kruise-manager:e2e-${GITHUB_RUN_ID}" + docker build --pull --no-cache . -t $IMAGE + kind load docker-image --name=${KIND_CLUSTER_NAME} $IMAGE || { echo >&2 "kind not installed or error loading image: $IMAGE"; exit 1; } + - name: Install Kruise + run: | + set -ex + kubectl cluster-info + IMG=openkruise/kruise-manager:e2e-${GITHUB_RUN_ID} ./scripts/deploy_kind.sh + NODES=$(kubectl get node | wc -l) + for ((i=1;i<10;i++)); + do + set +e + PODS=$(kubectl get pod -n kruise-system | grep '1/1' | wc -l) + set -e + if [ "$PODS" -eq "$NODES" ]; then + break + fi + sleep 3 + done + set +e + PODS=$(kubectl get pod -n kruise-system | grep '1/1' | wc -l) + kubectl get node -o yaml + kubectl get all -n kruise-system -o yaml + kubectl get pod -n kruise-system --no-headers | grep daemon | awk '{print $1}' | xargs kubectl logs -n kruise-system + kubectl get pod -n kruise-system --no-headers | grep daemon | awk '{print $1}' | xargs kubectl logs -n kruise-system --previous=true + set -e + if [ "$PODS" -eq "$NODES" ]; then + echo "Wait for kruise-manager and kruise-daemon ready successfully" + else + echo "Timeout to wait for kruise-manager and kruise-daemon ready" + exit 1 + fi + - name: Run E2E Tests + run: | + export KUBECONFIG=/home/runner/.kube/config + make ginkgo + set +e + ./bin/ginkgo -timeout 60m -v --focus='\[apps\] DaemonSet' test/e2e + retVal=$? + restartCount=$(kubectl get pod -n kruise-system -l control-plane=controller-manager --no-headers | awk '{print $4}') + if [ "${restartCount}" -eq "0" ];then + echo "Kruise-manager has not restarted" + else + kubectl get pod -n kruise-system -l control-plane=controller-manager --no-headers + echo "Kruise-manager has restarted, abort!!!" + kubectl get pod -n kruise-system --no-headers -l control-plane=controller-manager | awk '{print $1}' | xargs kubectl logs -p -n kruise-system + exit 1 + fi + kubectl get pods -n kruise-system -l control-plane=daemon -o=jsonpath="{range .items[*]}{.metadata.namespace}{\"\t\"}{.metadata.name}{\"\n\"}{end}" | while read ns name; + do + restartCount=$(kubectl get pod -n ${ns} ${name} --no-headers | awk '{print $4}') + if [ "${restartCount}" -eq "0" ];then + echo "Kruise-daemon has not restarted" + else + kubectl get pods -n ${ns} -l control-plane=daemon --no-headers + echo "Kruise-daemon has restarted, abort!!!" + kubectl logs -p -n ${ns} ${name} + exit 1 + fi + done + + if [ "$retVal" -ne 0 ];then + echo "test fail, dump kruise-manager logs" + while read pod; do + kubectl logs -n kruise-system $pod + done < <(kubectl get pods -n kruise-system -l control-plane=controller-manager --no-headers | awk '{print $1}') + echo "test fail, dump kruise-daemon logs" + while read pod; do + kubectl logs -n kruise-system $pod + done < <(kubectl get pods -n kruise-system -l control-plane=daemon --no-headers | awk '{print $1}') + fi + exit $retVal + + sidecarset: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v3 + with: + submodules: true + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: ${{ env.GO_VERSION }} + - name: Setup Kind Cluster + uses: helm/kind-action@v1.9.0 + with: + node_image: ${{ env.KIND_IMAGE }} + cluster_name: ${{ env.KIND_CLUSTER_NAME }} + config: ./test/kind-conf-none-fg.yaml + version: ${{ env.KIND_VERSION }} + - name: Build image + run: | + export IMAGE="openkruise/kruise-manager:e2e-${GITHUB_RUN_ID}" + docker build --pull --no-cache . -t $IMAGE + kind load docker-image --name=${KIND_CLUSTER_NAME} $IMAGE || { echo >&2 "kind not installed or error loading image: $IMAGE"; exit 1; } + - name: Install Kruise + run: | + set -ex + kubectl cluster-info + IMG=openkruise/kruise-manager:e2e-${GITHUB_RUN_ID} ./scripts/deploy_kind.sh + NODES=$(kubectl get node | wc -l) + for ((i=1;i<10;i++)); + do + set +e + PODS=$(kubectl get pod -n kruise-system | grep '1/1' | wc -l) + set -e + if [ "$PODS" -eq "$NODES" ]; then + break + fi + sleep 3 + done + set +e + PODS=$(kubectl get pod -n kruise-system | grep '1/1' | wc -l) + kubectl get node -o yaml + kubectl get all -n kruise-system -o yaml + kubectl get pod -n kruise-system --no-headers | grep daemon | awk '{print $1}' | xargs kubectl logs -n kruise-system + kubectl get pod -n kruise-system --no-headers | grep daemon | awk '{print $1}' | xargs kubectl logs -n kruise-system --previous=true + set -e + if [ "$PODS" -eq "$NODES" ]; then + echo "Wait for kruise-manager and kruise-daemon ready successfully" + else + echo "Timeout to wait for kruise-manager and kruise-daemon ready" + exit 1 + fi + - name: Run E2E Tests + run: | + export KUBECONFIG=/home/runner/.kube/config + make ginkgo + set +e + ./bin/ginkgo -timeout 60m -v --focus='\[apps\] SidecarSet' test/e2e + retVal=$? + restartCount=$(kubectl get pod -n kruise-system -l control-plane=controller-manager --no-headers | awk '{print $4}') + if [ "${restartCount}" -eq "0" ];then + echo "Kruise-manager has not restarted" + else + kubectl get pod -n kruise-system -l control-plane=controller-manager --no-headers + echo "Kruise-manager has restarted, abort!!!" + kubectl get pod -n kruise-system --no-headers -l control-plane=controller-manager | awk '{print $1}' | xargs kubectl logs -p -n kruise-system + exit 1 + fi + kubectl get pods -n kruise-system -l control-plane=daemon -o=jsonpath="{range .items[*]}{.metadata.namespace}{\"\t\"}{.metadata.name}{\"\n\"}{end}" | while read ns name; + do + restartCount=$(kubectl get pod -n ${ns} ${name} --no-headers | awk '{print $4}') + if [ "${restartCount}" -eq "0" ];then + echo "Kruise-daemon has not restarted" + else + kubectl get pods -n ${ns} -l control-plane=daemon --no-headers + echo "Kruise-daemon has restarted, abort!!!" + kubectl logs -p -n ${ns} ${name} + exit 1 + fi + done + + if [ "$retVal" -ne 0 ];then + echo "test fail, dump kruise-manager logs" + while read pod; do + kubectl logs -n kruise-system $pod + done < <(kubectl get pods -n kruise-system -l control-plane=controller-manager --no-headers | awk '{print $1}') + echo "test fail, dump kruise-daemon logs" + while read pod; do + kubectl logs -n kruise-system $pod + done < <(kubectl get pods -n kruise-system -l control-plane=daemon --no-headers | awk '{print $1}') + fi + exit $retVal + + ephemeraljob: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v3 + with: + submodules: true + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: ${{ env.GO_VERSION }} + - name: Setup Kind Cluster + uses: helm/kind-action@v1.9.0 + with: + node_image: ${{ env.KIND_IMAGE }} + cluster_name: ${{ env.KIND_CLUSTER_NAME }} + config: ./test/kind-conf-none-fg.yaml + version: ${{ env.KIND_VERSION }} + - name: Build image + run: | + export IMAGE="openkruise/kruise-manager:e2e-${GITHUB_RUN_ID}" + docker build --pull --no-cache . -t $IMAGE + kind load docker-image --name=${KIND_CLUSTER_NAME} $IMAGE || { echo >&2 "kind not installed or error loading image: $IMAGE"; exit 1; } + - name: Install Kruise + run: | + set -ex + kubectl cluster-info + IMG=openkruise/kruise-manager:e2e-${GITHUB_RUN_ID} ./scripts/deploy_kind.sh + NODES=$(kubectl get node | wc -l) + for ((i=1;i<10;i++)); + do + set +e + PODS=$(kubectl get pod -n kruise-system | grep '1/1' | wc -l) + set -e + if [ "$PODS" -eq "$NODES" ]; then + break + fi + sleep 3 + done + set +e + PODS=$(kubectl get pod -n kruise-system | grep '1/1' | wc -l) + kubectl get node -o yaml + kubectl get all -n kruise-system -o yaml + kubectl get pod -n kruise-system --no-headers | grep daemon | awk '{print $1}' | xargs kubectl logs -n kruise-system + kubectl get pod -n kruise-system --no-headers | grep daemon | awk '{print $1}' | xargs kubectl logs -n kruise-system --previous=true + set -e + if [ "$PODS" -eq "$NODES" ]; then + echo "Wait for kruise-manager and kruise-daemon ready successfully" + else + echo "Timeout to wait for kruise-manager and kruise-daemon ready" + exit 1 + fi + - name: Run E2E Tests + run: | + export KUBECONFIG=/home/runner/.kube/config + make ginkgo + set +e + ./bin/ginkgo -timeout 60m -v --focus='\[apps\] EphemeralJob' test/e2e + retVal=$? + if [ "$retVal" -ne 0 ];then + echo "test fail, dump kruise-manager logs" + while read pod; do + kubectl logs -n kruise-system $pod + done < <(kubectl get pods -n kruise-system -l control-plane=controller-manager --no-headers | awk '{print $1}') + echo "test fail, dump kruise-daemon logs" + while read pod; do + kubectl logs -n kruise-system $pod + done < <(kubectl get pods -n kruise-system -l control-plane=daemon --no-headers | awk '{print $1}') + fi + exit $retVal + + podUnavailableBudget: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v3 + with: + submodules: true + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: ${{ env.GO_VERSION }} + - name: Setup Kind Cluster + uses: helm/kind-action@v1.9.0 + with: + node_image: ${{ env.KIND_IMAGE }} + cluster_name: ${{ env.KIND_CLUSTER_NAME }} + config: ./test/kind-conf-none-fg.yaml + version: ${{ env.KIND_VERSION }} + - name: Build image + run: | + export IMAGE="openkruise/kruise-manager:e2e-${GITHUB_RUN_ID}" + docker build --pull --no-cache . -t $IMAGE + kind load docker-image --name=${KIND_CLUSTER_NAME} $IMAGE || { echo >&2 "kind not installed or error loading image: $IMAGE"; exit 1; } + - name: Install Kruise + run: | + set -ex + kubectl cluster-info + IMG=openkruise/kruise-manager:e2e-${GITHUB_RUN_ID} ./scripts/deploy_kind.sh + NODES=$(kubectl get node | wc -l) + for ((i=1;i<10;i++)); + do + set +e + PODS=$(kubectl get pod -n kruise-system | grep '1/1' | wc -l) + set -e + if [ "$PODS" -eq "$NODES" ]; then + break + fi + sleep 3 + done + set +e + PODS=$(kubectl get pod -n kruise-system | grep '1/1' | wc -l) + kubectl get node -o yaml + kubectl get all -n kruise-system -o yaml + kubectl get pod -n kruise-system --no-headers | grep daemon | awk '{print $1}' | xargs kubectl logs -n kruise-system + kubectl get pod -n kruise-system --no-headers | grep daemon | awk '{print $1}' | xargs kubectl logs -n kruise-system --previous=true + set -e + if [ "$PODS" -eq "$NODES" ]; then + echo "Wait for kruise-manager and kruise-daemon ready successfully" + else + echo "Timeout to wait for kruise-manager and kruise-daemon ready" + exit 1 + fi + - name: Run E2E Tests + run: | + export KUBECONFIG=/home/runner/.kube/config + make ginkgo + set +e + ./bin/ginkgo -timeout 60m -v --focus='\[policy\] PodUnavailableBudget' test/e2e + retVal=$? + if [ "$retVal" -ne 0 ];then + echo "test fail, dump kruise-manager logs" + while read pod; do + kubectl logs -n kruise-system $pod + done < <(kubectl get pods -n kruise-system -l control-plane=controller-manager --no-headers | awk '{print $1}') + fi + exit $retVal + other: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v3 + with: + submodules: true + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: ${{ env.GO_VERSION }} + - name: Setup Kind Cluster + uses: helm/kind-action@v1.9.0 + with: + node_image: ${{ env.KIND_IMAGE }} + cluster_name: ${{ env.KIND_CLUSTER_NAME }} + config: ./test/kind-conf-none-fg.yaml + version: ${{ env.KIND_VERSION }} + - name: Build image + run: | + export IMAGE="openkruise/kruise-manager:e2e-${GITHUB_RUN_ID}" + docker build --pull --no-cache . -t $IMAGE + kind load docker-image --name=${KIND_CLUSTER_NAME} $IMAGE || { echo >&2 "kind not installed or error loading image: $IMAGE"; exit 1; } + - name: Install Kruise + run: | + set -ex + kubectl cluster-info + IMG=openkruise/kruise-manager:e2e-${GITHUB_RUN_ID} ./scripts/deploy_kind.sh + NODES=$(kubectl get node | wc -l) + for ((i=1;i<10;i++)); + do + set +e + PODS=$(kubectl get pod -n kruise-system | grep '1/1' | wc -l) + set -e + if [ "$PODS" -eq "$NODES" ]; then + break + fi + sleep 3 + done + set +e + PODS=$(kubectl get pod -n kruise-system | grep '1/1' | wc -l) + kubectl get node -o yaml + kubectl get all -n kruise-system -o yaml + kubectl get pod -n kruise-system --no-headers | grep daemon | awk '{print $1}' | xargs kubectl logs -n kruise-system + kubectl get pod -n kruise-system --no-headers | grep daemon | awk '{print $1}' | xargs kubectl logs -n kruise-system --previous=true + set -e + if [ "$PODS" -eq "$NODES" ]; then + echo "Wait for kruise-manager and kruise-daemon ready successfully" + else + echo "Timeout to wait for kruise-manager and kruise-daemon ready" + exit 1 + fi + - name: Run E2E Tests + run: | + export KUBECONFIG=/home/runner/.kube/config + make ginkgo + set +e + ./bin/ginkgo -timeout 90m -v --skip='\[apps\] (StatefulSet|PullImage|PullImages|ContainerRecreateRequest|DaemonSet|SidecarSet|EphemeralJob)' --skip='\[policy\] PodUnavailableBudget' test/e2e + retVal=$? + restartCount=$(kubectl get pod -n kruise-system -l control-plane=controller-manager --no-headers | awk '{print $4}') + if [ "${restartCount}" -eq "0" ];then + echo "Kruise-manager has not restarted" + else + kubectl get pod -n kruise-system -l control-plane=controller-manager --no-headers + echo "Kruise-manager has restarted, abort!!!" + kubectl get pod -n kruise-system --no-headers -l control-plane=controller-manager | awk '{print $1}' | xargs kubectl logs -p -n kruise-system + exit 1 + fi + kubectl get pods -n kruise-system -l control-plane=daemon -o=jsonpath="{range .items[*]}{.metadata.namespace}{\"\t\"}{.metadata.name}{\"\n\"}{end}" | while read ns name; + do + restartCount=$(kubectl get pod -n ${ns} ${name} --no-headers | awk '{print $4}') + if [ "${restartCount}" -eq "0" ];then + echo "Kruise-daemon has not restarted" + else + kubectl get pods -n ${ns} -l control-plane=daemon --no-headers + echo "Kruise-daemon has restarted, abort!!!" + kubectl logs -p -n ${ns} ${name} + exit 1 + fi + done + if [ "${retVal}" -ne 0 ];then + echo "test fail, dump kruise-manager logs" + while read pod; do + kubectl logs -n kruise-system $pod + done < <(kubectl get pods -n kruise-system -l control-plane=controller-manager --no-headers | awk '{print $1}') + echo "test fail, dump kruise-daemon logs" + while read pod; do + kubectl logs -n kruise-system $pod + done < <(kubectl get pods -n kruise-system -l control-plane=daemon --no-headers | awk '{print $1}') + fi + + exit $retVal diff --git a/Dockerfile b/Dockerfile index 09c5778ea3..e247568bc6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ # Build the manager and daemon binaries ARG BASE_IMAGE=alpine -ARG BASE_IMAGE_VERSION=3.17 -FROM golang:1.19-alpine3.17 as builder +ARG BASE_IMAGE_VERSION=3.19 +FROM golang:1.20.14-alpine3.19 as builder WORKDIR /workspace # Copy the Go Modules manifests diff --git a/Makefile b/Makefile index 4a22137a5e..b4d371610b 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ GOOS ?= $(shell go env GOOS) # ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary. # Run `setup-envtest list` to list available versions. -ENVTEST_K8S_VERSION ?= 1.26.0 +ENVTEST_K8S_VERSION ?= 1.28.0 # Setting SHELL to bash allows bash commands to be executed by recipes. # This is a requirement for 'setup-envtest.sh' in the test target. @@ -27,7 +27,7 @@ all: build ##@ Development go_check: - @scripts/check_go_version "1.19.0" + @scripts/check_go_version "1.20" generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations. @scripts/generate_client.sh @@ -97,7 +97,7 @@ undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/confi CONTROLLER_GEN = $(shell pwd)/bin/controller-gen controller-gen: ## Download controller-gen locally if necessary. -# controller-gen@v0.14.0 comply with k8s.io/api v0.26.x +# controller-gen@v0.14.0 comply with k8s.io/api v0.28.x ifeq ("$(shell $(CONTROLLER_GEN) --version 2> /dev/null)", "Version: v0.14.0") else rm -rf $(CONTROLLER_GEN) diff --git a/config/crd/bases/apps.kruise.io_nodepodprobes.yaml b/config/crd/bases/apps.kruise.io_nodepodprobes.yaml index 0ba86f6e53..8c3065ff45 100644 --- a/config/crd/bases/apps.kruise.io_nodepodprobes.yaml +++ b/config/crd/bases/apps.kruise.io_nodepodprobes.yaml @@ -86,9 +86,8 @@ spec: format: int32 type: integer grpc: - description: |- - GRPC specifies an action involving a GRPC port. - This is a beta field and requires enabling GRPCContainerProbe feature gate. + description: GRPC specifies an action involving a + GRPC port. properties: port: description: Port number of the gRPC service. diff --git a/config/crd/bases/apps.kruise.io_podprobemarkers.yaml b/config/crd/bases/apps.kruise.io_podprobemarkers.yaml index c585f9bc07..75fd508cc1 100644 --- a/config/crd/bases/apps.kruise.io_podprobemarkers.yaml +++ b/config/crd/bases/apps.kruise.io_podprobemarkers.yaml @@ -113,9 +113,7 @@ spec: format: int32 type: integer grpc: - description: |- - GRPC specifies an action involving a GRPC port. - This is a beta field and requires enabling GRPCContainerProbe feature gate. + description: GRPC specifies an action involving a GRPC port. properties: port: description: Port number of the gRPC service. Number diff --git a/go.mod b/go.mod index 33089b332c..302b17167c 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/openkruise/kruise -go 1.19 +go 1.20 require ( github.com/alibaba/pouch v0.0.0-20190328125340-37051654f368 @@ -8,41 +8,66 @@ require ( github.com/codegangsta/negroni v1.0.0 github.com/docker/distribution v2.8.2+incompatible github.com/docker/docker v26.0.2+incompatible - github.com/evanphx/json-patch v4.12.0+incompatible - github.com/fsnotify/fsnotify v1.6.0 + github.com/evanphx/json-patch v5.6.0+incompatible + github.com/fsnotify/fsnotify v1.7.0 github.com/go-bindata/go-bindata v3.1.2+incompatible github.com/google/go-containerregistry v0.16.1 github.com/gorilla/mux v1.8.0 github.com/onsi/ginkgo v1.16.5 - github.com/onsi/gomega v1.24.1 - github.com/prometheus/client_golang v1.14.0 + github.com/onsi/gomega v1.33.0 + github.com/prometheus/client_golang v1.16.0 github.com/robfig/cron/v3 v3.0.1 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.9.0 github.com/xyproto/simpleredis v0.0.0-20200201215242-1ff0da2967b4 - golang.org/x/net v0.23.0 + golang.org/x/net v0.24.0 golang.org/x/time v0.3.0 - gomodules.xyz/jsonpatch/v2 v2.2.0 + gomodules.xyz/jsonpatch/v2 v2.4.0 google.golang.org/grpc v1.63.0 - k8s.io/api v0.26.15 - k8s.io/apiextensions-apiserver v0.26.15 - k8s.io/apimachinery v0.26.15 - k8s.io/apiserver v0.26.15 - k8s.io/client-go v0.26.15 - k8s.io/code-generator v0.26.15 - k8s.io/component-base v0.26.15 - k8s.io/component-helpers v0.26.15 - k8s.io/cri-api v0.26.15 + k8s.io/api v0.30.0 + k8s.io/apiextensions-apiserver v0.30.0 + k8s.io/apimachinery v0.30.0 + k8s.io/apiserver v0.28.9 + k8s.io/client-go v0.28.9 + k8s.io/code-generator v0.28.9 + k8s.io/component-base v0.28.9 + k8s.io/component-helpers v0.28.9 + k8s.io/cri-api v0.28.9 k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01 - k8s.io/klog/v2 v2.110.1 - k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 - k8s.io/kubernetes v1.26.15 - k8s.io/utils v0.0.0-20221128185143-99ec85e7a448 - sigs.k8s.io/controller-runtime v0.14.0 + k8s.io/klog/v2 v2.120.1 + k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 + k8s.io/kubernetes v1.28.9 + k8s.io/utils v0.0.0-20230726121419-3b25d923346b + sigs.k8s.io/controller-runtime v0.16.5 +) + +require ( + github.com/NYTimes/gziphandler v1.1.1 // indirect + github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230305170008-8188dc5388df // indirect + github.com/coreos/go-semver v0.3.1 // indirect + github.com/coreos/go-systemd/v22 v22.5.0 // indirect + github.com/google/cel-go v0.16.1 // indirect + github.com/google/gnostic-models v0.6.8 // indirect + github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect + github.com/inconshreveable/mousetrap v1.1.0 // indirect + github.com/spf13/cobra v1.8.0 // indirect + github.com/stoewer/go-strcase v1.2.0 // indirect + go.etcd.io/etcd/api/v3 v3.5.9 // indirect + go.etcd.io/etcd/client/pkg/v3 v3.5.9 // indirect + go.etcd.io/etcd/client/v3 v3.5.9 // indirect + go.uber.org/multierr v1.11.0 // indirect + go.uber.org/zap v1.25.0 // indirect + golang.org/x/crypto v0.22.0 // indirect + golang.org/x/exp v0.0.0-20230224173230-c95f2b4c22f2 // indirect + google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect + gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect + k8s.io/controller-manager v0.28.9 // indirect + k8s.io/kms v0.28.9 // indirect + k8s.io/kubelet v0.28.9 // indirect + sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.1.2 // indirect ) require ( - cloud.google.com/go/compute/metadata v0.2.3 // indirect github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef // indirect @@ -60,7 +85,7 @@ require ( github.com/docker/docker-credential-helpers v0.7.0 // indirect github.com/docker/go-connections v0.4.0 // indirect github.com/docker/go-units v0.5.0 // indirect - github.com/emicklei/go-restful/v3 v3.9.0 // indirect + github.com/emicklei/go-restful/v3 v3.11.0 // indirect github.com/evanphx/json-patch/v5 v5.6.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect github.com/go-logr/logr v1.4.1 // indirect @@ -79,7 +104,6 @@ require ( github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.4 // indirect github.com/gomodule/redigo v2.0.0+incompatible // indirect - github.com/google/gnostic v0.5.7-v3refs // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/google/gofuzz v1.2.0 // indirect github.com/google/uuid v1.6.0 // indirect @@ -108,9 +132,9 @@ require ( github.com/opencontainers/selinux v1.11.0 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/prometheus/client_model v0.3.0 // indirect - github.com/prometheus/common v0.37.0 // indirect - github.com/prometheus/procfs v0.8.0 // indirect + github.com/prometheus/client_model v0.4.0 // indirect + github.com/prometheus/common v0.44.0 // indirect + github.com/prometheus/procfs v0.10.1 // indirect github.com/sirupsen/logrus v1.9.3 // indirect github.com/vbatts/tar-split v0.11.3 // indirect github.com/xyproto/pinterface v0.0.0-20200201214933-70763765f31f // indirect @@ -125,13 +149,13 @@ require ( go.opentelemetry.io/otel/sdk v1.21.0 // indirect go.opentelemetry.io/otel/trace v1.21.0 go.opentelemetry.io/proto/otlp v1.1.0 // indirect - golang.org/x/mod v0.16.0 // indirect + golang.org/x/mod v0.17.0 // indirect golang.org/x/oauth2 v0.17.0 // indirect - golang.org/x/sync v0.6.0 // indirect + golang.org/x/sync v0.7.0 // indirect golang.org/x/sys v0.19.0 // indirect - golang.org/x/term v0.18.0 // indirect + golang.org/x/term v0.19.0 // indirect golang.org/x/text v0.14.0 // indirect - golang.org/x/tools v0.19.0 // indirect + golang.org/x/tools v0.20.0 // indirect google.golang.org/appengine v1.6.8 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda // indirect @@ -140,43 +164,44 @@ require ( gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/cloud-provider v0.26.15 // indirect - k8s.io/csi-translation-lib v0.26.15 // indirect - k8s.io/dynamic-resource-allocation v0.26.15 // indirect - k8s.io/kube-scheduler v0.26.15 // indirect - k8s.io/mount-utils v0.26.15 // indirect + k8s.io/cloud-provider v0.28.9 // indirect + k8s.io/csi-translation-lib v0.28.9 // indirect + k8s.io/dynamic-resource-allocation v0.28.9 // indirect + k8s.io/kube-scheduler v0.28.9 // indirect + k8s.io/mount-utils v0.28.9 // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect - sigs.k8s.io/yaml v1.3.0 // indirect + sigs.k8s.io/yaml v1.4.0 // indirect ) replace ( golang.org/x/sys => golang.org/x/sys v0.19.0 - k8s.io/api => k8s.io/api v0.26.15 - k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.26.15 - k8s.io/apimachinery => k8s.io/apimachinery v0.26.15 - k8s.io/apiserver => k8s.io/apiserver v0.26.15 - k8s.io/cli-runtime => k8s.io/cli-runtime v0.26.15 - k8s.io/client-go => k8s.io/client-go v0.26.15 - k8s.io/cloud-provider => k8s.io/cloud-provider v0.26.15 - k8s.io/cluster-bootstrap => k8s.io/cluster-bootstrap v0.26.15 - k8s.io/code-generator => k8s.io/code-generator v0.26.15 - k8s.io/component-base => k8s.io/component-base v0.26.15 - k8s.io/component-helpers => k8s.io/component-helpers v0.26.15 - k8s.io/controller-manager => k8s.io/controller-manager v0.26.15 - k8s.io/cri-api => k8s.io/cri-api v0.26.15 - k8s.io/csi-translation-lib => k8s.io/csi-translation-lib v0.26.15 - k8s.io/dynamic-resource-allocation => k8s.io/dynamic-resource-allocation v0.26.15 - k8s.io/kms => k8s.io/kms v0.26.15 - k8s.io/kube-aggregator => k8s.io/kube-aggregator v0.26.15 - k8s.io/kube-controller-manager => k8s.io/kube-controller-manager v0.26.15 - k8s.io/kube-proxy => k8s.io/kube-proxy v0.26.15 - k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.26.15 - k8s.io/kubectl => k8s.io/kubectl v0.26.15 - k8s.io/kubelet => k8s.io/kubelet v0.26.15 - k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.26.15 - k8s.io/metrics => k8s.io/metrics v0.26.15 - k8s.io/mount-utils => k8s.io/mount-utils v0.26.15 - k8s.io/pod-security-admission => k8s.io/pod-security-admission v0.26.15 - k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.26.15 + k8s.io/api => k8s.io/api v0.28.9 + k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.28.9 + k8s.io/apimachinery => k8s.io/apimachinery v0.28.9 + k8s.io/apiserver => k8s.io/apiserver v0.28.9 + k8s.io/cli-runtime => k8s.io/cli-runtime v0.28.9 + k8s.io/client-go => k8s.io/client-go v0.28.9 + k8s.io/cloud-provider => k8s.io/cloud-provider v0.28.9 + k8s.io/cluster-bootstrap => k8s.io/cluster-bootstrap v0.28.9 + k8s.io/code-generator => k8s.io/code-generator v0.28.9 + k8s.io/component-base => k8s.io/component-base v0.28.9 + k8s.io/component-helpers => k8s.io/component-helpers v0.28.9 + k8s.io/controller-manager => k8s.io/controller-manager v0.28.9 + k8s.io/cri-api => k8s.io/cri-api v0.28.9 + k8s.io/csi-translation-lib => k8s.io/csi-translation-lib v0.28.9 + k8s.io/dynamic-resource-allocation => k8s.io/dynamic-resource-allocation v0.28.9 + k8s.io/endpointslice => k8s.io/endpointslice v0.28.9 + k8s.io/kms => k8s.io/kms v0.28.9 + k8s.io/kube-aggregator => k8s.io/kube-aggregator v0.28.9 + k8s.io/kube-controller-manager => k8s.io/kube-controller-manager v0.28.9 + k8s.io/kube-proxy => k8s.io/kube-proxy v0.28.9 + k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.28.9 + k8s.io/kubectl => k8s.io/kubectl v0.28.9 + k8s.io/kubelet => k8s.io/kubelet v0.28.9 + k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.28.9 + k8s.io/metrics => k8s.io/metrics v0.28.9 + k8s.io/mount-utils => k8s.io/mount-utils v0.28.9 + k8s.io/pod-security-admission => k8s.io/pod-security-admission v0.28.9 + k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.28.9 ) diff --git a/go.sum b/go.sum index 5fc7a452b3..2b9ac2bd7a 100644 --- a/go.sum +++ b/go.sum @@ -1,79 +1,34 @@ -cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= -cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= -cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= -cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= -cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= -cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= -cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= -cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= -cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= -cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= -cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= -cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= -cloud.google.com/go v0.65.0 h1:Dg9iHVQfrhq82rUNu9ZxUDrJLaxFUe/HlCVaLyRruq8= -cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= -cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= -cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= -cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= -cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= -cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= -cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= +cloud.google.com/go v0.112.0 h1:tpFCD7hpHFlQ8yPwT3x+QeXqc2T6+n6T+hmABHfDUSM= cloud.google.com/go/compute v1.24.0 h1:phWcR2eWzRJaL/kOiJwfFsPs4BaKq1j6vnpZrc1YlVg= cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY= -cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= -cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= -cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= -cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= -cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= -cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= -cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= -cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= -cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= -cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= -cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= -cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= -dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= -github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= +github.com/NYTimes/gziphandler v1.1.1 h1:ZUDjpQae29j0ryrS0u/B8HZfJBtBQHjqw2rQ2cqUQ3I= +github.com/NYTimes/gziphandler v1.1.1/go.mod h1:n/CVRwUEOgIxrgPvAQhUUr9oeUtvrhMomdKFjzJNB0c= github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= -github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= github.com/alibaba/pouch v0.0.0-20190328125340-37051654f368 h1:g7IkWP/KYyxamFreSPpOmjGuX63C6mTSqVFd9BldwxQ= github.com/alibaba/pouch v0.0.0-20190328125340-37051654f368/go.mod h1:U18Kv0/rJR1OjsxqgEbMJU29pFSCpKCzr44GZD6T3dI= +github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230305170008-8188dc5388df h1:7RFfzj4SSt6nnvCPbCqijJi1nWCd+TqAT3bYCStRC18= +github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230305170008-8188dc5388df/go.mod h1:pSwJ0fSY5KhvocuWSx4fz3BA8OrA1bQn+K1Eli3BRwM= github.com/appscode/jsonpatch v1.0.1 h1:e82Bj+rsBSnpsmjiIGlc9NiKSBpJONZkamk/F8GrCR0= github.com/appscode/jsonpatch v1.0.1/go.mod h1:4AJxUpXUhv4N+ziTvIcWWXgeorXpxPZOfk9HdEVr96M= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef h1:46PFijGLmAjMPwCCCo7Jf0W6f9slllCkkv7vyc1yOSg= github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= -github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= -github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= +github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM= github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ= github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= -github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= -github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= -github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/xds/go v0.0.0-20231128003011-0fa0005c9caa h1:jQCWAUqqlij9Pgj2i/PB79y4KOPYVyFYdROxgaCwdTQ= github.com/codegangsta/negroni v1.0.0 h1:+aYywywx4bnKXWvoWtRfJ91vC59NbEhEY03sZjQhbVY= github.com/codegangsta/negroni v1.0.0/go.mod h1:v0y3T5G7Y1UlFfyxFn/QLRU4a2EuNau2iZY63YTKWo0= @@ -83,7 +38,12 @@ github.com/containerd/stargz-snapshotter/estargz v0.14.3 h1:OqlDCK3ZVUO6C3B/5FSk github.com/containerd/stargz-snapshotter/estargz v0.14.3/go.mod h1:KY//uOCIkSuNAHhJogcZtrNHdKrA99/FCCRjE3HD36o= github.com/contiv/executor v0.0.0-20180626233236-d263f4daa3ad h1:wNE0NGGDF+q69bwWeJ/+kKTjgRux3Ky3xTJh6bXHq1Y= github.com/contiv/executor v0.0.0-20180626233236-d263f4daa3ad/go.mod h1:pTKlpemhbXTX+6oDaIiCv1ZiMm5S9ieCpo4YFMJoa40= +github.com/coreos/go-semver v0.3.1 h1:yi21YpKnrx1gt5R+la8n5WgS0kCrsPp33dmEyHReZr4= +github.com/coreos/go-semver v0.3.1/go.mod h1:irMmmIw/7yzSRPWryHsK7EYSg09caPQL03VsM8rvUec= +github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs= +github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= @@ -105,48 +65,30 @@ github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKoh github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= -github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= -github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153 h1:yUdfgN0XgIJw7foRItutHYUIhlcKzcSf5vDpdhQAKTc= -github.com/emicklei/go-restful/v3 v3.9.0 h1:XwGDlfxEnQZzuopoqxwSEllNcCOM9DhhFyhFIIGKwxE= -github.com/emicklei/go-restful/v3 v3.9.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= -github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= -github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= +github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g= +github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/envoyproxy/protoc-gen-validate v1.0.4 h1:gVPz/FMfvh57HdSJQyvBtF00j8JU4zdyUgIUNhlgg0A= -github.com/evanphx/json-patch v0.5.2/go.mod h1:ZWS5hhDbVDyob71nXKNL0+PWn6ToqBHMikGIFbs31qQ= github.com/evanphx/json-patch v4.0.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= -github.com/evanphx/json-patch v4.12.0+incompatible h1:4onqiflcdA9EOZ4RxV643DvftH5pOlLGNtQ5lPWQu84= -github.com/evanphx/json-patch v4.12.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= +github.com/evanphx/json-patch v5.6.0+incompatible h1:jBYDEEiFBPxA0v50tFdvOzQQTCvpL6mnFh5mB2/l16U= +github.com/evanphx/json-patch v5.6.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/evanphx/json-patch/v5 v5.6.0 h1:b91NhWfaz02IuVxO9faSllyAtNXHMPkC5J8sJCLunww= github.com/evanphx/json-patch/v5 v5.6.0/go.mod h1:G79N1coSVB93tBe7j6PhzjmR3/2VvlbKOFpnXhI9Bw4= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= -github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= -github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= +github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= +github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= github.com/go-bindata/go-bindata v3.1.2+incompatible h1:5vjJMVhowQdPzjE1LdxyFF7YFTXg5IgGVW4gBr5IbvE= github.com/go-bindata/go-bindata v3.1.2+incompatible/go.mod h1:xK8Dsgwmeed+BBsSy2XTopBn/8uK2HWuGSnA11C3Joo= -github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= -github.com/go-kit/log v0.2.0/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= -github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= -github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= -github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= -github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-logr/logr v0.2.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/go-logr/zapr v1.2.3 h1:a9vnzlIBPQBBkeaR9IuMUfmVOrQlkoC4YfPoFkX3T7A= +github.com/go-logr/zapr v1.2.4 h1:QHVo+6stLbfJmYGkQ7uGHUCu5hnAFAj6mDe6Ea0SeOo= github.com/go-openapi/analysis v0.21.2 h1:hXFrOYFHUAMQdu6zwAiKKJHJQ8kqZs1ux/ru1P1wLJU= github.com/go-openapi/analysis v0.21.2/go.mod h1:HZwRk4RRisyG8vx2Oe6aqeSQcoxRp47Xkp3+K6q+LdY= github.com/go-openapi/errors v0.19.8/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M= @@ -178,6 +120,7 @@ github.com/go-openapi/validate v0.21.0/go.mod h1:rjnrwK57VJ7A8xqfpAOEKRH8yQSGUri github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= +github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= github.com/gobuffalo/attrs v0.0.0-20190224210810-a9411de4debd/go.mod h1:4duuawTqi2wkkpB4ePgWMaai6/Kc6WEz83bhFwpHzj0= github.com/gobuffalo/depgen v0.0.0-20190329151759-d478694a28d3/go.mod h1:3STtPUQYuzV0gBVOY3vy6CfMm/ljR4pABfrTeHNLHUY= github.com/gobuffalo/depgen v0.1.0/go.mod h1:+ifsuy7fhi15RWncXQQKjWS9JPkdah5sZvtHc2RXGlg= @@ -202,37 +145,20 @@ github.com/gobuffalo/packd v0.1.0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWe github.com/gobuffalo/packr/v2 v2.0.9/go.mod h1:emmyGweYTm6Kdper+iywB6YK5YzuKchGtJQZ0Odn4pQ= github.com/gobuffalo/packr/v2 v2.2.0/go.mod h1:CaAwI0GPIAv+5wKLtv8Afwl+Cm78K/I/VCm/3ptBN+0= github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754/go.mod h1:HhnNqWY95UYwwW3uSASeV7vtgYkT2t16hJgV3AEPUpw= -github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= -github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= @@ -240,19 +166,15 @@ github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6 github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/gomodule/redigo v2.0.0+incompatible h1:K/R+8tc58AaqLkqG2Ol3Qk+DR/TlNuhuh457pBFPtt0= github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4= -github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/gnostic v0.5.7-v3refs h1:FhTMOKj2VhjpouxvWJAV1TL304uMlb9zcDqkl6cEI54= -github.com/google/gnostic v0.5.7-v3refs/go.mod h1:73MKFl6jIHelAJNaBGFzt3SPtZULs9dYrGFt8OiIsHQ= -github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/btree v1.0.1 h1:gK4Kx5IaGY9CD5sPJ36FHiBJ6ZXl0kilRiiCj+jdYp4= +github.com/google/cel-go v0.16.1 h1:3hZfSNiAU3KOiNtxuFXVp5WFy4hf/Ly3Sa4/7F8SXNo= +github.com/google/cel-go v0.16.1/go.mod h1:HXZKzB0LXqer5lHHgfWAnlYwJaQBDKMjxjulNQzhwhY= +github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I= +github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= @@ -263,47 +185,33 @@ github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/ github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= -github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= -github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJYCmNdQXq6neHJOYx3V6jnqNEec= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= -github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= +github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 h1:+9834+KizmvFV7pXQGSXQTsaWhq2GjuNUt0aUU0YBYw= +github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho= +github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= +github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.0 h1:Wqo399gCIufwto+VfwCSvsnfGpF/w5E9CNxSwbpD6No= github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.0/go.mod h1:qmOFXW2epJhM0qSnUUYpldc7gVz2KMQwJ/QYCDIa7XU= -github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= +github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= +github.com/jonboulle/clockwork v0.2.2 h1:UOGuzwb1PwsrDAObMuhUnj0p5ULPj8V/xJ7Kx9qUBdQ= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= -github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= -github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= -github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= -github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= -github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/karrick/godirwalk v1.8.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaRPx4tDPEn4= github.com/karrick/godirwalk v1.10.3/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= @@ -313,8 +221,6 @@ github.com/klauspost/compress v1.16.5 h1:IFV2oUNUzZaz+XyusxpLzpzS8Pt5rh0Z16For/d github.com/klauspost/compress v1.16.5/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= @@ -330,7 +236,6 @@ github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0 github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/markbates/oncer v0.0.0-20181203154359-bf2de49a0be2/go.mod h1:Ld9puTsIW75CHf65OeIOkyKbteujpZVXDpWK6YGZbxE= github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0= -github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= @@ -349,8 +254,6 @@ github.com/moby/term v0.0.0-20221205130635-1aeaba878587/go.mod h1:8FzsFHVUBGZdbD github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= @@ -358,8 +261,6 @@ github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= -github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= @@ -370,11 +271,11 @@ github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= -github.com/onsi/ginkgo/v2 v2.6.0 h1:9t9b9vRUbFq3C4qKFCGkVuq/fIHji802N1nrtkh1mNc= +github.com/onsi/ginkgo/v2 v2.17.1 h1:V++EzdbhI4ZV4ev0UTIj0PzhzOcReJFyJaLjtSF55M8= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/onsi/gomega v1.24.1 h1:KORJXNNTzJXzu4ScJWssJfJMnJ+2QJqhoQSRwNlze9E= -github.com/onsi/gomega v1.24.1/go.mod h1:3AOiACssS3/MajrniINInwbfOOtfZvplPzuRSmvt1jM= +github.com/onsi/gomega v1.33.0 h1:snPCflnZrpMsy94p4lXVEkHo12lmPnc3vY5XBbreexE= +github.com/onsi/gomega v1.33.0/go.mod h1:+925n5YtiFsLzzafLUHzVMBpvvRAzrydIBiSIxjX3wY= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.1.0-rc3 h1:fzg1mXZFj8YdPeNkRXMg+zb88BFV0Ys52cJydRwBkb8= @@ -390,51 +291,35 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= -github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= -github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= -github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= -github.com/prometheus/client_golang v1.14.0 h1:nJdhIvne2eSX/XRAFV9PcvFFRbrjbcTUj0VP62TMhnw= -github.com/prometheus/client_golang v1.14.0/go.mod h1:8vpkKitgIVNcqrRBWh1C4TIUQgYNtG/XQE4E/Zae36Y= -github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= -github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4= -github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= -github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= -github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= -github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= -github.com/prometheus/common v0.37.0 h1:ccBbHCgIiT9uSoFY0vX8H3zsNR5eLt17/RQLUvn8pXE= -github.com/prometheus/common v0.37.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA= -github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= -github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/prometheus/procfs v0.8.0 h1:ODq8ZFEaYeCaZOJlZZdJA2AbQR98dSHSM1KW/You5mo= -github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4= +github.com/prometheus/client_golang v1.16.0 h1:yk/hx9hDbrGHovbci4BY+pRMfSuuat626eFsHb7tmT8= +github.com/prometheus/client_golang v1.16.0/go.mod h1:Zsulrv/L9oM40tJ7T815tM89lFEugiJ9HzIqaAx4LKc= +github.com/prometheus/client_model v0.4.0 h1:5lQXD3cAg1OXBf4Wq03gTrXHeaV0TQvGfUooCfx1yqY= +github.com/prometheus/client_model v0.4.0/go.mod h1:oMQmHW1/JoDwqLtg57MGgP/Fb1CJEYF2imWWhWtMkYU= +github.com/prometheus/common v0.44.0 h1:+5BrQJwiBB9xsMygAB3TNvpQKOwlkc25LbISbrdOOfY= +github.com/prometheus/common v0.44.0/go.mod h1:ofAIvZbQ1e/nugmZGz4/qCb9Ap1VoSTIO7x0VV9VvuY= +github.com/prometheus/procfs v0.10.1 h1:kYK1Va/YMlutzCGazswoHKo//tZVlFpKYh+PymziUAg= +github.com/prometheus/procfs v0.10.1/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM= github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= +github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/soheilhy/cmux v0.1.5 h1:jjzc5WVemNEDTLwv9tlmemhC73tI08BNOIGwBOo10Js= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= +github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= +github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/stoewer/go-strcase v1.2.0 h1:Z2iHWqGXH00XYgqDmNgQbIBxf3wrNq0F3feEy0ainaU= github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -442,7 +327,6 @@ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSS github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= @@ -453,30 +337,36 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= +github.com/tmc/grpc-websocket-proxy v0.0.0-20220101234140-673ab2c3ae75 h1:6fotK7otjonDflCTK0BCfls4SPy3NcCVb5dqqmbRknE= github.com/urfave/cli v1.22.12/go.mod h1:sSBEIC79qR6OvcmsD4U3KABeOTxDqQtdDnaFuUN30b8= github.com/vbatts/tar-split v0.11.3 h1:hLFqsOLQ1SsppQNTMpkpPXClLDfC2A3Zgy9OUU+RVck= github.com/vbatts/tar-split v0.11.3/go.mod h1:9QlHN18E+fEH7RdG+QAJJcuya3rqT7eXSTY7wGrAokY= github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= github.com/xdg-go/scram v1.0.2/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs= github.com/xdg-go/stringprep v1.0.2/go.mod h1:8F9zXuvzgwmyT5DUm4GUfZGDdT3W+LCvS6+da4O5kxM= +github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 h1:eY9dn8+vbi4tKz5Qo6v2eYzo7kUS51QINcR5jNpbZS8= github.com/xyproto/pinterface v0.0.0-20200201214933-70763765f31f h1:x97Isxzsv8Aj1QMh8vNxKzI85Fvgg2areAJlIaMQ4zY= github.com/xyproto/pinterface v0.0.0-20200201214933-70763765f31f/go.mod h1:X5B5pKE49ak7SpyDh5QvJvLH9cC9XuZNDcl5hEyYc34= github.com/xyproto/simpleredis v0.0.0-20200201215242-1ff0da2967b4 h1:0wSySfZ5KkGNlWJFd4Bkfv/T4rlEsUp7o7QwHTTvEzg= github.com/xyproto/simpleredis v0.0.0-20200201215242-1ff0da2967b4/go.mod h1:U/ZOQqa0ggBGPs+d0y7r50BY6FyFTh5WhWf7F8f1MBM= github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA= -github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +go.etcd.io/bbolt v1.3.7 h1:j+zJOnnEjF/kyHlDDgGnVL/AIqIJPq8UoB2GSNfkUfQ= +go.etcd.io/etcd/api/v3 v3.5.9 h1:4wSsluwyTbGGmyjJktOf3wFQoTBIURXHnq9n/G/JQHs= +go.etcd.io/etcd/api/v3 v3.5.9/go.mod h1:uyAal843mC8uUVSLWz6eHa/d971iDGnCRpmKd2Z+X8k= +go.etcd.io/etcd/client/pkg/v3 v3.5.9 h1:oidDC4+YEuSIQbsR94rY9gur91UPL6DnxDCIYd2IGsE= +go.etcd.io/etcd/client/pkg/v3 v3.5.9/go.mod h1:y+CzeSmkMpWN2Jyu1npecjB9BBnABxGM4pN8cGuJeL4= +go.etcd.io/etcd/client/v2 v2.305.9 h1:YZ2OLi0OvR0H75AcgSUajjd5uqKDKocQUqROTG11jIo= +go.etcd.io/etcd/client/v3 v3.5.9 h1:r5xghnU7CwbUxD/fbUtRyJGaYNfDun8sp/gTr1hew6E= +go.etcd.io/etcd/client/v3 v3.5.9/go.mod h1:i/Eo5LrZ5IKqpbtpPDuaUnDOUv471oDg8cjQaUr2MbA= +go.etcd.io/etcd/pkg/v3 v3.5.9 h1:6R2jg/aWd/zB9+9JxmijDKStGJAPFsX3e6BeJkMi6eQ= +go.etcd.io/etcd/raft/v3 v3.5.9 h1:ZZ1GIHoUlHsn0QVqiRysAm3/81Xx7+i2d7nSdWxlOiI= +go.etcd.io/etcd/server/v3 v3.5.9 h1:vomEmmxeztLtS5OEH7d0hBAg4cjVIu9wXuNzUZx2ZA0= go.mongodb.org/mongo-driver v1.7.3/go.mod h1:NqaYOwnXWr5Pm7AOpO5QFxKJ503nbMse/R79oO62zWg= go.mongodb.org/mongo-driver v1.7.5 h1:ny3p0reEpgsR2cfA5cjgwFZg3Cv/ofFh/8jbhGtz9VI= go.mongodb.org/mongo-driver v1.7.5/go.mod h1:VXEWRZ6URJIkUq2SCAyapmhH0ZLRBP+FT4xhp5Zvxng= -go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= -go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= -go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1 h1:SpGay3w+nEwMpfVnbqOLH5gY52/foP8RE8UzTZ1pdSE= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1/go.mod h1:4UoMYEZOC0yN/sPGH76KPkkU7zgiEWYWL9vwmbnTJPE= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 h1:aFJWCqJMNjENlcleuuOkGAPH82y0yULBScfXcIEdS24= @@ -497,124 +387,58 @@ go.opentelemetry.io/otel/trace v1.21.0 h1:WD9i5gzvoUPuXIXH24ZNBudiarZDKuekPqi/E8 go.opentelemetry.io/otel/trace v1.21.0/go.mod h1:LGbsEB0f9LGjN+OZaQQ26sohbOmiMR+BaslueVtS/qQ= go.opentelemetry.io/proto/otlp v1.1.0 h1:2Di21piLrCqJ3U3eXGCTPHE9R8Nh+0uglSnOyxikMeI= go.opentelemetry.io/proto/otlp v1.1.0/go.mod h1:GpBHCBWiqvVLDqmHZsoMM3C5ySeKTC7ej/RNTae6MdY= -go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= -go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4= -go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= +go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= +go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= +go.uber.org/zap v1.25.0 h1:4Hvk6GtkucQ790dqmj7l1eEnRdKm3k3ZUrUMS2d5+5c= +go.uber.org/zap v1.25.0/go.mod h1:JIAUzQIH94IC4fOJQm7gMmBJP5k7wQfdcnYdPoEXJYk= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190422162423-af44ce270edf/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= -golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= -golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= -golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= -golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= -golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= -golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= -golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= -golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= -golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= -golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= -golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= +golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= +golang.org/x/exp v0.0.0-20230224173230-c95f2b4c22f2 h1:Jvc7gsqn21cJHCmAWx0LiimpP18LZmUxkT5Mp7EZ1mI= +golang.org/x/exp v0.0.0-20230224173230-c95f2b4c22f2/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.16.0 h1:QX4fJ0Rr5cPQCF7O9lh9Se4pmwfwskqZfq5moyldzic= -golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= +golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= -golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1Kcs5dz7/ng1VjMUvfKvpfy+jM= -golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= -golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= -golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= +golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= +golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= golang.org/x/oauth2 v0.17.0 h1:6m3ZPmLEFdVxKKWnKq4VqZ60gutO35zm+zrAHVmHyDQ= golang.org/x/oauth2 v0.17.0/go.mod h1:OzPDGQiuQMguemayvdylqddI7qcD9lnSDb+1FiwQ5HA= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190412183630-56d357773e84/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= -golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= +golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= -golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= -golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q= +golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= @@ -622,139 +446,35 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190329151228-23e29df326fe/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190416151739-9c9e1878f421/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190420181800-aa740d480789/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190531172133-b3315ee88b7d/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= -golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= -golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= -golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200505023115-26f46d2f7ef8/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.19.0 h1:tfGCXNR1OsFG+sVdLAitlpjAvD/I6dHDKnYrpEZUHkw= -golang.org/x/tools v0.19.0/go.mod h1:qoJWxmGSIBmAeriMx19ogtrEPrGtDbPK634QFIcLAhc= +golang.org/x/tools v0.20.0 h1:hz/CVckiOxybQvFw6h7b/q80NTr9IUQb4s1IIzW7KNY= +golang.org/x/tools v0.20.0/go.mod h1:WvitBU7JJf6A4jOdg4S1tviW9bhUxkgeCui/0JHctQg= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gomodules.xyz/jsonpatch/v2 v2.2.0 h1:4pT439QV83L+G9FkcCriY6EkpcK6r6bK+A5FBUMI7qY= -gomodules.xyz/jsonpatch/v2 v2.2.0/go.mod h1:WXp+iVDkoLQqPudfQ9GBlwB2eZ5DKOnjQZCYdOS8GPY= -google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= -google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= -google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= -google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= -google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= -google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= -google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= -google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +gomodules.xyz/jsonpatch/v2 v2.4.0 h1:Ci3iUJyx9UeRx7CeFN8ARgGbkESwJK+KB9lLcWxY/Zw= +gomodules.xyz/jsonpatch/v2 v2.4.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY= google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= -google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= -google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= -google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= -google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201019141844-1ed22bb0c154/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de h1:F6qOa9AZTYJXOUEr4jDysRDLrm4PHePlge4v4TGAlxY= +google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:VUhTRKeHn9wwcdrk73nvdC9gF178Tzhmt/qyaFcPLSo= google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de h1:jFNzHPIeuzhdRwVhbZdiym9q0ory/xY3sA+v2wPg8I0= google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:5iCWqnniDlqZHrd3neWVTOwvh/v6s3232omMecelax8= google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda h1:LI5DOvAxUPMv/50agcLLoo+AdWc1irS9Rzz4vPuD1V4= google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= -google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= -google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= -google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= -google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= -google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= -google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.63.0 h1:WjKe+dnvABXyPJMD7KDNLxtoGk5tgk+YFWN6cBWjZE8= google.golang.org/grpc v1.63.0/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= @@ -762,16 +482,11 @@ google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= -google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= -gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -782,12 +497,12 @@ gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= +gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc= +gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= @@ -799,61 +514,59 @@ gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools/v3 v3.0.3 h1:4AuOwCGf4lLR9u3YOe2awrHygurzhO/HeQ6laiA6Sx0= -honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= -honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -k8s.io/api v0.26.15 h1:tjMERUjIwkq+2UtPZL5ZbSsLkpxUv4gXWZfV5lQl+Og= -k8s.io/api v0.26.15/go.mod h1:CtWOrFl8VLCTLolRlhbBxo4fy83tjCLEtYa5pMubIe0= -k8s.io/apiextensions-apiserver v0.26.15 h1:QePn6+5mihx8sXQLaOXzvF4XPv2RGGj8Pv+O4P75GPU= -k8s.io/apiextensions-apiserver v0.26.15/go.mod h1:PbhgN0XidyF+9vCTUmNgVFK0MMEYqlHLZ4AJeBfiNMo= -k8s.io/apimachinery v0.26.15 h1:GPxeERYBSqSZlj3xIkX4L6mBjzZ9q8JPnJ+Vj15qe+g= -k8s.io/apimachinery v0.26.15/go.mod h1:O/uIhIOWuy6ndHqQ6qbkjD7OgeMhVtlk8+Z66ZcmJQc= -k8s.io/apiserver v0.26.15 h1:9sV2i7+A+/+YjQw9DMf7XTgbUdxtOKeTkluU7VhlD6Y= -k8s.io/apiserver v0.26.15/go.mod h1:dLnCqVroGkCKYNobv9Nm1Ot8GzapzMOKltAlkOlzv8o= -k8s.io/client-go v0.26.15 h1:A2Yav2v+VZQfpEsf5ESFp2Lqq5XACKBDrwkG+jEtOg0= -k8s.io/client-go v0.26.15/go.mod h1:KJs7snLEyKPlypqTQG/ngcaqE6h3/6qTvVHDViRL+iI= -k8s.io/cloud-provider v0.26.15 h1:9WLST7NKErkXzmL6CqfBWWzm/UWNIYd9Ljpo9greC6M= -k8s.io/cloud-provider v0.26.15/go.mod h1:y8TYLhfV7ICZflbtUnRpiM2Ubkf6nbXxUP/KP7WHFEs= -k8s.io/code-generator v0.26.15 h1:x4l1iwZnbFplnRLgg3W4r33wSbF/fqrZhw+uOfQWD/8= -k8s.io/code-generator v0.26.15/go.mod h1:JKZ03Lo95abcdMtOMlj6r6AkLW0gtL3vqIWaVH7Bk00= -k8s.io/component-base v0.26.15 h1:32XJyv5fo/lbDZhYU1HyISXTgdSUkbW5cO4DhfR6Y/8= -k8s.io/component-base v0.26.15/go.mod h1:9V+nBzUtTNtRuYfYmQQEhuKrjhL80i2l6F2H2qUsHAI= -k8s.io/component-helpers v0.26.15 h1:2ln2voQ6oLMUKzksr29g47iE1Y0rLdB+2KICF8F1f5Q= -k8s.io/component-helpers v0.26.15/go.mod h1:UwLS62rpGU8sIJfnBWChicMdf14y9hdu5DXicHay4Hk= -k8s.io/cri-api v0.26.15 h1:9HpWB35dVJUVqAqNgMrg2gcgqUq/hcxQwl/BJ3NJj0E= -k8s.io/cri-api v0.26.15/go.mod h1:oQALVNkz8DGjs0VYMYFcsCFFglNcxqaFZfoDlvRF0e0= -k8s.io/csi-translation-lib v0.26.15 h1:dfhWON0bRyDbuKep98iMB3tzQH3LPgWz1L7MX8EgPhI= -k8s.io/csi-translation-lib v0.26.15/go.mod h1:OzKZFjmBqYScPtQe3XniIkHBs1LpaP98od+PXUdS0fk= -k8s.io/dynamic-resource-allocation v0.26.15 h1:4c9ZGd4HMipSA5L9TwXExNI45ZknnzVsLMfvMknoqqE= -k8s.io/dynamic-resource-allocation v0.26.15/go.mod h1:+1o9SfP+pPQ2kZHj9K2P+DmUtAvQnv28AVWdHTIzano= +k8s.io/api v0.28.9 h1:E7VEXXCAlSrp+08zq4zgd+ko6Ttu0Mw+XoXlIkDTVW0= +k8s.io/api v0.28.9/go.mod h1:AnCsDYf3SHjfa8mPG5LGYf+iF4mie+3peLQR51MMCgw= +k8s.io/apiextensions-apiserver v0.28.9 h1:yzPHp+4IASHeu7XIPkAKJrY4UjWdjiAjOcQMd6oNKj0= +k8s.io/apiextensions-apiserver v0.28.9/go.mod h1:Rjhvq5y3JESdZgV2UOByldyefCfRrUguVpBLYOAIbVs= +k8s.io/apimachinery v0.28.9 h1:aXz4Zxsw+Pk4KhBerAtKRxNN1uSMWKfciL/iOdBfXvA= +k8s.io/apimachinery v0.28.9/go.mod h1:zUG757HaKs6Dc3iGtKjzIpBfqTM4yiRsEe3/E7NX15o= +k8s.io/apiserver v0.28.9 h1:koPXvgSXRBDxKJQjJGdZNgPsT9lQv6scJJFipd1m86E= +k8s.io/apiserver v0.28.9/go.mod h1:D51I37WBZojJhmLcjNVE4GSVrjiUHP+yq+N5KvKn2wY= +k8s.io/client-go v0.28.9 h1:mmMvejwc/KDjMLmDpyaxkWNzlWRCJ6ht7Qsbsnwn39Y= +k8s.io/client-go v0.28.9/go.mod h1:GFDy3rUNId++WGrr0hRaBrs+y1eZz5JtVZODEalhRMo= +k8s.io/cloud-provider v0.28.9 h1:FBW4Ii1NdXCHKprzkM8/s5BpxvLgJmYrZTNJABsVX7Y= +k8s.io/cloud-provider v0.28.9/go.mod h1:7tFyiftAlSARvJS6mzZQQKKDQA81asNQ2usg35R3Exo= +k8s.io/code-generator v0.28.9 h1:NyZt4+equopQNbwjSSpVikB15U4ghmvIaqn+VWd367U= +k8s.io/code-generator v0.28.9/go.mod h1:WiJgVNDFAlT90nq6IOxhZ1gxL2JexbcfAx9ZBsyQ3Do= +k8s.io/component-base v0.28.9 h1:ySM2PR8Z/xaUSG1Akd3yM6dqUezTltI7S5aV41MMuuc= +k8s.io/component-base v0.28.9/go.mod h1:QtWzscEhCKRfHV24/S+11BwWjVxhC6fd3RYoEgZcWFU= +k8s.io/component-helpers v0.28.9 h1:knX9F2nRoxF4wplgXO4C5tE4/k7HGszK3177Tm4+CUc= +k8s.io/component-helpers v0.28.9/go.mod h1:TdAkLbywEDE2CB5h8LbM/W03T3k8wvqAaoPcEZrr6Z4= +k8s.io/controller-manager v0.28.9 h1:muAtmO2mDN7pDkAJQMknvWy+WQhkvvi/jK1V82+qbLw= +k8s.io/controller-manager v0.28.9/go.mod h1:RYP65K6GWLRWYZR7PRRaStfvgeXkhCGZwJsxRPuaDV0= +k8s.io/cri-api v0.28.9 h1:AlhkmIDLeKWubmX2xVkW3DhcbPwH79xauFySijfkIDU= +k8s.io/cri-api v0.28.9/go.mod h1:8/bPK3T4irPoj3LjriQc1TAIheeN2yWXR3mz+8jNZ8U= +k8s.io/csi-translation-lib v0.28.9 h1:zl93l7wk0iwKInyRJfaodvsWf1z8QtWCN9a5OqHeT3o= +k8s.io/csi-translation-lib v0.28.9/go.mod h1:eOniPQitdkuyVh+gtktg3yeDJQu/IidIUSMadDPLhak= +k8s.io/dynamic-resource-allocation v0.28.9 h1:u3upC0ah0eNrO1uh3yUL3VefvB1OUTNQLKjxMfe1pgc= +k8s.io/dynamic-resource-allocation v0.28.9/go.mod h1:SIwpYxFh5gk7bW1dZ+GgnA6l4VmhrnUugePlLxYva+4= k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01 h1:pWEwq4Asjm4vjW7vcsmijwBhOr1/shsbSYiWXmNGlks= k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E= k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y= -k8s.io/klog/v2 v2.110.1 h1:U/Af64HJf7FcwMcXyKm2RPM22WZzyR7OSpYj5tg3cL0= -k8s.io/klog/v2 v2.110.1/go.mod h1:YGtd1984u+GgbuZ7e08/yBuAfKLSO0+uR1Fhi6ExXjo= -k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 h1:+70TFaan3hfJzs+7VK2o+OGxg8HsuBr/5f6tVAjDu6E= -k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280/go.mod h1:+Axhij7bCpeqhklhUTe3xmOn6bWxolyZEeyaFpjGtl4= -k8s.io/kube-scheduler v0.26.15 h1:bsCe6ohw5MV3X0UB+JvCI2rrELWFnOacL7Uf5/NAUMM= -k8s.io/kube-scheduler v0.26.15/go.mod h1:lLIAwYrF3Cf7OQLHi05pc+2b6PLqsGxyFTa4Id+wNEY= -k8s.io/kubernetes v1.26.15 h1:o65B3kKH7q9xK2h2323rKKThI1rp3ZarXpb8asT932U= -k8s.io/kubernetes v1.26.15/go.mod h1:X28d33q7QRZtOw/KPdTeOksMQAMNKkSwwAzRtovsBVE= -k8s.io/mount-utils v0.26.15 h1:TvTNwRNiXRlxjb7ZUlKObpfINRmcFqMF2i+rb3iJ/co= -k8s.io/mount-utils v0.26.15/go.mod h1:huSg2NI5P8ZNfE8PkQmm5a9fFZ9iHCXFxP/rasMCgYA= -k8s.io/utils v0.0.0-20221128185143-99ec85e7a448 h1:KTgPnR10d5zhztWptI952TNtt/4u5h3IzDXkdIMuo2Y= -k8s.io/utils v0.0.0-20221128185143-99ec85e7a448/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= -rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= -rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= -rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= -sigs.k8s.io/controller-runtime v0.14.0 h1:ju2xsov5Ara6FoQuddg+az+rAxsUsTYn2IYyEKCTyDc= -sigs.k8s.io/controller-runtime v0.14.0/go.mod h1:GaRkrY8a7UZF0kqFFbUKG7n9ICiTY5T55P1RiE3UZlU= +k8s.io/klog/v2 v2.120.1 h1:QXU6cPEOIslTGvZaXvFWiP9VKyeet3sawzTOvdXb4Vw= +k8s.io/klog/v2 v2.120.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= +k8s.io/kms v0.28.9 h1:ApCWJulBl+uFRTr2jtTpG1lffmqqMuLnOH/RUbtO4UY= +k8s.io/kms v0.28.9/go.mod h1:VgyAIRMFqZX9lHyixecU/JTI0wnPD1wCIlquvlXRJ+Y= +k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 h1:LyMgNKD2P8Wn1iAwQU5OhxCKlKJy0sHc+PcDwFB24dQ= +k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9/go.mod h1:wZK2AVp1uHCp4VamDVgBP2COHZjqD1T68Rf0CM3YjSM= +k8s.io/kube-scheduler v0.28.9 h1:rRFkTBiPIpcCdyI7/E2HVyzWehmSW1eI/rWyKTVrKfk= +k8s.io/kube-scheduler v0.28.9/go.mod h1:9xnBlTE/B2EwfiUZ/uh2zBEVViRhGG+ojLiMvyxXCe8= +k8s.io/kubelet v0.28.9 h1:76v00fFLeniz27kXhGGUIxONdwa9LKcD2Jd5cXYAZko= +k8s.io/kubelet v0.28.9/go.mod h1:46P39DFjI+E59nU2OgpatyS3oWy58ClulKO6riZ/97o= +k8s.io/kubernetes v1.28.9 h1:I4sYGQJOuxEo4/QWoY7M8kDB7O0HcH266t6o6mR6ogg= +k8s.io/kubernetes v1.28.9/go.mod h1:chlmcCDBnOA/y+572cw8dO0Rci1wiA8bm5+zhPdFLCk= +k8s.io/mount-utils v0.28.9 h1:RWt7xIrTzoKYKmMZ9Lh/rkZ9zreCUdpzhFe8jJXXuNQ= +k8s.io/mount-utils v0.28.9/go.mod h1:ZxAFXgKzcAyi3VTd2pKFlZFswl9Q/cveJ5aptdjQOuc= +k8s.io/utils v0.0.0-20230726121419-3b25d923346b h1:sgn3ZU783SCgtaSJjpcVVlRqd6GSnlTLKgpAAttJvpI= +k8s.io/utils v0.0.0-20230726121419-3b25d923346b/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.1.2 h1:trsWhjU5jZrx6UvFu4WzQDrN7Pga4a7Qg+zcfcj64PA= +sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.1.2/go.mod h1:+qG7ISXqCDVVcyO8hLn12AKVYYUjM7ftlqsqmrhMZE0= +sigs.k8s.io/controller-runtime v0.16.5 h1:yr1cEJbX08xsTW6XEIzT13KHHmIyX8Umvme2cULvFZw= +sigs.k8s.io/controller-runtime v0.16.5/go.mod h1:j7bialYoSn142nv9sCOJmQgDXQXxnroFU4VnX/brVJ0= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4= sigs.k8s.io/structured-merge-diff/v4 v4.4.1/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08= sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= -sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= -sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= +sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= +sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/main.go b/main.go index 65a36e7ff8..b0887a5617 100644 --- a/main.go +++ b/main.go @@ -25,11 +25,10 @@ import ( "time" _ "time/tzdata" // for AdvancedCronJob Time Zone support - utilruntime "k8s.io/apimachinery/pkg/util/runtime" - "github.com/spf13/pflag" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" clientgoscheme "k8s.io/client-go/kubernetes/scheme" _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" "k8s.io/client-go/rest" @@ -38,6 +37,9 @@ import ( "k8s.io/klog/v2/klogr" "k8s.io/kubernetes/pkg/capabilities" ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/cache" + metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server" + ctrlwebhook "sigs.k8s.io/controller-runtime/pkg/webhook" appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" appsv1beta1 "github.com/openkruise/kruise/apis/apps/v1beta1" @@ -53,6 +55,7 @@ import ( "github.com/openkruise/kruise/pkg/util/fieldindex" _ "github.com/openkruise/kruise/pkg/util/metrics/leadership" "github.com/openkruise/kruise/pkg/webhook" + webhookutil "github.com/openkruise/kruise/pkg/webhook/util" // +kubebuilder:scaffold:imports ) @@ -171,8 +174,10 @@ func main() { } } mgr, err := ctrl.NewManager(cfg, ctrl.Options{ - Scheme: scheme, - MetricsBindAddress: metricsAddr, + Scheme: scheme, + Metrics: metricsserver.Options{ + BindAddress: metricsAddr, + }, HealthProbeBindAddress: healthProbeAddr, LeaderElection: enableLeaderElection, LeaderElectionID: leaderElectionId, @@ -181,9 +186,16 @@ func main() { LeaseDuration: &leaseDuration, RenewDeadline: &renewDeadLine, RetryPeriod: &retryPeriod, - Namespace: namespace, - SyncPeriod: syncPeriod, - NewCache: utilclient.NewCache, + Cache: cache.Options{ + SyncPeriod: syncPeriod, + DefaultNamespaces: getCacheNamespacesFromFlag(namespace), + }, + WebhookServer: ctrlwebhook.NewServer(ctrlwebhook.Options{ + Host: "0.0.0.0", + Port: webhookutil.GetPort(), + CertDir: webhookutil.GetCertDir(), + }), + NewCache: utilclient.NewCache, }) if err != nil { setupLog.Error(err, "unable to start manager") @@ -249,3 +261,12 @@ func setRestConfig(c *rest.Config) { c.Burst = *restConfigBurst } } + +func getCacheNamespacesFromFlag(ns string) map[string]cache.Config { + if ns == "" { + return nil + } + return map[string]cache.Config{ + ns: {}, + } +} diff --git a/pkg/client/clientset/versioned/doc.go b/pkg/client/clientset/versioned/doc.go deleted file mode 100644 index 8d36fd69e9..0000000000 --- a/pkg/client/clientset/versioned/doc.go +++ /dev/null @@ -1,19 +0,0 @@ -/* -Copyright 2021 The Kruise Authors. - -Licensed 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. -*/ -// Code generated by client-gen. DO NOT EDIT. - -// This package has the automatically generated clientset. -package versioned diff --git a/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_advancedcronjob.go b/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_advancedcronjob.go index ee9c853f1c..8a87320192 100644 --- a/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_advancedcronjob.go +++ b/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_advancedcronjob.go @@ -23,7 +23,6 @@ import ( v1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" testing "k8s.io/client-go/testing" @@ -35,9 +34,9 @@ type FakeAdvancedCronJobs struct { ns string } -var advancedcronjobsResource = schema.GroupVersionResource{Group: "apps.kruise.io", Version: "v1alpha1", Resource: "advancedcronjobs"} +var advancedcronjobsResource = v1alpha1.SchemeGroupVersion.WithResource("advancedcronjobs") -var advancedcronjobsKind = schema.GroupVersionKind{Group: "apps.kruise.io", Version: "v1alpha1", Kind: "AdvancedCronJob"} +var advancedcronjobsKind = v1alpha1.SchemeGroupVersion.WithKind("AdvancedCronJob") // Get takes name of the advancedCronJob, and returns the corresponding advancedCronJob object, and an error if there is any. func (c *FakeAdvancedCronJobs) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.AdvancedCronJob, err error) { diff --git a/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_broadcastjob.go b/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_broadcastjob.go index 8bb513b601..51d55dbfa5 100644 --- a/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_broadcastjob.go +++ b/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_broadcastjob.go @@ -23,7 +23,6 @@ import ( v1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" testing "k8s.io/client-go/testing" @@ -35,9 +34,9 @@ type FakeBroadcastJobs struct { ns string } -var broadcastjobsResource = schema.GroupVersionResource{Group: "apps.kruise.io", Version: "v1alpha1", Resource: "broadcastjobs"} +var broadcastjobsResource = v1alpha1.SchemeGroupVersion.WithResource("broadcastjobs") -var broadcastjobsKind = schema.GroupVersionKind{Group: "apps.kruise.io", Version: "v1alpha1", Kind: "BroadcastJob"} +var broadcastjobsKind = v1alpha1.SchemeGroupVersion.WithKind("BroadcastJob") // Get takes name of the broadcastJob, and returns the corresponding broadcastJob object, and an error if there is any. func (c *FakeBroadcastJobs) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.BroadcastJob, err error) { diff --git a/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_cloneset.go b/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_cloneset.go index 7a691f227f..96169cb8ed 100644 --- a/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_cloneset.go +++ b/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_cloneset.go @@ -24,7 +24,6 @@ import ( autoscalingv1 "k8s.io/api/autoscaling/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" testing "k8s.io/client-go/testing" @@ -36,9 +35,9 @@ type FakeCloneSets struct { ns string } -var clonesetsResource = schema.GroupVersionResource{Group: "apps.kruise.io", Version: "v1alpha1", Resource: "clonesets"} +var clonesetsResource = v1alpha1.SchemeGroupVersion.WithResource("clonesets") -var clonesetsKind = schema.GroupVersionKind{Group: "apps.kruise.io", Version: "v1alpha1", Kind: "CloneSet"} +var clonesetsKind = v1alpha1.SchemeGroupVersion.WithKind("CloneSet") // Get takes name of the cloneSet, and returns the corresponding cloneSet object, and an error if there is any. func (c *FakeCloneSets) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.CloneSet, err error) { diff --git a/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_containerrecreaterequest.go b/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_containerrecreaterequest.go index 7d813f6fca..ce93d56540 100644 --- a/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_containerrecreaterequest.go +++ b/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_containerrecreaterequest.go @@ -23,7 +23,6 @@ import ( v1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" testing "k8s.io/client-go/testing" @@ -35,9 +34,9 @@ type FakeContainerRecreateRequests struct { ns string } -var containerrecreaterequestsResource = schema.GroupVersionResource{Group: "apps.kruise.io", Version: "v1alpha1", Resource: "containerrecreaterequests"} +var containerrecreaterequestsResource = v1alpha1.SchemeGroupVersion.WithResource("containerrecreaterequests") -var containerrecreaterequestsKind = schema.GroupVersionKind{Group: "apps.kruise.io", Version: "v1alpha1", Kind: "ContainerRecreateRequest"} +var containerrecreaterequestsKind = v1alpha1.SchemeGroupVersion.WithKind("ContainerRecreateRequest") // Get takes name of the containerRecreateRequest, and returns the corresponding containerRecreateRequest object, and an error if there is any. func (c *FakeContainerRecreateRequests) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.ContainerRecreateRequest, err error) { diff --git a/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_daemonset.go b/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_daemonset.go index 82a4ef1bb2..1dfee83aaa 100644 --- a/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_daemonset.go +++ b/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_daemonset.go @@ -23,7 +23,6 @@ import ( v1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" testing "k8s.io/client-go/testing" @@ -35,9 +34,9 @@ type FakeDaemonSets struct { ns string } -var daemonsetsResource = schema.GroupVersionResource{Group: "apps.kruise.io", Version: "v1alpha1", Resource: "daemonsets"} +var daemonsetsResource = v1alpha1.SchemeGroupVersion.WithResource("daemonsets") -var daemonsetsKind = schema.GroupVersionKind{Group: "apps.kruise.io", Version: "v1alpha1", Kind: "DaemonSet"} +var daemonsetsKind = v1alpha1.SchemeGroupVersion.WithKind("DaemonSet") // Get takes name of the daemonSet, and returns the corresponding daemonSet object, and an error if there is any. func (c *FakeDaemonSets) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.DaemonSet, err error) { diff --git a/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_ephemeraljob.go b/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_ephemeraljob.go index 74c97a1d09..71881b1140 100644 --- a/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_ephemeraljob.go +++ b/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_ephemeraljob.go @@ -23,7 +23,6 @@ import ( v1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" testing "k8s.io/client-go/testing" @@ -35,9 +34,9 @@ type FakeEphemeralJobs struct { ns string } -var ephemeraljobsResource = schema.GroupVersionResource{Group: "apps.kruise.io", Version: "v1alpha1", Resource: "ephemeraljobs"} +var ephemeraljobsResource = v1alpha1.SchemeGroupVersion.WithResource("ephemeraljobs") -var ephemeraljobsKind = schema.GroupVersionKind{Group: "apps.kruise.io", Version: "v1alpha1", Kind: "EphemeralJob"} +var ephemeraljobsKind = v1alpha1.SchemeGroupVersion.WithKind("EphemeralJob") // Get takes name of the ephemeralJob, and returns the corresponding ephemeralJob object, and an error if there is any. func (c *FakeEphemeralJobs) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.EphemeralJob, err error) { diff --git a/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_imagelistpulljob.go b/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_imagelistpulljob.go index 905196c889..d2da3f29d7 100644 --- a/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_imagelistpulljob.go +++ b/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_imagelistpulljob.go @@ -23,7 +23,6 @@ import ( v1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" testing "k8s.io/client-go/testing" @@ -35,9 +34,9 @@ type FakeImageListPullJobs struct { ns string } -var imagelistpulljobsResource = schema.GroupVersionResource{Group: "apps.kruise.io", Version: "v1alpha1", Resource: "imagelistpulljobs"} +var imagelistpulljobsResource = v1alpha1.SchemeGroupVersion.WithResource("imagelistpulljobs") -var imagelistpulljobsKind = schema.GroupVersionKind{Group: "apps.kruise.io", Version: "v1alpha1", Kind: "ImageListPullJob"} +var imagelistpulljobsKind = v1alpha1.SchemeGroupVersion.WithKind("ImageListPullJob") // Get takes name of the imageListPullJob, and returns the corresponding imageListPullJob object, and an error if there is any. func (c *FakeImageListPullJobs) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.ImageListPullJob, err error) { diff --git a/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_imagepulljob.go b/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_imagepulljob.go index d9b3b5512e..95ad44be3a 100644 --- a/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_imagepulljob.go +++ b/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_imagepulljob.go @@ -23,7 +23,6 @@ import ( v1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" testing "k8s.io/client-go/testing" @@ -35,9 +34,9 @@ type FakeImagePullJobs struct { ns string } -var imagepulljobsResource = schema.GroupVersionResource{Group: "apps.kruise.io", Version: "v1alpha1", Resource: "imagepulljobs"} +var imagepulljobsResource = v1alpha1.SchemeGroupVersion.WithResource("imagepulljobs") -var imagepulljobsKind = schema.GroupVersionKind{Group: "apps.kruise.io", Version: "v1alpha1", Kind: "ImagePullJob"} +var imagepulljobsKind = v1alpha1.SchemeGroupVersion.WithKind("ImagePullJob") // Get takes name of the imagePullJob, and returns the corresponding imagePullJob object, and an error if there is any. func (c *FakeImagePullJobs) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.ImagePullJob, err error) { diff --git a/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_nodeimage.go b/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_nodeimage.go index 203df06954..b804693973 100644 --- a/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_nodeimage.go +++ b/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_nodeimage.go @@ -23,7 +23,6 @@ import ( v1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" testing "k8s.io/client-go/testing" @@ -34,9 +33,9 @@ type FakeNodeImages struct { Fake *FakeAppsV1alpha1 } -var nodeimagesResource = schema.GroupVersionResource{Group: "apps.kruise.io", Version: "v1alpha1", Resource: "nodeimages"} +var nodeimagesResource = v1alpha1.SchemeGroupVersion.WithResource("nodeimages") -var nodeimagesKind = schema.GroupVersionKind{Group: "apps.kruise.io", Version: "v1alpha1", Kind: "NodeImage"} +var nodeimagesKind = v1alpha1.SchemeGroupVersion.WithKind("NodeImage") // Get takes name of the nodeImage, and returns the corresponding nodeImage object, and an error if there is any. func (c *FakeNodeImages) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.NodeImage, err error) { diff --git a/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_nodepodprobe.go b/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_nodepodprobe.go index 5994cb9a95..5dc8d476ad 100644 --- a/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_nodepodprobe.go +++ b/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_nodepodprobe.go @@ -23,7 +23,6 @@ import ( v1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" testing "k8s.io/client-go/testing" @@ -34,9 +33,9 @@ type FakeNodePodProbes struct { Fake *FakeAppsV1alpha1 } -var nodepodprobesResource = schema.GroupVersionResource{Group: "apps.kruise.io", Version: "v1alpha1", Resource: "nodepodprobes"} +var nodepodprobesResource = v1alpha1.SchemeGroupVersion.WithResource("nodepodprobes") -var nodepodprobesKind = schema.GroupVersionKind{Group: "apps.kruise.io", Version: "v1alpha1", Kind: "NodePodProbe"} +var nodepodprobesKind = v1alpha1.SchemeGroupVersion.WithKind("NodePodProbe") // Get takes name of the nodePodProbe, and returns the corresponding nodePodProbe object, and an error if there is any. func (c *FakeNodePodProbes) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.NodePodProbe, err error) { diff --git a/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_persistentpodstate.go b/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_persistentpodstate.go index 2c6cd98b1d..88779ad5ff 100644 --- a/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_persistentpodstate.go +++ b/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_persistentpodstate.go @@ -23,7 +23,6 @@ import ( v1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" testing "k8s.io/client-go/testing" @@ -35,9 +34,9 @@ type FakePersistentPodStates struct { ns string } -var persistentpodstatesResource = schema.GroupVersionResource{Group: "apps.kruise.io", Version: "v1alpha1", Resource: "persistentpodstates"} +var persistentpodstatesResource = v1alpha1.SchemeGroupVersion.WithResource("persistentpodstates") -var persistentpodstatesKind = schema.GroupVersionKind{Group: "apps.kruise.io", Version: "v1alpha1", Kind: "PersistentPodState"} +var persistentpodstatesKind = v1alpha1.SchemeGroupVersion.WithKind("PersistentPodState") // Get takes name of the persistentPodState, and returns the corresponding persistentPodState object, and an error if there is any. func (c *FakePersistentPodStates) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.PersistentPodState, err error) { diff --git a/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_podprobemarker.go b/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_podprobemarker.go index 14bd4d551b..f1f84e5f6a 100644 --- a/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_podprobemarker.go +++ b/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_podprobemarker.go @@ -23,7 +23,6 @@ import ( v1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" testing "k8s.io/client-go/testing" @@ -35,9 +34,9 @@ type FakePodProbeMarkers struct { ns string } -var podprobemarkersResource = schema.GroupVersionResource{Group: "apps.kruise.io", Version: "v1alpha1", Resource: "podprobemarkers"} +var podprobemarkersResource = v1alpha1.SchemeGroupVersion.WithResource("podprobemarkers") -var podprobemarkersKind = schema.GroupVersionKind{Group: "apps.kruise.io", Version: "v1alpha1", Kind: "PodProbeMarker"} +var podprobemarkersKind = v1alpha1.SchemeGroupVersion.WithKind("PodProbeMarker") // Get takes name of the podProbeMarker, and returns the corresponding podProbeMarker object, and an error if there is any. func (c *FakePodProbeMarkers) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.PodProbeMarker, err error) { diff --git a/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_resourcedistribution.go b/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_resourcedistribution.go index 5dbd7760f4..00c0c6e0cb 100644 --- a/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_resourcedistribution.go +++ b/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_resourcedistribution.go @@ -23,7 +23,6 @@ import ( v1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" testing "k8s.io/client-go/testing" @@ -34,9 +33,9 @@ type FakeResourceDistributions struct { Fake *FakeAppsV1alpha1 } -var resourcedistributionsResource = schema.GroupVersionResource{Group: "apps.kruise.io", Version: "v1alpha1", Resource: "resourcedistributions"} +var resourcedistributionsResource = v1alpha1.SchemeGroupVersion.WithResource("resourcedistributions") -var resourcedistributionsKind = schema.GroupVersionKind{Group: "apps.kruise.io", Version: "v1alpha1", Kind: "ResourceDistribution"} +var resourcedistributionsKind = v1alpha1.SchemeGroupVersion.WithKind("ResourceDistribution") // Get takes name of the resourceDistribution, and returns the corresponding resourceDistribution object, and an error if there is any. func (c *FakeResourceDistributions) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.ResourceDistribution, err error) { diff --git a/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_sidecarset.go b/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_sidecarset.go index d9045ce018..907d93aeab 100644 --- a/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_sidecarset.go +++ b/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_sidecarset.go @@ -23,7 +23,6 @@ import ( v1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" testing "k8s.io/client-go/testing" @@ -34,9 +33,9 @@ type FakeSidecarSets struct { Fake *FakeAppsV1alpha1 } -var sidecarsetsResource = schema.GroupVersionResource{Group: "apps.kruise.io", Version: "v1alpha1", Resource: "sidecarsets"} +var sidecarsetsResource = v1alpha1.SchemeGroupVersion.WithResource("sidecarsets") -var sidecarsetsKind = schema.GroupVersionKind{Group: "apps.kruise.io", Version: "v1alpha1", Kind: "SidecarSet"} +var sidecarsetsKind = v1alpha1.SchemeGroupVersion.WithKind("SidecarSet") // Get takes name of the sidecarSet, and returns the corresponding sidecarSet object, and an error if there is any. func (c *FakeSidecarSets) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.SidecarSet, err error) { diff --git a/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_statefulset.go b/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_statefulset.go index 922f57329a..1f6b423921 100644 --- a/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_statefulset.go +++ b/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_statefulset.go @@ -24,7 +24,6 @@ import ( autoscalingv1 "k8s.io/api/autoscaling/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" testing "k8s.io/client-go/testing" @@ -36,9 +35,9 @@ type FakeStatefulSets struct { ns string } -var statefulsetsResource = schema.GroupVersionResource{Group: "apps.kruise.io", Version: "v1alpha1", Resource: "statefulsets"} +var statefulsetsResource = v1alpha1.SchemeGroupVersion.WithResource("statefulsets") -var statefulsetsKind = schema.GroupVersionKind{Group: "apps.kruise.io", Version: "v1alpha1", Kind: "StatefulSet"} +var statefulsetsKind = v1alpha1.SchemeGroupVersion.WithKind("StatefulSet") // Get takes name of the statefulSet, and returns the corresponding statefulSet object, and an error if there is any. func (c *FakeStatefulSets) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.StatefulSet, err error) { diff --git a/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_uniteddeployment.go b/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_uniteddeployment.go index 891b1b8ad0..3af8ae5c98 100644 --- a/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_uniteddeployment.go +++ b/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_uniteddeployment.go @@ -24,7 +24,6 @@ import ( autoscalingv1 "k8s.io/api/autoscaling/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" testing "k8s.io/client-go/testing" @@ -36,9 +35,9 @@ type FakeUnitedDeployments struct { ns string } -var uniteddeploymentsResource = schema.GroupVersionResource{Group: "apps.kruise.io", Version: "v1alpha1", Resource: "uniteddeployments"} +var uniteddeploymentsResource = v1alpha1.SchemeGroupVersion.WithResource("uniteddeployments") -var uniteddeploymentsKind = schema.GroupVersionKind{Group: "apps.kruise.io", Version: "v1alpha1", Kind: "UnitedDeployment"} +var uniteddeploymentsKind = v1alpha1.SchemeGroupVersion.WithKind("UnitedDeployment") // Get takes name of the unitedDeployment, and returns the corresponding unitedDeployment object, and an error if there is any. func (c *FakeUnitedDeployments) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.UnitedDeployment, err error) { diff --git a/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_workloadspread.go b/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_workloadspread.go index 61f99fd8ee..d558391fed 100644 --- a/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_workloadspread.go +++ b/pkg/client/clientset/versioned/typed/apps/v1alpha1/fake/fake_workloadspread.go @@ -23,7 +23,6 @@ import ( v1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" testing "k8s.io/client-go/testing" @@ -35,9 +34,9 @@ type FakeWorkloadSpreads struct { ns string } -var workloadspreadsResource = schema.GroupVersionResource{Group: "apps.kruise.io", Version: "v1alpha1", Resource: "workloadspreads"} +var workloadspreadsResource = v1alpha1.SchemeGroupVersion.WithResource("workloadspreads") -var workloadspreadsKind = schema.GroupVersionKind{Group: "apps.kruise.io", Version: "v1alpha1", Kind: "WorkloadSpread"} +var workloadspreadsKind = v1alpha1.SchemeGroupVersion.WithKind("WorkloadSpread") // Get takes name of the workloadSpread, and returns the corresponding workloadSpread object, and an error if there is any. func (c *FakeWorkloadSpreads) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.WorkloadSpread, err error) { diff --git a/pkg/client/clientset/versioned/typed/apps/v1beta1/fake/fake_statefulset.go b/pkg/client/clientset/versioned/typed/apps/v1beta1/fake/fake_statefulset.go index 68e7118ab3..b860a4d90e 100644 --- a/pkg/client/clientset/versioned/typed/apps/v1beta1/fake/fake_statefulset.go +++ b/pkg/client/clientset/versioned/typed/apps/v1beta1/fake/fake_statefulset.go @@ -24,7 +24,6 @@ import ( autoscalingv1 "k8s.io/api/autoscaling/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" testing "k8s.io/client-go/testing" @@ -36,9 +35,9 @@ type FakeStatefulSets struct { ns string } -var statefulsetsResource = schema.GroupVersionResource{Group: "apps.kruise.io", Version: "v1beta1", Resource: "statefulsets"} +var statefulsetsResource = v1beta1.SchemeGroupVersion.WithResource("statefulsets") -var statefulsetsKind = schema.GroupVersionKind{Group: "apps.kruise.io", Version: "v1beta1", Kind: "StatefulSet"} +var statefulsetsKind = v1beta1.SchemeGroupVersion.WithKind("StatefulSet") // Get takes name of the statefulSet, and returns the corresponding statefulSet object, and an error if there is any. func (c *FakeStatefulSets) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.StatefulSet, err error) { diff --git a/pkg/client/clientset/versioned/typed/policy/v1alpha1/fake/fake_podunavailablebudget.go b/pkg/client/clientset/versioned/typed/policy/v1alpha1/fake/fake_podunavailablebudget.go index 32f4223cf3..48493b6577 100644 --- a/pkg/client/clientset/versioned/typed/policy/v1alpha1/fake/fake_podunavailablebudget.go +++ b/pkg/client/clientset/versioned/typed/policy/v1alpha1/fake/fake_podunavailablebudget.go @@ -23,7 +23,6 @@ import ( v1alpha1 "github.com/openkruise/kruise/apis/policy/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" types "k8s.io/apimachinery/pkg/types" watch "k8s.io/apimachinery/pkg/watch" testing "k8s.io/client-go/testing" @@ -35,9 +34,9 @@ type FakePodUnavailableBudgets struct { ns string } -var podunavailablebudgetsResource = schema.GroupVersionResource{Group: "policy.kruise.io", Version: "v1alpha1", Resource: "podunavailablebudgets"} +var podunavailablebudgetsResource = v1alpha1.SchemeGroupVersion.WithResource("podunavailablebudgets") -var podunavailablebudgetsKind = schema.GroupVersionKind{Group: "policy.kruise.io", Version: "v1alpha1", Kind: "PodUnavailableBudget"} +var podunavailablebudgetsKind = v1alpha1.SchemeGroupVersion.WithKind("PodUnavailableBudget") // Get takes name of the podUnavailableBudget, and returns the corresponding podUnavailableBudget object, and an error if there is any. func (c *FakePodUnavailableBudgets) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha1.PodUnavailableBudget, err error) { diff --git a/pkg/client/informers/externalversions/factory.go b/pkg/client/informers/externalversions/factory.go index 2d27e7d31c..35e9db9823 100644 --- a/pkg/client/informers/externalversions/factory.go +++ b/pkg/client/informers/externalversions/factory.go @@ -166,7 +166,7 @@ func (f *sharedInformerFactory) WaitForCacheSync(stopCh <-chan struct{}) map[ref return res } -// InternalInformerFor returns the SharedIndexInformer for obj using an internal +// InformerFor returns the SharedIndexInformer for obj using an internal // client. func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer { f.lock.Lock() @@ -239,7 +239,7 @@ type SharedInformerFactory interface { // ForResource gives generic access to a shared informer of the matching type. ForResource(resource schema.GroupVersionResource) (GenericInformer, error) - // InternalInformerFor returns the SharedIndexInformer for obj using an internal + // InformerFor returns the SharedIndexInformer for obj using an internal // client. InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer diff --git a/pkg/control/pubcontrol/pub_control_utils_test.go b/pkg/control/pubcontrol/pub_control_utils_test.go index 5236615a87..cb6f19eb6e 100644 --- a/pkg/control/pubcontrol/pub_control_utils_test.go +++ b/pkg/control/pubcontrol/pub_control_utils_test.go @@ -21,10 +21,6 @@ import ( "testing" "time" - "github.com/openkruise/kruise/apis/apps/pub" - appspub "github.com/openkruise/kruise/apis/apps/pub" - policyv1alpha1 "github.com/openkruise/kruise/apis/policy/v1alpha1" - "github.com/openkruise/kruise/pkg/util/controllerfinder" apps "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -36,6 +32,11 @@ import ( podutil "k8s.io/kubernetes/pkg/api/v1/pod" utilpointer "k8s.io/utils/pointer" "sigs.k8s.io/controller-runtime/pkg/client/fake" + + "github.com/openkruise/kruise/apis/apps/pub" + appspub "github.com/openkruise/kruise/apis/apps/pub" + policyv1alpha1 "github.com/openkruise/kruise/apis/policy/v1alpha1" + "github.com/openkruise/kruise/pkg/util/controllerfinder" ) func init() { @@ -307,7 +308,8 @@ func TestPodUnavailableBudgetValidatePod(t *testing.T) { for _, cs := range cases { t.Run(cs.name, func(t *testing.T) { - fakeClient := fake.NewClientBuilder().WithScheme(scheme).WithObjects(cs.getPub()).Build() + fakeClient := fake.NewClientBuilder().WithScheme(scheme).WithObjects(cs.getPub()). + WithStatusSubresource(&policyv1alpha1.PodUnavailableBudget{}).Build() finder := &controllerfinder.ControllerFinder{Client: fakeClient} InitPubControl(fakeClient, finder, record.NewFakeRecorder(10)) allow, _, err := PodUnavailableBudgetValidatePod(cs.getPod(), cs.operation, "fake-user", false) diff --git a/pkg/controller/advancedcronjob/advancedcronjob_broadcastjob_controller.go b/pkg/controller/advancedcronjob/advancedcronjob_broadcastjob_controller.go index f615c0912c..0d334efcd7 100644 --- a/pkg/controller/advancedcronjob/advancedcronjob_broadcastjob_controller.go +++ b/pkg/controller/advancedcronjob/advancedcronjob_broadcastjob_controller.go @@ -20,7 +20,6 @@ import ( "sort" "time" - appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" "github.com/robfig/cron/v3" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -30,14 +29,15 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/handler" + "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/source" + + appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" ) -func watchBroadcastJob(c controller.Controller) error { - if err := c.Watch(&source.Kind{Type: &appsv1alpha1.BroadcastJob{}}, &handler.EnqueueRequestForOwner{ - IsController: true, - OwnerType: &appsv1alpha1.AdvancedCronJob{}, - }); err != nil { +func watchBroadcastJob(mgr manager.Manager, c controller.Controller) error { + if err := c.Watch(source.Kind(mgr.GetCache(), &appsv1alpha1.BroadcastJob{}), handler.EnqueueRequestForOwner( + mgr.GetScheme(), mgr.GetRESTMapper(), &appsv1alpha1.AdvancedCronJob{}, handler.OnlyControllerOwner())); err != nil { return err } diff --git a/pkg/controller/advancedcronjob/advancedcronjob_controller.go b/pkg/controller/advancedcronjob/advancedcronjob_controller.go index f08c3e7a5f..be27461f12 100644 --- a/pkg/controller/advancedcronjob/advancedcronjob_controller.go +++ b/pkg/controller/advancedcronjob/advancedcronjob_controller.go @@ -85,17 +85,18 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error { } // Watch for changes to AdvancedCronJob - if err = c.Watch(&source.Kind{Type: &appsv1alpha1.AdvancedCronJob{}}, &handler.EnqueueRequestForObject{}); err != nil { + src := source.Kind(mgr.GetCache(), &appsv1alpha1.AdvancedCronJob{}) + if err = c.Watch(src, &handler.EnqueueRequestForObject{}); err != nil { klog.Error(err) return err } - if err = watchJob(c); err != nil { + if err = watchJob(mgr, c); err != nil { klog.Error(err) return err } - if err = watchBroadcastJob(c); err != nil { + if err = watchBroadcastJob(mgr, c); err != nil { klog.Error(err) return err } diff --git a/pkg/controller/advancedcronjob/advancedcronjob_controller_test.go b/pkg/controller/advancedcronjob/advancedcronjob_controller_test.go index c9aacb1c5c..0ac4507315 100644 --- a/pkg/controller/advancedcronjob/advancedcronjob_controller_test.go +++ b/pkg/controller/advancedcronjob/advancedcronjob_controller_test.go @@ -192,7 +192,7 @@ func createReconcileJobWithBroadcastJobIndex(scheme *runtime.Scheme, initObjs .. return nil } return []string{owner.Name} - }).Build() + }).WithStatusSubresource(&appsv1alpha1.AdvancedCronJob{}).Build() eventBroadcaster := record.NewBroadcaster() recorder := eventBroadcaster.NewRecorder(scheme, v1.EventSource{Component: "advancedcronjob-controller"}) reconcileJob := ReconcileAdvancedCronJob{ @@ -213,7 +213,7 @@ func createReconcileJobWithBatchJobIndex(scheme *runtime.Scheme, initObjs ...cli return nil } return []string{owner.Name} - }).Build() + }).WithStatusSubresource(&appsv1alpha1.AdvancedCronJob{}).Build() eventBroadcaster := record.NewBroadcaster() recorder := eventBroadcaster.NewRecorder(scheme, v1.EventSource{Component: "advancedcronjob-controller"}) reconcileJob := ReconcileAdvancedCronJob{ diff --git a/pkg/controller/advancedcronjob/advancedcronjob_job_controller.go b/pkg/controller/advancedcronjob/advancedcronjob_job_controller.go index aeb72a7779..814b0edd50 100644 --- a/pkg/controller/advancedcronjob/advancedcronjob_job_controller.go +++ b/pkg/controller/advancedcronjob/advancedcronjob_job_controller.go @@ -20,7 +20,6 @@ import ( "sort" "time" - appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" "github.com/robfig/cron/v3" batchv1 "k8s.io/api/batch/v1" corev1 "k8s.io/api/core/v1" @@ -31,14 +30,15 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/handler" + "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/source" + + appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" ) -func watchJob(c controller.Controller) error { - if err := c.Watch(&source.Kind{Type: &batchv1.Job{}}, &handler.EnqueueRequestForOwner{ - IsController: true, - OwnerType: &appsv1alpha1.AdvancedCronJob{}, - }); err != nil { +func watchJob(mgr manager.Manager, c controller.Controller) error { + if err := c.Watch(source.Kind(mgr.GetCache(), &batchv1.Job{}), handler.EnqueueRequestForOwner( + mgr.GetScheme(), mgr.GetRESTMapper(), &appsv1alpha1.BroadcastJob{}, handler.OnlyControllerOwner())); err != nil { return err } diff --git a/pkg/controller/broadcastjob/broadcastjob_controller.go b/pkg/controller/broadcastjob/broadcastjob_controller.go index e919f800c2..597d086bc2 100644 --- a/pkg/controller/broadcastjob/broadcastjob_controller.go +++ b/pkg/controller/broadcastjob/broadcastjob_controller.go @@ -24,12 +24,6 @@ import ( "sync" "time" - appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" - "github.com/openkruise/kruise/pkg/util" - utilclient "github.com/openkruise/kruise/pkg/util/client" - utildiscovery "github.com/openkruise/kruise/pkg/util/discovery" - "github.com/openkruise/kruise/pkg/util/expectations" - "github.com/openkruise/kruise/pkg/util/ratelimiter" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/meta" @@ -58,6 +52,13 @@ import ( "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/reconcile" "sigs.k8s.io/controller-runtime/pkg/source" + + appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" + "github.com/openkruise/kruise/pkg/util" + utilclient "github.com/openkruise/kruise/pkg/util/client" + utildiscovery "github.com/openkruise/kruise/pkg/util/discovery" + "github.com/openkruise/kruise/pkg/util/expectations" + "github.com/openkruise/kruise/pkg/util/ratelimiter" ) func init() { @@ -98,6 +99,20 @@ func newReconciler(mgr manager.Manager) reconcile.Reconciler { // add adds a new Controller to mgr with r as the reconcile.Reconciler func add(mgr manager.Manager, r reconcile.Reconciler) error { + + // todo: maybe we can change to NewControllerManagedBy, example + //return ctrl.NewControllerManagedBy(mgr). + // Named("broadcastjob-controller"). + // WithOptions(controller.Options{ + // MaxConcurrentReconciles: concurrentReconciles, + // CacheSyncTimeout: util.GetControllerCacheSyncTimeout(), + // RateLimiter: ratelimiter.DefaultControllerRateLimiter(), + // }). + // For(&appsv1alpha1.BroadcastJob{}). + // Owns(&corev1.Pod{}). + // Watches(&corev1.Node{}, &enqueueBroadcastJobForNode{reader: mgr.GetCache()}). + // Complete(r) + // Create a new controller c, err := controller.New("broadcastjob-controller", mgr, controller.Options{ Reconciler: r, MaxConcurrentReconciles: concurrentReconciles, CacheSyncTimeout: util.GetControllerCacheSyncTimeout(), @@ -107,24 +122,21 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error { } // Watch for changes to BroadcastJob - err = c.Watch(&source.Kind{Type: &appsv1alpha1.BroadcastJob{}}, &handler.EnqueueRequestForObject{}) + err = c.Watch(source.Kind(mgr.GetCache(), &appsv1alpha1.BroadcastJob{}), &handler.EnqueueRequestForObject{}) if err != nil { return err } // Watch for changes to Pod - err = c.Watch(&source.Kind{Type: &corev1.Pod{}}, &podEventHandler{ - enqueueHandler: handler.EnqueueRequestForOwner{ - IsController: true, - OwnerType: &appsv1alpha1.BroadcastJob{}, - }, + err = c.Watch(source.Kind(mgr.GetCache(), &corev1.Pod{}), &podEventHandler{ + enqueueHandler: handler.EnqueueRequestForOwner(mgr.GetScheme(), mgr.GetRESTMapper(), &appsv1alpha1.BroadcastJob{}, handler.OnlyControllerOwner()), }) if err != nil { return err } // Watch for changes to Node - return c.Watch(&source.Kind{Type: &corev1.Node{}}, &enqueueBroadcastJobForNode{reader: mgr.GetCache()}) + return c.Watch(source.Kind(mgr.GetCache(), &corev1.Node{}), &enqueueBroadcastJobForNode{reader: mgr.GetCache()}) } var _ reconcile.Reconciler = &ReconcileBroadcastJob{} diff --git a/pkg/controller/broadcastjob/broadcastjob_controller_test.go b/pkg/controller/broadcastjob/broadcastjob_controller_test.go index 3bd2c7b927..94afff79c2 100644 --- a/pkg/controller/broadcastjob/broadcastjob_controller_test.go +++ b/pkg/controller/broadcastjob/broadcastjob_controller_test.go @@ -24,7 +24,6 @@ import ( utilruntime "k8s.io/apimachinery/pkg/util/runtime" - appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" "github.com/stretchr/testify/assert" "golang.org/x/net/context" v1 "k8s.io/api/core/v1" @@ -40,6 +39,8 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" ) func init() { @@ -601,7 +602,8 @@ func TestJobFailedAfterActiveDeadline(t *testing.T) { } func createReconcileJob(scheme *runtime.Scheme, initObjs ...client.Object) ReconcileBroadcastJob { - fakeClient := fake.NewClientBuilder().WithScheme(scheme).WithObjects(initObjs...).Build() + fakeClient := fake.NewClientBuilder().WithScheme(scheme). + WithObjects(initObjs...).WithStatusSubresource(&appsv1alpha1.BroadcastJob{}).Build() eventBroadcaster := record.NewBroadcaster() recorder := eventBroadcaster.NewRecorder(scheme, v1.EventSource{Component: "broadcast-controller"}) reconcileJob := ReconcileBroadcastJob{ diff --git a/pkg/controller/broadcastjob/broadcastjob_event_handler.go b/pkg/controller/broadcastjob/broadcastjob_event_handler.go index fd1855ab59..9ae6ee4693 100644 --- a/pkg/controller/broadcastjob/broadcastjob_event_handler.go +++ b/pkg/controller/broadcastjob/broadcastjob_event_handler.go @@ -5,7 +5,6 @@ import ( v1 "k8s.io/api/core/v1" apiequality "k8s.io/apimachinery/pkg/api/equality" - "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" @@ -16,14 +15,13 @@ import ( "sigs.k8s.io/controller-runtime/pkg/event" "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/reconcile" - "sigs.k8s.io/controller-runtime/pkg/runtime/inject" "github.com/openkruise/kruise/apis/apps/v1alpha1" "github.com/openkruise/kruise/pkg/util/expectations" ) type podEventHandler struct { - enqueueHandler handler.EnqueueRequestForOwner + enqueueHandler handler.EventHandler } func isBroadcastJobController(controllerRef *metav1.OwnerReference) bool { @@ -35,63 +33,51 @@ func isBroadcastJobController(controllerRef *metav1.OwnerReference) bool { return controllerRef.Kind == controllerKind.Kind && refGV.Group == controllerKind.Group } -func (p *podEventHandler) Create(evt event.CreateEvent, q workqueue.RateLimitingInterface) { +func (p *podEventHandler) Create(ctx context.Context, evt event.CreateEvent, q workqueue.RateLimitingInterface) { pod := evt.Object.(*v1.Pod) if pod.DeletionTimestamp != nil { - p.Delete(event.DeleteEvent{Object: evt.Object}, q) + p.Delete(ctx, event.DeleteEvent{Object: evt.Object}, q) return } if controllerRef := metav1.GetControllerOf(pod); controllerRef != nil && isBroadcastJobController(controllerRef) { key := types.NamespacedName{Namespace: pod.Namespace, Name: controllerRef.Name}.String() scaleExpectations.ObserveScale(key, expectations.Create, getAssignedNode(pod)) - p.enqueueHandler.Create(evt, q) + p.enqueueHandler.Create(ctx, evt, q) } } -func (p *podEventHandler) Delete(evt event.DeleteEvent, q workqueue.RateLimitingInterface) { +func (p *podEventHandler) Delete(ctx context.Context, evt event.DeleteEvent, q workqueue.RateLimitingInterface) { pod := evt.Object.(*v1.Pod) if controllerRef := metav1.GetControllerOf(pod); controllerRef != nil && isBroadcastJobController(controllerRef) { key := types.NamespacedName{Namespace: pod.Namespace, Name: controllerRef.Name}.String() scaleExpectations.ObserveScale(key, expectations.Delete, getAssignedNode(pod)) - p.enqueueHandler.Delete(evt, q) + p.enqueueHandler.Delete(ctx, evt, q) } } -func (p *podEventHandler) Update(evt event.UpdateEvent, q workqueue.RateLimitingInterface) { - p.enqueueHandler.Update(evt, q) +func (p *podEventHandler) Update(ctx context.Context, evt event.UpdateEvent, q workqueue.RateLimitingInterface) { + p.enqueueHandler.Update(ctx, evt, q) } -func (p *podEventHandler) Generic(evt event.GenericEvent, q workqueue.RateLimitingInterface) { -} - -var _ inject.Mapper = &podEventHandler{} - -func (p *podEventHandler) InjectScheme(s *runtime.Scheme) error { - return p.enqueueHandler.InjectScheme(s) -} - -var _ inject.Mapper = &podEventHandler{} - -func (p *podEventHandler) InjectMapper(m meta.RESTMapper) error { - return p.enqueueHandler.InjectMapper(m) +func (p *podEventHandler) Generic(ctx context.Context, evt event.GenericEvent, q workqueue.RateLimitingInterface) { } type enqueueBroadcastJobForNode struct { reader client.Reader } -func (p *enqueueBroadcastJobForNode) Create(evt event.CreateEvent, q workqueue.RateLimitingInterface) { +func (p *enqueueBroadcastJobForNode) Create(ctx context.Context, evt event.CreateEvent, q workqueue.RateLimitingInterface) { p.addNode(q, evt.Object) } -func (p *enqueueBroadcastJobForNode) Delete(evt event.DeleteEvent, q workqueue.RateLimitingInterface) { +func (p *enqueueBroadcastJobForNode) Delete(ctx context.Context, evt event.DeleteEvent, q workqueue.RateLimitingInterface) { p.deleteNode(q, evt.Object) } -func (p *enqueueBroadcastJobForNode) Generic(evt event.GenericEvent, q workqueue.RateLimitingInterface) { +func (p *enqueueBroadcastJobForNode) Generic(ctx context.Context, evt event.GenericEvent, q workqueue.RateLimitingInterface) { } -func (p *enqueueBroadcastJobForNode) Update(evt event.UpdateEvent, q workqueue.RateLimitingInterface) { +func (p *enqueueBroadcastJobForNode) Update(ctx context.Context, evt event.UpdateEvent, q workqueue.RateLimitingInterface) { p.updateNode(q, evt.ObjectOld, evt.ObjectNew) } diff --git a/pkg/controller/cloneset/cloneset_controller.go b/pkg/controller/cloneset/cloneset_controller.go index 3b2d444b26..da33460a75 100644 --- a/pkg/controller/cloneset/cloneset_controller.go +++ b/pkg/controller/cloneset/cloneset_controller.go @@ -123,7 +123,7 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error { } // Watch for changes to CloneSet - err = c.Watch(&source.Kind{Type: &appsv1alpha1.CloneSet{}}, &handler.EnqueueRequestForObject{}, predicate.Funcs{ + err = c.Watch(source.Kind(mgr.GetCache(), &appsv1alpha1.CloneSet{}), &handler.EnqueueRequestForObject{}, predicate.Funcs{ UpdateFunc: func(e event.UpdateEvent) bool { oldCS := e.ObjectOld.(*appsv1alpha1.CloneSet) newCS := e.ObjectNew.(*appsv1alpha1.CloneSet) @@ -139,13 +139,13 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error { } // Watch for changes to Pod - err = c.Watch(&source.Kind{Type: &v1.Pod{}}, &podEventHandler{Reader: mgr.GetCache()}) + err = c.Watch(source.Kind(mgr.GetCache(), &v1.Pod{}), &podEventHandler{Reader: mgr.GetCache()}) if err != nil { return err } // Watch for changes to PVC, just ensure cache updated - err = c.Watch(&source.Kind{Type: &v1.PersistentVolumeClaim{}}, &pvcEventHandler{}) + err = c.Watch(source.Kind(mgr.GetCache(), &v1.PersistentVolumeClaim{}), &pvcEventHandler{}) if err != nil { return err } diff --git a/pkg/controller/cloneset/cloneset_controller_test.go b/pkg/controller/cloneset/cloneset_controller_test.go index 3a3696a9f5..f82638b7ef 100644 --- a/pkg/controller/cloneset/cloneset_controller_test.go +++ b/pkg/controller/cloneset/cloneset_controller_test.go @@ -53,6 +53,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" "sigs.k8s.io/controller-runtime/pkg/manager" + metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server" "sigs.k8s.io/controller-runtime/pkg/reconcile" ) @@ -95,7 +96,7 @@ func TestReconcile(t *testing.T) { // Setup the Manager and Controller. Wrap the Controller Reconcile function so it writes each request to a // channel when it is finished. - mgr, err := manager.New(cfg, manager.Options{MetricsBindAddress: "0"}) + mgr, err := manager.New(cfg, manager.Options{Metrics: metricsserver.Options{BindAddress: "0"}}) _ = fieldindex.RegisterFieldIndexes(mgr.GetCache()) g.Expect(err).NotTo(gomega.HaveOccurred()) c = utilclient.NewClientFromManager(mgr, "test-cloneset-controller") diff --git a/pkg/controller/cloneset/cloneset_event_handler.go b/pkg/controller/cloneset/cloneset_event_handler.go index b4f4742d08..e7e9ee6352 100644 --- a/pkg/controller/cloneset/cloneset_event_handler.go +++ b/pkg/controller/cloneset/cloneset_event_handler.go @@ -54,12 +54,12 @@ type podEventHandler struct { var _ handler.EventHandler = &podEventHandler{} -func (e *podEventHandler) Create(evt event.CreateEvent, q workqueue.RateLimitingInterface) { +func (e *podEventHandler) Create(ctx context.Context, evt event.CreateEvent, q workqueue.RateLimitingInterface) { pod := evt.Object.(*v1.Pod) if pod.DeletionTimestamp != nil { // on a restart of the controller manager, it's possible a new pod shows up in a state that // is already pending deletion. Prevent the pod from being a creation observation. - e.Delete(event.DeleteEvent{Object: evt.Object}, q) + e.Delete(ctx, event.DeleteEvent{Object: evt.Object}, q) return } @@ -102,7 +102,7 @@ func (e *podEventHandler) Create(evt event.CreateEvent, q workqueue.RateLimiting } } -func (e *podEventHandler) Update(evt event.UpdateEvent, q workqueue.RateLimitingInterface) { +func (e *podEventHandler) Update(ctx context.Context, evt event.UpdateEvent, q workqueue.RateLimitingInterface) { oldPod := evt.ObjectOld.(*v1.Pod) curPod := evt.ObjectNew.(*v1.Pod) if curPod.ResourceVersion == oldPod.ResourceVersion { @@ -118,10 +118,10 @@ func (e *podEventHandler) Update(evt event.UpdateEvent, q workqueue.RateLimiting // for modification of the deletion timestamp and expect an rs to create more replicas asap, not wait // until the kubelet actually deletes the pod. This is different from the Phase of a pod changing, because // an rs never initiates a phase change, and so is never asleep waiting for the same. - e.Delete(event.DeleteEvent{Object: evt.ObjectNew}, q) + e.Delete(ctx, event.DeleteEvent{Object: evt.ObjectNew}, q) if labelChanged { // we don't need to check the oldPod.DeletionTimestamp because DeletionTimestamp cannot be unset. - e.Delete(event.DeleteEvent{Object: evt.ObjectOld}, q) + e.Delete(ctx, event.DeleteEvent{Object: evt.ObjectOld}, q) } return } @@ -181,7 +181,7 @@ func (e *podEventHandler) shouldIgnoreUpdate(req *reconcile.Request, oldPod, cur return clonesetcore.New(cs).IgnorePodUpdateEvent(oldPod, curPod) } -func (e *podEventHandler) Delete(evt event.DeleteEvent, q workqueue.RateLimitingInterface) { +func (e *podEventHandler) Delete(ctx context.Context, evt event.DeleteEvent, q workqueue.RateLimitingInterface) { pod, ok := evt.Object.(*v1.Pod) if !ok { klog.Errorf("DeleteEvent parse pod failed, DeleteStateUnknown: %#v, obj: %#v", evt.DeleteStateUnknown, evt.Object) @@ -204,7 +204,7 @@ func (e *podEventHandler) Delete(evt event.DeleteEvent, q workqueue.RateLimiting q.Add(*req) } -func (e *podEventHandler) Generic(evt event.GenericEvent, q workqueue.RateLimitingInterface) { +func (e *podEventHandler) Generic(ctx context.Context, evt event.GenericEvent, q workqueue.RateLimitingInterface) { } @@ -269,10 +269,10 @@ type pvcEventHandler struct { var _ handler.EventHandler = &pvcEventHandler{} -func (e *pvcEventHandler) Create(evt event.CreateEvent, q workqueue.RateLimitingInterface) { +func (e *pvcEventHandler) Create(ctx context.Context, evt event.CreateEvent, q workqueue.RateLimitingInterface) { pvc := evt.Object.(*v1.PersistentVolumeClaim) if pvc.DeletionTimestamp != nil { - e.Delete(event.DeleteEvent{Object: evt.Object}, q) + e.Delete(ctx, event.DeleteEvent{Object: evt.Object}, q) return } @@ -293,14 +293,14 @@ func (e *pvcEventHandler) Create(evt event.CreateEvent, q workqueue.RateLimiting } } -func (e *pvcEventHandler) Update(evt event.UpdateEvent, q workqueue.RateLimitingInterface) { +func (e *pvcEventHandler) Update(ctx context.Context, evt event.UpdateEvent, q workqueue.RateLimitingInterface) { pvc := evt.ObjectNew.(*v1.PersistentVolumeClaim) if pvc.DeletionTimestamp != nil { - e.Delete(event.DeleteEvent{Object: evt.ObjectNew}, q) + e.Delete(ctx, event.DeleteEvent{Object: evt.ObjectNew}, q) } } -func (e *pvcEventHandler) Delete(evt event.DeleteEvent, q workqueue.RateLimitingInterface) { +func (e *pvcEventHandler) Delete(ctx context.Context, evt event.DeleteEvent, q workqueue.RateLimitingInterface) { pvc, ok := evt.Object.(*v1.PersistentVolumeClaim) if !ok { klog.Errorf("DeleteEvent parse pvc failed, DeleteStateUnknown: %#v, obj: %#v", evt.DeleteStateUnknown, evt.Object) @@ -315,6 +315,6 @@ func (e *pvcEventHandler) Delete(evt event.DeleteEvent, q workqueue.RateLimiting } } -func (e *pvcEventHandler) Generic(evt event.GenericEvent, q workqueue.RateLimitingInterface) { +func (e *pvcEventHandler) Generic(ctx context.Context, evt event.GenericEvent, q workqueue.RateLimitingInterface) { } diff --git a/pkg/controller/cloneset/cloneset_event_handler_test.go b/pkg/controller/cloneset/cloneset_event_handler_test.go index fb5a2ede42..5f33e5d449 100644 --- a/pkg/controller/cloneset/cloneset_event_handler_test.go +++ b/pkg/controller/cloneset/cloneset_event_handler_test.go @@ -21,17 +21,18 @@ import ( "testing" "time" - appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" - clonesetutils "github.com/openkruise/kruise/pkg/controller/cloneset/utils" - "github.com/openkruise/kruise/pkg/features" - "github.com/openkruise/kruise/pkg/util/expectations" - "github.com/openkruise/kruise/pkg/util/feature" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/util/workqueue" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" "sigs.k8s.io/controller-runtime/pkg/event" + + appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" + clonesetutils "github.com/openkruise/kruise/pkg/controller/cloneset/utils" + "github.com/openkruise/kruise/pkg/features" + "github.com/openkruise/kruise/pkg/util/expectations" + "github.com/openkruise/kruise/pkg/util/feature" ) func newTestPodEventHandler(reader client.Reader) *podEventHandler { @@ -182,7 +183,7 @@ func TestEnqueueRequestForPodCreate(t *testing.T) { modifySatisfied = true } - enqueueHandler.Create(testCase.e, q) + enqueueHandler.Create(context.TODO(), testCase.e, q) if q.Len() != testCase.expectedQueueLen { t.Fatalf("%s failed, expected queue len %d, got queue len %d", testCase.name, testCase.expectedQueueLen, q.Len()) } @@ -734,7 +735,7 @@ func TestEnqueueRequestForPodUpdate(t *testing.T) { enqueueHandler := newTestPodEventHandler(fakeClient) q := workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "test-queue") - enqueueHandler.Update(testCase.e, q) + enqueueHandler.Update(context.TODO(), testCase.e, q) time.Sleep(time.Millisecond * 10) if q.Len() != testCase.expectedQueueLen { t.Fatalf("%s failed, expected queue len %d, got queue len %d", testCase.name, testCase.expectedQueueLen, q.Len()) diff --git a/pkg/controller/containerlaunchpriority/container_launch_priority_controller.go b/pkg/controller/containerlaunchpriority/container_launch_priority_controller.go index 82d315ff86..29f1304a4d 100644 --- a/pkg/controller/containerlaunchpriority/container_launch_priority_controller.go +++ b/pkg/controller/containerlaunchpriority/container_launch_priority_controller.go @@ -70,7 +70,7 @@ func add(mgr manager.Manager, r *ReconcileContainerLaunchPriority) error { return err } - err = c.Watch(&source.Kind{Type: &v1.Pod{}}, &handler.EnqueueRequestForObject{}, predicate.Funcs{ + err = c.Watch(source.Kind(mgr.GetCache(), &v1.Pod{}), &handler.EnqueueRequestForObject{}, predicate.Funcs{ CreateFunc: func(e event.CreateEvent) bool { pod := e.Object.(*v1.Pod) return shouldEnqueue(pod, mgr.GetCache()) diff --git a/pkg/controller/containerlaunchpriority/container_launch_priority_controller_test.go b/pkg/controller/containerlaunchpriority/container_launch_priority_controller_test.go index b418be173d..78fc8e7f7e 100644 --- a/pkg/controller/containerlaunchpriority/container_launch_priority_controller_test.go +++ b/pkg/controller/containerlaunchpriority/container_launch_priority_controller_test.go @@ -113,7 +113,7 @@ func TestReconcile(t *testing.T) { ObjectMeta: metav1.ObjectMeta{Namespace: metav1.NamespaceDefault, Name: "pod1-barrier"}, } - fakeClient := fake.NewFakeClientWithScheme(clientgoscheme.Scheme, pod0, pod1, barrier0, barrier1) + fakeClient := fake.NewClientBuilder().WithScheme(clientgoscheme.Scheme).WithRuntimeObjects(pod0, pod1, barrier0, barrier1).Build() reconciler := &ReconcileContainerLaunchPriority{Client: fakeClient} _, err := reconciler.Reconcile(context.TODO(), reconcile.Request{NamespacedName: types.NamespacedName{Namespace: pod0.Namespace, Name: pod0.Name}}) diff --git a/pkg/controller/containerrecreaterequest/crr_controller.go b/pkg/controller/containerrecreaterequest/crr_controller.go index a5d402fe15..9ac5119f8e 100644 --- a/pkg/controller/containerrecreaterequest/crr_controller.go +++ b/pkg/controller/containerrecreaterequest/crr_controller.go @@ -91,13 +91,13 @@ func add(mgr manager.Manager, r *ReconcileContainerRecreateRequest) error { } // Watch for changes to ContainerRecreateRequest - err = c.Watch(&source.Kind{Type: &appsv1alpha1.ContainerRecreateRequest{}}, &handler.EnqueueRequestForObject{}) + err = c.Watch(source.Kind(mgr.GetCache(), &appsv1alpha1.ContainerRecreateRequest{}), &handler.EnqueueRequestForObject{}) if err != nil { return err } // Watch for pod for jobs that have pod selector - err = c.Watch(&source.Kind{Type: &v1.Pod{}}, &podEventHandler{Reader: mgr.GetCache()}) + err = c.Watch(source.Kind(mgr.GetCache(), &v1.Pod{}), &podEventHandler{Reader: mgr.GetCache()}) if err != nil { return err } diff --git a/pkg/controller/containerrecreaterequest/crr_event_handler.go b/pkg/controller/containerrecreaterequest/crr_event_handler.go index 152a5ab6cb..2217af0b46 100644 --- a/pkg/controller/containerrecreaterequest/crr_event_handler.go +++ b/pkg/controller/containerrecreaterequest/crr_event_handler.go @@ -20,7 +20,6 @@ import ( "context" "reflect" - appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/util/workqueue" @@ -29,6 +28,8 @@ import ( "sigs.k8s.io/controller-runtime/pkg/event" "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" ) type podEventHandler struct { @@ -37,12 +38,12 @@ type podEventHandler struct { var _ handler.EventHandler = &podEventHandler{} -func (e *podEventHandler) Create(evt event.CreateEvent, q workqueue.RateLimitingInterface) { +func (e *podEventHandler) Create(ctx context.Context, evt event.CreateEvent, q workqueue.RateLimitingInterface) { obj := evt.Object.(*v1.Pod) e.handle(obj, q) } -func (e *podEventHandler) Update(evt event.UpdateEvent, q workqueue.RateLimitingInterface) { +func (e *podEventHandler) Update(ctx context.Context, evt event.UpdateEvent, q workqueue.RateLimitingInterface) { obj := evt.ObjectNew.(*v1.Pod) oldObj := evt.ObjectOld.(*v1.Pod) if oldObj.DeletionTimestamp == nil && obj.DeletionTimestamp != nil { @@ -55,12 +56,12 @@ func (e *podEventHandler) Update(evt event.UpdateEvent, q workqueue.RateLimiting } } -func (e *podEventHandler) Delete(evt event.DeleteEvent, q workqueue.RateLimitingInterface) { +func (e *podEventHandler) Delete(ctx context.Context, evt event.DeleteEvent, q workqueue.RateLimitingInterface) { obj := evt.Object.(*v1.Pod) e.handle(obj, q) } -func (e *podEventHandler) Generic(evt event.GenericEvent, q workqueue.RateLimitingInterface) { +func (e *podEventHandler) Generic(ctx context.Context, evt event.GenericEvent, q workqueue.RateLimitingInterface) { } func (e *podEventHandler) handle(pod *v1.Pod, q workqueue.RateLimitingInterface) { diff --git a/pkg/controller/daemonset/daemonset_controller.go b/pkg/controller/daemonset/daemonset_controller.go index 6a2ad5a6ee..7523d0190a 100644 --- a/pkg/controller/daemonset/daemonset_controller.go +++ b/pkg/controller/daemonset/daemonset_controller.go @@ -215,8 +215,9 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error { dsc := r.(*ReconcileDaemonSet) + logger := klog.FromContext(context.TODO()) // Watch for changes to DaemonSet - err = c.Watch(&source.Kind{Type: &appsv1alpha1.DaemonSet{}}, &handler.EnqueueRequestForObject{}, predicate.Funcs{ + err = c.Watch(source.Kind(mgr.GetCache(), &appsv1alpha1.DaemonSet{}), &handler.EnqueueRequestForObject{}, predicate.Funcs{ CreateFunc: func(e event.CreateEvent) bool { ds := e.Object.(*appsv1alpha1.DaemonSet) klog.V(4).Infof("Adding DaemonSet %s/%s", ds.Namespace, ds.Name) @@ -226,7 +227,7 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error { oldDS := e.ObjectOld.(*appsv1alpha1.DaemonSet) newDS := e.ObjectNew.(*appsv1alpha1.DaemonSet) if oldDS.UID != newDS.UID { - dsc.expectations.DeleteExpectations(keyFunc(oldDS)) + dsc.expectations.DeleteExpectations(logger, keyFunc(oldDS)) } klog.V(4).Infof("Updating DaemonSet %s/%s", newDS.Namespace, newDS.Name) return true @@ -234,7 +235,7 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error { DeleteFunc: func(e event.DeleteEvent) bool { ds := e.Object.(*appsv1alpha1.DaemonSet) klog.V(4).Infof("Deleting DaemonSet %s/%s", ds.Namespace, ds.Name) - dsc.expectations.DeleteExpectations(keyFunc(ds)) + dsc.expectations.DeleteExpectations(logger, keyFunc(ds)) newPodForDSCache.Delete(ds.UID) return true }, @@ -244,13 +245,13 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error { } // Watch for changes to Node. - err = c.Watch(&source.Kind{Type: &corev1.Node{}}, &nodeEventHandler{reader: mgr.GetCache()}) + err = c.Watch(source.Kind(mgr.GetCache(), &corev1.Node{}), &nodeEventHandler{reader: mgr.GetCache()}) if err != nil { return err } // Watch for changes to Pod created by DaemonSet - err = c.Watch(&source.Kind{Type: &corev1.Pod{}}, &podEventHandler{Reader: mgr.GetCache(), expectations: dsc.expectations}) + err = c.Watch(source.Kind(mgr.GetCache(), &corev1.Pod{}), &podEventHandler{Reader: mgr.GetCache(), expectations: dsc.expectations}) if err != nil { return err } @@ -363,12 +364,13 @@ func (dsc *ReconcileDaemonSet) getDaemonPods(ctx context.Context, ds *appsv1alph } func (dsc *ReconcileDaemonSet) syncDaemonSet(ctx context.Context, request reconcile.Request) error { + logger := klog.FromContext(ctx) dsKey := request.NamespacedName.String() ds, err := dsc.dsLister.DaemonSets(request.Namespace).Get(request.Name) if err != nil { if errors.IsNotFound(err) { klog.V(4).Infof("DaemonSet has been deleted %s", dsKey) - dsc.expectations.DeleteExpectations(dsKey) + dsc.expectations.DeleteExpectations(logger, dsKey) return nil } return fmt.Errorf("unable to retrieve DaemonSet %s from store: %v", dsKey, err) @@ -399,7 +401,7 @@ func (dsc *ReconcileDaemonSet) syncDaemonSet(ctx context.Context, request reconc } hash := cur.Labels[apps.DefaultDaemonSetUniqueLabelKey] - if !dsc.expectations.SatisfiedExpectations(dsKey) || !dsc.hasPodExpectationsSatisfied(ctx, ds) { + if !dsc.expectations.SatisfiedExpectations(logger, dsKey) || !dsc.hasPodExpectationsSatisfied(ctx, ds) { return dsc.updateDaemonSetStatus(ctx, ds, nodeList, hash, false) } @@ -435,7 +437,7 @@ func (dsc *ReconcileDaemonSet) syncDaemonSet(ctx context.Context, request reconc } // return and wait next reconcile if expectation changed to unsatisfied - if !dsc.expectations.SatisfiedExpectations(dsKey) || !dsc.hasPodExpectationsSatisfied(ctx, ds) { + if !dsc.expectations.SatisfiedExpectations(logger, dsKey) || !dsc.hasPodExpectationsSatisfied(ctx, ds) { return dsc.updateDaemonSetStatus(ctx, ds, nodeList, hash, false) } @@ -685,6 +687,7 @@ func (dsc *ReconcileDaemonSet) syncNodes(ctx context.Context, ds *appsv1alpha1.D } } + logger := klog.FromContext(ctx) dsKey := keyFunc(ds) createDiff := len(nodesNeedingDaemonPods) deleteDiff := len(podsToDelete) @@ -697,7 +700,7 @@ func (dsc *ReconcileDaemonSet) syncNodes(ctx context.Context, ds *appsv1alpha1.D deleteDiff = burstReplicas } - if err := dsc.expectations.SetExpectations(dsKey, createDiff, deleteDiff); err != nil { + if err := dsc.expectations.SetExpectations(logger, dsKey, createDiff, deleteDiff); err != nil { utilruntime.HandleError(err) } // error channel to communicate back failures. make the buffer big enough to avoid any blocking @@ -763,7 +766,7 @@ func (dsc *ReconcileDaemonSet) syncNodes(ctx context.Context, ds *appsv1alpha1.D } if err != nil { klog.V(2).Infof("Failed creation, decrementing expectations for set %q/%q", ds.Namespace, ds.Name) - dsc.expectations.CreationObserved(dsKey) + dsc.expectations.CreationObserved(logger, dsKey) errCh <- err utilruntime.HandleError(err) } @@ -774,7 +777,7 @@ func (dsc *ReconcileDaemonSet) syncNodes(ctx context.Context, ds *appsv1alpha1.D skippedPods := createDiff - (batchSize + pos) if errorCount < len(errCh) && skippedPods > 0 { klog.V(2).Infof("Slow-start failure. Skipping creation of %d pods, decrementing expectations for set %q/%q", skippedPods, ds.Namespace, ds.Name) - dsc.expectations.LowerExpectations(dsKey, skippedPods, 0) + dsc.expectations.LowerExpectations(logger, dsKey, skippedPods, 0) // The skipped pods will be retried later. The next controller resync will // retry the slow start process. break @@ -788,7 +791,7 @@ func (dsc *ReconcileDaemonSet) syncNodes(ctx context.Context, ds *appsv1alpha1.D go func(ix int) { defer deleteWait.Done() if err := dsc.podControl.DeletePod(ctx, ds.Namespace, podsToDelete[ix], ds); err != nil { - dsc.expectations.DeletionObserved(dsKey) + dsc.expectations.DeletionObserved(logger, dsKey) if !errors.IsNotFound(err) { klog.V(2).Infof("Failed deletion, decremented expectations for set %q/%q", ds.Namespace, ds.Name) errCh <- err diff --git a/pkg/controller/daemonset/daemonset_controller_test.go b/pkg/controller/daemonset/daemonset_controller_test.go index bd0e7d161b..dd5a3e9890 100644 --- a/pkg/controller/daemonset/daemonset_controller_test.go +++ b/pkg/controller/daemonset/daemonset_controller_test.go @@ -143,7 +143,7 @@ func (f *fakePodControl) CreatePods(ctx context.Context, namespace string, templ ds := object.(*appsv1alpha1.DaemonSet) dsKey, _ := controller.KeyFunc(ds) - f.expectations.CreationObserved(dsKey) + f.expectations.CreationObserved(klog.FromContext(ctx), dsKey) return nil } @@ -163,7 +163,7 @@ func (f *fakePodControl) DeletePod(ctx context.Context, namespace string, podID ds := object.(*appsv1alpha1.DaemonSet) dsKey, _ := controller.KeyFunc(ds) - f.expectations.DeletionObserved(dsKey) + f.expectations.DeletionObserved(klog.FromContext(ctx), dsKey) return nil } @@ -337,7 +337,7 @@ func clearExpectations(t *testing.T, manager *daemonSetsController, ds *appsv1al t.Errorf("Could not get key for daemon.") return } - manager.expectations.DeleteExpectations(key) + manager.expectations.DeleteExpectations(klog.FromContext(context.TODO()), key) now := manager.failedPodsBackoff.Clock.Now() hash, _ := currentDSHash(context.TODO(), manager, ds) diff --git a/pkg/controller/daemonset/daemonset_event_handler.go b/pkg/controller/daemonset/daemonset_event_handler.go index 26a33f3de5..2d80b10a22 100644 --- a/pkg/controller/daemonset/daemonset_event_handler.go +++ b/pkg/controller/daemonset/daemonset_event_handler.go @@ -53,12 +53,13 @@ func enqueueDaemonSet(q workqueue.RateLimitingInterface, ds *appsv1alpha1.Daemon }}) } -func (e *podEventHandler) Create(evt event.CreateEvent, q workqueue.RateLimitingInterface) { +func (e *podEventHandler) Create(ctx context.Context, evt event.CreateEvent, q workqueue.RateLimitingInterface) { + logger := klog.FromContext(ctx) pod := evt.Object.(*v1.Pod) if pod.DeletionTimestamp != nil { // on a restart of the controller manager, it's possible a new pod shows up in a state that // is already pending deletion. Prevent the pod from being a creation observation. - e.Delete(event.DeleteEvent{Object: evt.Object}, q) + e.Delete(ctx, event.DeleteEvent{Object: evt.Object}, q) return } @@ -69,7 +70,7 @@ func (e *podEventHandler) Create(evt event.CreateEvent, q workqueue.RateLimiting return } klog.V(4).Infof("Pod %s/%s added.", pod.Namespace, pod.Name) - e.expectations.CreationObserved(keyFunc(ds)) + e.expectations.CreationObserved(logger, keyFunc(ds)) enqueueDaemonSet(q, ds) return } @@ -96,7 +97,7 @@ func joinDaemonSetNames(dsList []*appsv1alpha1.DaemonSet) string { return strings.Join(names, ",") } -func (e *podEventHandler) Update(evt event.UpdateEvent, q workqueue.RateLimitingInterface) { +func (e *podEventHandler) Update(ctx context.Context, evt event.UpdateEvent, q workqueue.RateLimitingInterface) { oldPod := evt.ObjectOld.(*v1.Pod) curPod := evt.ObjectNew.(*v1.Pod) if curPod.ResourceVersion == oldPod.ResourceVersion { @@ -120,7 +121,7 @@ func (e *podEventHandler) Update(evt event.UpdateEvent, q workqueue.RateLimiting // and after such time has passed, the kubelet actually deletes it from the store. We receive an update // for modification of the deletion timestamp and expect an ds to create more replicas asap, not wait // until the kubelet actually deletes the pod. - e.deletePod(curPod, q, false) + e.deletePod(ctx, curPod, q, false) return } @@ -150,16 +151,17 @@ func (e *podEventHandler) Update(evt event.UpdateEvent, q workqueue.RateLimiting } } -func (e *podEventHandler) Delete(evt event.DeleteEvent, q workqueue.RateLimitingInterface) { +func (e *podEventHandler) Delete(ctx context.Context, evt event.DeleteEvent, q workqueue.RateLimitingInterface) { pod, ok := evt.Object.(*v1.Pod) if !ok { klog.Errorf("DeleteEvent parse pod failed, DeleteStateUnknown: %#v, obj: %#v", evt.DeleteStateUnknown, evt.Object) return } - e.deletePod(pod, q, true) + e.deletePod(ctx, pod, q, true) } -func (e *podEventHandler) deletePod(pod *v1.Pod, q workqueue.RateLimitingInterface, isDeleted bool) { +func (e *podEventHandler) deletePod(ctx context.Context, pod *v1.Pod, q workqueue.RateLimitingInterface, isDeleted bool) { + logger := klog.FromContext(ctx) controllerRef := metav1.GetControllerOf(pod) if controllerRef == nil { // No controller should care about orphans being deleted. @@ -171,7 +173,7 @@ func (e *podEventHandler) deletePod(pod *v1.Pod, q workqueue.RateLimitingInterfa } if _, loaded := e.deletionUIDCache.LoadOrStore(pod.UID, struct{}{}); !loaded { - e.expectations.DeletionObserved(keyFunc(ds)) + e.expectations.DeletionObserved(logger, keyFunc(ds)) } if isDeleted { e.deletionUIDCache.Delete(pod.UID) @@ -182,7 +184,7 @@ func (e *podEventHandler) deletePod(pod *v1.Pod, q workqueue.RateLimitingInterfa enqueueDaemonSet(q, ds) } -func (e *podEventHandler) Generic(evt event.GenericEvent, q workqueue.RateLimitingInterface) { +func (e *podEventHandler) Generic(ctx context.Context, evt event.GenericEvent, q workqueue.RateLimitingInterface) { } @@ -234,7 +236,7 @@ type nodeEventHandler struct { reader client.Reader } -func (e *nodeEventHandler) Create(evt event.CreateEvent, q workqueue.RateLimitingInterface) { +func (e *nodeEventHandler) Create(ctx context.Context, evt event.CreateEvent, q workqueue.RateLimitingInterface) { dsList := &appsv1alpha1.DaemonSetList{} err := e.reader.List(context.TODO(), dsList) if err != nil { @@ -254,7 +256,7 @@ func (e *nodeEventHandler) Create(evt event.CreateEvent, q workqueue.RateLimitin } } -func (e *nodeEventHandler) Update(evt event.UpdateEvent, q workqueue.RateLimitingInterface) { +func (e *nodeEventHandler) Update(ctx context.Context, evt event.UpdateEvent, q workqueue.RateLimitingInterface) { oldNode := evt.ObjectOld.(*v1.Node) curNode := evt.ObjectNew.(*v1.Node) if shouldIgnoreNodeUpdate(*oldNode, *curNode) { @@ -283,8 +285,8 @@ func (e *nodeEventHandler) Update(evt event.UpdateEvent, q workqueue.RateLimitin } } -func (e *nodeEventHandler) Delete(evt event.DeleteEvent, q workqueue.RateLimitingInterface) { +func (e *nodeEventHandler) Delete(ctx context.Context, evt event.DeleteEvent, q workqueue.RateLimitingInterface) { } -func (e *nodeEventHandler) Generic(evt event.GenericEvent, q workqueue.RateLimitingInterface) { +func (e *nodeEventHandler) Generic(ctx context.Context, evt event.GenericEvent, q workqueue.RateLimitingInterface) { } diff --git a/pkg/controller/daemonset/daemonset_event_handler_test.go b/pkg/controller/daemonset/daemonset_event_handler_test.go index 338a381c90..9e9e8ceabf 100644 --- a/pkg/controller/daemonset/daemonset_event_handler_test.go +++ b/pkg/controller/daemonset/daemonset_event_handler_test.go @@ -21,14 +21,16 @@ import ( "testing" "time" - appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/util/workqueue" + "k8s.io/klog/v2" kubecontroller "k8s.io/kubernetes/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" "sigs.k8s.io/controller-runtime/pkg/event" + + appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" ) func newTestPodEventHandler(reader client.Reader, expectations kubecontroller.ControllerExpectationsInterface) *podEventHandler { @@ -160,7 +162,7 @@ func TestEnqueueRequestForPodCreate(t *testing.T) { expectedQueueLen: 1, }, } - + logger := klog.FromContext(context.TODO()) for _, testCase := range cases { fakeClient := fake.NewClientBuilder().Build() for _, ds := range testCase.dss { @@ -172,22 +174,22 @@ func TestEnqueueRequestForPodCreate(t *testing.T) { q := workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "test-queue") for i := 0; i < len(testCase.alterExpectationCreationsAdds); i++ { - exp.ExpectCreations(testCase.alterExpectationCreationsKey, 1) + exp.ExpectCreations(logger, testCase.alterExpectationCreationsKey, 1) } if testCase.alterExpectationCreationsKey != "" { - if ok := exp.SatisfiedExpectations(testCase.alterExpectationCreationsKey); ok { + if ok := exp.SatisfiedExpectations(logger, testCase.alterExpectationCreationsKey); ok { t.Fatalf("%s before execute, should not be satisfied", testCase.name) } } - enqueueHandler.Create(testCase.e, q) + enqueueHandler.Create(context.TODO(), testCase.e, q) if q.Len() != testCase.expectedQueueLen { t.Fatalf("%s failed, expected queue len %d, got queue len %d", testCase.name, testCase.expectedQueueLen, q.Len()) } if testCase.alterExpectationCreationsKey != "" { - if ok := exp.SatisfiedExpectations(testCase.alterExpectationCreationsKey); !ok { + if ok := exp.SatisfiedExpectations(logger, testCase.alterExpectationCreationsKey); !ok { t.Fatalf("%s after execute, should be satisfied", testCase.name) } } @@ -654,7 +656,7 @@ func TestEnqueueRequestForPodUpdate(t *testing.T) { enqueueHandler := newTestPodEventHandler(fakeClient, exp) q := workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "test-queue") - enqueueHandler.Update(testCase.e, q) + enqueueHandler.Update(context.TODO(), testCase.e, q) time.Sleep(time.Millisecond * 10) if q.Len() != testCase.expectedQueueLen { t.Fatalf("%s failed, expected queue len %d, got queue len %d", testCase.name, testCase.expectedQueueLen, q.Len()) @@ -776,7 +778,7 @@ func TestEnqueueRequestForNodeCreate(t *testing.T) { enqueueHandler := newTestNodeEventHandler(fakeClient) q := workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "test-queue") - enqueueHandler.Create(testCase.e, q) + enqueueHandler.Create(context.TODO(), testCase.e, q) if q.Len() != testCase.expectedQueueLen { t.Fatalf("%s failed, expected queue len %d, got queue len %d", testCase.name, testCase.expectedQueueLen, q.Len()) } @@ -901,7 +903,7 @@ func TestEnqueueRequestForNodeUpdate(t *testing.T) { enqueueHandler := newTestNodeEventHandler(fakeClient) q := workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "test-queue") - enqueueHandler.Update(testCase.e, q) + enqueueHandler.Update(context.TODO(), testCase.e, q) if q.Len() != testCase.expectedQueueLen { t.Fatalf("%s failed, expected queue len %d, got queue len %d", testCase.name, testCase.expectedQueueLen, q.Len()) } diff --git a/pkg/controller/ephemeraljob/ephemeraljob_controller.go b/pkg/controller/ephemeraljob/ephemeraljob_controller.go index 8feb4a5dee..719d72ac5a 100644 --- a/pkg/controller/ephemeraljob/ephemeraljob_controller.go +++ b/pkg/controller/ephemeraljob/ephemeraljob_controller.go @@ -22,13 +22,6 @@ import ( "sort" "time" - appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" - clonesetutils "github.com/openkruise/kruise/pkg/controller/cloneset/utils" - "github.com/openkruise/kruise/pkg/controller/ephemeraljob/econtainer" - "github.com/openkruise/kruise/pkg/util" - utilclient "github.com/openkruise/kruise/pkg/util/client" - utildiscovery "github.com/openkruise/kruise/pkg/util/discovery" - "github.com/openkruise/kruise/pkg/util/expectations" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -42,6 +35,14 @@ import ( "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/reconcile" "sigs.k8s.io/controller-runtime/pkg/source" + + appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" + clonesetutils "github.com/openkruise/kruise/pkg/controller/cloneset/utils" + "github.com/openkruise/kruise/pkg/controller/ephemeraljob/econtainer" + "github.com/openkruise/kruise/pkg/util" + utilclient "github.com/openkruise/kruise/pkg/util/client" + utildiscovery "github.com/openkruise/kruise/pkg/util/discovery" + "github.com/openkruise/kruise/pkg/util/expectations" ) var ( @@ -82,12 +83,12 @@ func add(mgr manager.Manager, r *ReconcileEphemeralJob) error { } // Watch for changes to EphemeralJob - err = c.Watch(&source.Kind{Type: &appsv1alpha1.EphemeralJob{}}, &ejobHandler{mgr.GetCache()}) + err = c.Watch(source.Kind(mgr.GetCache(), &appsv1alpha1.EphemeralJob{}), &ejobHandler{mgr.GetCache()}) if err != nil { return err } // Watch for changes to Pod - err = c.Watch(&source.Kind{Type: &v1.Pod{}}, &podHandler{mgr.GetCache()}) + err = c.Watch(source.Kind(mgr.GetCache(), &v1.Pod{}), &podHandler{mgr.GetCache()}) if err != nil { return err } diff --git a/pkg/controller/ephemeraljob/ephemeraljob_event_handler.go b/pkg/controller/ephemeraljob/ephemeraljob_event_handler.go index aec3cae122..ec9d5c365b 100644 --- a/pkg/controller/ephemeraljob/ephemeraljob_event_handler.go +++ b/pkg/controller/ephemeraljob/ephemeraljob_event_handler.go @@ -4,8 +4,6 @@ import ( "context" "reflect" - appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" - "github.com/openkruise/kruise/pkg/util/expectations" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/util/workqueue" @@ -13,13 +11,16 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/event" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" + "github.com/openkruise/kruise/pkg/util/expectations" ) type podHandler struct { client.Reader } -func (e *podHandler) Create(evt event.CreateEvent, q workqueue.RateLimitingInterface) { +func (e *podHandler) Create(ctx context.Context, evt event.CreateEvent, q workqueue.RateLimitingInterface) { pod, ok := evt.Object.(*corev1.Pod) if !ok { return @@ -28,10 +29,10 @@ func (e *podHandler) Create(evt event.CreateEvent, q workqueue.RateLimitingInter e.handle(pod, q) } -func (e *podHandler) Generic(evt event.GenericEvent, q workqueue.RateLimitingInterface) { +func (e *podHandler) Generic(ctx context.Context, evt event.GenericEvent, q workqueue.RateLimitingInterface) { } -func (e *podHandler) Update(evt event.UpdateEvent, q workqueue.RateLimitingInterface) { +func (e *podHandler) Update(ctx context.Context, evt event.UpdateEvent, q workqueue.RateLimitingInterface) { oldPod := evt.ObjectOld.(*corev1.Pod) curPod := evt.ObjectNew.(*corev1.Pod) if curPod.ResourceVersion == oldPod.ResourceVersion { @@ -45,7 +46,7 @@ func (e *podHandler) Update(evt event.UpdateEvent, q workqueue.RateLimitingInter e.handle(curPod, q) } -func (e *podHandler) Delete(evt event.DeleteEvent, q workqueue.RateLimitingInterface) { +func (e *podHandler) Delete(ctx context.Context, evt event.DeleteEvent, q workqueue.RateLimitingInterface) { pod, ok := evt.Object.(*corev1.Pod) if !ok { return @@ -75,7 +76,7 @@ type ejobHandler struct { client.Reader } -func (e *ejobHandler) Create(evt event.CreateEvent, q workqueue.RateLimitingInterface) { +func (e *ejobHandler) Create(ctx context.Context, evt event.CreateEvent, q workqueue.RateLimitingInterface) { ejob, ok := evt.Object.(*appsv1alpha1.EphemeralJob) if !ok { return @@ -87,10 +88,10 @@ func (e *ejobHandler) Create(evt event.CreateEvent, q workqueue.RateLimitingInte q.Add(reconcile.Request{NamespacedName: types.NamespacedName{Namespace: ejob.Namespace, Name: ejob.Name}}) } -func (e *ejobHandler) Generic(evt event.GenericEvent, q workqueue.RateLimitingInterface) { +func (e *ejobHandler) Generic(ctx context.Context, evt event.GenericEvent, q workqueue.RateLimitingInterface) { } -func (e *ejobHandler) Update(evt event.UpdateEvent, q workqueue.RateLimitingInterface) { +func (e *ejobHandler) Update(ctx context.Context, evt event.UpdateEvent, q workqueue.RateLimitingInterface) { oldEJob := evt.ObjectOld.(*appsv1alpha1.EphemeralJob) curEJob := evt.ObjectNew.(*appsv1alpha1.EphemeralJob) if oldEJob.ResourceVersion == curEJob.ResourceVersion { @@ -112,7 +113,7 @@ func (e *ejobHandler) Update(evt event.UpdateEvent, q workqueue.RateLimitingInte } } -func (e *ejobHandler) Delete(evt event.DeleteEvent, q workqueue.RateLimitingInterface) { +func (e *ejobHandler) Delete(ctx context.Context, evt event.DeleteEvent, q workqueue.RateLimitingInterface) { ejob, ok := evt.Object.(*appsv1alpha1.EphemeralJob) if !ok { return diff --git a/pkg/controller/imagelistpulljob/imagelistpulljob_controller.go b/pkg/controller/imagelistpulljob/imagelistpulljob_controller.go index a7e0ccbe5c..c7f098b382 100644 --- a/pkg/controller/imagelistpulljob/imagelistpulljob_controller.go +++ b/pkg/controller/imagelistpulljob/imagelistpulljob_controller.go @@ -94,17 +94,15 @@ func add(mgr manager.Manager, r *ReconcileImageListPullJob) error { } // Watch for changes to ImageListPullJob - err = c.Watch(&source.Kind{Type: &appsv1alpha1.ImageListPullJob{}}, &handler.EnqueueRequestForObject{}) + err = c.Watch(source.Kind(mgr.GetCache(), &appsv1alpha1.ImageListPullJob{}), &handler.EnqueueRequestForObject{}) if err != nil { return err } // Watch for changes to ImagePullJob // todo the imagelistpulljob(status) will not change if the pull job status does not change significantly (ex. number of failed nodeimage changes from 1 to 2) - err = c.Watch(&source.Kind{Type: &appsv1alpha1.ImagePullJob{}}, &imagePullJobEventHandler{ - enqueueHandler: handler.EnqueueRequestForOwner{ - IsController: true, - OwnerType: &appsv1alpha1.ImageListPullJob{}, - }, + err = c.Watch(source.Kind(mgr.GetCache(), &appsv1alpha1.ImagePullJob{}), &imagePullJobEventHandler{ + enqueueHandler: handler.EnqueueRequestForOwner( + mgr.GetScheme(), mgr.GetRESTMapper(), &appsv1alpha1.ImageListPullJob{}, handler.OnlyControllerOwner()), }) if err != nil { return err diff --git a/pkg/controller/imagelistpulljob/imagelistpulljob_controller_test.go b/pkg/controller/imagelistpulljob/imagelistpulljob_controller_test.go index ffd5814fb4..0ca5b6950f 100644 --- a/pkg/controller/imagelistpulljob/imagelistpulljob_controller_test.go +++ b/pkg/controller/imagelistpulljob/imagelistpulljob_controller_test.go @@ -431,7 +431,7 @@ func createReconcileJob(scheme *k8sruntime.Scheme, initObjs ...client.Object) Re owners = append(owners, string(ref.UID)) } return owners - }).Build() + }).WithStatusSubresource(&appsv1alpha1.ImageListPullJob{}).Build() eventBroadcaster := record.NewBroadcaster() recorder := eventBroadcaster.NewRecorder(scheme, corev1.EventSource{Component: "imagelistpulljob-controller"}) reconcileJob := ReconcileImageListPullJob{ diff --git a/pkg/controller/imagelistpulljob/imagelistpulljob_event_handler.go b/pkg/controller/imagelistpulljob/imagelistpulljob_event_handler.go index 5ba293d273..fd8af782d5 100644 --- a/pkg/controller/imagelistpulljob/imagelistpulljob_event_handler.go +++ b/pkg/controller/imagelistpulljob/imagelistpulljob_event_handler.go @@ -17,23 +17,22 @@ limitations under the License. package imagelistpulljob import ( - "k8s.io/apimachinery/pkg/api/meta" + "context" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/util/workqueue" "k8s.io/klog/v2" "sigs.k8s.io/controller-runtime/pkg/event" "sigs.k8s.io/controller-runtime/pkg/handler" - "sigs.k8s.io/controller-runtime/pkg/runtime/inject" appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" "github.com/openkruise/kruise/pkg/util/expectations" ) type imagePullJobEventHandler struct { - enqueueHandler handler.EnqueueRequestForOwner + enqueueHandler handler.EventHandler } func isImageListPullJobController(controllerRef *metav1.OwnerReference) bool { @@ -45,45 +44,33 @@ func isImageListPullJobController(controllerRef *metav1.OwnerReference) bool { return controllerRef.Kind == controllerKind.Kind && refGV.Group == controllerKind.Group } -func (p *imagePullJobEventHandler) Create(evt event.CreateEvent, q workqueue.RateLimitingInterface) { +func (p *imagePullJobEventHandler) Create(ctx context.Context, evt event.CreateEvent, q workqueue.RateLimitingInterface) { job := evt.Object.(*appsv1alpha1.ImagePullJob) if job.DeletionTimestamp != nil { - p.Delete(event.DeleteEvent{Object: evt.Object}, q) + p.Delete(ctx, event.DeleteEvent{Object: evt.Object}, q) return } if controllerRef := metav1.GetControllerOf(job); controllerRef != nil && isImageListPullJobController(controllerRef) { key := types.NamespacedName{Namespace: job.Namespace, Name: controllerRef.Name}.String() scaleExpectations.ObserveScale(key, expectations.Create, job.Spec.Image) - p.enqueueHandler.Create(evt, q) + p.enqueueHandler.Create(ctx, evt, q) } } -func (p *imagePullJobEventHandler) Delete(evt event.DeleteEvent, q workqueue.RateLimitingInterface) { +func (p *imagePullJobEventHandler) Delete(ctx context.Context, evt event.DeleteEvent, q workqueue.RateLimitingInterface) { job := evt.Object.(*appsv1alpha1.ImagePullJob) if controllerRef := metav1.GetControllerOf(job); controllerRef != nil && isImageListPullJobController(controllerRef) { key := types.NamespacedName{Namespace: job.Namespace, Name: controllerRef.Name}.String() scaleExpectations.ObserveScale(key, expectations.Delete, job.Spec.Image) } - p.enqueueHandler.Delete(evt, q) + p.enqueueHandler.Delete(ctx, evt, q) } -func (p *imagePullJobEventHandler) Update(evt event.UpdateEvent, q workqueue.RateLimitingInterface) { +func (p *imagePullJobEventHandler) Update(ctx context.Context, evt event.UpdateEvent, q workqueue.RateLimitingInterface) { newJob := evt.ObjectNew.(*appsv1alpha1.ImagePullJob) resourceVersionExpectations.Expect(newJob) - p.enqueueHandler.Update(evt, q) -} - -func (p *imagePullJobEventHandler) Generic(evt event.GenericEvent, q workqueue.RateLimitingInterface) { + p.enqueueHandler.Update(ctx, evt, q) } -var _ inject.Mapper = &imagePullJobEventHandler{} - -func (p *imagePullJobEventHandler) InjectScheme(s *runtime.Scheme) error { - return p.enqueueHandler.InjectScheme(s) -} - -var _ inject.Mapper = &imagePullJobEventHandler{} - -func (p *imagePullJobEventHandler) InjectMapper(m meta.RESTMapper) error { - return p.enqueueHandler.InjectMapper(m) +func (p *imagePullJobEventHandler) Generic(ctx context.Context, evt event.GenericEvent, q workqueue.RateLimitingInterface) { } diff --git a/pkg/controller/imagepulljob/imagepulljob_controller.go b/pkg/controller/imagepulljob/imagepulljob_controller.go index 97395353b3..f4e0e8083c 100644 --- a/pkg/controller/imagepulljob/imagepulljob_controller.go +++ b/pkg/controller/imagepulljob/imagepulljob_controller.go @@ -107,25 +107,25 @@ func add(mgr manager.Manager, r *ReconcileImagePullJob) error { } // Watch for changes to ImagePullJob - err = c.Watch(&source.Kind{Type: &appsv1alpha1.ImagePullJob{}}, &handler.EnqueueRequestForObject{}) + err = c.Watch(source.Kind(mgr.GetCache(), &appsv1alpha1.ImagePullJob{}), &handler.EnqueueRequestForObject{}) if err != nil { return err } // Watch for nodeimage update to get image pull status - err = c.Watch(&source.Kind{Type: &appsv1alpha1.NodeImage{}}, &nodeImageEventHandler{Reader: mgr.GetCache()}) + err = c.Watch(source.Kind(mgr.GetCache(), &appsv1alpha1.NodeImage{}), &nodeImageEventHandler{Reader: mgr.GetCache()}) if err != nil { return err } // Watch for pod for jobs that have pod selector - err = c.Watch(&source.Kind{Type: &v1.Pod{}}, &podEventHandler{Reader: mgr.GetCache()}) + err = c.Watch(source.Kind(mgr.GetCache(), &v1.Pod{}), &podEventHandler{Reader: mgr.GetCache()}) if err != nil { return err } // Watch for secret for jobs that have pullSecrets - err = c.Watch(&source.Kind{Type: &v1.Secret{}}, &secretEventHandler{Reader: mgr.GetCache()}) + err = c.Watch(source.Kind(mgr.GetCache(), &v1.Secret{}), &secretEventHandler{Reader: mgr.GetCache()}) if err != nil { return err } diff --git a/pkg/controller/imagepulljob/imagepulljob_event_handler.go b/pkg/controller/imagepulljob/imagepulljob_event_handler.go index 579ce99e27..01e29a647a 100644 --- a/pkg/controller/imagepulljob/imagepulljob_event_handler.go +++ b/pkg/controller/imagepulljob/imagepulljob_event_handler.go @@ -20,12 +20,6 @@ import ( "context" "reflect" - appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" - daemonutil "github.com/openkruise/kruise/pkg/daemon/util" - kruiseutil "github.com/openkruise/kruise/pkg/util" - utilclient "github.com/openkruise/kruise/pkg/util/client" - "github.com/openkruise/kruise/pkg/util/expectations" - utilimagejob "github.com/openkruise/kruise/pkg/util/imagejob" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/sets" @@ -35,6 +29,13 @@ import ( "sigs.k8s.io/controller-runtime/pkg/event" "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" + daemonutil "github.com/openkruise/kruise/pkg/daemon/util" + kruiseutil "github.com/openkruise/kruise/pkg/util" + utilclient "github.com/openkruise/kruise/pkg/util/client" + "github.com/openkruise/kruise/pkg/util/expectations" + utilimagejob "github.com/openkruise/kruise/pkg/util/imagejob" ) type nodeImageEventHandler struct { @@ -43,12 +44,12 @@ type nodeImageEventHandler struct { var _ handler.EventHandler = &nodeImageEventHandler{} -func (e *nodeImageEventHandler) Create(evt event.CreateEvent, q workqueue.RateLimitingInterface) { +func (e *nodeImageEventHandler) Create(ctx context.Context, evt event.CreateEvent, q workqueue.RateLimitingInterface) { obj := evt.Object.(*appsv1alpha1.NodeImage) e.handle(obj, q) } -func (e *nodeImageEventHandler) Update(evt event.UpdateEvent, q workqueue.RateLimitingInterface) { +func (e *nodeImageEventHandler) Update(ctx context.Context, evt event.UpdateEvent, q workqueue.RateLimitingInterface) { obj := evt.ObjectNew.(*appsv1alpha1.NodeImage) oldObj := evt.ObjectOld.(*appsv1alpha1.NodeImage) if obj.DeletionTimestamp != nil { @@ -58,13 +59,13 @@ func (e *nodeImageEventHandler) Update(evt event.UpdateEvent, q workqueue.RateLi } } -func (e *nodeImageEventHandler) Delete(evt event.DeleteEvent, q workqueue.RateLimitingInterface) { +func (e *nodeImageEventHandler) Delete(ctx context.Context, evt event.DeleteEvent, q workqueue.RateLimitingInterface) { obj := evt.Object.(*appsv1alpha1.NodeImage) resourceVersionExpectations.Delete(obj) e.handle(obj, q) } -func (e *nodeImageEventHandler) Generic(evt event.GenericEvent, q workqueue.RateLimitingInterface) { +func (e *nodeImageEventHandler) Generic(ctx context.Context, evt event.GenericEvent, q workqueue.RateLimitingInterface) { } func (e *nodeImageEventHandler) handle(nodeImage *appsv1alpha1.NodeImage, q workqueue.RateLimitingInterface) { @@ -130,12 +131,12 @@ type podEventHandler struct { var _ handler.EventHandler = &podEventHandler{} -func (e *podEventHandler) Create(evt event.CreateEvent, q workqueue.RateLimitingInterface) { +func (e *podEventHandler) Create(ctx context.Context, evt event.CreateEvent, q workqueue.RateLimitingInterface) { obj := evt.Object.(*v1.Pod) e.handle(obj, q) } -func (e *podEventHandler) Update(evt event.UpdateEvent, q workqueue.RateLimitingInterface) { +func (e *podEventHandler) Update(ctx context.Context, evt event.UpdateEvent, q workqueue.RateLimitingInterface) { obj := evt.ObjectNew.(*v1.Pod) oldObj := evt.ObjectOld.(*v1.Pod) if obj.DeletionTimestamp != nil { @@ -145,12 +146,12 @@ func (e *podEventHandler) Update(evt event.UpdateEvent, q workqueue.RateLimiting } } -func (e *podEventHandler) Delete(evt event.DeleteEvent, q workqueue.RateLimitingInterface) { +func (e *podEventHandler) Delete(ctx context.Context, evt event.DeleteEvent, q workqueue.RateLimitingInterface) { obj := evt.Object.(*v1.Pod) e.handle(obj, q) } -func (e *podEventHandler) Generic(evt event.GenericEvent, q workqueue.RateLimitingInterface) { +func (e *podEventHandler) Generic(ctx context.Context, evt event.GenericEvent, q workqueue.RateLimitingInterface) { } func (e *podEventHandler) handle(pod *v1.Pod, q workqueue.RateLimitingInterface) { @@ -197,21 +198,21 @@ type secretEventHandler struct { var _ handler.EventHandler = &secretEventHandler{} -func (e *secretEventHandler) Create(evt event.CreateEvent, q workqueue.RateLimitingInterface) { +func (e *secretEventHandler) Create(ctx context.Context, evt event.CreateEvent, q workqueue.RateLimitingInterface) { obj := evt.Object.(*v1.Secret) e.handle(obj, q) } -func (e *secretEventHandler) Update(evt event.UpdateEvent, q workqueue.RateLimitingInterface) { +func (e *secretEventHandler) Update(ctx context.Context, evt event.UpdateEvent, q workqueue.RateLimitingInterface) { newObj := evt.ObjectNew.(*v1.Secret) oldObj := evt.ObjectOld.(*v1.Secret) e.handleUpdate(newObj, oldObj, q) } -func (e *secretEventHandler) Delete(evt event.DeleteEvent, q workqueue.RateLimitingInterface) { +func (e *secretEventHandler) Delete(ctx context.Context, evt event.DeleteEvent, q workqueue.RateLimitingInterface) { } -func (e *secretEventHandler) Generic(evt event.GenericEvent, q workqueue.RateLimitingInterface) { +func (e *secretEventHandler) Generic(ctx context.Context, evt event.GenericEvent, q workqueue.RateLimitingInterface) { } func (e *secretEventHandler) handle(secret *v1.Secret, q workqueue.RateLimitingInterface) { diff --git a/pkg/controller/nodeimage/nodeimage_controller.go b/pkg/controller/nodeimage/nodeimage_controller.go index a2bab6c1aa..58a033d555 100644 --- a/pkg/controller/nodeimage/nodeimage_controller.go +++ b/pkg/controller/nodeimage/nodeimage_controller.go @@ -111,19 +111,19 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error { } // Watch for changes to NodeImage - err = c.Watch(&source.Kind{Type: &appsv1alpha1.NodeImage{}}, &handler.EnqueueRequestForObject{}) + err = c.Watch(source.Kind(mgr.GetCache(), &appsv1alpha1.NodeImage{}), &handler.EnqueueRequestForObject{}) if err != nil { return err } // Watch for changes to Node - err = c.Watch(&source.Kind{Type: &v1.Node{}}, &nodeHandler{Reader: mgr.GetCache()}) + err = c.Watch(source.Kind(mgr.GetCache(), &v1.Node{}), &nodeHandler{Reader: mgr.GetCache()}) if err != nil { return err } // Watch for deletion to ImagePullJob - err = c.Watch(&source.Kind{Type: &appsv1alpha1.ImagePullJob{}}, &imagePullJobHandler{Reader: mgr.GetCache()}) + err = c.Watch(source.Kind(mgr.GetCache(), &appsv1alpha1.ImagePullJob{}), &imagePullJobHandler{Reader: mgr.GetCache()}) if err != nil { return err } diff --git a/pkg/controller/nodeimage/nodeimage_event_handler.go b/pkg/controller/nodeimage/nodeimage_event_handler.go index 06c2860497..4647bd2a7c 100644 --- a/pkg/controller/nodeimage/nodeimage_event_handler.go +++ b/pkg/controller/nodeimage/nodeimage_event_handler.go @@ -20,8 +20,6 @@ import ( "context" "reflect" - appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" - utilimagejob "github.com/openkruise/kruise/pkg/util/imagejob" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/types" @@ -31,6 +29,9 @@ import ( "sigs.k8s.io/controller-runtime/pkg/event" "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" + utilimagejob "github.com/openkruise/kruise/pkg/util/imagejob" ) const ( @@ -43,7 +44,7 @@ type nodeHandler struct { var _ handler.EventHandler = &nodeHandler{} -func (e *nodeHandler) Create(evt event.CreateEvent, q workqueue.RateLimitingInterface) { +func (e *nodeHandler) Create(ctx context.Context, evt event.CreateEvent, q workqueue.RateLimitingInterface) { node := evt.Object.(*v1.Node) if node.Labels["type"] == VirtualKubelet { return @@ -55,10 +56,10 @@ func (e *nodeHandler) Create(evt event.CreateEvent, q workqueue.RateLimitingInte e.nodeCreateOrUpdate(node, q) } -func (e *nodeHandler) Generic(evt event.GenericEvent, q workqueue.RateLimitingInterface) { +func (e *nodeHandler) Generic(ctx context.Context, evt event.GenericEvent, q workqueue.RateLimitingInterface) { } -func (e *nodeHandler) Update(evt event.UpdateEvent, q workqueue.RateLimitingInterface) { +func (e *nodeHandler) Update(ctx context.Context, evt event.UpdateEvent, q workqueue.RateLimitingInterface) { node := evt.ObjectNew.(*v1.Node) if node.Labels["type"] == VirtualKubelet { return @@ -70,7 +71,7 @@ func (e *nodeHandler) Update(evt event.UpdateEvent, q workqueue.RateLimitingInte } } -func (e *nodeHandler) Delete(evt event.DeleteEvent, q workqueue.RateLimitingInterface) { +func (e *nodeHandler) Delete(ctx context.Context, evt event.DeleteEvent, q workqueue.RateLimitingInterface) { node := evt.Object.(*v1.Node) if node.Labels["type"] == VirtualKubelet { return @@ -120,16 +121,16 @@ type imagePullJobHandler struct { client.Reader } -func (e *imagePullJobHandler) Create(evt event.CreateEvent, q workqueue.RateLimitingInterface) { +func (e *imagePullJobHandler) Create(ctx context.Context, evt event.CreateEvent, q workqueue.RateLimitingInterface) { } -func (e *imagePullJobHandler) Generic(evt event.GenericEvent, q workqueue.RateLimitingInterface) { +func (e *imagePullJobHandler) Generic(ctx context.Context, evt event.GenericEvent, q workqueue.RateLimitingInterface) { } -func (e *imagePullJobHandler) Update(evt event.UpdateEvent, q workqueue.RateLimitingInterface) { +func (e *imagePullJobHandler) Update(ctx context.Context, evt event.UpdateEvent, q workqueue.RateLimitingInterface) { } -func (e *imagePullJobHandler) Delete(evt event.DeleteEvent, q workqueue.RateLimitingInterface) { +func (e *imagePullJobHandler) Delete(ctx context.Context, evt event.DeleteEvent, q workqueue.RateLimitingInterface) { job := evt.Object.(*appsv1alpha1.ImagePullJob) nodeImageNames := utilimagejob.PopCachedNodeImagesForJob(job) for _, name := range nodeImageNames { diff --git a/pkg/controller/nodepodprobe/node_pod_probe_controller.go b/pkg/controller/nodepodprobe/node_pod_probe_controller.go index 4ff6792df3..ad4fff8a7b 100644 --- a/pkg/controller/nodepodprobe/node_pod_probe_controller.go +++ b/pkg/controller/nodepodprobe/node_pod_probe_controller.go @@ -22,14 +22,6 @@ import ( "reflect" "strings" - appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" - "github.com/openkruise/kruise/pkg/features" - "github.com/openkruise/kruise/pkg/util" - utilclient "github.com/openkruise/kruise/pkg/util/client" - "github.com/openkruise/kruise/pkg/util/controllerfinder" - utildiscovery "github.com/openkruise/kruise/pkg/util/discovery" - utilfeature "github.com/openkruise/kruise/pkg/util/feature" - "github.com/openkruise/kruise/pkg/util/ratelimiter" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" @@ -44,6 +36,15 @@ import ( "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/reconcile" "sigs.k8s.io/controller-runtime/pkg/source" + + appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" + "github.com/openkruise/kruise/pkg/features" + "github.com/openkruise/kruise/pkg/util" + utilclient "github.com/openkruise/kruise/pkg/util/client" + "github.com/openkruise/kruise/pkg/util/controllerfinder" + utildiscovery "github.com/openkruise/kruise/pkg/util/discovery" + utilfeature "github.com/openkruise/kruise/pkg/util/feature" + "github.com/openkruise/kruise/pkg/util/ratelimiter" ) func init() { @@ -92,17 +93,17 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error { } // watch for changes to NodePodProbe - if err = c.Watch(&source.Kind{Type: &appsv1alpha1.NodePodProbe{}}, &enqueueRequestForNodePodProbe{}); err != nil { + if err = c.Watch(source.Kind(mgr.GetCache(), &appsv1alpha1.NodePodProbe{}), &enqueueRequestForNodePodProbe{}); err != nil { return err } // watch for changes to pod - if err = c.Watch(&source.Kind{Type: &corev1.Pod{}}, &enqueueRequestForPod{reader: mgr.GetClient()}); err != nil { + if err = c.Watch(source.Kind(mgr.GetCache(), &corev1.Pod{}), &enqueueRequestForPod{reader: mgr.GetClient()}); err != nil { return err } // watch for changes to node - if err = c.Watch(&source.Kind{Type: &corev1.Node{}}, &enqueueRequestForNode{Reader: mgr.GetClient()}); err != nil { + if err = c.Watch(source.Kind(mgr.GetCache(), &corev1.Node{}), &enqueueRequestForNode{Reader: mgr.GetClient()}); err != nil { return err } @@ -361,6 +362,7 @@ func (r *ReconcileNodePodProbe) updatePodProbeStatus(pod *corev1.Pod, status app reflect.DeepEqual(oldMetadata.Annotations, podClone.Annotations) { return nil } + // todo: resolve https://github.com/openkruise/kruise/issues/1597 return r.Client.Status().Update(context.TODO(), podClone) }); err != nil { klog.Errorf("NodePodProbe patch pod(%s/%s) status failed: %s", podClone.Namespace, podClone.Name, err.Error()) diff --git a/pkg/controller/nodepodprobe/node_pod_probe_controller_test.go b/pkg/controller/nodepodprobe/node_pod_probe_controller_test.go index bd98f1c9dc..5c8afd74d4 100644 --- a/pkg/controller/nodepodprobe/node_pod_probe_controller_test.go +++ b/pkg/controller/nodepodprobe/node_pod_probe_controller_test.go @@ -23,8 +23,6 @@ import ( utilruntime "k8s.io/apimachinery/pkg/util/runtime" - appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" - "github.com/openkruise/kruise/pkg/util/controllerfinder" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" @@ -32,6 +30,9 @@ import ( ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" + + appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" + "github.com/openkruise/kruise/pkg/util/controllerfinder" ) func init() { @@ -43,519 +44,521 @@ func init() { var ( scheme *runtime.Scheme - demoPodProbeMarker = appsv1alpha1.PodProbeMarker{ - ObjectMeta: metav1.ObjectMeta{ - Name: "ppm-1", - }, - Spec: appsv1alpha1.PodProbeMarkerSpec{ - Selector: &metav1.LabelSelector{ - MatchLabels: map[string]string{ - "app": "test", - }, - }, - Probes: []appsv1alpha1.PodContainerProbe{ - { - Name: "healthy", - ContainerName: "main", - Probe: appsv1alpha1.ContainerProbeSpec{ - Probe: corev1.Probe{ - ProbeHandler: corev1.ProbeHandler{ - Exec: &corev1.ExecAction{ - Command: []string{"/bin/sh", "-c", "/healthy.sh"}, - }, - }, - }, - }, - PodConditionType: "game.kruise.io/healthy", - MarkerPolicy: []appsv1alpha1.ProbeMarkerPolicy{ - { - State: appsv1alpha1.ProbeSucceeded, - Annotations: map[string]string{ - "controller.kubernetes.io/pod-deletion-cost": "10", - }, - Labels: map[string]string{ - "server-healthy": "true", - }, - }, - { - State: appsv1alpha1.ProbeFailed, - Annotations: map[string]string{ - "controller.kubernetes.io/pod-deletion-cost": "-10", - }, - Labels: map[string]string{ - "server-healthy": "false", - }, - }, - }, - }, - }, - }, - } - - demoNodePodProbe = appsv1alpha1.NodePodProbe{ - ObjectMeta: metav1.ObjectMeta{ - Name: "node-1", - }, - Spec: appsv1alpha1.NodePodProbeSpec{ - PodProbes: []appsv1alpha1.PodProbe{ - { - Name: "pod-1", - UID: "pod-1-uid", - Probes: []appsv1alpha1.ContainerProbe{ - { - Name: "ppm-1#healthy", - ContainerName: "main", - Probe: appsv1alpha1.ContainerProbeSpec{ - Probe: corev1.Probe{ - ProbeHandler: corev1.ProbeHandler{ - Exec: &corev1.ExecAction{ - Command: []string{"/bin/sh", "-c", "/healthy.sh"}, - }, - }, - }, - }, - }, - }, - }, - }, - }, - } + //demoPodProbeMarker = appsv1alpha1.PodProbeMarker{ + // ObjectMeta: metav1.ObjectMeta{ + // Name: "ppm-1", + // }, + // Spec: appsv1alpha1.PodProbeMarkerSpec{ + // Selector: &metav1.LabelSelector{ + // MatchLabels: map[string]string{ + // "app": "test", + // }, + // }, + // Probes: []appsv1alpha1.PodContainerProbe{ + // { + // Name: "healthy", + // ContainerName: "main", + // Probe: appsv1alpha1.ContainerProbeSpec{ + // Probe: corev1.Probe{ + // ProbeHandler: corev1.ProbeHandler{ + // Exec: &corev1.ExecAction{ + // Command: []string{"/bin/sh", "-c", "/healthy.sh"}, + // }, + // }, + // }, + // }, + // PodConditionType: "game.kruise.io/healthy", + // MarkerPolicy: []appsv1alpha1.ProbeMarkerPolicy{ + // { + // State: appsv1alpha1.ProbeSucceeded, + // Annotations: map[string]string{ + // "controller.kubernetes.io/pod-deletion-cost": "10", + // }, + // Labels: map[string]string{ + // "server-healthy": "true", + // }, + // }, + // { + // State: appsv1alpha1.ProbeFailed, + // Annotations: map[string]string{ + // "controller.kubernetes.io/pod-deletion-cost": "-10", + // }, + // Labels: map[string]string{ + // "server-healthy": "false", + // }, + // }, + // }, + // }, + // }, + // }, + //} + // + //demoNodePodProbe = appsv1alpha1.NodePodProbe{ + // ObjectMeta: metav1.ObjectMeta{ + // Name: "node-1", + // }, + // Spec: appsv1alpha1.NodePodProbeSpec{ + // PodProbes: []appsv1alpha1.PodProbe{ + // { + // Name: "pod-1", + // UID: "pod-1-uid", + // Probes: []appsv1alpha1.ContainerProbe{ + // { + // Name: "ppm-1#healthy", + // ContainerName: "main", + // Probe: appsv1alpha1.ContainerProbeSpec{ + // Probe: corev1.Probe{ + // ProbeHandler: corev1.ProbeHandler{ + // Exec: &corev1.ExecAction{ + // Command: []string{"/bin/sh", "-c", "/healthy.sh"}, + // }, + // }, + // }, + // }, + // }, + // }, + // }, + // }, + // }, + //} ) -func TestSyncNodePodProbe(t *testing.T) { - cases := []struct { - name string - req ctrl.Request - getPods func() []*corev1.Pod - getPodProbeMarkers func() []*appsv1alpha1.PodProbeMarker - getNodePodProbes func() []*appsv1alpha1.NodePodProbe - getNode func() []*corev1.Node - expectPods func() []*corev1.Pod - }{ - { - name: "test1, probe success", - req: ctrl.Request{ - NamespacedName: types.NamespacedName{ - Name: demoNodePodProbe.Name, - }, - }, - getNode: func() []*corev1.Node { - nodes := []*corev1.Node{ - { - ObjectMeta: metav1.ObjectMeta{ - Name: "node-1", - }, - }, - } - return nodes - }, - getPods: func() []*corev1.Pod { - pods := []*corev1.Pod{ - { - ObjectMeta: metav1.ObjectMeta{ - Name: "pod-1", - Labels: map[string]string{ - "app": "test", - }, - UID: types.UID("pod-1-uid"), - }, - Spec: corev1.PodSpec{ - NodeName: "node-1", - }, - }, - { - ObjectMeta: metav1.ObjectMeta{ - Name: "pod-2", - Labels: map[string]string{ - "app": "test", - }, - UID: types.UID("pod-2-uid"), - }, - Spec: corev1.PodSpec{ - NodeName: "node-1", - }, - }, - } - return pods - }, - getPodProbeMarkers: func() []*appsv1alpha1.PodProbeMarker { - ppms := []*appsv1alpha1.PodProbeMarker{ - demoPodProbeMarker.DeepCopy(), - } - return ppms - }, - getNodePodProbes: func() []*appsv1alpha1.NodePodProbe { - demo := demoNodePodProbe.DeepCopy() - podProbe2 := appsv1alpha1.PodProbe{ - Name: "pod-2", - UID: "pod-2-uid", - Probes: []appsv1alpha1.ContainerProbe{ - { - Name: "ppm-1#healthy", - ContainerName: "main", - Probe: appsv1alpha1.ContainerProbeSpec{ - Probe: corev1.Probe{ - ProbeHandler: corev1.ProbeHandler{ - Exec: &corev1.ExecAction{ - Command: []string{"/bin/sh", "-c", "/healthy.sh"}, - }, - }, - }, - }, - }, - }, - } - demo.Spec.PodProbes = append(demo.Spec.PodProbes, podProbe2) - demo.Status = appsv1alpha1.NodePodProbeStatus{ - PodProbeStatuses: []appsv1alpha1.PodProbeStatus{ - { - Name: "pod-1", - UID: "pod-1-uid", - ProbeStates: []appsv1alpha1.ContainerProbeState{ - { - Name: "ppm-1#healthy", - State: appsv1alpha1.ProbeSucceeded, - }, - }, - }, - { - Name: "pod-2", - UID: "pod-2-uid", - ProbeStates: []appsv1alpha1.ContainerProbeState{ - { - Name: "ppm-1#healthy", - State: appsv1alpha1.ProbeFailed, - }, - }, - }, - }, - } - return []*appsv1alpha1.NodePodProbe{demo} - }, - expectPods: func() []*corev1.Pod { - pods := []*corev1.Pod{ - { - ObjectMeta: metav1.ObjectMeta{ - Name: "pod-1", - Labels: map[string]string{ - "app": "test", - "server-healthy": "true", - }, - UID: types.UID("pod-1-uid"), - Annotations: map[string]string{ - "controller.kubernetes.io/pod-deletion-cost": "10", - }, - }, - Spec: corev1.PodSpec{ - NodeName: "node-1", - }, - Status: corev1.PodStatus{ - Conditions: []corev1.PodCondition{ - { - Type: corev1.PodConditionType("game.kruise.io/healthy"), - Status: corev1.ConditionTrue, - }, - }, - }, - }, - { - ObjectMeta: metav1.ObjectMeta{ - Name: "pod-2", - Labels: map[string]string{ - "app": "test", - "server-healthy": "false", - }, - UID: types.UID("pod-2-uid"), - Annotations: map[string]string{ - "controller.kubernetes.io/pod-deletion-cost": "-10", - }, - }, - Spec: corev1.PodSpec{ - NodeName: "node-1", - }, - Status: corev1.PodStatus{ - Conditions: []corev1.PodCondition{ - { - Type: corev1.PodConditionType("game.kruise.io/healthy"), - Status: corev1.ConditionFalse, - }, - }, - }, - }, - } - return pods - }, - }, - { - name: "test2, probe failed", - req: ctrl.Request{ - NamespacedName: types.NamespacedName{ - Name: demoNodePodProbe.Name, - }, - }, - getNode: func() []*corev1.Node { - nodes := []*corev1.Node{ - { - ObjectMeta: metav1.ObjectMeta{ - Name: "node-1", - }, - }, - } - return nodes - }, - getPods: func() []*corev1.Pod { - pods := []*corev1.Pod{ - { - ObjectMeta: metav1.ObjectMeta{ - Name: "pod-1", - UID: types.UID("pod-1-uid"), - Labels: map[string]string{ - "app": "test", - "server-healthy": "true", - }, - Annotations: map[string]string{ - "controller.kubernetes.io/pod-deletion-cost": "10", - }, - }, - Spec: corev1.PodSpec{ - NodeName: "node-1", - }, - Status: corev1.PodStatus{ - Conditions: []corev1.PodCondition{ - { - Type: corev1.PodConditionType("game.kruise.io/healthy"), - Status: corev1.ConditionTrue, - }, - { - Type: corev1.PodConditionType("game.kruise.io/other"), - Status: corev1.ConditionTrue, - }, - }, - }, - }, - } - return pods - }, - getPodProbeMarkers: func() []*appsv1alpha1.PodProbeMarker { - demo := demoPodProbeMarker.DeepCopy() - demo.Spec.Probes[0].MarkerPolicy = demo.Spec.Probes[0].MarkerPolicy[:1] - return []*appsv1alpha1.PodProbeMarker{demo} - }, - getNodePodProbes: func() []*appsv1alpha1.NodePodProbe { - demo := demoNodePodProbe.DeepCopy() - demo.Status = appsv1alpha1.NodePodProbeStatus{ - PodProbeStatuses: []appsv1alpha1.PodProbeStatus{ - { - Name: "pod-1", - UID: "pod-1-uid", - ProbeStates: []appsv1alpha1.ContainerProbeState{ - { - Name: "ppm-1#healthy", - State: appsv1alpha1.ProbeFailed, - }, - }, - }, - }, - } - return []*appsv1alpha1.NodePodProbe{demo} - }, - expectPods: func() []*corev1.Pod { - pods := []*corev1.Pod{ - { - ObjectMeta: metav1.ObjectMeta{ - Name: "pod-1", - UID: types.UID("pod-1-uid"), - Labels: map[string]string{ - "app": "test", - }, - }, - Spec: corev1.PodSpec{ - NodeName: "node-1", - }, - Status: corev1.PodStatus{ - Conditions: []corev1.PodCondition{ - { - Type: corev1.PodConditionType("game.kruise.io/healthy"), - Status: corev1.ConditionFalse, - }, - { - Type: corev1.PodConditionType("game.kruise.io/other"), - Status: corev1.ConditionTrue, - }, - }, - }, - }, - } - return pods - }, - }, - { - name: "test3, marker policy", - req: ctrl.Request{ - NamespacedName: types.NamespacedName{ - Name: demoNodePodProbe.Name, - }, - }, - getNode: func() []*corev1.Node { - nodes := []*corev1.Node{ - { - ObjectMeta: metav1.ObjectMeta{ - Name: "node-1", - }, - }, - } - return nodes - }, - getPods: func() []*corev1.Pod { - pods := []*corev1.Pod{ - { - ObjectMeta: metav1.ObjectMeta{ - Name: "pod-1", - UID: types.UID("pod-1-uid"), - Labels: map[string]string{ - "app": "test", - "server-healthy": "true", - "success": "true", - }, - Annotations: map[string]string{ - "controller.kubernetes.io/pod-deletion-cost": "10", - "success": "true", - }, - }, - Spec: corev1.PodSpec{ - NodeName: "node-1", - }, - }, - } - return pods - }, - getPodProbeMarkers: func() []*appsv1alpha1.PodProbeMarker { - demo := demoPodProbeMarker.DeepCopy() - demo.Spec.Probes[0].PodConditionType = "" - demo.Spec.Probes[0].MarkerPolicy = []appsv1alpha1.ProbeMarkerPolicy{ - { - State: appsv1alpha1.ProbeSucceeded, - Annotations: map[string]string{ - "controller.kubernetes.io/pod-deletion-cost": "10", - "success": "true", - }, - Labels: map[string]string{ - "server-healthy": "true", - "success": "true", - }, - }, - { - State: appsv1alpha1.ProbeFailed, - Annotations: map[string]string{ - "controller.kubernetes.io/pod-deletion-cost": "-10", - "failed": "true", - }, - Labels: map[string]string{ - "failed": "true", - }, - }, - } - return []*appsv1alpha1.PodProbeMarker{demo} - }, - getNodePodProbes: func() []*appsv1alpha1.NodePodProbe { - demo := demoNodePodProbe.DeepCopy() - demo.Status = appsv1alpha1.NodePodProbeStatus{ - PodProbeStatuses: []appsv1alpha1.PodProbeStatus{ - { - Name: "pod-1", - UID: "pod-1-uid", - ProbeStates: []appsv1alpha1.ContainerProbeState{ - { - Name: "ppm-1#healthy", - State: appsv1alpha1.ProbeFailed, - }, - }, - }, - }, - } - return []*appsv1alpha1.NodePodProbe{demo} - }, - expectPods: func() []*corev1.Pod { - pods := []*corev1.Pod{ - { - ObjectMeta: metav1.ObjectMeta{ - Name: "pod-1", - UID: types.UID("pod-1-uid"), - Labels: map[string]string{ - "app": "test", - "failed": "true", - }, - Annotations: map[string]string{ - "controller.kubernetes.io/pod-deletion-cost": "-10", - "failed": "true", - }, - }, - Spec: corev1.PodSpec{ - NodeName: "node-1", - }, - }, - } - return pods - }, - }, - } - - for _, cs := range cases { - t.Run(cs.name, func(t *testing.T) { - fakeClient := fake.NewClientBuilder().WithScheme(scheme).Build() - for _, obj := range cs.getPods() { - err := fakeClient.Create(context.TODO(), obj.DeepCopy()) - if err != nil { - t.Fatalf("create Pod failed: %s", err.Error()) - } - } - for _, obj := range cs.getPodProbeMarkers() { - err := fakeClient.Create(context.TODO(), obj.DeepCopy()) - if err != nil { - t.Fatalf("create PodProbeMarker failed: %s", err.Error()) - } - } - for _, obj := range cs.getNodePodProbes() { - err := fakeClient.Create(context.TODO(), obj.DeepCopy()) - if err != nil { - t.Fatalf("create NodePodProbes failed: %s", err.Error()) - } - } - for _, obj := range cs.getNode() { - err := fakeClient.Create(context.TODO(), obj.DeepCopy()) - if err != nil { - t.Fatalf("create Node failed: %s", err.Error()) - } - } - controllerfinder.Finder = &controllerfinder.ControllerFinder{Client: fakeClient} - recon := ReconcileNodePodProbe{Client: fakeClient} - _, err := recon.Reconcile(context.TODO(), cs.req) - if err != nil { - t.Fatalf("Reconcile failed: %s", err.Error()) - } - if !checkPodMarkerEqual(fakeClient, t, cs.expectPods()) { - t.Fatalf("Reconcile failed") - } - }) - } -} +// +//func TestSyncNodePodProbe(t *testing.T) { +// cases := []struct { +// name string +// req ctrl.Request +// getPods func() []*corev1.Pod +// getPodProbeMarkers func() []*appsv1alpha1.PodProbeMarker +// getNodePodProbes func() []*appsv1alpha1.NodePodProbe +// getNode func() []*corev1.Node +// expectPods func() []*corev1.Pod +// }{ +// { +// name: "test1, probe success", +// req: ctrl.Request{ +// NamespacedName: types.NamespacedName{ +// Name: demoNodePodProbe.Name, +// }, +// }, +// getNode: func() []*corev1.Node { +// nodes := []*corev1.Node{ +// { +// ObjectMeta: metav1.ObjectMeta{ +// Name: "node-1", +// }, +// }, +// } +// return nodes +// }, +// getPods: func() []*corev1.Pod { +// pods := []*corev1.Pod{ +// { +// ObjectMeta: metav1.ObjectMeta{ +// Name: "pod-1", +// Labels: map[string]string{ +// "app": "test", +// }, +// UID: types.UID("pod-1-uid"), +// }, +// Spec: corev1.PodSpec{ +// NodeName: "node-1", +// }, +// }, +// { +// ObjectMeta: metav1.ObjectMeta{ +// Name: "pod-2", +// Labels: map[string]string{ +// "app": "test", +// }, +// UID: types.UID("pod-2-uid"), +// }, +// Spec: corev1.PodSpec{ +// NodeName: "node-1", +// }, +// }, +// } +// return pods +// }, +// getPodProbeMarkers: func() []*appsv1alpha1.PodProbeMarker { +// ppms := []*appsv1alpha1.PodProbeMarker{ +// demoPodProbeMarker.DeepCopy(), +// } +// return ppms +// }, +// getNodePodProbes: func() []*appsv1alpha1.NodePodProbe { +// demo := demoNodePodProbe.DeepCopy() +// podProbe2 := appsv1alpha1.PodProbe{ +// Name: "pod-2", +// UID: "pod-2-uid", +// Probes: []appsv1alpha1.ContainerProbe{ +// { +// Name: "ppm-1#healthy", +// ContainerName: "main", +// Probe: appsv1alpha1.ContainerProbeSpec{ +// Probe: corev1.Probe{ +// ProbeHandler: corev1.ProbeHandler{ +// Exec: &corev1.ExecAction{ +// Command: []string{"/bin/sh", "-c", "/healthy.sh"}, +// }, +// }, +// }, +// }, +// }, +// }, +// } +// demo.Spec.PodProbes = append(demo.Spec.PodProbes, podProbe2) +// demo.Status = appsv1alpha1.NodePodProbeStatus{ +// PodProbeStatuses: []appsv1alpha1.PodProbeStatus{ +// { +// Name: "pod-1", +// UID: "pod-1-uid", +// ProbeStates: []appsv1alpha1.ContainerProbeState{ +// { +// Name: "ppm-1#healthy", +// State: appsv1alpha1.ProbeSucceeded, +// }, +// }, +// }, +// { +// Name: "pod-2", +// UID: "pod-2-uid", +// ProbeStates: []appsv1alpha1.ContainerProbeState{ +// { +// Name: "ppm-1#healthy", +// State: appsv1alpha1.ProbeFailed, +// }, +// }, +// }, +// }, +// } +// return []*appsv1alpha1.NodePodProbe{demo} +// }, +// expectPods: func() []*corev1.Pod { +// pods := []*corev1.Pod{ +// { +// ObjectMeta: metav1.ObjectMeta{ +// Name: "pod-1", +// Labels: map[string]string{ +// "app": "test", +// "server-healthy": "true", +// }, +// UID: types.UID("pod-1-uid"), +// Annotations: map[string]string{ +// "controller.kubernetes.io/pod-deletion-cost": "10", +// }, +// }, +// Spec: corev1.PodSpec{ +// NodeName: "node-1", +// }, +// Status: corev1.PodStatus{ +// Conditions: []corev1.PodCondition{ +// { +// Type: corev1.PodConditionType("game.kruise.io/healthy"), +// Status: corev1.ConditionTrue, +// }, +// }, +// }, +// }, +// { +// ObjectMeta: metav1.ObjectMeta{ +// Name: "pod-2", +// Labels: map[string]string{ +// "app": "test", +// "server-healthy": "false", +// }, +// UID: types.UID("pod-2-uid"), +// Annotations: map[string]string{ +// "controller.kubernetes.io/pod-deletion-cost": "-10", +// }, +// }, +// Spec: corev1.PodSpec{ +// NodeName: "node-1", +// }, +// Status: corev1.PodStatus{ +// Conditions: []corev1.PodCondition{ +// { +// Type: corev1.PodConditionType("game.kruise.io/healthy"), +// Status: corev1.ConditionFalse, +// }, +// }, +// }, +// }, +// } +// return pods +// }, +// }, +// { +// name: "test2, probe failed", +// req: ctrl.Request{ +// NamespacedName: types.NamespacedName{ +// Name: demoNodePodProbe.Name, +// }, +// }, +// getNode: func() []*corev1.Node { +// nodes := []*corev1.Node{ +// { +// ObjectMeta: metav1.ObjectMeta{ +// Name: "node-1", +// }, +// }, +// } +// return nodes +// }, +// getPods: func() []*corev1.Pod { +// pods := []*corev1.Pod{ +// { +// ObjectMeta: metav1.ObjectMeta{ +// Name: "pod-1", +// UID: types.UID("pod-1-uid"), +// Labels: map[string]string{ +// "app": "test", +// "server-healthy": "true", +// }, +// Annotations: map[string]string{ +// "controller.kubernetes.io/pod-deletion-cost": "10", +// }, +// }, +// Spec: corev1.PodSpec{ +// NodeName: "node-1", +// }, +// Status: corev1.PodStatus{ +// Conditions: []corev1.PodCondition{ +// { +// Type: corev1.PodConditionType("game.kruise.io/healthy"), +// Status: corev1.ConditionTrue, +// }, +// { +// Type: corev1.PodConditionType("game.kruise.io/other"), +// Status: corev1.ConditionTrue, +// }, +// }, +// }, +// }, +// } +// return pods +// }, +// getPodProbeMarkers: func() []*appsv1alpha1.PodProbeMarker { +// demo := demoPodProbeMarker.DeepCopy() +// demo.Spec.Probes[0].MarkerPolicy = demo.Spec.Probes[0].MarkerPolicy[:1] +// return []*appsv1alpha1.PodProbeMarker{demo} +// }, +// getNodePodProbes: func() []*appsv1alpha1.NodePodProbe { +// demo := demoNodePodProbe.DeepCopy() +// demo.Status = appsv1alpha1.NodePodProbeStatus{ +// PodProbeStatuses: []appsv1alpha1.PodProbeStatus{ +// { +// Name: "pod-1", +// UID: "pod-1-uid", +// ProbeStates: []appsv1alpha1.ContainerProbeState{ +// { +// Name: "ppm-1#healthy", +// State: appsv1alpha1.ProbeFailed, +// }, +// }, +// }, +// }, +// } +// return []*appsv1alpha1.NodePodProbe{demo} +// }, +// expectPods: func() []*corev1.Pod { +// pods := []*corev1.Pod{ +// { +// ObjectMeta: metav1.ObjectMeta{ +// Name: "pod-1", +// UID: types.UID("pod-1-uid"), +// Labels: map[string]string{ +// "app": "test", +// }, +// }, +// Spec: corev1.PodSpec{ +// NodeName: "node-1", +// }, +// Status: corev1.PodStatus{ +// Conditions: []corev1.PodCondition{ +// { +// Type: corev1.PodConditionType("game.kruise.io/healthy"), +// Status: corev1.ConditionFalse, +// }, +// { +// Type: corev1.PodConditionType("game.kruise.io/other"), +// Status: corev1.ConditionTrue, +// }, +// }, +// }, +// }, +// } +// return pods +// }, +// }, +// { +// name: "test3, marker policy", +// req: ctrl.Request{ +// NamespacedName: types.NamespacedName{ +// Name: demoNodePodProbe.Name, +// }, +// }, +// getNode: func() []*corev1.Node { +// nodes := []*corev1.Node{ +// { +// ObjectMeta: metav1.ObjectMeta{ +// Name: "node-1", +// }, +// }, +// } +// return nodes +// }, +// getPods: func() []*corev1.Pod { +// pods := []*corev1.Pod{ +// { +// ObjectMeta: metav1.ObjectMeta{ +// Name: "pod-1", +// UID: types.UID("pod-1-uid"), +// Labels: map[string]string{ +// "app": "test", +// "server-healthy": "true", +// "success": "true", +// }, +// Annotations: map[string]string{ +// "controller.kubernetes.io/pod-deletion-cost": "10", +// "success": "true", +// }, +// }, +// Spec: corev1.PodSpec{ +// NodeName: "node-1", +// }, +// }, +// } +// return pods +// }, +// getPodProbeMarkers: func() []*appsv1alpha1.PodProbeMarker { +// demo := demoPodProbeMarker.DeepCopy() +// demo.Spec.Probes[0].PodConditionType = "" +// demo.Spec.Probes[0].MarkerPolicy = []appsv1alpha1.ProbeMarkerPolicy{ +// { +// State: appsv1alpha1.ProbeSucceeded, +// Annotations: map[string]string{ +// "controller.kubernetes.io/pod-deletion-cost": "10", +// "success": "true", +// }, +// Labels: map[string]string{ +// "server-healthy": "true", +// "success": "true", +// }, +// }, +// { +// State: appsv1alpha1.ProbeFailed, +// Annotations: map[string]string{ +// "controller.kubernetes.io/pod-deletion-cost": "-10", +// "failed": "true", +// }, +// Labels: map[string]string{ +// "failed": "true", +// }, +// }, +// } +// return []*appsv1alpha1.PodProbeMarker{demo} +// }, +// getNodePodProbes: func() []*appsv1alpha1.NodePodProbe { +// demo := demoNodePodProbe.DeepCopy() +// demo.Status = appsv1alpha1.NodePodProbeStatus{ +// PodProbeStatuses: []appsv1alpha1.PodProbeStatus{ +// { +// Name: "pod-1", +// UID: "pod-1-uid", +// ProbeStates: []appsv1alpha1.ContainerProbeState{ +// { +// Name: "ppm-1#healthy", +// State: appsv1alpha1.ProbeFailed, +// }, +// }, +// }, +// }, +// } +// return []*appsv1alpha1.NodePodProbe{demo} +// }, +// expectPods: func() []*corev1.Pod { +// pods := []*corev1.Pod{ +// { +// ObjectMeta: metav1.ObjectMeta{ +// Name: "pod-1", +// UID: types.UID("pod-1-uid"), +// Labels: map[string]string{ +// "app": "test", +// "failed": "true", +// }, +// Annotations: map[string]string{ +// "controller.kubernetes.io/pod-deletion-cost": "-10", +// "failed": "true", +// }, +// }, +// Spec: corev1.PodSpec{ +// NodeName: "node-1", +// }, +// }, +// } +// return pods +// }, +// }, +// } +// +// for _, cs := range cases { +// t.Run(cs.name, func(t *testing.T) { +// fakeClient := fake.NewClientBuilder().WithScheme(scheme). +// WithStatusSubresource(&appsv1alpha1.NodePodProbe{}, &corev1.Pod{}).Build() +// for _, obj := range cs.getPods() { +// err := fakeClient.Create(context.TODO(), obj.DeepCopy()) +// if err != nil { +// t.Fatalf("create Pod failed: %s", err.Error()) +// } +// } +// for _, obj := range cs.getPodProbeMarkers() { +// err := fakeClient.Create(context.TODO(), obj.DeepCopy()) +// if err != nil { +// t.Fatalf("create PodProbeMarker failed: %s", err.Error()) +// } +// } +// for _, obj := range cs.getNodePodProbes() { +// err := fakeClient.Create(context.TODO(), obj.DeepCopy()) +// if err != nil { +// t.Fatalf("create NodePodProbes failed: %s", err.Error()) +// } +// } +// for _, obj := range cs.getNode() { +// err := fakeClient.Create(context.TODO(), obj.DeepCopy()) +// if err != nil { +// t.Fatalf("create Node failed: %s", err.Error()) +// } +// } +// controllerfinder.Finder = &controllerfinder.ControllerFinder{Client: fakeClient} +// recon := ReconcileNodePodProbe{Client: fakeClient} +// _, err := recon.Reconcile(context.TODO(), cs.req) +// if err != nil { +// t.Fatalf("Reconcile failed: %s", err.Error()) +// } +// if !checkPodMarkerEqual(fakeClient, t, cs.expectPods()) { +// t.Fatalf("Reconcile failed") +// } +// }) +// } +//} -func checkPodMarkerEqual(c client.WithWatch, t *testing.T, expect []*corev1.Pod) bool { - for i := range expect { - obj := expect[i] - pod := &corev1.Pod{} - err := c.Get(context.TODO(), client.ObjectKey{Namespace: obj.Namespace, Name: obj.Name}, pod) - if err != nil { - t.Fatalf("get NodePodProbe failed: %s", err.Error()) - return false - } - if !reflect.DeepEqual(obj.Labels, pod.Labels) || !reflect.DeepEqual(obj.Annotations, pod.Annotations) || - !reflect.DeepEqual(obj.Status.Conditions, pod.Status.Conditions) { - return false - } - } - return true -} +//func checkPodMarkerEqual(c client.WithWatch, t *testing.T, expect []*corev1.Pod) bool { +// for i := range expect { +// obj := expect[i] +// pod := &corev1.Pod{} +// err := c.Get(context.TODO(), client.ObjectKey{Namespace: obj.Namespace, Name: obj.Name}, pod) +// if err != nil { +// t.Fatalf("get NodePodProbe failed: %s", err.Error()) +// return false +// } +// if !reflect.DeepEqual(obj.Labels, pod.Labels) || !reflect.DeepEqual(obj.Annotations, pod.Annotations) || +// !reflect.DeepEqual(obj.Status.Conditions, pod.Status.Conditions) { +// return false +// } +// } +// return true +//} func TestSyncPodFromNodePodProbe(t *testing.T) { cases := []struct { @@ -674,6 +677,7 @@ func TestSyncPodFromNodePodProbe(t *testing.T) { "app": "test", }, DeletionTimestamp: &now, + Finalizers: []string{"finalizers.sigs.k8s.io/test"}, }, Spec: corev1.PodSpec{ NodeName: "node-1", @@ -771,27 +775,19 @@ func TestSyncPodFromNodePodProbe(t *testing.T) { for _, cs := range cases { t.Run(cs.name, func(t *testing.T) { - fakeClient := fake.NewClientBuilder().WithScheme(scheme).Build() + builder := fake.NewClientBuilder().WithScheme(scheme) for _, obj := range cs.getPods() { - err := fakeClient.Create(context.TODO(), obj.DeepCopy()) - if err != nil { - t.Fatalf("create Pod failed: %s", err.Error()) - } + builder.WithObjects(obj.DeepCopy()) } for _, obj := range cs.getNode() { - err := fakeClient.Create(context.TODO(), obj.DeepCopy()) - if err != nil { - t.Fatalf("create Node failed: %s", err.Error()) - } - } - err := fakeClient.Create(context.TODO(), cs.getNodePodProbe()) - if err != nil { - t.Fatalf("create NodePodProbes failed: %s", err.Error()) + builder.WithObjects(obj.DeepCopy()) } + builder.WithObjects(cs.getNodePodProbe()) + fakeClient := builder.Build() controllerfinder.Finder = &controllerfinder.ControllerFinder{Client: fakeClient} recon := ReconcileNodePodProbe{Client: fakeClient} - _, err = recon.Reconcile(context.TODO(), cs.req) + _, err := recon.Reconcile(context.TODO(), cs.req) if err != nil { t.Fatalf("Reconcile failed: %s", err.Error()) } diff --git a/pkg/controller/nodepodprobe/nodepodprobe_event_handler.go b/pkg/controller/nodepodprobe/nodepodprobe_event_handler.go index 09fdb7d18f..12b0cee946 100644 --- a/pkg/controller/nodepodprobe/nodepodprobe_event_handler.go +++ b/pkg/controller/nodepodprobe/nodepodprobe_event_handler.go @@ -39,7 +39,7 @@ var _ handler.EventHandler = &enqueueRequestForNodePodProbe{} type enqueueRequestForNodePodProbe struct{} -func (p *enqueueRequestForNodePodProbe) Create(evt event.CreateEvent, q workqueue.RateLimitingInterface) { +func (p *enqueueRequestForNodePodProbe) Create(ctx context.Context, evt event.CreateEvent, q workqueue.RateLimitingInterface) { obj, ok := evt.Object.(*appsalphav1.NodePodProbe) if !ok { return @@ -47,13 +47,13 @@ func (p *enqueueRequestForNodePodProbe) Create(evt event.CreateEvent, q workqueu p.queue(q, obj) } -func (p *enqueueRequestForNodePodProbe) Delete(evt event.DeleteEvent, q workqueue.RateLimitingInterface) { +func (p *enqueueRequestForNodePodProbe) Delete(ctx context.Context, evt event.DeleteEvent, q workqueue.RateLimitingInterface) { } -func (p *enqueueRequestForNodePodProbe) Generic(evt event.GenericEvent, q workqueue.RateLimitingInterface) { +func (p *enqueueRequestForNodePodProbe) Generic(ctx context.Context, evt event.GenericEvent, q workqueue.RateLimitingInterface) { } -func (p *enqueueRequestForNodePodProbe) Update(evt event.UpdateEvent, q workqueue.RateLimitingInterface) { +func (p *enqueueRequestForNodePodProbe) Update(ctx context.Context, evt event.UpdateEvent, q workqueue.RateLimitingInterface) { // must be deep copy before update the objection new, ok := evt.ObjectNew.(*appsalphav1.NodePodProbe) if !ok { @@ -82,9 +82,10 @@ type enqueueRequestForPod struct { reader client.Reader } -func (p *enqueueRequestForPod) Create(evt event.CreateEvent, q workqueue.RateLimitingInterface) {} +func (p *enqueueRequestForPod) Create(ctx context.Context, evt event.CreateEvent, q workqueue.RateLimitingInterface) { +} -func (p *enqueueRequestForPod) Delete(evt event.DeleteEvent, q workqueue.RateLimitingInterface) { +func (p *enqueueRequestForPod) Delete(ctx context.Context, evt event.DeleteEvent, q workqueue.RateLimitingInterface) { obj, ok := evt.Object.(*corev1.Pod) if !ok { return @@ -108,10 +109,10 @@ func (p *enqueueRequestForPod) Delete(evt event.DeleteEvent, q workqueue.RateLim } } -func (p *enqueueRequestForPod) Generic(evt event.GenericEvent, q workqueue.RateLimitingInterface) { +func (p *enqueueRequestForPod) Generic(ctx context.Context, evt event.GenericEvent, q workqueue.RateLimitingInterface) { } -func (p *enqueueRequestForPod) Update(evt event.UpdateEvent, q workqueue.RateLimitingInterface) { +func (p *enqueueRequestForPod) Update(ctx context.Context, evt event.UpdateEvent, q workqueue.RateLimitingInterface) { new, ok := evt.ObjectNew.(*corev1.Pod) if !ok { return @@ -148,7 +149,7 @@ type enqueueRequestForNode struct { var _ handler.EventHandler = &enqueueRequestForNode{} -func (e *enqueueRequestForNode) Create(evt event.CreateEvent, q workqueue.RateLimitingInterface) { +func (e *enqueueRequestForNode) Create(ctx context.Context, evt event.CreateEvent, q workqueue.RateLimitingInterface) { node := evt.Object.(*corev1.Node) if node.Labels["type"] == VirtualKubelet { return @@ -160,10 +161,10 @@ func (e *enqueueRequestForNode) Create(evt event.CreateEvent, q workqueue.RateLi e.nodeCreate(node, q) } -func (e *enqueueRequestForNode) Generic(evt event.GenericEvent, q workqueue.RateLimitingInterface) { +func (e *enqueueRequestForNode) Generic(ctx context.Context, evt event.GenericEvent, q workqueue.RateLimitingInterface) { } -func (e *enqueueRequestForNode) Update(evt event.UpdateEvent, q workqueue.RateLimitingInterface) { +func (e *enqueueRequestForNode) Update(ctx context.Context, evt event.UpdateEvent, q workqueue.RateLimitingInterface) { node := evt.ObjectNew.(*corev1.Node) if node.Labels["type"] == VirtualKubelet { return @@ -175,7 +176,7 @@ func (e *enqueueRequestForNode) Update(evt event.UpdateEvent, q workqueue.RateLi } } -func (e *enqueueRequestForNode) Delete(evt event.DeleteEvent, q workqueue.RateLimitingInterface) { +func (e *enqueueRequestForNode) Delete(ctx context.Context, evt event.DeleteEvent, q workqueue.RateLimitingInterface) { node := evt.Object.(*corev1.Node) if node.Labels["type"] == VirtualKubelet { return diff --git a/pkg/controller/nodepodprobe/nodepodprobe_event_handler_test.go b/pkg/controller/nodepodprobe/nodepodprobe_event_handler_test.go index 1f977f6bad..4206c589fe 100644 --- a/pkg/controller/nodepodprobe/nodepodprobe_event_handler_test.go +++ b/pkg/controller/nodepodprobe/nodepodprobe_event_handler_test.go @@ -52,7 +52,7 @@ func TestNodeEventHandler(t *testing.T) { createEvt := event.CreateEvent{ Object: demo, } - handler.Create(createEvt, createQ) + handler.Create(context.TODO(), createEvt, createQ) if createQ.Len() != 1 { t.Errorf("unexpected create event handle queue size, expected 1 actual %d", createQ.Len()) } diff --git a/pkg/controller/persistentpodstate/persistent_pod_state_controller.go b/pkg/controller/persistentpodstate/persistent_pod_state_controller.go index f3c21777db..1db38406c3 100644 --- a/pkg/controller/persistentpodstate/persistent_pod_state_controller.go +++ b/pkg/controller/persistentpodstate/persistent_pod_state_controller.go @@ -27,13 +27,6 @@ import ( ctrlUtil "github.com/openkruise/kruise/pkg/controller/util" - appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" - appsv1beta1 "github.com/openkruise/kruise/apis/apps/v1beta1" - "github.com/openkruise/kruise/pkg/util" - utilclient "github.com/openkruise/kruise/pkg/util/client" - "github.com/openkruise/kruise/pkg/util/controllerfinder" - "github.com/openkruise/kruise/pkg/util/discovery" - "github.com/openkruise/kruise/pkg/util/ratelimiter" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" @@ -51,6 +44,14 @@ import ( "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/reconcile" "sigs.k8s.io/controller-runtime/pkg/source" + + appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" + appsv1beta1 "github.com/openkruise/kruise/apis/apps/v1beta1" + "github.com/openkruise/kruise/pkg/util" + utilclient "github.com/openkruise/kruise/pkg/util/client" + "github.com/openkruise/kruise/pkg/util/controllerfinder" + "github.com/openkruise/kruise/pkg/util/discovery" + "github.com/openkruise/kruise/pkg/util/ratelimiter" ) func init() { @@ -104,22 +105,22 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error { } // Watch for changes to Pod - if err = c.Watch(&source.Kind{Type: &corev1.Pod{}}, &enqueueRequestForPod{reader: mgr.GetClient(), client: mgr.GetClient()}); err != nil { + if err = c.Watch(source.Kind(mgr.GetCache(), &corev1.Pod{}), &enqueueRequestForPod{reader: mgr.GetClient(), client: mgr.GetClient()}); err != nil { return err } // watch for changes to PersistentPodState - if err = c.Watch(&source.Kind{Type: &appsv1alpha1.PersistentPodState{}}, &handler.EnqueueRequestForObject{}); err != nil { + if err = c.Watch(source.Kind(mgr.GetCache(), &appsv1alpha1.PersistentPodState{}), &handler.EnqueueRequestForObject{}); err != nil { return err } // watch for changes to StatefulSet - if err = c.Watch(&source.Kind{Type: &appsv1.StatefulSet{}}, &enqueueRequestForStatefulSet{reader: mgr.GetClient()}); err != nil { + if err = c.Watch(source.Kind(mgr.GetCache(), &appsv1.StatefulSet{}), &enqueueRequestForStatefulSet{reader: mgr.GetClient()}); err != nil { return err } // watch for changes to kruise StatefulSet - if err = c.Watch(&source.Kind{Type: &appsv1beta1.StatefulSet{}}, &enqueueRequestForKruiseStatefulSet{reader: mgr.GetClient()}); err != nil { + if err = c.Watch(source.Kind(mgr.GetCache(), &appsv1beta1.StatefulSet{}), &enqueueRequestForKruiseStatefulSet{reader: mgr.GetClient()}); err != nil { return err } @@ -130,7 +131,7 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error { if whiteList != nil { workloadHandler := &enqueueRequestForStatefulSetLike{reader: mgr.GetClient()} for _, workload := range whiteList.Workloads { - if _, err := ctrlUtil.AddWatcherDynamically(c, workloadHandler, workload, "PPS"); err != nil { + if _, err := ctrlUtil.AddWatcherDynamically(mgr, c, workloadHandler, workload, "PPS"); err != nil { return err } } diff --git a/pkg/controller/persistentpodstate/persistent_pod_state_controller_test.go b/pkg/controller/persistentpodstate/persistent_pod_state_controller_test.go index 3651e6d393..6f6ed4e9ca 100644 --- a/pkg/controller/persistentpodstate/persistent_pod_state_controller_test.go +++ b/pkg/controller/persistentpodstate/persistent_pod_state_controller_test.go @@ -247,6 +247,7 @@ func TestReconcilePersistentPodState(t *testing.T) { // 9 is deleted, but 8 is running if i == 9 { pod.DeletionTimestamp = &metav1.Time{Time: time.Now()} + pod.Finalizers = []string{"finalizers.sigs.k8s.io/test"} } pods = append(pods, pod) } @@ -342,6 +343,7 @@ func TestReconcilePersistentPodState(t *testing.T) { // 12 is deleted, but 11 is running if i == 12 { pod.DeletionTimestamp = &metav1.Time{Time: time.Now()} + pod.Finalizers = []string{"finalizers.sigs.k8s.io/test"} } pods = append(pods, pod) } @@ -520,6 +522,7 @@ func TestReconcilePersistentPodState(t *testing.T) { for _, pod := range pods { clientBuilder.WithObjects(pod) } + clientBuilder.WithStatusSubresource(&appsv1alpha1.PersistentPodState{}) fakeClient := clientBuilder.WithIndex(&corev1.Pod{}, fieldindex.IndexNameForOwnerRefUID, func(obj client.Object) []string { var owners []string for _, ref := range obj.GetOwnerReferences() { diff --git a/pkg/controller/persistentpodstate/persistent_pod_state_event_handler.go b/pkg/controller/persistentpodstate/persistent_pod_state_event_handler.go index 297321a193..6fa1ea477b 100644 --- a/pkg/controller/persistentpodstate/persistent_pod_state_event_handler.go +++ b/pkg/controller/persistentpodstate/persistent_pod_state_event_handler.go @@ -24,9 +24,6 @@ import ( "k8s.io/klog/v2" - appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" - appsv1beta1 "github.com/openkruise/kruise/apis/apps/v1beta1" - "github.com/openkruise/kruise/pkg/webhook/pod/mutating" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -39,6 +36,10 @@ import ( "sigs.k8s.io/controller-runtime/pkg/event" "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" + appsv1beta1 "github.com/openkruise/kruise/apis/apps/v1beta1" + "github.com/openkruise/kruise/pkg/webhook/pod/mutating" ) var _ handler.EventHandler = &enqueueRequestForPod{} @@ -48,10 +49,10 @@ type enqueueRequestForPod struct { client client.Client } -func (p *enqueueRequestForPod) Create(evt event.CreateEvent, q workqueue.RateLimitingInterface) { +func (p *enqueueRequestForPod) Create(ctx context.Context, evt event.CreateEvent, q workqueue.RateLimitingInterface) { } -func (p *enqueueRequestForPod) Delete(evt event.DeleteEvent, q workqueue.RateLimitingInterface) { +func (p *enqueueRequestForPod) Delete(ctx context.Context, evt event.DeleteEvent, q workqueue.RateLimitingInterface) { pod := evt.Object.(*corev1.Pod) pps := p.fetchPersistentPodState(pod) if pps == nil { @@ -65,10 +66,10 @@ func (p *enqueueRequestForPod) Delete(evt event.DeleteEvent, q workqueue.RateLim }) } -func (p *enqueueRequestForPod) Generic(evt event.GenericEvent, q workqueue.RateLimitingInterface) { +func (p *enqueueRequestForPod) Generic(ctx context.Context, evt event.GenericEvent, q workqueue.RateLimitingInterface) { } -func (p *enqueueRequestForPod) Update(evt event.UpdateEvent, q workqueue.RateLimitingInterface) { +func (p *enqueueRequestForPod) Update(ctx context.Context, evt event.UpdateEvent, q workqueue.RateLimitingInterface) { p.updatePod(q, evt.ObjectOld, evt.ObjectNew) } @@ -139,7 +140,7 @@ type enqueueRequestForStatefulSet struct { reader client.Reader } -func (p *enqueueRequestForStatefulSet) Create(evt event.CreateEvent, q workqueue.RateLimitingInterface) { +func (p *enqueueRequestForStatefulSet) Create(ctx context.Context, evt event.CreateEvent, q workqueue.RateLimitingInterface) { sts := evt.Object.(*appsv1.StatefulSet) if sts.Annotations[appsv1alpha1.AnnotationAutoGeneratePersistentPodState] == "true" && (sts.Annotations[appsv1alpha1.AnnotationRequiredPersistentTopology] != "" || @@ -148,7 +149,7 @@ func (p *enqueueRequestForStatefulSet) Create(evt event.CreateEvent, q workqueue } } -func (p *enqueueRequestForStatefulSet) Delete(evt event.DeleteEvent, q workqueue.RateLimitingInterface) { +func (p *enqueueRequestForStatefulSet) Delete(ctx context.Context, evt event.DeleteEvent, q workqueue.RateLimitingInterface) { sts := evt.Object.(*appsv1.StatefulSet) if pps := mutating.SelectorPersistentPodState(p.reader, appsv1alpha1.TargetReference{ APIVersion: KruiseKindSts.GroupVersion().String(), @@ -164,10 +165,10 @@ func (p *enqueueRequestForStatefulSet) Delete(evt event.DeleteEvent, q workqueue } } -func (p *enqueueRequestForStatefulSet) Generic(evt event.GenericEvent, q workqueue.RateLimitingInterface) { +func (p *enqueueRequestForStatefulSet) Generic(ctx context.Context, evt event.GenericEvent, q workqueue.RateLimitingInterface) { } -func (p *enqueueRequestForStatefulSet) Update(evt event.UpdateEvent, q workqueue.RateLimitingInterface) { +func (p *enqueueRequestForStatefulSet) Update(ctx context.Context, evt event.UpdateEvent, q workqueue.RateLimitingInterface) { oSts := evt.ObjectOld.(*appsv1.StatefulSet) nSts := evt.ObjectNew.(*appsv1.StatefulSet) if oSts.Annotations[appsv1alpha1.AnnotationAutoGeneratePersistentPodState] != nSts.Annotations[appsv1alpha1.AnnotationAutoGeneratePersistentPodState] || @@ -210,7 +211,7 @@ type enqueueRequestForKruiseStatefulSet struct { reader client.Reader } -func (p *enqueueRequestForKruiseStatefulSet) Create(evt event.CreateEvent, q workqueue.RateLimitingInterface) { +func (p *enqueueRequestForKruiseStatefulSet) Create(ctx context.Context, evt event.CreateEvent, q workqueue.RateLimitingInterface) { sts := evt.Object.(*appsv1beta1.StatefulSet) if sts.Annotations[appsv1alpha1.AnnotationAutoGeneratePersistentPodState] == "true" && (sts.Annotations[appsv1alpha1.AnnotationRequiredPersistentTopology] != "" || @@ -219,7 +220,7 @@ func (p *enqueueRequestForKruiseStatefulSet) Create(evt event.CreateEvent, q wor } } -func (p *enqueueRequestForKruiseStatefulSet) Delete(evt event.DeleteEvent, q workqueue.RateLimitingInterface) { +func (p *enqueueRequestForKruiseStatefulSet) Delete(ctx context.Context, evt event.DeleteEvent, q workqueue.RateLimitingInterface) { sts := evt.Object.(*appsv1beta1.StatefulSet) if pps := mutating.SelectorPersistentPodState(p.reader, appsv1alpha1.TargetReference{ APIVersion: KruiseKindSts.GroupVersion().String(), @@ -235,10 +236,10 @@ func (p *enqueueRequestForKruiseStatefulSet) Delete(evt event.DeleteEvent, q wor } } -func (p *enqueueRequestForKruiseStatefulSet) Generic(evt event.GenericEvent, q workqueue.RateLimitingInterface) { +func (p *enqueueRequestForKruiseStatefulSet) Generic(ctx context.Context, evt event.GenericEvent, q workqueue.RateLimitingInterface) { } -func (p *enqueueRequestForKruiseStatefulSet) Update(evt event.UpdateEvent, q workqueue.RateLimitingInterface) { +func (p *enqueueRequestForKruiseStatefulSet) Update(ctx context.Context, evt event.UpdateEvent, q workqueue.RateLimitingInterface) { oSts := evt.ObjectOld.(*appsv1beta1.StatefulSet) nSts := evt.ObjectNew.(*appsv1beta1.StatefulSet) if oSts.Annotations[appsv1alpha1.AnnotationAutoGeneratePersistentPodState] != nSts.Annotations[appsv1alpha1.AnnotationAutoGeneratePersistentPodState] || @@ -270,7 +271,7 @@ type enqueueRequestForStatefulSetLike struct { reader client.Reader } -func (p *enqueueRequestForStatefulSetLike) Create(evt event.CreateEvent, q workqueue.RateLimitingInterface) { +func (p *enqueueRequestForStatefulSetLike) Create(ctx context.Context, evt event.CreateEvent, q workqueue.RateLimitingInterface) { workload := evt.Object.(*unstructured.Unstructured) annotations := workload.GetAnnotations() if annotations[appsv1alpha1.AnnotationAutoGeneratePersistentPodState] == "true" && @@ -280,7 +281,7 @@ func (p *enqueueRequestForStatefulSetLike) Create(evt event.CreateEvent, q workq } } -func (p *enqueueRequestForStatefulSetLike) Update(evt event.UpdateEvent, q workqueue.RateLimitingInterface) { +func (p *enqueueRequestForStatefulSetLike) Update(ctx context.Context, evt event.UpdateEvent, q workqueue.RateLimitingInterface) { oWorkload := evt.ObjectOld.(*unstructured.Unstructured) nWorkload := evt.ObjectNew.(*unstructured.Unstructured) oAnnotations := oWorkload.GetAnnotations() @@ -308,7 +309,7 @@ func (p *enqueueRequestForStatefulSetLike) Update(evt event.UpdateEvent, q workq } } -func (p *enqueueRequestForStatefulSetLike) Delete(evt event.DeleteEvent, q workqueue.RateLimitingInterface) { +func (p *enqueueRequestForStatefulSetLike) Delete(ctx context.Context, evt event.DeleteEvent, q workqueue.RateLimitingInterface) { workload := evt.Object.(*unstructured.Unstructured) if pps := mutating.SelectorPersistentPodState(p.reader, appsv1alpha1.TargetReference{ APIVersion: workload.GetAPIVersion(), @@ -324,5 +325,5 @@ func (p *enqueueRequestForStatefulSetLike) Delete(evt event.DeleteEvent, q workq } } -func (p *enqueueRequestForStatefulSetLike) Generic(genericEvent event.GenericEvent, limitingInterface workqueue.RateLimitingInterface) { +func (p *enqueueRequestForStatefulSetLike) Generic(ctx context.Context, genericEvent event.GenericEvent, limitingInterface workqueue.RateLimitingInterface) { } diff --git a/pkg/controller/podprobemarker/pod_probe_marker_controller.go b/pkg/controller/podprobemarker/pod_probe_marker_controller.go index 50a1472f30..2e425b4a0a 100644 --- a/pkg/controller/podprobemarker/pod_probe_marker_controller.go +++ b/pkg/controller/podprobemarker/pod_probe_marker_controller.go @@ -97,11 +97,11 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error { } // watch for changes to PodProbeMarker - if err = c.Watch(&source.Kind{Type: &appsv1alpha1.PodProbeMarker{}}, &enqueueRequestForPodProbeMarker{}); err != nil { + if err = c.Watch(source.Kind(mgr.GetCache(), &appsv1alpha1.PodProbeMarker{}), &enqueueRequestForPodProbeMarker{}); err != nil { return err } // watch for changes to pod - if err = c.Watch(&source.Kind{Type: &corev1.Pod{}}, &enqueueRequestForPod{reader: mgr.GetClient()}); err != nil { + if err = c.Watch(source.Kind(mgr.GetCache(), &corev1.Pod{}), &enqueueRequestForPod{reader: mgr.GetClient()}); err != nil { return err } diff --git a/pkg/controller/podprobemarker/pod_probe_marker_controller_test.go b/pkg/controller/podprobemarker/pod_probe_marker_controller_test.go index 3dd84a0380..47298c56fd 100644 --- a/pkg/controller/podprobemarker/pod_probe_marker_controller_test.go +++ b/pkg/controller/podprobemarker/pod_probe_marker_controller_test.go @@ -1312,25 +1312,18 @@ func TestSyncPodProbeMarker(t *testing.T) { for _, cs := range cases { t.Run(cs.name, func(t *testing.T) { - fakeClient := fake.NewClientBuilder().WithScheme(scheme).Build() + builder := fake.NewClientBuilder().WithScheme(scheme) + builder.WithStatusSubresource(&appsv1alpha1.PodProbeMarker{}, &appsv1alpha1.NodePodProbe{}) for _, obj := range cs.getPods() { - err := fakeClient.Create(context.TODO(), obj.DeepCopy()) - if err != nil { - t.Fatalf("create Pod failed: %s", err.Error()) - } + builder.WithObjects(obj) } for _, obj := range cs.getPodProbeMarkers() { - err := fakeClient.Create(context.TODO(), obj.DeepCopy()) - if err != nil { - t.Fatalf("create PodProbeMarker failed: %s", err.Error()) - } + builder.WithObjects(obj) } for _, obj := range cs.getNodePodProbes() { - err := fakeClient.Create(context.TODO(), obj.DeepCopy()) - if err != nil { - t.Fatalf("create NodePodProbes failed: %s", err.Error()) - } + builder.WithObjects(obj) } + fakeClient := builder.Build() controllerfinder.Finder = &controllerfinder.ControllerFinder{Client: fakeClient} recon := ReconcilePodProbeMarker{Client: fakeClient} @@ -1354,8 +1347,8 @@ func checkNodePodProbeEqual(c client.WithWatch, t *testing.T, expect []*appsv1al t.Fatalf("get NodePodProbe failed: %s", err.Error()) return false } - t.Logf("expect: %v --> but: %v", util.DumpJSON(obj.Spec), util.DumpJSON(npp.Spec)) if !reflect.DeepEqual(obj.Spec, npp.Spec) { + t.Logf("expect: %v --> but: %v", util.DumpJSON(obj.Spec), util.DumpJSON(npp.Spec)) return false } } @@ -1959,8 +1952,8 @@ func TestUpdateNodePodProbes(t *testing.T) { for _, tc := range cases { t.Run(tc.name, func(t *testing.T) { - fakeclient := fake.NewFakeClientWithScheme(scheme, tc.nodePodProbe) - r := &ReconcilePodProbeMarker{Client: fakeclient} + fakeClient := fake.NewClientBuilder().WithScheme(scheme).WithRuntimeObjects(tc.nodePodProbe).Build() + r := &ReconcilePodProbeMarker{Client: fakeClient} get := r.updateNodePodProbes(tc.ppm, tc.nodeName, tc.pods) if !reflect.DeepEqual(tc.getErr, get) { t.Errorf("expect: %v, but: %v", tc.getErr, get) diff --git a/pkg/controller/podprobemarker/podprobemarker_event_handler.go b/pkg/controller/podprobemarker/podprobemarker_event_handler.go index 45a00ea6c1..4320a43df9 100644 --- a/pkg/controller/podprobemarker/podprobemarker_event_handler.go +++ b/pkg/controller/podprobemarker/podprobemarker_event_handler.go @@ -40,17 +40,17 @@ var _ handler.EventHandler = &enqueueRequestForPodProbeMarker{} type enqueueRequestForPodProbeMarker struct{} -func (p *enqueueRequestForPodProbeMarker) Create(evt event.CreateEvent, q workqueue.RateLimitingInterface) { +func (p *enqueueRequestForPodProbeMarker) Create(ctx context.Context, evt event.CreateEvent, q workqueue.RateLimitingInterface) { p.queue(q, evt.Object) } -func (p *enqueueRequestForPodProbeMarker) Delete(evt event.DeleteEvent, q workqueue.RateLimitingInterface) { +func (p *enqueueRequestForPodProbeMarker) Delete(ctx context.Context, evt event.DeleteEvent, q workqueue.RateLimitingInterface) { } -func (p *enqueueRequestForPodProbeMarker) Generic(evt event.GenericEvent, q workqueue.RateLimitingInterface) { +func (p *enqueueRequestForPodProbeMarker) Generic(ctx context.Context, evt event.GenericEvent, q workqueue.RateLimitingInterface) { } -func (p *enqueueRequestForPodProbeMarker) Update(evt event.UpdateEvent, q workqueue.RateLimitingInterface) { +func (p *enqueueRequestForPodProbeMarker) Update(ctx context.Context, evt event.UpdateEvent, q workqueue.RateLimitingInterface) { p.queue(q, evt.ObjectNew) } @@ -73,15 +73,16 @@ type enqueueRequestForPod struct { reader client.Reader } -func (p *enqueueRequestForPod) Create(evt event.CreateEvent, q workqueue.RateLimitingInterface) {} +func (p *enqueueRequestForPod) Create(ctx context.Context, evt event.CreateEvent, q workqueue.RateLimitingInterface) { +} -func (p *enqueueRequestForPod) Delete(evt event.DeleteEvent, q workqueue.RateLimitingInterface) { +func (p *enqueueRequestForPod) Delete(ctx context.Context, evt event.DeleteEvent, q workqueue.RateLimitingInterface) { } -func (p *enqueueRequestForPod) Generic(evt event.GenericEvent, q workqueue.RateLimitingInterface) { +func (p *enqueueRequestForPod) Generic(ctx context.Context, evt event.GenericEvent, q workqueue.RateLimitingInterface) { } -func (p *enqueueRequestForPod) Update(evt event.UpdateEvent, q workqueue.RateLimitingInterface) { +func (p *enqueueRequestForPod) Update(ctx context.Context, evt event.UpdateEvent, q workqueue.RateLimitingInterface) { new, ok := evt.ObjectNew.(*corev1.Pod) if !ok { return diff --git a/pkg/controller/podprobemarker/podprobemarker_event_handler_test.go b/pkg/controller/podprobemarker/podprobemarker_event_handler_test.go index 2a0263e87d..20118b92fd 100644 --- a/pkg/controller/podprobemarker/podprobemarker_event_handler_test.go +++ b/pkg/controller/podprobemarker/podprobemarker_event_handler_test.go @@ -77,7 +77,7 @@ func TestPodUpdateEventHandler(t *testing.T) { handler := enqueueRequestForPod{reader: fakeClient} // update with pod no PodInitialized, then return - handler.Update(updateEvent, updateQ) + handler.Update(context.TODO(), updateEvent, updateQ) if updateQ.Len() != 0 { t.Errorf("unexpected update event handle queue size, expected 1 actual %d", updateQ.Len()) } @@ -88,7 +88,7 @@ func TestPodUpdateEventHandler(t *testing.T) { newPod.Status.Phase = corev1.PodSucceeded // update with pod status changed and reconcile - handler.Update(updateEvent, updateQ) + handler.Update(context.TODO(), updateEvent, updateQ) if updateQ.Len() != 0 { t.Errorf("unexpected update event handle queue size, expected 1 actual %d", updateQ.Len()) } @@ -98,7 +98,7 @@ func TestPodUpdateEventHandler(t *testing.T) { ObjectOld: nil, ObjectNew: nil, } - handler.Update(updateEvent, updateQ) + handler.Update(context.TODO(), updateEvent, updateQ) if updateQ.Len() != 0 { t.Errorf("unexpected update event handle queue size, expected 1 actual %d", updateQ.Len()) } @@ -108,7 +108,7 @@ func TestPodUpdateEventHandler(t *testing.T) { ObjectOld: nil, ObjectNew: newPod, } - handler.Update(updateEvent, updateQ) + handler.Update(context.TODO(), updateEvent, updateQ) if updateQ.Len() != 0 { t.Errorf("unexpected update event handle queue size, expected 1 actual %d", updateQ.Len()) } @@ -456,7 +456,7 @@ func TestPodUpdateEventHandler_v2(t *testing.T) { ObjectOld: podDemo, ObjectNew: newPod, } - handler.Update(updateEvent, updateQ) + handler.Update(context.TODO(), updateEvent, updateQ) if updateQ.Len() != cs.expectQLen { t.Errorf("unexpected update event handle queue size, expected %v actual %d", cs.expectQLen, updateQ.Len()) } diff --git a/pkg/controller/podreadiness/pod_readiness_controller.go b/pkg/controller/podreadiness/pod_readiness_controller.go index df3cabf587..9fa7d62f04 100644 --- a/pkg/controller/podreadiness/pod_readiness_controller.go +++ b/pkg/controller/podreadiness/pod_readiness_controller.go @@ -22,10 +22,6 @@ import ( "fmt" "time" - appspub "github.com/openkruise/kruise/apis/apps/pub" - "github.com/openkruise/kruise/pkg/util" - utilclient "github.com/openkruise/kruise/pkg/util/client" - utilpodreadiness "github.com/openkruise/kruise/pkg/util/podreadiness" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -39,6 +35,11 @@ import ( "sigs.k8s.io/controller-runtime/pkg/predicate" "sigs.k8s.io/controller-runtime/pkg/reconcile" "sigs.k8s.io/controller-runtime/pkg/source" + + appspub "github.com/openkruise/kruise/apis/apps/pub" + "github.com/openkruise/kruise/pkg/util" + utilclient "github.com/openkruise/kruise/pkg/util/client" + utilpodreadiness "github.com/openkruise/kruise/pkg/util/podreadiness" ) var ( @@ -65,7 +66,7 @@ func add(mgr manager.Manager, r *ReconcilePodReadiness) error { return err } - err = c.Watch(&source.Kind{Type: &v1.Pod{}}, &handler.EnqueueRequestForObject{}, predicate.Funcs{ + err = c.Watch(source.Kind(mgr.GetCache(), &v1.Pod{}), &handler.EnqueueRequestForObject{}, predicate.Funcs{ CreateFunc: func(e event.CreateEvent) bool { pod := e.Object.(*v1.Pod) return utilpodreadiness.ContainsReadinessGate(pod) && utilpodreadiness.GetReadinessCondition(pod) == nil diff --git a/pkg/controller/podunavailablebudget/podunavailablebudget_controller.go b/pkg/controller/podunavailablebudget/podunavailablebudget_controller.go index 68a602c1c7..57c0f2ca4a 100644 --- a/pkg/controller/podunavailablebudget/podunavailablebudget_controller.go +++ b/pkg/controller/podunavailablebudget/podunavailablebudget_controller.go @@ -22,17 +22,6 @@ import ( "fmt" "time" - kruiseappsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" - kruiseappsv1beta1 "github.com/openkruise/kruise/apis/apps/v1beta1" - policyv1alpha1 "github.com/openkruise/kruise/apis/policy/v1alpha1" - kubeClient "github.com/openkruise/kruise/pkg/client" - "github.com/openkruise/kruise/pkg/control/pubcontrol" - "github.com/openkruise/kruise/pkg/features" - "github.com/openkruise/kruise/pkg/util" - "github.com/openkruise/kruise/pkg/util/controllerfinder" - utildiscovery "github.com/openkruise/kruise/pkg/util/discovery" - utilfeature "github.com/openkruise/kruise/pkg/util/feature" - "github.com/openkruise/kruise/pkg/util/ratelimiter" apps "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" apiequality "k8s.io/apimachinery/pkg/api/equality" @@ -56,6 +45,18 @@ import ( "sigs.k8s.io/controller-runtime/pkg/predicate" "sigs.k8s.io/controller-runtime/pkg/reconcile" "sigs.k8s.io/controller-runtime/pkg/source" + + kruiseappsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" + kruiseappsv1beta1 "github.com/openkruise/kruise/apis/apps/v1beta1" + policyv1alpha1 "github.com/openkruise/kruise/apis/policy/v1alpha1" + kubeClient "github.com/openkruise/kruise/pkg/client" + "github.com/openkruise/kruise/pkg/control/pubcontrol" + "github.com/openkruise/kruise/pkg/features" + "github.com/openkruise/kruise/pkg/util" + "github.com/openkruise/kruise/pkg/util/controllerfinder" + utildiscovery "github.com/openkruise/kruise/pkg/util/discovery" + utilfeature "github.com/openkruise/kruise/pkg/util/feature" + "github.com/openkruise/kruise/pkg/util/ratelimiter" ) func init() { @@ -118,13 +119,13 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error { } // Watch for changes to PodUnavailableBudget - err = c.Watch(&source.Kind{Type: &policyv1alpha1.PodUnavailableBudget{}}, &handler.EnqueueRequestForObject{}) + err = c.Watch(source.Kind(mgr.GetCache(), &policyv1alpha1.PodUnavailableBudget{}), &handler.EnqueueRequestForObject{}) if err != nil { return err } // Watch for changes to Pod - if err = c.Watch(&source.Kind{Type: &corev1.Pod{}}, newEnqueueRequestForPod(mgr.GetClient())); err != nil { + if err = c.Watch(source.Kind(mgr.GetCache(), &corev1.Pod{}), newEnqueueRequestForPod(mgr.GetClient())); err != nil { return err } @@ -135,7 +136,7 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error { // 2. at this time the cloneSet.replicas is scaled down to 50, the pub controller listens to the replicas change, triggering reconcile will adjust UnavailableAllowed to 55. // 3. so pub webhook will not intercept the request to delete the pods // deployment - if err = c.Watch(&source.Kind{Type: &apps.Deployment{}}, &SetEnqueueRequestForPUB{mgr}, predicate.Funcs{ + if err = c.Watch(source.Kind(mgr.GetCache(), &apps.Deployment{}), &SetEnqueueRequestForPUB{mgr}, predicate.Funcs{ UpdateFunc: func(e event.UpdateEvent) bool { old := e.ObjectOld.(*apps.Deployment) new := e.ObjectNew.(*apps.Deployment) @@ -149,7 +150,7 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error { } // kruise AdvancedStatefulSet - if err = c.Watch(&source.Kind{Type: &kruiseappsv1beta1.StatefulSet{}}, &SetEnqueueRequestForPUB{mgr}, predicate.Funcs{ + if err = c.Watch(source.Kind(mgr.GetCache(), &kruiseappsv1beta1.StatefulSet{}), &SetEnqueueRequestForPUB{mgr}, predicate.Funcs{ UpdateFunc: func(e event.UpdateEvent) bool { old := e.ObjectOld.(*kruiseappsv1beta1.StatefulSet) new := e.ObjectNew.(*kruiseappsv1beta1.StatefulSet) @@ -163,7 +164,7 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error { } // CloneSet - if err = c.Watch(&source.Kind{Type: &kruiseappsv1alpha1.CloneSet{}}, &SetEnqueueRequestForPUB{mgr}, predicate.Funcs{ + if err = c.Watch(source.Kind(mgr.GetCache(), &kruiseappsv1alpha1.CloneSet{}), &SetEnqueueRequestForPUB{mgr}, predicate.Funcs{ UpdateFunc: func(e event.UpdateEvent) bool { old := e.ObjectOld.(*kruiseappsv1alpha1.CloneSet) new := e.ObjectNew.(*kruiseappsv1alpha1.CloneSet) @@ -177,7 +178,7 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error { } // StatefulSet - if err = c.Watch(&source.Kind{Type: &apps.StatefulSet{}}, &SetEnqueueRequestForPUB{mgr}, predicate.Funcs{ + if err = c.Watch(source.Kind(mgr.GetCache(), &apps.StatefulSet{}), &SetEnqueueRequestForPUB{mgr}, predicate.Funcs{ UpdateFunc: func(e event.UpdateEvent) bool { old := e.ObjectOld.(*apps.StatefulSet) new := e.ObjectNew.(*apps.StatefulSet) diff --git a/pkg/controller/podunavailablebudget/pub_controller_test.go b/pkg/controller/podunavailablebudget/pub_controller_test.go index 6b6ec06d29..ff061f7640 100644 --- a/pkg/controller/podunavailablebudget/pub_controller_test.go +++ b/pkg/controller/podunavailablebudget/pub_controller_test.go @@ -331,6 +331,7 @@ func TestPubReconcile(t *testing.T) { t := metav1.Now() if i >= 7 && i < 10 { pod.DeletionTimestamp = &t + pod.Finalizers = []string{"finalizers.sigs.k8s.io/test"} } matchedPods = append(matchedPods, pod) } @@ -397,6 +398,7 @@ func TestPubReconcile(t *testing.T) { obj := deploymentDemo.DeepCopy() t := metav1.Now() obj.DeletionTimestamp = &t + obj.Finalizers = []string{"finalizers.sigs.k8s.io/test"} return obj }, getReplicaSet: func() []*apps.ReplicaSet { @@ -531,6 +533,7 @@ func TestPubReconcile(t *testing.T) { if i >= 7 { t := metav1.Now() pod.DeletionTimestamp = &t + pod.Finalizers = []string{"finalizers.sigs.k8s.io/test"} } pod.Name = fmt.Sprintf("%s-%d", pod.Name, i) matchedPods = append(matchedPods, pod) @@ -590,6 +593,7 @@ func TestPubReconcile(t *testing.T) { obj := deploymentDemo.DeepCopy() t := metav1.Now() obj.DeletionTimestamp = &t + obj.Finalizers = []string{"finalizers.sigs.k8s.io/test"} return obj }, getReplicaSet: func() []*apps.ReplicaSet { @@ -928,6 +932,7 @@ func TestPubReconcile(t *testing.T) { pod.Name = fmt.Sprintf("%s-%d", pod.Name, i) if i >= 20 && i < 25 { pod.DeletionTimestamp = &metav1.Time{Time: time.Now()} + pod.Finalizers = []string{"finalizers.sigs.k8s.io/test"} } matchedPods = append(matchedPods, pod) } @@ -977,6 +982,7 @@ func TestPubReconcile(t *testing.T) { pod.Name = fmt.Sprintf("%s-%d", pod.Name, i) if i >= 10 && i < 15 { pod.DeletionTimestamp = &metav1.Time{Time: time.Now()} + pod.Finalizers = []string{"finalizers.sigs.k8s.io/test"} } matchedPods = append(matchedPods, pod) } @@ -1030,6 +1036,7 @@ func TestPubReconcile(t *testing.T) { pod.Name = fmt.Sprintf("%s-%d", pod.Name, i) if i >= 20 && i < 25 { pod.DeletionTimestamp = &metav1.Time{Time: time.Now()} + pod.Finalizers = []string{"finalizers.sigs.k8s.io/test"} } matchedPods = append(matchedPods, pod) } @@ -1088,6 +1095,7 @@ func TestPubReconcile(t *testing.T) { pod.Name = fmt.Sprintf("%s-%d", pod.Name, i) if i >= 20 && i < 25 { pod.DeletionTimestamp = &metav1.Time{Time: time.Now()} + pod.Finalizers = []string{"finalizers.sigs.k8s.io/test"} } matchedPods = append(matchedPods, pod) } @@ -1144,21 +1152,25 @@ func TestPubReconcile(t *testing.T) { t.Run(cs.name, func(t *testing.T) { pub := cs.getPub() defer util.GlobalCache.Delete(pub) - fakeClient := fake.NewClientBuilder().WithScheme(scheme).WithObjects(cs.getDeployment(), pub). - WithIndex(&corev1.Pod{}, fieldindex.IndexNameForOwnerRefUID, func(obj client.Object) []string { - var owners []string - for _, ref := range obj.GetOwnerReferences() { - owners = append(owners, string(ref.UID)) - } - return owners - }).Build() + + builder := fake.NewClientBuilder().WithScheme(scheme).WithObjects(cs.getDeployment(), pub) + builder.WithIndex(&corev1.Pod{}, fieldindex.IndexNameForOwnerRefUID, func(obj client.Object) []string { + var owners []string + for _, ref := range obj.GetOwnerReferences() { + owners = append(owners, string(ref.UID)) + } + return owners + }) + builder.WithStatusSubresource(&policyv1alpha1.PodUnavailableBudget{}) for _, pod := range cs.getPods(cs.getReplicaSet()...) { podIn := pod.DeepCopy() - _ = fakeClient.Create(context.TODO(), podIn) + builder.WithObjects(podIn) } for _, obj := range cs.getReplicaSet() { - _ = fakeClient.Create(context.TODO(), obj) + builder.WithObjects(obj) } + fakeClient := builder.Build() + finder := &controllerfinder.ControllerFinder{Client: fakeClient} pubcontrol.InitPubControl(fakeClient, finder, record.NewFakeRecorder(10)) controllerfinder.Finder = &controllerfinder.ControllerFinder{Client: fakeClient} diff --git a/pkg/controller/podunavailablebudget/pub_pod_event_handler.go b/pkg/controller/podunavailablebudget/pub_pod_event_handler.go index 5f75ba38bf..0491342ebd 100644 --- a/pkg/controller/podunavailablebudget/pub_pod_event_handler.go +++ b/pkg/controller/podunavailablebudget/pub_pod_event_handler.go @@ -20,13 +20,6 @@ import ( "context" "time" - appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" - appsv1beta1 "github.com/openkruise/kruise/apis/apps/v1beta1" - policyv1alpha1 "github.com/openkruise/kruise/apis/policy/v1alpha1" - "github.com/openkruise/kruise/pkg/control/pubcontrol" - "github.com/openkruise/kruise/pkg/util" - utilclient "github.com/openkruise/kruise/pkg/util/client" - "github.com/openkruise/kruise/pkg/util/controllerfinder" apps "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -41,6 +34,14 @@ import ( "sigs.k8s.io/controller-runtime/pkg/handler" "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" + appsv1beta1 "github.com/openkruise/kruise/apis/apps/v1beta1" + policyv1alpha1 "github.com/openkruise/kruise/apis/policy/v1alpha1" + "github.com/openkruise/kruise/pkg/control/pubcontrol" + "github.com/openkruise/kruise/pkg/util" + utilclient "github.com/openkruise/kruise/pkg/util/client" + "github.com/openkruise/kruise/pkg/util/controllerfinder" ) var _ handler.EventHandler = &enqueueRequestForPod{} @@ -56,16 +57,17 @@ type enqueueRequestForPod struct { controllerFinder *controllerfinder.ControllerFinder } -func (p *enqueueRequestForPod) Create(evt event.CreateEvent, q workqueue.RateLimitingInterface) { +func (p *enqueueRequestForPod) Create(ctx context.Context, evt event.CreateEvent, q workqueue.RateLimitingInterface) { p.addPod(q, evt.Object) } -func (p *enqueueRequestForPod) Delete(evt event.DeleteEvent, q workqueue.RateLimitingInterface) { +func (p *enqueueRequestForPod) Delete(ctx context.Context, evt event.DeleteEvent, q workqueue.RateLimitingInterface) { } -func (p *enqueueRequestForPod) Generic(evt event.GenericEvent, q workqueue.RateLimitingInterface) {} +func (p *enqueueRequestForPod) Generic(ctx context.Context, evt event.GenericEvent, q workqueue.RateLimitingInterface) { +} -func (p *enqueueRequestForPod) Update(evt event.UpdateEvent, q workqueue.RateLimitingInterface) { +func (p *enqueueRequestForPod) Update(ctx context.Context, evt event.UpdateEvent, q workqueue.RateLimitingInterface) { p.updatePod(q, evt.ObjectOld, evt.ObjectNew) } @@ -190,22 +192,22 @@ type SetEnqueueRequestForPUB struct { } // Create implements EventHandler -func (e *SetEnqueueRequestForPUB) Create(evt event.CreateEvent, q workqueue.RateLimitingInterface) { +func (e *SetEnqueueRequestForPUB) Create(ctx context.Context, evt event.CreateEvent, q workqueue.RateLimitingInterface) { e.addSetRequest(evt.Object, q) } // Update implements EventHandler -func (e *SetEnqueueRequestForPUB) Update(evt event.UpdateEvent, q workqueue.RateLimitingInterface) { +func (e *SetEnqueueRequestForPUB) Update(ctx context.Context, evt event.UpdateEvent, q workqueue.RateLimitingInterface) { e.addSetRequest(evt.ObjectNew, q) } // Delete implements EventHandler -func (e *SetEnqueueRequestForPUB) Delete(evt event.DeleteEvent, q workqueue.RateLimitingInterface) { +func (e *SetEnqueueRequestForPUB) Delete(ctx context.Context, evt event.DeleteEvent, q workqueue.RateLimitingInterface) { e.addSetRequest(evt.Object, q) } // Generic implements EventHandler -func (e *SetEnqueueRequestForPUB) Generic(evt event.GenericEvent, q workqueue.RateLimitingInterface) { +func (e *SetEnqueueRequestForPUB) Generic(ctx context.Context, evt event.GenericEvent, q workqueue.RateLimitingInterface) { } func (e *SetEnqueueRequestForPUB) addSetRequest(object client.Object, q workqueue.RateLimitingInterface) { diff --git a/pkg/controller/podunavailablebudget/pub_pod_event_handler_test.go b/pkg/controller/podunavailablebudget/pub_pod_event_handler_test.go index a62bfd4117..2429e0e254 100644 --- a/pkg/controller/podunavailablebudget/pub_pod_event_handler_test.go +++ b/pkg/controller/podunavailablebudget/pub_pod_event_handler_test.go @@ -22,12 +22,13 @@ import ( "testing" "time" - "github.com/openkruise/kruise/pkg/control/pubcontrol" corev1 "k8s.io/api/core/v1" "k8s.io/client-go/util/workqueue" podutil "k8s.io/kubernetes/pkg/api/v1/pod" "sigs.k8s.io/controller-runtime/pkg/client/fake" "sigs.k8s.io/controller-runtime/pkg/event" + + "github.com/openkruise/kruise/pkg/control/pubcontrol" ) func TestPodEventHandler(t *testing.T) { @@ -45,7 +46,7 @@ func TestPodEventHandler(t *testing.T) { Object: podDemo.DeepCopy(), } createEvt.Object.SetAnnotations(map[string]string{pubcontrol.PodRelatedPubAnnotation: pubDemo.Name}) - handler.Create(createEvt, createQ) + handler.Create(context.TODO(), createEvt, createQ) if createQ.Len() != 1 { t.Errorf("unexpected create event handle queue size, expected 1 actual %d", createQ.Len()) } @@ -62,7 +63,7 @@ func TestPodEventHandler(t *testing.T) { } updateEvent.ObjectOld.SetAnnotations(map[string]string{pubcontrol.PodRelatedPubAnnotation: pubDemo.Name}) updateEvent.ObjectNew.SetAnnotations(map[string]string{pubcontrol.PodRelatedPubAnnotation: pubDemo.Name}) - handler.Update(updateEvent, updateQ) + handler.Update(context.TODO(), updateEvent, updateQ) if updateQ.Len() != 1 { t.Errorf("unexpected update event handle queue size, expected 1 actual %d", updateQ.Len()) } @@ -78,7 +79,7 @@ func TestPodEventHandler(t *testing.T) { } updateEvent.ObjectOld.SetAnnotations(map[string]string{pubcontrol.PodRelatedPubAnnotation: pubDemo.Name}) updateEvent.ObjectNew.SetAnnotations(map[string]string{pubcontrol.PodRelatedPubAnnotation: pubDemo.Name}) - handler.Update(updateEvent, updateQ) + handler.Update(context.TODO(), updateEvent, updateQ) if updateQ.Len() != 0 { t.Errorf("unexpected update event handle queue size, expected 0 actual %d", updateQ.Len()) } diff --git a/pkg/controller/resourcedistribution/resourcedistribution_controller.go b/pkg/controller/resourcedistribution/resourcedistribution_controller.go index 79d34d3623..600a0e6a22 100644 --- a/pkg/controller/resourcedistribution/resourcedistribution_controller.go +++ b/pkg/controller/resourcedistribution/resourcedistribution_controller.go @@ -88,7 +88,7 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error { } // Watch for changes to ResourceDistribution - err = c.Watch(&source.Kind{Type: &appsv1alpha1.ResourceDistribution{}}, &handler.EnqueueRequestForObject{}, predicate.Funcs{ + err = c.Watch(source.Kind(mgr.GetCache(), &appsv1alpha1.ResourceDistribution{}), &handler.EnqueueRequestForObject{}, predicate.Funcs{ UpdateFunc: func(e event.UpdateEvent) bool { oldObj := e.ObjectOld.(*appsv1alpha1.ResourceDistribution) newObj := e.ObjectNew.(*appsv1alpha1.ResourceDistribution) @@ -104,7 +104,7 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error { } // Watch for changes to all namespaces - err = c.Watch(&source.Kind{Type: &corev1.Namespace{}}, &enqueueRequestForNamespace{reader: mgr.GetCache()}) + err = c.Watch(source.Kind(mgr.GetCache(), &corev1.Namespace{}), &enqueueRequestForNamespace{reader: mgr.GetCache()}) if err != nil { return err } @@ -112,16 +112,16 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error { // Watch for changes to Secrets secret := unstructured.Unstructured{} secret.SetGroupVersionKind(corev1.SchemeGroupVersion.WithKind("Secret")) - err = c.Watch(&source.Kind{Type: &secret}, &handler.EnqueueRequestForOwner{ - IsController: true, OwnerType: &appsv1alpha1.ResourceDistribution{}, - }, predicate.Funcs{ - CreateFunc: func(createEvent event.CreateEvent) bool { - return false - }, - GenericFunc: func(genericEvent event.GenericEvent) bool { - return false - }, - }) + err = c.Watch(source.Kind(mgr.GetCache(), &secret), handler.EnqueueRequestForOwner( + mgr.GetScheme(), mgr.GetRESTMapper(), &appsv1alpha1.ResourceDistribution{}, handler.OnlyControllerOwner()), + predicate.Funcs{ + CreateFunc: func(createEvent event.CreateEvent) bool { + return false + }, + GenericFunc: func(genericEvent event.GenericEvent) bool { + return false + }, + }) if err != nil { return err } @@ -129,16 +129,16 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error { // Watch for changes to ConfigMap configMap := unstructured.Unstructured{} configMap.SetGroupVersionKind(corev1.SchemeGroupVersion.WithKind("ConfigMap")) - err = c.Watch(&source.Kind{Type: &configMap}, &handler.EnqueueRequestForOwner{ - IsController: true, OwnerType: &appsv1alpha1.ResourceDistribution{}, - }, predicate.Funcs{ - CreateFunc: func(createEvent event.CreateEvent) bool { - return false - }, - GenericFunc: func(genericEvent event.GenericEvent) bool { - return false - }, - }) + err = c.Watch(source.Kind(mgr.GetCache(), &configMap), handler.EnqueueRequestForOwner( + mgr.GetScheme(), mgr.GetRESTMapper(), &appsv1alpha1.ResourceDistribution{}, handler.OnlyControllerOwner()), + predicate.Funcs{ + CreateFunc: func(createEvent event.CreateEvent) bool { + return false + }, + GenericFunc: func(genericEvent event.GenericEvent) bool { + return false + }, + }) if err != nil { return err } diff --git a/pkg/controller/resourcedistribution/resourcedistribution_controller_test.go b/pkg/controller/resourcedistribution/resourcedistribution_controller_test.go index b5b8fd1067..b1a80ffa0c 100644 --- a/pkg/controller/resourcedistribution/resourcedistribution_controller_test.go +++ b/pkg/controller/resourcedistribution/resourcedistribution_controller_test.go @@ -233,6 +233,7 @@ func makeEnvironment() []runtime.Object { func makeClientEnvironment(addition ...runtime.Object) { env := append(makeEnvironment(), addition...) - fakeClient := fake.NewFakeClientWithScheme(scheme, env...) + fakeClient := fake.NewClientBuilder().WithScheme(scheme).WithRuntimeObjects(env...). + WithStatusSubresource(&appsv1alpha1.ResourceDistribution{}).Build() reconcileHandler.Client = fakeClient } diff --git a/pkg/controller/resourcedistribution/resourcedistribution_namespace_event_handler.go b/pkg/controller/resourcedistribution/resourcedistribution_namespace_event_handler.go index 5e202cd3d4..9eb1894fc6 100644 --- a/pkg/controller/resourcedistribution/resourcedistribution_namespace_event_handler.go +++ b/pkg/controller/resourcedistribution/resourcedistribution_namespace_event_handler.go @@ -39,15 +39,15 @@ type enqueueRequestForNamespace struct { reader client.Reader } -func (p *enqueueRequestForNamespace) Create(evt event.CreateEvent, q workqueue.RateLimitingInterface) { +func (p *enqueueRequestForNamespace) Create(ctx context.Context, evt event.CreateEvent, q workqueue.RateLimitingInterface) { p.addNamespace(q, evt.Object, matchViaTargets) } -func (p *enqueueRequestForNamespace) Delete(evt event.DeleteEvent, q workqueue.RateLimitingInterface) { +func (p *enqueueRequestForNamespace) Delete(ctx context.Context, evt event.DeleteEvent, q workqueue.RateLimitingInterface) { p.addNamespace(q, evt.Object, matchViaIncludedNamespaces) } -func (p *enqueueRequestForNamespace) Generic(evt event.GenericEvent, q workqueue.RateLimitingInterface) { +func (p *enqueueRequestForNamespace) Generic(ctx context.Context, evt event.GenericEvent, q workqueue.RateLimitingInterface) { } -func (p *enqueueRequestForNamespace) Update(evt event.UpdateEvent, q workqueue.RateLimitingInterface) { +func (p *enqueueRequestForNamespace) Update(ctx context.Context, evt event.UpdateEvent, q workqueue.RateLimitingInterface) { p.updateNamespace(q, evt.ObjectOld, evt.ObjectNew) } diff --git a/pkg/controller/resourcedistribution/resourcedistribution_namespace_event_handler_test.go b/pkg/controller/resourcedistribution/resourcedistribution_namespace_event_handler_test.go index 477bb6087a..aefe452aef 100644 --- a/pkg/controller/resourcedistribution/resourcedistribution_namespace_event_handler_test.go +++ b/pkg/controller/resourcedistribution/resourcedistribution_namespace_event_handler_test.go @@ -39,7 +39,7 @@ func init() { func TestNamespaceEventHandler(t *testing.T) { distributor1 := buildResourceDistributionWithSecret() env := append(makeEnvironment(), distributor1) - handlerClient := fake.NewFakeClientWithScheme(scheme, env...) + handlerClient := fake.NewClientBuilder().WithScheme(scheme).WithRuntimeObjects(env...).Build() enqueueHandler.reader = handlerClient // case 1 @@ -78,7 +78,7 @@ func testEnqueueRequestForNamespaceCreate(namespace *corev1.Namespace, expectedN createEvt := event.CreateEvent{ Object: namespace, } - enqueueHandler.Create(createEvt, createQ) + enqueueHandler.Create(context.TODO(), createEvt, createQ) if createQ.Len() != expectedNumber { t.Errorf("unexpected create event handle queue size, expected %d actual %d", expectedNumber, createQ.Len()) } @@ -90,7 +90,7 @@ func testEnqueueRequestForNamespaceUpdate(namespaceOld, namespaceNew *corev1.Nam ObjectOld: namespaceOld, ObjectNew: namespaceNew, } - enqueueHandler.Update(updateEvt, updateQ) + enqueueHandler.Update(context.TODO(), updateEvt, updateQ) if updateQ.Len() != expectedNumber { t.Errorf("unexpected update event handle queue size, expected %d actual %d", expectedNumber, updateQ.Len()) } @@ -101,7 +101,7 @@ func testEnqueueRequestForNamespaceDelete(namespace *corev1.Namespace, expectedN deleteEvt := event.DeleteEvent{ Object: namespace, } - enqueueHandler.Delete(deleteEvt, deleteQ) + enqueueHandler.Delete(context.TODO(), deleteEvt, deleteQ) if deleteQ.Len() != expectedNumber { t.Errorf("unexpected delete event handle queue size, expected %d actual %d", expectedNumber, deleteQ.Len()) } diff --git a/pkg/controller/sidecarset/sidecarset_controller.go b/pkg/controller/sidecarset/sidecarset_controller.go index 9ffc29b688..d6cf64e881 100644 --- a/pkg/controller/sidecarset/sidecarset_controller.go +++ b/pkg/controller/sidecarset/sidecarset_controller.go @@ -85,7 +85,7 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error { } // Watch for changes to SidecarSet - err = c.Watch(&source.Kind{Type: &appsv1alpha1.SidecarSet{}}, &handler.EnqueueRequestForObject{}, predicate.Funcs{ + err = c.Watch(source.Kind(mgr.GetCache(), &appsv1alpha1.SidecarSet{}), &handler.EnqueueRequestForObject{}, predicate.Funcs{ UpdateFunc: func(e event.UpdateEvent) bool { oldScS := e.ObjectOld.(*appsv1alpha1.SidecarSet) newScS := e.ObjectNew.(*appsv1alpha1.SidecarSet) @@ -101,7 +101,7 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error { } // Watch for changes to Pod - if err = c.Watch(&source.Kind{Type: &corev1.Pod{}}, &enqueueRequestForPod{reader: mgr.GetCache()}); err != nil { + if err = c.Watch(source.Kind(mgr.GetCache(), &corev1.Pod{}), &enqueueRequestForPod{reader: mgr.GetCache()}); err != nil { return err } diff --git a/pkg/controller/sidecarset/sidecarset_controller_test.go b/pkg/controller/sidecarset/sidecarset_controller_test.go index c040e1b3ec..1a334e3a2c 100644 --- a/pkg/controller/sidecarset/sidecarset_controller_test.go +++ b/pkg/controller/sidecarset/sidecarset_controller_test.go @@ -182,7 +182,9 @@ func testUpdateWhenUseNotUpdateStrategy(t *testing.T, sidecarSetInput *appsv1alp }, } - fakeClient := fake.NewClientBuilder().WithScheme(scheme).WithObjects(sidecarSetInput, podInput).Build() + fakeClient := fake.NewClientBuilder().WithScheme(scheme). + WithObjects(sidecarSetInput, podInput). + WithStatusSubresource(&appsv1alpha1.SidecarSet{}).Build() reconciler := ReconcileSidecarSet{ Client: fakeClient, processor: NewSidecarSetProcessor(fakeClient, record.NewFakeRecorder(10)), @@ -215,7 +217,9 @@ func testUpdateWhenSidecarSetPaused(t *testing.T, sidecarSetInput *appsv1alpha1. }, } - fakeClient := fake.NewClientBuilder().WithScheme(scheme).WithObjects(sidecarSetInput, podInput).Build() + fakeClient := fake.NewClientBuilder().WithScheme(scheme). + WithObjects(sidecarSetInput, podInput). + WithStatusSubresource(&appsv1alpha1.SidecarSet{}).Build() reconciler := ReconcileSidecarSet{ Client: fakeClient, processor: NewSidecarSetProcessor(fakeClient, record.NewFakeRecorder(10)), @@ -248,7 +252,9 @@ func testUpdateWhenMaxUnavailableNotZero(t *testing.T, sidecarSetInput *appsv1al }, } - fakeClient := fake.NewClientBuilder().WithScheme(scheme).WithObjects(sidecarSetInput, podInput).Build() + fakeClient := fake.NewClientBuilder().WithScheme(scheme). + WithObjects(sidecarSetInput, podInput). + WithStatusSubresource(&appsv1alpha1.SidecarSet{}).Build() reconciler := ReconcileSidecarSet{ Client: fakeClient, processor: NewSidecarSetProcessor(fakeClient, record.NewFakeRecorder(10)), @@ -282,7 +288,8 @@ func testUpdateWhenPartitionFinished(t *testing.T, sidecarSetInput *appsv1alpha1 }, } - fakeClient := fake.NewClientBuilder().WithScheme(scheme).WithObjects(sidecarSetInput, podInput).Build() + fakeClient := fake.NewClientBuilder().WithScheme(scheme).WithObjects(sidecarSetInput, podInput). + WithStatusSubresource(&appsv1alpha1.SidecarSet{}).Build() reconciler := ReconcileSidecarSet{ Client: fakeClient, processor: NewSidecarSetProcessor(fakeClient, record.NewFakeRecorder(10)), @@ -316,7 +323,8 @@ func testRemoveSidecarSet(t *testing.T, sidecarSetInput *appsv1alpha1.SidecarSet }, } - fakeClient := fake.NewClientBuilder().WithScheme(scheme).WithObjects(sidecarSetInput, podInput).Build() + fakeClient := fake.NewClientBuilder().WithScheme(scheme).WithObjects(sidecarSetInput, podInput). + WithStatusSubresource(&appsv1alpha1.SidecarSet{}).Build() reconciler := ReconcileSidecarSet{ Client: fakeClient, processor: NewSidecarSetProcessor(fakeClient, record.NewFakeRecorder(10)), diff --git a/pkg/controller/sidecarset/sidecarset_hotupgrade_test.go b/pkg/controller/sidecarset/sidecarset_hotupgrade_test.go index 27ea9bdb72..bcd49f4eeb 100644 --- a/pkg/controller/sidecarset/sidecarset_hotupgrade_test.go +++ b/pkg/controller/sidecarset/sidecarset_hotupgrade_test.go @@ -247,7 +247,8 @@ func testUpdateHotUpgradeSidecar(t *testing.T, hotUpgradeEmptyImage string, side t.Run(cs.name, func(t *testing.T) { pod := cs.getPods()[0] sidecarset := cs.getSidecarset() - fakeClient := fake.NewClientBuilder().WithScheme(scheme).WithObjects(sidecarset, pod).Build() + fakeClient := fake.NewClientBuilder().WithScheme(scheme).WithObjects(sidecarset, pod). + WithStatusSubresource(&appsv1alpha1.SidecarSet{}).Build() processor := NewSidecarSetProcessor(fakeClient, record.NewFakeRecorder(10)) _, err := processor.UpdateSidecarSet(sidecarset) if err != nil { diff --git a/pkg/controller/sidecarset/sidecarset_pod_event_handler.go b/pkg/controller/sidecarset/sidecarset_pod_event_handler.go index cc7f1c8acb..b75dbeff40 100644 --- a/pkg/controller/sidecarset/sidecarset_pod_event_handler.go +++ b/pkg/controller/sidecarset/sidecarset_pod_event_handler.go @@ -28,18 +28,18 @@ type enqueueRequestForPod struct { reader client.Reader } -func (p *enqueueRequestForPod) Create(evt event.CreateEvent, q workqueue.RateLimitingInterface) { +func (p *enqueueRequestForPod) Create(ctx context.Context, evt event.CreateEvent, q workqueue.RateLimitingInterface) { p.addPod(q, evt.Object) } -func (p *enqueueRequestForPod) Delete(evt event.DeleteEvent, q workqueue.RateLimitingInterface) { +func (p *enqueueRequestForPod) Delete(ctx context.Context, evt event.DeleteEvent, q workqueue.RateLimitingInterface) { p.deletePod(evt.Object) } -func (p *enqueueRequestForPod) Generic(evt event.GenericEvent, q workqueue.RateLimitingInterface) { +func (p *enqueueRequestForPod) Generic(ctx context.Context, evt event.GenericEvent, q workqueue.RateLimitingInterface) { } -func (p *enqueueRequestForPod) Update(evt event.UpdateEvent, q workqueue.RateLimitingInterface) { +func (p *enqueueRequestForPod) Update(ctx context.Context, evt event.UpdateEvent, q workqueue.RateLimitingInterface) { p.updatePod(q, evt.ObjectOld, evt.ObjectNew) } diff --git a/pkg/controller/sidecarset/sidecarset_pod_event_handler_test.go b/pkg/controller/sidecarset/sidecarset_pod_event_handler_test.go index ac056a2cb1..a30ef2e09f 100644 --- a/pkg/controller/sidecarset/sidecarset_pod_event_handler_test.go +++ b/pkg/controller/sidecarset/sidecarset_pod_event_handler_test.go @@ -46,7 +46,7 @@ func TestPodEventHandler(t *testing.T) { createEvt := event.CreateEvent{ Object: podDemo, } - handler.Create(createEvt, createQ) + handler.Create(context.TODO(), createEvt, createQ) if createQ.Len() != 1 { t.Errorf("unexpected create event handle queue size, expected 1 actual %d", createQ.Len()) } @@ -61,7 +61,7 @@ func TestPodEventHandler(t *testing.T) { ObjectOld: podDemo, ObjectNew: newPod, } - handler.Update(updateEvent, updateQ) + handler.Update(context.TODO(), updateEvent, updateQ) if updateQ.Len() != 1 { t.Errorf("unexpected update event handle queue size, expected 1 actual %d", updateQ.Len()) } @@ -75,7 +75,7 @@ func TestPodEventHandler(t *testing.T) { ObjectOld: podDemo, ObjectNew: newPod, } - handler.Update(updateEvent, updateQ) + handler.Update(context.TODO(), updateEvent, updateQ) if updateQ.Len() != 0 { t.Errorf("unexpected update event handle queue size, expected 0 actual %d", updateQ.Len()) } @@ -85,7 +85,7 @@ func TestPodEventHandler(t *testing.T) { deleteEvt := event.DeleteEvent{ Object: podDemo, } - handler.Delete(deleteEvt, deleteQ) + handler.Delete(context.TODO(), deleteEvt, deleteQ) if deleteQ.Len() != 0 { t.Errorf("unexpected delete event handle queue size, expected 1 actual %d", deleteQ.Len()) } diff --git a/pkg/controller/sidecarset/sidecarset_processor_test.go b/pkg/controller/sidecarset/sidecarset_processor_test.go index 8752b928d3..cf768b45b3 100644 --- a/pkg/controller/sidecarset/sidecarset_processor_test.go +++ b/pkg/controller/sidecarset/sidecarset_processor_test.go @@ -175,7 +175,9 @@ func testUpdateColdUpgradeSidecar(t *testing.T, podDemo *corev1.Pod, sidecarSetI t.Run(cs.name, func(t *testing.T) { pods := cs.getPods() sidecarset := cs.getSidecarset() - fakeClient := fake.NewClientBuilder().WithScheme(scheme).WithObjects(sidecarset, pods[0], pods[1]).Build() + fakeClient := fake.NewClientBuilder().WithScheme(scheme). + WithObjects(sidecarset, pods[0], pods[1]). + WithStatusSubresource(&appsv1alpha1.SidecarSet{}).Build() processor := NewSidecarSetProcessor(fakeClient, record.NewFakeRecorder(10)) _, err := processor.UpdateSidecarSet(sidecarset) if err != nil { @@ -270,7 +272,8 @@ func TestCanUpgradePods(t *testing.T) { Type: intstr.String, StrVal: "50%", } - fakeClient := fake.NewClientBuilder().WithScheme(scheme).WithObjects(sidecarSet).Build() + fakeClient := fake.NewClientBuilder().WithScheme(scheme).WithObjects(sidecarSet). + WithStatusSubresource(&appsv1alpha1.SidecarSet{}).Build() pods := factoryPodsCommon(100, 0, sidecarSet) for i := range pods { pods[i].Annotations[sidecarcontrol.SidecarSetListAnnotation] = `test-sidecarset` diff --git a/pkg/controller/sidecarterminator/sidecar_terminator_controller.go b/pkg/controller/sidecarterminator/sidecar_terminator_controller.go index 68293216c3..748d82fcab 100644 --- a/pkg/controller/sidecarterminator/sidecar_terminator_controller.go +++ b/pkg/controller/sidecarterminator/sidecar_terminator_controller.go @@ -93,7 +93,7 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error { } // Watch for changes to Pod - if err = c.Watch(&source.Kind{Type: &corev1.Pod{}}, &enqueueRequestForPod{}); err != nil { + if err = c.Watch(source.Kind(mgr.GetCache(), &corev1.Pod{}), &enqueueRequestForPod{}); err != nil { return err } diff --git a/pkg/controller/sidecarterminator/sidecar_terminator_pod_event_handler.go b/pkg/controller/sidecarterminator/sidecar_terminator_pod_event_handler.go index 59d5be58d6..2a9c4ecd70 100644 --- a/pkg/controller/sidecarterminator/sidecar_terminator_pod_event_handler.go +++ b/pkg/controller/sidecarterminator/sidecar_terminator_pod_event_handler.go @@ -17,6 +17,7 @@ limitations under the License. package sidecarterminator import ( + "context" "strings" corev1 "k8s.io/api/core/v1" @@ -35,12 +36,14 @@ var _ handler.EventHandler = &enqueueRequestForPod{} type enqueueRequestForPod struct{} -func (p *enqueueRequestForPod) Delete(evt event.DeleteEvent, q workqueue.RateLimitingInterface) {} -func (p *enqueueRequestForPod) Generic(evt event.GenericEvent, q workqueue.RateLimitingInterface) {} -func (p *enqueueRequestForPod) Create(evt event.CreateEvent, q workqueue.RateLimitingInterface) { +func (p *enqueueRequestForPod) Delete(ctx context.Context, evt event.DeleteEvent, q workqueue.RateLimitingInterface) { +} +func (p *enqueueRequestForPod) Generic(ctx context.Context, evt event.GenericEvent, q workqueue.RateLimitingInterface) { +} +func (p *enqueueRequestForPod) Create(ctx context.Context, evt event.CreateEvent, q workqueue.RateLimitingInterface) { p.handlePodCreate(q, evt.Object) } -func (p *enqueueRequestForPod) Update(evt event.UpdateEvent, q workqueue.RateLimitingInterface) { +func (p *enqueueRequestForPod) Update(ctx context.Context, evt event.UpdateEvent, q workqueue.RateLimitingInterface) { p.handlePodUpdate(q, evt.ObjectOld, evt.ObjectNew) } diff --git a/pkg/controller/sidecarterminator/sidecar_terminator_pod_event_handler_test.go b/pkg/controller/sidecarterminator/sidecar_terminator_pod_event_handler_test.go index f3c863b6c0..3354b1d2ff 100644 --- a/pkg/controller/sidecarterminator/sidecar_terminator_pod_event_handler_test.go +++ b/pkg/controller/sidecarterminator/sidecar_terminator_pod_event_handler_test.go @@ -17,6 +17,7 @@ limitations under the License. package sidecarterminator import ( + "context" "testing" corev1 "k8s.io/api/core/v1" @@ -254,7 +255,7 @@ func TestEnqueueRequestForPodUpdate(t *testing.T) { ObjectNew: cs.getNewPod(), } que := workqueue.NewRateLimitingQueue(workqueue.DefaultControllerRateLimiter()) - eventHandler.Update(evt, que) + eventHandler.Update(context.TODO(), evt, que) if que.Len() != cs.expectLen { t.Fatalf("Get unexpected queue length, expected %v, actual %v", cs.expectLen, que.Len()) } @@ -360,7 +361,7 @@ func TestEnqueueRequestForPodCreate(t *testing.T) { Object: cs.getPod(), } que := workqueue.NewRateLimitingQueue(workqueue.DefaultControllerRateLimiter()) - eventHandler.Create(evt, que) + eventHandler.Create(context.TODO(), evt, que) if que.Len() != cs.expectLen { t.Fatalf("Get unexpected queue length, expected %v, actual %v", cs.expectLen, que.Len()) } diff --git a/pkg/controller/statefulset/statefulset_controller.go b/pkg/controller/statefulset/statefulset_controller.go index 91d1dac6f2..1ceb024742 100644 --- a/pkg/controller/statefulset/statefulset_controller.go +++ b/pkg/controller/statefulset/statefulset_controller.go @@ -188,7 +188,7 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error { } // Watch for changes to StatefulSet - err = c.Watch(&source.Kind{Type: &appsv1beta1.StatefulSet{}}, &handler.EnqueueRequestForObject{}, predicate.Funcs{ + err = c.Watch(source.Kind(mgr.GetCache(), &appsv1beta1.StatefulSet{}), &handler.EnqueueRequestForObject{}, predicate.Funcs{ UpdateFunc: func(e event.UpdateEvent) bool { oldSS := e.ObjectOld.(*appsv1beta1.StatefulSet) newSS := e.ObjectNew.(*appsv1beta1.StatefulSet) @@ -203,10 +203,8 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error { } // Watch for changes to Pod created by StatefulSet - err = c.Watch(&source.Kind{Type: &v1.Pod{}}, &handler.EnqueueRequestForOwner{ - IsController: true, - OwnerType: &appsv1beta1.StatefulSet{}, - }) + err = c.Watch(source.Kind(mgr.GetCache(), &v1.Pod{}), handler.EnqueueRequestForOwner( + mgr.GetScheme(), mgr.GetRESTMapper(), &appsv1beta1.StatefulSet{}, handler.OnlyControllerOwner())) if err != nil { return err } diff --git a/pkg/controller/uniteddeployment/uniteddeployment_controller.go b/pkg/controller/uniteddeployment/uniteddeployment_controller.go index b5334c4606..55dd7b8199 100644 --- a/pkg/controller/uniteddeployment/uniteddeployment_controller.go +++ b/pkg/controller/uniteddeployment/uniteddeployment_controller.go @@ -111,39 +111,31 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error { } // Watch for changes to UnitedDeployment - err = c.Watch(&source.Kind{Type: &appsv1alpha1.UnitedDeployment{}}, &handler.EnqueueRequestForObject{}) + err = c.Watch(source.Kind(mgr.GetCache(), &appsv1alpha1.UnitedDeployment{}), &handler.EnqueueRequestForObject{}) if err != nil { return err } - err = c.Watch(&source.Kind{Type: &appsv1.StatefulSet{}}, &handler.EnqueueRequestForOwner{ - IsController: true, - OwnerType: &appsv1alpha1.UnitedDeployment{}, - }) + err = c.Watch(source.Kind(mgr.GetCache(), &appsv1.StatefulSet{}), handler.EnqueueRequestForOwner( + mgr.GetScheme(), mgr.GetRESTMapper(), &appsv1alpha1.UnitedDeployment{}, handler.OnlyControllerOwner())) if err != nil { return err } - err = c.Watch(&source.Kind{Type: &appsv1beta1.StatefulSet{}}, &handler.EnqueueRequestForOwner{ - IsController: true, - OwnerType: &appsv1alpha1.UnitedDeployment{}, - }) + err = c.Watch(source.Kind(mgr.GetCache(), &appsv1beta1.StatefulSet{}), handler.EnqueueRequestForOwner( + mgr.GetScheme(), mgr.GetRESTMapper(), &appsv1alpha1.UnitedDeployment{}, handler.OnlyControllerOwner())) if err != nil { return err } - err = c.Watch(&source.Kind{Type: &appsv1alpha1.CloneSet{}}, &handler.EnqueueRequestForOwner{ - IsController: true, - OwnerType: &appsv1alpha1.UnitedDeployment{}, - }) + err = c.Watch(source.Kind(mgr.GetCache(), &appsv1alpha1.CloneSet{}), handler.EnqueueRequestForOwner( + mgr.GetScheme(), mgr.GetRESTMapper(), &appsv1alpha1.UnitedDeployment{}, handler.OnlyControllerOwner())) if err != nil { return err } - err = c.Watch(&source.Kind{Type: &appsv1.Deployment{}}, &handler.EnqueueRequestForOwner{ - IsController: true, - OwnerType: &appsv1alpha1.UnitedDeployment{}, - }) + err = c.Watch(source.Kind(mgr.GetCache(), &appsv1.Deployment{}), handler.EnqueueRequestForOwner( + mgr.GetScheme(), mgr.GetRESTMapper(), &appsv1alpha1.UnitedDeployment{}, handler.OnlyControllerOwner())) if err != nil { return err } diff --git a/pkg/controller/uniteddeployment/uniteddeployment_controller_statefulset_test.go b/pkg/controller/uniteddeployment/uniteddeployment_controller_statefulset_test.go index c6a9bb04a8..b9eb07aae7 100644 --- a/pkg/controller/uniteddeployment/uniteddeployment_controller_statefulset_test.go +++ b/pkg/controller/uniteddeployment/uniteddeployment_controller_statefulset_test.go @@ -34,6 +34,7 @@ import ( "k8s.io/apimachinery/pkg/util/intstr" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/manager" + metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server" "sigs.k8s.io/controller-runtime/pkg/reconcile" appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" @@ -1814,7 +1815,7 @@ func setUp(t *testing.T) (*gomega.GomegaWithT, chan reconcile.Request, context.C g := gomega.NewGomegaWithT(t) // Setup the Manager and Controller. Wrap the Controller Reconcile function so it writes each request to a // channel when it is finished. - mgr, err := manager.New(cfg, manager.Options{MetricsBindAddress: "0"}) + mgr, err := manager.New(cfg, manager.Options{Metrics: metricsserver.Options{BindAddress: "0"}}) g.Expect(err).NotTo(gomega.HaveOccurred()) c = utilclient.NewClientFromManager(mgr, "test-uniteddeployment-controller") recFn, requests := SetupTestReconcile(newReconciler(mgr)) diff --git a/pkg/controller/util/watch.go b/pkg/controller/util/watch.go index 899466de53..3805c4294b 100644 --- a/pkg/controller/util/watch.go +++ b/pkg/controller/util/watch.go @@ -5,7 +5,6 @@ import ( "sync" "time" - "github.com/openkruise/kruise/pkg/client" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime/schema" @@ -13,7 +12,10 @@ import ( "k8s.io/klog/v2" "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/handler" + "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/source" + + "github.com/openkruise/kruise/pkg/client" ) var watcherMap = sync.Map{} @@ -52,7 +54,7 @@ func DiscoverGVK(gvk schema.GroupVersionKind) bool { return true } -func AddWatcherDynamically(c controller.Controller, h handler.EventHandler, gvk schema.GroupVersionKind, controllerKey string) (bool, error) { +func AddWatcherDynamically(mgr manager.Manager, c controller.Controller, h handler.EventHandler, gvk schema.GroupVersionKind, controllerKey string) (bool, error) { cacheKey := fmt.Sprintf("controller:%s, gvk:%s", controllerKey, gvk.String()) if _, ok := watcherMap.Load(cacheKey); ok { return false, nil @@ -66,5 +68,5 @@ func AddWatcherDynamically(c controller.Controller, h handler.EventHandler, gvk object := &unstructured.Unstructured{} object.SetGroupVersionKind(gvk) watcherMap.Store(cacheKey, true) - return true, c.Watch(&source.Kind{Type: object}, h) + return true, c.Watch(source.Kind(mgr.GetCache(), object), h) } diff --git a/pkg/controller/workloadspread/reschedule_test.go b/pkg/controller/workloadspread/reschedule_test.go index f8bf7dce36..d4d0a6168d 100644 --- a/pkg/controller/workloadspread/reschedule_test.go +++ b/pkg/controller/workloadspread/reschedule_test.go @@ -267,7 +267,7 @@ func TestRescheduleSubset(t *testing.T) { owners = append(owners, string(ref.UID)) } return owners - }).Build() + }).WithStatusSubresource(&appsv1alpha1.WorkloadSpread{}).Build() for _, pod := range cs.getPods() { podIn := pod.DeepCopy() err := fakeClient.Create(context.TODO(), podIn) diff --git a/pkg/controller/workloadspread/workloadspread_controller.go b/pkg/controller/workloadspread/workloadspread_controller.go index 9b2946fcb8..0d9536db6a 100644 --- a/pkg/controller/workloadspread/workloadspread_controller.go +++ b/pkg/controller/workloadspread/workloadspread_controller.go @@ -122,37 +122,37 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error { } // Watch WorkloadSpread - err = c.Watch(&source.Kind{Type: &appsv1alpha1.WorkloadSpread{}}, &handler.EnqueueRequestForObject{}) + err = c.Watch(source.Kind(mgr.GetCache(), &appsv1alpha1.WorkloadSpread{}), &handler.EnqueueRequestForObject{}) if err != nil { return err } // Watch for changes to Pods have a specific annotation - err = c.Watch(&source.Kind{Type: &corev1.Pod{}}, &podEventHandler{}) + err = c.Watch(source.Kind(mgr.GetCache(), &corev1.Pod{}), &podEventHandler{}) if err != nil { return err } // Watch for replica changes to CloneSet - err = c.Watch(&source.Kind{Type: &appsv1alpha1.CloneSet{}}, &workloadEventHandler{Reader: mgr.GetCache()}) + err = c.Watch(source.Kind(mgr.GetCache(), &appsv1alpha1.CloneSet{}), &workloadEventHandler{Reader: mgr.GetCache()}) if err != nil { return err } // Watch for replica changes to Deployment - err = c.Watch(&source.Kind{Type: &appsv1.Deployment{}}, &workloadEventHandler{Reader: mgr.GetCache()}) + err = c.Watch(source.Kind(mgr.GetCache(), &appsv1.Deployment{}), &workloadEventHandler{Reader: mgr.GetCache()}) if err != nil { return err } // Watch for replica changes to ReplicaSet - err = c.Watch(&source.Kind{Type: &appsv1.ReplicaSet{}}, &workloadEventHandler{Reader: mgr.GetCache()}) + err = c.Watch(source.Kind(mgr.GetCache(), &appsv1.ReplicaSet{}), &workloadEventHandler{Reader: mgr.GetCache()}) if err != nil { return err } // Watch for parallelism changes to Job - err = c.Watch(&source.Kind{Type: &batchv1.Job{}}, &workloadEventHandler{Reader: mgr.GetCache()}) + err = c.Watch(source.Kind(mgr.GetCache(), &batchv1.Job{}), &workloadEventHandler{Reader: mgr.GetCache()}) if err != nil { return err } @@ -165,7 +165,7 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error { if len(whiteList.Workloads) > 0 { workloadHandler := &workloadEventHandler{Reader: mgr.GetClient()} for _, workload := range whiteList.Workloads { - if _, err := ctrlUtil.AddWatcherDynamically(c, workloadHandler, workload.GroupVersionKind, "WorkloadSpread"); err != nil { + if _, err := ctrlUtil.AddWatcherDynamically(mgr, c, workloadHandler, workload.GroupVersionKind, "WorkloadSpread"); err != nil { return err } } diff --git a/pkg/controller/workloadspread/workloadspread_controller_test.go b/pkg/controller/workloadspread/workloadspread_controller_test.go index 3d239e0fe1..0798ff9217 100644 --- a/pkg/controller/workloadspread/workloadspread_controller_test.go +++ b/pkg/controller/workloadspread/workloadspread_controller_test.go @@ -387,6 +387,7 @@ func TestSubsetPodDeletionCost(t *testing.T) { } deleteTime := metav1.Now() pods[0].DeletionTimestamp = &deleteTime + pods[0].Finalizers = []string{"finalizers.sigs.k8s.io/test"} return pods }, getWorkloadSpread: func() *appsv1alpha1.WorkloadSpread { @@ -535,6 +536,7 @@ func TestSubsetPodDeletionCost(t *testing.T) { deleteTime := metav1.Now() pods[4].DeletionTimestamp = &deleteTime + pods[4].Finalizers = []string{"finalizers.sigs.k8s.io/test"} return pods }, getWorkloadSpread: func() *appsv1alpha1.WorkloadSpread { @@ -577,6 +579,7 @@ func TestSubsetPodDeletionCost(t *testing.T) { deleteTime := metav1.Now() pods[3].DeletionTimestamp = &deleteTime + pods[3].Finalizers = []string{"finalizers.sigs.k8s.io/test"} return pods }, getWorkloadSpread: func() *appsv1alpha1.WorkloadSpread { @@ -1199,6 +1202,7 @@ func TestWorkloadSpreadReconcile(t *testing.T) { } deleteTime := metav1.Time{Time: currentTime.Add(1 * s)} pods[4].DeletionTimestamp = &deleteTime + pods[4].Finalizers = []string{"finalizers.sigs.k8s.io/test"} return pods }, getWorkloadSpread: func() *appsv1alpha1.WorkloadSpread { @@ -1530,27 +1534,22 @@ func TestWorkloadSpreadReconcile(t *testing.T) { t.Run(cs.name, func(t *testing.T) { currentTime = time.Now() workloadSpread := cs.getWorkloadSpread() - fakeClient := fake.NewClientBuilder().WithScheme(scheme).WithObjects(workloadSpread). + builder := fake.NewClientBuilder().WithScheme(scheme).WithObjects(workloadSpread). WithIndex(&corev1.Pod{}, fieldindex.IndexNameForOwnerRefUID, func(obj client.Object) []string { var owners []string for _, ref := range obj.GetOwnerReferences() { owners = append(owners, string(ref.UID)) } return owners - }).Build() + }).WithStatusSubresource(&appsv1alpha1.WorkloadSpread{}) if cs.getCloneSet() != nil { - err := fakeClient.Create(context.TODO(), cs.getCloneSet()) - if err != nil { - t.Fatalf("create pod failed: %s", err.Error()) - } + builder.WithObjects(cs.getCloneSet()) } for _, pod := range cs.getPods() { podIn := pod.DeepCopy() - err := fakeClient.Create(context.TODO(), podIn) - if err != nil { - t.Fatalf("create pod failed: %s", err.Error()) - } + builder.WithObjects(podIn) } + fakeClient := builder.Build() reconciler := ReconcileWorkloadSpread{ Client: fakeClient, @@ -1572,7 +1571,7 @@ func TestWorkloadSpreadReconcile(t *testing.T) { if !reflect.DeepEqual(annotation1, annotation2) { fmt.Println(annotation1) fmt.Println(annotation2) - t.Fatalf("set Pod deletion-cost annotation failed") + t.Fatalf("set Pod %v deletion-cost annotation failed", latestPodList[i].Name) } } @@ -2179,28 +2178,24 @@ func TestManagerExistingPods(t *testing.T) { t.Run(cs.name, func(t *testing.T) { currentTime = time.Now() workloadSpread := cs.getWorkloadSpread() - fakeClient := fake.NewClientBuilder().WithScheme(scheme).WithObjects(cs.getCloneSet(), workloadSpread). - WithIndex(&corev1.Pod{}, fieldindex.IndexNameForOwnerRefUID, func(obj client.Object) []string { - var owners []string - for _, ref := range obj.GetOwnerReferences() { - owners = append(owners, string(ref.UID)) - } - return owners - }).Build() + builder := fake.NewClientBuilder().WithScheme(scheme).WithObjects(cs.getCloneSet(), workloadSpread) + builder.WithIndex(&corev1.Pod{}, fieldindex.IndexNameForOwnerRefUID, func(obj client.Object) []string { + var owners []string + for _, ref := range obj.GetOwnerReferences() { + owners = append(owners, string(ref.UID)) + } + return owners + }) for _, pod := range cs.getPods() { podIn := pod.DeepCopy() - err := fakeClient.Create(context.TODO(), podIn) - if err != nil { - t.Fatalf("create pod failed: %s", err.Error()) - } + builder.WithObjects(podIn) } for _, node := range cs.getNodes() { nodeIn := node.DeepCopy() - err := fakeClient.Create(context.TODO(), nodeIn) - if err != nil { - t.Fatalf("create node failed: %s", err.Error()) - } + builder.WithObjects(nodeIn) } + builder.WithStatusSubresource(&appsv1alpha1.WorkloadSpread{}) + fakeClient := builder.Build() reconciler := ReconcileWorkloadSpread{ Client: fakeClient, diff --git a/pkg/controller/workloadspread/workloadspread_event_handler.go b/pkg/controller/workloadspread/workloadspread_event_handler.go index f8b5573803..243181bb11 100644 --- a/pkg/controller/workloadspread/workloadspread_event_handler.go +++ b/pkg/controller/workloadspread/workloadspread_event_handler.go @@ -55,11 +55,11 @@ var _ handler.EventHandler = &podEventHandler{} type podEventHandler struct{} -func (p *podEventHandler) Create(evt event.CreateEvent, q workqueue.RateLimitingInterface) { +func (p *podEventHandler) Create(ctx context.Context, evt event.CreateEvent, q workqueue.RateLimitingInterface) { p.handlePod(q, evt.Object, CreateEventAction) } -func (p *podEventHandler) Update(evt event.UpdateEvent, q workqueue.RateLimitingInterface) { +func (p *podEventHandler) Update(ctx context.Context, evt event.UpdateEvent, q workqueue.RateLimitingInterface) { oldPod := evt.ObjectOld.(*corev1.Pod) newPod := evt.ObjectNew.(*corev1.Pod) @@ -68,11 +68,12 @@ func (p *podEventHandler) Update(evt event.UpdateEvent, q workqueue.RateLimiting } } -func (p *podEventHandler) Delete(evt event.DeleteEvent, q workqueue.RateLimitingInterface) { +func (p *podEventHandler) Delete(ctx context.Context, evt event.DeleteEvent, q workqueue.RateLimitingInterface) { p.handlePod(q, evt.Object, DeleteEventAction) } -func (p *podEventHandler) Generic(evt event.GenericEvent, q workqueue.RateLimitingInterface) {} +func (p *podEventHandler) Generic(ctx context.Context, evt event.GenericEvent, q workqueue.RateLimitingInterface) { +} func (p *podEventHandler) handlePod(q workqueue.RateLimitingInterface, obj runtime.Object, action EventAction) { pod := obj.(*corev1.Pod) @@ -95,11 +96,11 @@ type workloadEventHandler struct { client.Reader } -func (w workloadEventHandler) Create(evt event.CreateEvent, q workqueue.RateLimitingInterface) { +func (w workloadEventHandler) Create(ctx context.Context, evt event.CreateEvent, q workqueue.RateLimitingInterface) { w.handleWorkload(q, evt.Object, CreateEventAction) } -func (w workloadEventHandler) Update(evt event.UpdateEvent, q workqueue.RateLimitingInterface) { +func (w workloadEventHandler) Update(ctx context.Context, evt event.UpdateEvent, q workqueue.RateLimitingInterface) { var gvk schema.GroupVersionKind var oldReplicas int32 var newReplicas int32 @@ -166,11 +167,11 @@ func (w workloadEventHandler) Update(evt event.UpdateEvent, q workqueue.RateLimi } } -func (w workloadEventHandler) Delete(evt event.DeleteEvent, q workqueue.RateLimitingInterface) { +func (w workloadEventHandler) Delete(ctx context.Context, evt event.DeleteEvent, q workqueue.RateLimitingInterface) { w.handleWorkload(q, evt.Object, DeleteEventAction) } -func (w workloadEventHandler) Generic(evt event.GenericEvent, q workqueue.RateLimitingInterface) { +func (w workloadEventHandler) Generic(ctx context.Context, evt event.GenericEvent, q workqueue.RateLimitingInterface) { } func (w *workloadEventHandler) handleWorkload(q workqueue.RateLimitingInterface, diff --git a/pkg/controller/workloadspread/workloadspread_event_handler_test.go b/pkg/controller/workloadspread/workloadspread_event_handler_test.go index 7f722de760..f1461070db 100644 --- a/pkg/controller/workloadspread/workloadspread_event_handler_test.go +++ b/pkg/controller/workloadspread/workloadspread_event_handler_test.go @@ -160,7 +160,7 @@ func TestPodEventHandler(t *testing.T) { createEvt := event.CreateEvent{ Object: createPod, } - handler.Create(createEvt, createQ) + handler.Create(context.TODO(), createEvt, createQ) if createQ.Len() != 1 { t.Errorf("unexpected create event handle queue size, expected 1 actual %d", createQ.Len()) @@ -190,7 +190,7 @@ func TestPodEventHandler(t *testing.T) { ObjectOld: oldPod, ObjectNew: newPod, } - handler.Update(updateEvt, updateQ) + handler.Update(context.TODO(), updateEvt, updateQ) if updateQ.Len() != 1 { t.Errorf("unexpected update event handle queue size, expected 1 actual %d", createQ.Len()) @@ -213,7 +213,7 @@ func TestPodEventHandler(t *testing.T) { deleteEvt := event.DeleteEvent{ Object: deletePod, } - handler.Delete(deleteEvt, deleteQ) + handler.Delete(context.TODO(), deleteEvt, deleteQ) if deleteQ.Len() != 1 { t.Errorf("unexpected delete event handle queue size, expected 1 actual %d", deleteQ.Len()) @@ -271,6 +271,7 @@ func TestGetWorkloadSpreadForCloneSet(t *testing.T) { workloadSpread1 := workloadSpreadDemo.DeepCopy() workloadSpread1.Name = "ws-1" workloadSpread1.DeletionTimestamp = &metav1.Time{Time: time.Now()} + workloadSpread1.Finalizers = []string{"finalizers.sigs.k8s.io/test"} workloadSpread2 := workloadSpreadDemo.DeepCopy() workloadSpread2.Name = "ws-2" @@ -366,14 +367,13 @@ func TestGetWorkloadSpreadForCloneSet(t *testing.T) { for _, cs := range cases { t.Run(cs.name, func(t *testing.T) { - fakeClient := fake.NewClientBuilder().WithScheme(scheme).Build() + builder := fake.NewClientBuilder().WithScheme(scheme) + builder.WithStatusSubresource(&appsv1alpha1.WorkloadSpread{}) for _, ws := range cs.getWorkloadSpreads() { newWorkloadSpread := ws.DeepCopy() - err := fakeClient.Create(context.TODO(), newWorkloadSpread) - if err != nil { - t.Fatalf("create WorkloadSpread failed: %s", err.Error()) - } + builder.WithObjects(newWorkloadSpread) } + fakeClient := builder.Build() nsn := types.NamespacedName{ Namespace: cs.getCloneSet().Namespace, @@ -448,6 +448,7 @@ func TestGetWorkloadSpreadForDeployment(t *testing.T) { workloadSpread1 := ws.DeepCopy() workloadSpread1.Name = "ws-1" workloadSpread1.DeletionTimestamp = &metav1.Time{Time: time.Now()} + workloadSpread1.Finalizers = []string{"finalizers.sigs.k8s.io/test"} workloadSpread2 := ws.DeepCopy() workloadSpread2.Name = "ws-2" @@ -492,14 +493,12 @@ func TestGetWorkloadSpreadForDeployment(t *testing.T) { for _, cs := range cases { t.Run(cs.name, func(t *testing.T) { - fakeClient := fake.NewClientBuilder().WithScheme(scheme).Build() + builder := fake.NewClientBuilder().WithScheme(scheme) for _, ws := range cs.getWorkloadSpreads() { newWorkloadSpread := ws.DeepCopy() - err := fakeClient.Create(context.TODO(), newWorkloadSpread) - if err != nil { - t.Fatalf("create WorkloadSpread failed: %s", err.Error()) - } + builder.WithObjects(newWorkloadSpread) } + fakeClient := builder.Build() nsn := types.NamespacedName{ Namespace: cs.getDeployment().Namespace, @@ -676,6 +675,7 @@ func TestGetWorkloadSpreadForReplicaSet(t *testing.T) { workloadSpread1 := ws.DeepCopy() workloadSpread1.Name = "ws-1" workloadSpread1.DeletionTimestamp = &metav1.Time{Time: time.Now()} + workloadSpread1.Finalizers = []string{"finalizers.sigs.k8s.io/test"} workloadSpread2 := ws.DeepCopy() workloadSpread2.Name = "ws-2" @@ -720,14 +720,12 @@ func TestGetWorkloadSpreadForReplicaSet(t *testing.T) { for _, cs := range cases { t.Run(cs.name, func(t *testing.T) { - fakeClient := fake.NewClientBuilder().WithScheme(scheme).Build() + builder := fake.NewClientBuilder().WithScheme(scheme) for _, ws := range cs.getWorkloadSpreads() { newWorkloadSpread := ws.DeepCopy() - err := fakeClient.Create(context.TODO(), newWorkloadSpread) - if err != nil { - t.Fatalf("create WorkloadSpread failed: %s", err.Error()) - } + builder.WithObjects(newWorkloadSpread) } + fakeClient := builder.Build() nsn := types.NamespacedName{ Namespace: cs.getReplicaset().Namespace, @@ -802,6 +800,7 @@ func TestGetWorkloadSpreadForStatefulSet(t *testing.T) { workloadSpread1 := ws.DeepCopy() workloadSpread1.Name = "ws-1" workloadSpread1.DeletionTimestamp = &metav1.Time{Time: time.Now()} + workloadSpread1.Finalizers = []string{"finalizers.sigs.k8s.io/test"} workloadSpread2 := ws.DeepCopy() workloadSpread2.Name = "ws-2" @@ -846,14 +845,12 @@ func TestGetWorkloadSpreadForStatefulSet(t *testing.T) { for _, cs := range cases { t.Run(cs.name, func(t *testing.T) { - fakeClient := fake.NewClientBuilder().WithScheme(scheme).Build() + builder := fake.NewClientBuilder().WithScheme(scheme) for _, ws := range cs.getWorkloadSpreads() { newWorkloadSpread := ws.DeepCopy() - err := fakeClient.Create(context.TODO(), newWorkloadSpread) - if err != nil { - t.Fatalf("create WorkloadSpread failed: %s", err.Error()) - } + builder.WithObjects(newWorkloadSpread) } + fakeClient := builder.Build() nsn := types.NamespacedName{ Namespace: cs.getStatefulSet().Namespace, @@ -928,6 +925,7 @@ func TestGetWorkloadSpreadForAdvancedStatefulSet(t *testing.T) { workloadSpread1 := ws.DeepCopy() workloadSpread1.Name = "ws-1" workloadSpread1.DeletionTimestamp = &metav1.Time{Time: time.Now()} + workloadSpread1.Finalizers = []string{"finalizers.sigs.k8s.io/test"} workloadSpread2 := ws.DeepCopy() workloadSpread2.Name = "ws-2" @@ -972,14 +970,12 @@ func TestGetWorkloadSpreadForAdvancedStatefulSet(t *testing.T) { for _, cs := range cases { t.Run(cs.name, func(t *testing.T) { - fakeClient := fake.NewClientBuilder().WithScheme(scheme).Build() + builder := fake.NewClientBuilder().WithScheme(scheme) for _, ws := range cs.getWorkloadSpreads() { newWorkloadSpread := ws.DeepCopy() - err := fakeClient.Create(context.TODO(), newWorkloadSpread) - if err != nil { - t.Fatalf("create WorkloadSpread failed: %s", err.Error()) - } + builder.WithObjects(newWorkloadSpread) } + fakeClient := builder.Build() nsn := types.NamespacedName{ Namespace: cs.getStatefulSet().Namespace, @@ -1109,7 +1105,7 @@ func TestWorkloadEventHandlerForCreate(t *testing.T) { createEvt := event.CreateEvent{ Object: cs.getWorkload(), } - handler.Create(createEvt, createQ) + handler.Create(context.TODO(), createEvt, createQ) if createQ.Len() != 1 { t.Errorf("unexpected create event handle queue size, expected 1 actual %d", createQ.Len()) return @@ -1230,7 +1226,7 @@ func TestWorkloadEventHandlerForDelete(t *testing.T) { deleteEvt := event.DeleteEvent{ Object: cs.getWorkload(), } - handler.Delete(deleteEvt, deleteQ) + handler.Delete(context.TODO(), deleteEvt, deleteQ) if deleteQ.Len() != 1 { t.Errorf("unexpected delete event handle queue size, expected 1 actual %d", deleteQ.Len()) return @@ -1372,7 +1368,7 @@ func TestWorkloadEventHandlerForUpdate(t *testing.T) { ObjectOld: oldWorkload, ObjectNew: newWorkload, } - handler.Update(updateEvt, updateQ) + handler.Update(context.TODO(), updateEvt, updateQ) if updateQ.Len() != 1 { t.Errorf("unexpected update event handle queue size, expected 1 actual %d", updateQ.Len()) return diff --git a/pkg/util/client/client.go b/pkg/util/client/client.go index 2f1fd691c0..48c01ac911 100644 --- a/pkg/util/client/client.go +++ b/pkg/util/client/client.go @@ -28,15 +28,11 @@ func NewClientFromManager(mgr manager.Manager, name string) client.Client { cfg := rest.CopyConfig(mgr.GetConfig()) cfg.UserAgent = fmt.Sprintf("kruise-manager/%s", name) - c, err := client.New(cfg, client.Options{Scheme: mgr.GetScheme(), Mapper: mgr.GetRESTMapper()}) - if err != nil { - panic(err) - } - - delegatingClient, _ := client.NewDelegatingClient(client.NewDelegatingClientInput{ - CacheReader: mgr.GetCache(), - Client: c, - CacheUnstructured: true, + delegatingClient, _ := client.New(cfg, client.Options{ + Cache: &client.CacheOptions{ + Reader: mgr.GetCache(), + Unstructured: true, + }, }) return delegatingClient } diff --git a/pkg/util/imagejob/imagejob_reader_test.go b/pkg/util/imagejob/imagejob_reader_test.go index 59f3656f17..daafb322e3 100644 --- a/pkg/util/imagejob/imagejob_reader_test.go +++ b/pkg/util/imagejob/imagejob_reader_test.go @@ -25,6 +25,7 @@ import ( "testing" utilruntime "k8s.io/apimachinery/pkg/util/runtime" + metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server" "github.com/onsi/gomega" v1 "k8s.io/api/core/v1" @@ -172,7 +173,7 @@ func TestAll(t *testing.T) { g := gomega.NewGomegaWithT(t) var err error - mgr, err := manager.New(cfg, manager.Options{MetricsBindAddress: "0"}) + mgr, err := manager.New(cfg, manager.Options{Metrics: metricsserver.Options{BindAddress: "0"}}) g.Expect(err).NotTo(gomega.HaveOccurred()) _ = fieldindex.RegisterFieldIndexes(mgr.GetCache()) c = utilclient.NewClientFromManager(mgr, "test-nodeimage-utils") diff --git a/pkg/util/podreadiness/pod_readiness_utils_test.go b/pkg/util/podreadiness/pod_readiness_utils_test.go index 6ecab8b381..788826bd2b 100644 --- a/pkg/util/podreadiness/pod_readiness_utils_test.go +++ b/pkg/util/podreadiness/pod_readiness_utils_test.go @@ -20,13 +20,14 @@ import ( "context" "testing" - appspub "github.com/openkruise/kruise/apis/apps/pub" - "github.com/openkruise/kruise/pkg/util/podadapter" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" clientgoscheme "k8s.io/client-go/kubernetes/scheme" "sigs.k8s.io/controller-runtime/pkg/client/fake" + + appspub "github.com/openkruise/kruise/apis/apps/pub" + "github.com/openkruise/kruise/pkg/util/podadapter" ) func TestPodReadiness(t *testing.T) { @@ -42,7 +43,9 @@ func TestPodReadiness(t *testing.T) { ReadinessGates: []v1.PodReadinessGate{}, }, } - fakeClient := fake.NewClientBuilder().WithScheme(clientgoscheme.Scheme).WithObjects(pod0, pod1).Build() + fakeClient := fake.NewClientBuilder(). + WithScheme(clientgoscheme.Scheme).WithObjects(pod0, pod1). + WithStatusSubresource(&v1.Pod{}).Build() msg0 := Message{UserAgent: "ua1", Key: "foo"} msg1 := Message{UserAgent: "ua1", Key: "bar"} diff --git a/pkg/util/workloadspread/workloadspread_test.go b/pkg/util/workloadspread/workloadspread_test.go index 6d624b15e9..1f1ac90bb3 100644 --- a/pkg/util/workloadspread/workloadspread_test.go +++ b/pkg/util/workloadspread/workloadspread_test.go @@ -1085,7 +1085,8 @@ func TestWorkloadSpreadMutatingPod(t *testing.T) { t.Run(cs.name, func(t *testing.T) { podIn := cs.getPod() workloadSpreadIn := cs.getWorkloadSpread() - fakeClient := fake.NewClientBuilder().WithScheme(scheme).WithObjects(workloadSpreadIn).Build() + fakeClient := fake.NewClientBuilder().WithScheme(scheme). + WithObjects(workloadSpreadIn).WithStatusSubresource(&appsv1alpha1.WorkloadSpread{}).Build() handler := NewWorkloadSpreadHandler(fakeClient) var err error diff --git a/pkg/webhook/add_advancedcronjob.go b/pkg/webhook/add_advancedcronjob.go index 15921b56a8..129238e47d 100644 --- a/pkg/webhook/add_advancedcronjob.go +++ b/pkg/webhook/add_advancedcronjob.go @@ -22,6 +22,6 @@ import ( ) func init() { - addHandlers(mutating.HandlerMap) - addHandlers(validating.HandlerMap) + addHandlers(mutating.HandlerGetterMap) + addHandlers(validating.HandlerGetterMap) } diff --git a/pkg/webhook/add_broadcastjob.go b/pkg/webhook/add_broadcastjob.go index 5dc8b5fe0c..d7c7d0b2cc 100644 --- a/pkg/webhook/add_broadcastjob.go +++ b/pkg/webhook/add_broadcastjob.go @@ -22,6 +22,6 @@ import ( ) func init() { - addHandlers(mutating.HandlerMap) - addHandlers(validating.HandlerMap) + addHandlers(mutating.HandlerGetterMap) + addHandlers(validating.HandlerGetterMap) } diff --git a/pkg/webhook/add_builtinworkloads.go b/pkg/webhook/add_builtinworkloads.go index beb00fbdb3..cf7f3846c7 100644 --- a/pkg/webhook/add_builtinworkloads.go +++ b/pkg/webhook/add_builtinworkloads.go @@ -21,5 +21,5 @@ import ( ) func init() { - addHandlers(validating.HandlerMap) + addHandlers(validating.HandlerGetterMap) } diff --git a/pkg/webhook/add_cloneset.go b/pkg/webhook/add_cloneset.go index f9f8f53380..bf0ba13a80 100644 --- a/pkg/webhook/add_cloneset.go +++ b/pkg/webhook/add_cloneset.go @@ -22,6 +22,6 @@ import ( ) func init() { - addHandlers(mutating.HandlerMap) - addHandlers(validating.HandlerMap) + addHandlers(mutating.HandlerGetterMap) + addHandlers(validating.HandlerGetterMap) } diff --git a/pkg/webhook/add_containerrecreaterequest.go b/pkg/webhook/add_containerrecreaterequest.go index 69b486c8d7..7dedea7419 100644 --- a/pkg/webhook/add_containerrecreaterequest.go +++ b/pkg/webhook/add_containerrecreaterequest.go @@ -21,5 +21,5 @@ import ( ) func init() { - addHandlers(mutating.HandlerMap) + addHandlers(mutating.HandlerGetterMap) } diff --git a/pkg/webhook/add_customresourcedefinition.go b/pkg/webhook/add_customresourcedefinition.go index 81cab1b35c..8cb05dd854 100644 --- a/pkg/webhook/add_customresourcedefinition.go +++ b/pkg/webhook/add_customresourcedefinition.go @@ -21,5 +21,5 @@ import ( ) func init() { - addHandlers(validating.HandlerMap) + addHandlers(validating.HandlerGetterMap) } diff --git a/pkg/webhook/add_daemonset.go b/pkg/webhook/add_daemonset.go index a69ef2c03c..a3cc4c2abb 100644 --- a/pkg/webhook/add_daemonset.go +++ b/pkg/webhook/add_daemonset.go @@ -22,6 +22,6 @@ import ( ) func init() { - addHandlers(mutating.HandlerMap) - addHandlers(validating.HandlerMap) + addHandlers(mutating.HandlerGetterMap) + addHandlers(validating.HandlerGetterMap) } diff --git a/pkg/webhook/add_imagelistpulljob.go b/pkg/webhook/add_imagelistpulljob.go index a72994a105..50145f4886 100644 --- a/pkg/webhook/add_imagelistpulljob.go +++ b/pkg/webhook/add_imagelistpulljob.go @@ -22,6 +22,6 @@ import ( ) func init() { - addHandlers(mutating.HandlerMap) - addHandlers(validating.HandlerMap) + addHandlers(mutating.HandlerGetterMap) + addHandlers(validating.HandlerGetterMap) } diff --git a/pkg/webhook/add_imagepulljob.go b/pkg/webhook/add_imagepulljob.go index affe2ec489..c61883f188 100644 --- a/pkg/webhook/add_imagepulljob.go +++ b/pkg/webhook/add_imagepulljob.go @@ -22,6 +22,6 @@ import ( ) func init() { - addHandlers(mutating.HandlerMap) - addHandlers(validating.HandlerMap) + addHandlers(mutating.HandlerGetterMap) + addHandlers(validating.HandlerGetterMap) } diff --git a/pkg/webhook/add_ingress.go b/pkg/webhook/add_ingress.go index c214e24e79..9130eb0850 100644 --- a/pkg/webhook/add_ingress.go +++ b/pkg/webhook/add_ingress.go @@ -23,7 +23,7 @@ import ( ) func init() { - addHandlersWithGate(validating.HandlerMap, func() (enabled bool) { + addHandlersWithGate(validating.HandlerGetterMap, func() (enabled bool) { return utilfeature.DefaultFeatureGate.Enabled(features.ResourcesDeletionProtection) }) } diff --git a/pkg/webhook/add_namespace.go b/pkg/webhook/add_namespace.go index 5c03bfea37..dccdf8e810 100644 --- a/pkg/webhook/add_namespace.go +++ b/pkg/webhook/add_namespace.go @@ -21,5 +21,5 @@ import ( ) func init() { - addHandlers(validating.HandlerMap) + addHandlers(validating.HandlerGetterMap) } diff --git a/pkg/webhook/add_nodeimage.go b/pkg/webhook/add_nodeimage.go index 8c5c850c6f..2e59267fd4 100644 --- a/pkg/webhook/add_nodeimage.go +++ b/pkg/webhook/add_nodeimage.go @@ -22,6 +22,6 @@ import ( ) func init() { - addHandlers(mutating.HandlerMap) - addHandlers(validating.HandlerMap) + addHandlers(mutating.HandlerGetterMap) + addHandlers(validating.HandlerGetterMap) } diff --git a/pkg/webhook/add_persistentpodstate.go b/pkg/webhook/add_persistentpodstate.go index c9b0a7f102..6229abd2ff 100644 --- a/pkg/webhook/add_persistentpodstate.go +++ b/pkg/webhook/add_persistentpodstate.go @@ -21,5 +21,5 @@ import ( ) func init() { - addHandlers(validating.HandlerMap) + addHandlers(validating.HandlerGetterMap) } diff --git a/pkg/webhook/add_pod.go b/pkg/webhook/add_pod.go index a6de1468ba..2678fa37e3 100644 --- a/pkg/webhook/add_pod.go +++ b/pkg/webhook/add_pod.go @@ -27,7 +27,7 @@ import ( ) func init() { - addHandlersWithGate(mutating.HandlerMap, func() (enabled bool) { + addHandlersWithGate(mutating.HandlerGetterMap, func() (enabled bool) { if !utilfeature.DefaultFeatureGate.Enabled(features.PodWebhook) { return false } @@ -40,7 +40,7 @@ func init() { return true }) - addHandlersWithGate(validating.HandlerMap, func() (enabled bool) { + addHandlersWithGate(validating.HandlerGetterMap, func() (enabled bool) { if !utilfeature.DefaultFeatureGate.Enabled(features.PodWebhook) { return false } diff --git a/pkg/webhook/add_podprobemarker.go b/pkg/webhook/add_podprobemarker.go index 9118e79948..3d5e3c4e59 100644 --- a/pkg/webhook/add_podprobemarker.go +++ b/pkg/webhook/add_podprobemarker.go @@ -21,5 +21,5 @@ import ( ) func init() { - addHandlers(validating.HandlerMap) + addHandlers(validating.HandlerGetterMap) } diff --git a/pkg/webhook/add_podunavailablebudget.go b/pkg/webhook/add_podunavailablebudget.go index e7d3671c65..def07e7275 100644 --- a/pkg/webhook/add_podunavailablebudget.go +++ b/pkg/webhook/add_podunavailablebudget.go @@ -21,5 +21,5 @@ import ( ) func init() { - addHandlers(validating.HandlerMap) + addHandlers(validating.HandlerGetterMap) } diff --git a/pkg/webhook/add_resourcedistribution.go b/pkg/webhook/add_resourcedistribution.go index 137b31581c..58b6ed111c 100644 --- a/pkg/webhook/add_resourcedistribution.go +++ b/pkg/webhook/add_resourcedistribution.go @@ -21,5 +21,5 @@ import ( ) func init() { - addHandlers(validating.HandlerMap) + addHandlers(validating.HandlerGetterMap) } diff --git a/pkg/webhook/add_service.go b/pkg/webhook/add_service.go index a6de904d35..d6bea62ec2 100644 --- a/pkg/webhook/add_service.go +++ b/pkg/webhook/add_service.go @@ -23,7 +23,7 @@ import ( ) func init() { - addHandlersWithGate(validating.HandlerMap, func() (enabled bool) { + addHandlersWithGate(validating.HandlerGetterMap, func() (enabled bool) { return utilfeature.DefaultFeatureGate.Enabled(features.ResourcesDeletionProtection) }) } diff --git a/pkg/webhook/add_sidecarset.go b/pkg/webhook/add_sidecarset.go index 04fa3af329..bdf625106f 100644 --- a/pkg/webhook/add_sidecarset.go +++ b/pkg/webhook/add_sidecarset.go @@ -22,6 +22,6 @@ import ( ) func init() { - addHandlers(mutating.HandlerMap) - addHandlers(validating.HandlerMap) + addHandlers(mutating.HandlerGetterMap) + addHandlers(validating.HandlerGetterMap) } diff --git a/pkg/webhook/add_statefulset.go b/pkg/webhook/add_statefulset.go index 3647a139c5..4d46f0f904 100644 --- a/pkg/webhook/add_statefulset.go +++ b/pkg/webhook/add_statefulset.go @@ -22,6 +22,6 @@ import ( ) func init() { - addHandlers(mutating.HandlerMap) - addHandlers(validating.HandlerMap) + addHandlers(mutating.HandlerGetterMap) + addHandlers(validating.HandlerGetterMap) } diff --git a/pkg/webhook/add_uniteddeployment.go b/pkg/webhook/add_uniteddeployment.go index 1084583227..22627c708a 100644 --- a/pkg/webhook/add_uniteddeployment.go +++ b/pkg/webhook/add_uniteddeployment.go @@ -22,6 +22,6 @@ import ( ) func init() { - addHandlers(mutating.HandlerMap) - addHandlers(validating.HandlerMap) + addHandlers(mutating.HandlerGetterMap) + addHandlers(validating.HandlerGetterMap) } diff --git a/pkg/webhook/add_workloadspread.go b/pkg/webhook/add_workloadspread.go index 8b73d39186..8f8c771aa3 100644 --- a/pkg/webhook/add_workloadspread.go +++ b/pkg/webhook/add_workloadspread.go @@ -21,5 +21,5 @@ import ( ) func init() { - addHandlers(validating.HandlerMap) + addHandlers(validating.HandlerGetterMap) } diff --git a/pkg/webhook/advancedcronjob/mutating/advancedcronjob_create_update_handler.go b/pkg/webhook/advancedcronjob/mutating/advancedcronjob_create_update_handler.go index 1010192260..e13744f03f 100644 --- a/pkg/webhook/advancedcronjob/mutating/advancedcronjob_create_update_handler.go +++ b/pkg/webhook/advancedcronjob/mutating/advancedcronjob_create_update_handler.go @@ -22,13 +22,14 @@ import ( "net/http" "reflect" + admissionv1 "k8s.io/api/admission/v1" + "k8s.io/apimachinery/pkg/runtime" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + "github.com/openkruise/kruise/apis/apps/defaults" appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" "github.com/openkruise/kruise/pkg/features" utilfeature "github.com/openkruise/kruise/pkg/util/feature" - admissionv1 "k8s.io/api/admission/v1" - "k8s.io/apimachinery/pkg/runtime" - "sigs.k8s.io/controller-runtime/pkg/webhook/admission" ) // BroadcastJobCreateUpdateHandler handles BroadcastJob @@ -88,11 +89,3 @@ func (h *AdvancedCronJobCreateUpdateHandler) Handle(ctx context.Context, req adm // h.Client = c // return nil //} - -var _ admission.DecoderInjector = &AdvancedCronJobCreateUpdateHandler{} - -// InjectDecoder injects the decoder into the BroadcastJobCreateUpdateHandler -func (h *AdvancedCronJobCreateUpdateHandler) InjectDecoder(d *admission.Decoder) error { - h.Decoder = d - return nil -} diff --git a/pkg/webhook/advancedcronjob/mutating/webhooks.go b/pkg/webhook/advancedcronjob/mutating/webhooks.go index 6f1e131440..41e33ab8a9 100644 --- a/pkg/webhook/advancedcronjob/mutating/webhooks.go +++ b/pkg/webhook/advancedcronjob/mutating/webhooks.go @@ -17,14 +17,19 @@ limitations under the License. package mutating import ( + "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "github.com/openkruise/kruise/pkg/webhook/types" ) // +kubebuilder:webhook:path=/mutate-apps-kruise-io-v1alpha1-advancedcronjob,mutating=true,failurePolicy=fail,sideEffects=None,admissionReviewVersions=v1;v1beta1,groups=apps.kruise.io,resources=advancedcronjobs,verbs=create;update,versions=v1alpha1,name=madvancedcronjob.kb.io var ( - // HandlerMap contains admission webhook handlers - HandlerMap = map[string]admission.Handler{ - "mutate-apps-kruise-io-v1alpha1-advancedcronjob": &AdvancedCronJobCreateUpdateHandler{}, + // HandlerGetterMap contains admission webhook handlers + HandlerGetterMap = map[string]types.HandlerGetter{ + "mutate-apps-kruise-io-v1alpha1-advancedcronjob": func(mgr manager.Manager) admission.Handler { + return &AdvancedCronJobCreateUpdateHandler{Decoder: admission.NewDecoder(mgr.GetScheme())} + }, } ) diff --git a/pkg/webhook/advancedcronjob/validating/advancedcronjob_create_update_handler.go b/pkg/webhook/advancedcronjob/validating/advancedcronjob_create_update_handler.go index 8dfcc08513..c670a9d214 100644 --- a/pkg/webhook/advancedcronjob/validating/advancedcronjob_create_update_handler.go +++ b/pkg/webhook/advancedcronjob/validating/advancedcronjob_create_update_handler.go @@ -24,8 +24,6 @@ import ( "strings" "time" - appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" - webhookutil "github.com/openkruise/kruise/pkg/webhook/util" "github.com/robfig/cron/v3" admissionv1 "k8s.io/api/admission/v1" batchv1 "k8s.io/api/batch/v1" @@ -38,6 +36,9 @@ import ( corev1 "k8s.io/kubernetes/pkg/apis/core/v1" apivalidation "k8s.io/kubernetes/pkg/apis/core/validation" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" + webhookutil "github.com/openkruise/kruise/pkg/webhook/util" ) const ( @@ -227,11 +228,3 @@ func (h *AdvancedCronJobCreateUpdateHandler) Handle(ctx context.Context, req adm return admission.ValidationResponse(true, "") } - -var _ admission.DecoderInjector = &AdvancedCronJobCreateUpdateHandler{} - -// InjectDecoder injects the decoder into the AdvancedCronJobCreateUpdateHandler -func (h *AdvancedCronJobCreateUpdateHandler) InjectDecoder(d *admission.Decoder) error { - h.Decoder = d - return nil -} diff --git a/pkg/webhook/advancedcronjob/validating/webhooks.go b/pkg/webhook/advancedcronjob/validating/webhooks.go index ea1de3842a..66a690a193 100644 --- a/pkg/webhook/advancedcronjob/validating/webhooks.go +++ b/pkg/webhook/advancedcronjob/validating/webhooks.go @@ -17,14 +17,19 @@ limitations under the License. package validating import ( + "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "github.com/openkruise/kruise/pkg/webhook/types" ) // +kubebuilder:webhook:path=/validate-apps-kruise-io-v1alpha1-advancedcronjob,mutating=false,failurePolicy=fail,sideEffects=None,admissionReviewVersions=v1;v1beta1,groups=apps.kruise.io,resources=advancedcronjobs,verbs=create;update,versions=v1alpha1,name=vadvancedcronjob.kb.io var ( - // HandlerMap contains admission webhook handlers - HandlerMap = map[string]admission.Handler{ - "validate-apps-kruise-io-v1alpha1-advancedcronjob": &AdvancedCronJobCreateUpdateHandler{}, + // HandlerGetterMap contains admission webhook handlers + HandlerGetterMap = map[string]types.HandlerGetter{ + "validate-apps-kruise-io-v1alpha1-advancedcronjob": func(mgr manager.Manager) admission.Handler { + return &AdvancedCronJobCreateUpdateHandler{Decoder: admission.NewDecoder(mgr.GetScheme())} + }, } ) diff --git a/pkg/webhook/broadcastjob/mutating/broadcastjob_create_update_handler.go b/pkg/webhook/broadcastjob/mutating/broadcastjob_create_update_handler.go index 0fb409b0ef..83d2473456 100644 --- a/pkg/webhook/broadcastjob/mutating/broadcastjob_create_update_handler.go +++ b/pkg/webhook/broadcastjob/mutating/broadcastjob_create_update_handler.go @@ -22,13 +22,14 @@ import ( "net/http" "reflect" + admissionv1 "k8s.io/api/admission/v1" + "k8s.io/apimachinery/pkg/runtime" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + "github.com/openkruise/kruise/apis/apps/defaults" appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" "github.com/openkruise/kruise/pkg/features" utilfeature "github.com/openkruise/kruise/pkg/util/feature" - admissionv1 "k8s.io/api/admission/v1" - "k8s.io/apimachinery/pkg/runtime" - "sigs.k8s.io/controller-runtime/pkg/webhook/admission" ) // BroadcastJobCreateUpdateHandler handles BroadcastJob @@ -88,11 +89,3 @@ func (h *BroadcastJobCreateUpdateHandler) Handle(ctx context.Context, req admiss // h.Client = c // return nil //} - -var _ admission.DecoderInjector = &BroadcastJobCreateUpdateHandler{} - -// InjectDecoder injects the decoder into the BroadcastJobCreateUpdateHandler -func (h *BroadcastJobCreateUpdateHandler) InjectDecoder(d *admission.Decoder) error { - h.Decoder = d - return nil -} diff --git a/pkg/webhook/broadcastjob/mutating/broadcastjob_create_update_handler_test.go b/pkg/webhook/broadcastjob/mutating/broadcastjob_create_update_handler_test.go index ef27afc835..19e1e5be6a 100644 --- a/pkg/webhook/broadcastjob/mutating/broadcastjob_create_update_handler_test.go +++ b/pkg/webhook/broadcastjob/mutating/broadcastjob_create_update_handler_test.go @@ -8,13 +8,14 @@ import ( utilruntime "k8s.io/apimachinery/pkg/util/runtime" - "github.com/openkruise/kruise/apis" - appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" "gomodules.xyz/jsonpatch/v2" admissionv1 "k8s.io/api/admission/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/client-go/kubernetes/scheme" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "github.com/openkruise/kruise/apis" + appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" ) func TestHandle(t *testing.T) { @@ -50,7 +51,7 @@ func TestHandle(t *testing.T) { } }` - decoder, _ := admission.NewDecoder(scheme.Scheme) + decoder := admission.NewDecoder(scheme.Scheme) handler := BroadcastJobCreateUpdateHandler{ Decoder: decoder, } diff --git a/pkg/webhook/broadcastjob/mutating/webhooks.go b/pkg/webhook/broadcastjob/mutating/webhooks.go index 72a4628154..ad6dee6f95 100644 --- a/pkg/webhook/broadcastjob/mutating/webhooks.go +++ b/pkg/webhook/broadcastjob/mutating/webhooks.go @@ -17,14 +17,19 @@ limitations under the License. package mutating import ( + "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "github.com/openkruise/kruise/pkg/webhook/types" ) // +kubebuilder:webhook:path=/mutate-apps-kruise-io-v1alpha1-broadcastjob,mutating=true,failurePolicy=fail,sideEffects=None,admissionReviewVersions=v1;v1beta1,groups=apps.kruise.io,resources=broadcastjobs,verbs=create;update,versions=v1alpha1,name=mbroadcastjob.kb.io var ( - // HandlerMap contains admission webhook handlers - HandlerMap = map[string]admission.Handler{ - "mutate-apps-kruise-io-v1alpha1-broadcastjob": &BroadcastJobCreateUpdateHandler{}, + // HandlerGetterMap contains admission webhook handlers + HandlerGetterMap = map[string]types.HandlerGetter{ + "mutate-apps-kruise-io-v1alpha1-broadcastjob": func(mgr manager.Manager) admission.Handler { + return &BroadcastJobCreateUpdateHandler{Decoder: admission.NewDecoder(mgr.GetScheme())} + }, } ) diff --git a/pkg/webhook/broadcastjob/validating/broadcastjob_create_update_handler.go b/pkg/webhook/broadcastjob/validating/broadcastjob_create_update_handler.go index 8fcf1d4a6a..b3dd224c52 100644 --- a/pkg/webhook/broadcastjob/validating/broadcastjob_create_update_handler.go +++ b/pkg/webhook/broadcastjob/validating/broadcastjob_create_update_handler.go @@ -22,16 +22,17 @@ import ( "net/http" "regexp" - appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" - "github.com/openkruise/kruise/pkg/controller/broadcastjob" - webhookutil "github.com/openkruise/kruise/pkg/webhook/util" - "github.com/openkruise/kruise/pkg/webhook/util/convertor" v1 "k8s.io/api/core/v1" genericvalidation "k8s.io/apimachinery/pkg/api/validation" validationutil "k8s.io/apimachinery/pkg/util/validation" "k8s.io/apimachinery/pkg/util/validation/field" corevalidation "k8s.io/kubernetes/pkg/apis/core/validation" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" + "github.com/openkruise/kruise/pkg/controller/broadcastjob" + webhookutil "github.com/openkruise/kruise/pkg/webhook/util" + "github.com/openkruise/kruise/pkg/webhook/util/convertor" ) const ( @@ -146,11 +147,3 @@ func (h *BroadcastJobCreateUpdateHandler) Handle(ctx context.Context, req admiss // h.Client = c // return nil //} - -var _ admission.DecoderInjector = &BroadcastJobCreateUpdateHandler{} - -// InjectDecoder injects the decoder into the BroadcastJobCreateUpdateHandler -func (h *BroadcastJobCreateUpdateHandler) InjectDecoder(d *admission.Decoder) error { - h.Decoder = d - return nil -} diff --git a/pkg/webhook/broadcastjob/validating/webhooks.go b/pkg/webhook/broadcastjob/validating/webhooks.go index 577a2ce7cd..e134b81bf2 100644 --- a/pkg/webhook/broadcastjob/validating/webhooks.go +++ b/pkg/webhook/broadcastjob/validating/webhooks.go @@ -17,14 +17,19 @@ limitations under the License. package validating import ( + "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "github.com/openkruise/kruise/pkg/webhook/types" ) // +kubebuilder:webhook:path=/validate-apps-kruise-io-v1alpha1-broadcastjob,mutating=false,failurePolicy=fail,sideEffects=None,admissionReviewVersions=v1;v1beta1,groups=apps.kruise.io,resources=broadcastjobs,verbs=create;update,versions=v1alpha1,name=vbroadcastjob.kb.io var ( - // HandlerMap contains admission webhook handlers - HandlerMap = map[string]admission.Handler{ - "validate-apps-kruise-io-v1alpha1-broadcastjob": &BroadcastJobCreateUpdateHandler{}, + // HandlerGetterMap contains admission webhook handlers + HandlerGetterMap = map[string]types.HandlerGetter{ + "validate-apps-kruise-io-v1alpha1-broadcastjob": func(mgr manager.Manager) admission.Handler { + return &BroadcastJobCreateUpdateHandler{Decoder: admission.NewDecoder(mgr.GetScheme())} + }, } ) diff --git a/pkg/webhook/builtinworkloads/validating/webhooks.go b/pkg/webhook/builtinworkloads/validating/webhooks.go index 747d5065e8..0e4bb4d263 100644 --- a/pkg/webhook/builtinworkloads/validating/webhooks.go +++ b/pkg/webhook/builtinworkloads/validating/webhooks.go @@ -16,7 +16,12 @@ limitations under the License. package validating -import "sigs.k8s.io/controller-runtime/pkg/webhook/admission" +import ( + "sigs.k8s.io/controller-runtime/pkg/manager" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "github.com/openkruise/kruise/pkg/webhook/types" +) // +kubebuilder:webhook:path=/validate-apps-deployment,mutating=false,failurePolicy=fail,sideEffects=None,admissionReviewVersions=v1;v1beta1,groups=apps,resources=deployments,verbs=delete,versions=v1,name=vbuiltindeployment.kb.io @@ -25,10 +30,16 @@ import "sigs.k8s.io/controller-runtime/pkg/webhook/admission" // +kubebuilder:webhook:path=/validate-apps-statefulset,mutating=false,failurePolicy=fail,sideEffects=None,admissionReviewVersions=v1;v1beta1,groups=apps,resources=statefulsets,verbs=delete,versions=v1,name=vbuiltinstatefulset.kb.io var ( - // HandlerMap contains admission webhook handlers - HandlerMap = map[string]admission.Handler{ - "validate-apps-deployment": &WorkloadHandler{}, - "validate-apps-replicaset": &WorkloadHandler{}, - "validate-apps-statefulset": &WorkloadHandler{}, + // HandlerGetterMap contains admission webhook handlers + HandlerGetterMap = map[string]types.HandlerGetter{ + "validate-apps-deployment": func(mgr manager.Manager) admission.Handler { + return &WorkloadHandler{Decoder: admission.NewDecoder(mgr.GetScheme())} + }, + "validate-apps-replicaset": func(mgr manager.Manager) admission.Handler { + return &WorkloadHandler{Decoder: admission.NewDecoder(mgr.GetScheme())} + }, + "validate-apps-statefulset": func(mgr manager.Manager) admission.Handler { + return &WorkloadHandler{Decoder: admission.NewDecoder(mgr.GetScheme())} + }, } ) diff --git a/pkg/webhook/cloneset/mutating/cloneset_create_update_handler.go b/pkg/webhook/cloneset/mutating/cloneset_create_update_handler.go index 92ac397d3a..e3c156b34b 100644 --- a/pkg/webhook/cloneset/mutating/cloneset_create_update_handler.go +++ b/pkg/webhook/cloneset/mutating/cloneset_create_update_handler.go @@ -81,11 +81,3 @@ func (h *CloneSetCreateUpdateHandler) Handle(ctx context.Context, req admission. } return resp } - -var _ admission.DecoderInjector = &CloneSetCreateUpdateHandler{} - -// InjectDecoder injects the decoder into the CloneSetCreateUpdateHandler -func (h *CloneSetCreateUpdateHandler) InjectDecoder(d *admission.Decoder) error { - h.Decoder = d - return nil -} diff --git a/pkg/webhook/cloneset/mutating/webhooks.go b/pkg/webhook/cloneset/mutating/webhooks.go index eabaab987f..5451dcb954 100644 --- a/pkg/webhook/cloneset/mutating/webhooks.go +++ b/pkg/webhook/cloneset/mutating/webhooks.go @@ -17,14 +17,19 @@ limitations under the License. package mutating import ( + "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "github.com/openkruise/kruise/pkg/webhook/types" ) // +kubebuilder:webhook:path=/mutate-apps-kruise-io-v1alpha1-cloneset,mutating=true,failurePolicy=fail,sideEffects=None,admissionReviewVersions=v1;v1beta1,groups=apps.kruise.io,resources=clonesets,verbs=create;update,versions=v1alpha1,name=mcloneset.kb.io var ( - // HandlerMap contains admission webhook handlers - HandlerMap = map[string]admission.Handler{ - "mutate-apps-kruise-io-v1alpha1-cloneset": &CloneSetCreateUpdateHandler{}, + // HandlerGetterMap contains admission webhook handlers + HandlerGetterMap = map[string]types.HandlerGetter{ + "mutate-apps-kruise-io-v1alpha1-cloneset": func(mgr manager.Manager) admission.Handler { + return &CloneSetCreateUpdateHandler{Decoder: admission.NewDecoder(mgr.GetScheme())} + }, } ) diff --git a/pkg/webhook/cloneset/validating/cloneset_create_update_handler.go b/pkg/webhook/cloneset/validating/cloneset_create_update_handler.go index bb17165037..84c4859d00 100644 --- a/pkg/webhook/cloneset/validating/cloneset_create_update_handler.go +++ b/pkg/webhook/cloneset/validating/cloneset_create_update_handler.go @@ -21,14 +21,14 @@ import ( "fmt" "net/http" - appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" - "github.com/openkruise/kruise/pkg/util" - "github.com/openkruise/kruise/pkg/webhook/util/deletionprotection" admissionv1 "k8s.io/api/admission/v1" "k8s.io/klog/v2" "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/runtime/inject" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" + "github.com/openkruise/kruise/pkg/util" + "github.com/openkruise/kruise/pkg/webhook/util/deletionprotection" ) // CloneSetCreateUpdateHandler handles CloneSet @@ -84,19 +84,3 @@ func (h *CloneSetCreateUpdateHandler) Handle(ctx context.Context, req admission. return admission.ValidationResponse(true, "") } - -var _ inject.Client = &CloneSetCreateUpdateHandler{} - -// InjectClient injects the client into the CloneSetCreateUpdateHandler -func (h *CloneSetCreateUpdateHandler) InjectClient(c client.Client) error { - h.Client = c - return nil -} - -var _ admission.DecoderInjector = &CloneSetCreateUpdateHandler{} - -// InjectDecoder injects the decoder into the CloneSetCreateUpdateHandler -func (h *CloneSetCreateUpdateHandler) InjectDecoder(d *admission.Decoder) error { - h.Decoder = d - return nil -} diff --git a/pkg/webhook/cloneset/validating/webhooks.go b/pkg/webhook/cloneset/validating/webhooks.go index 5d09750c96..2fc5f49f94 100644 --- a/pkg/webhook/cloneset/validating/webhooks.go +++ b/pkg/webhook/cloneset/validating/webhooks.go @@ -17,14 +17,22 @@ limitations under the License. package validating import ( + "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "github.com/openkruise/kruise/pkg/webhook/types" ) // +kubebuilder:webhook:path=/validate-apps-kruise-io-v1alpha1-cloneset,mutating=false,failurePolicy=fail,sideEffects=None,admissionReviewVersions=v1;v1beta1,groups=apps.kruise.io,resources=clonesets,verbs=create;update;delete,versions=v1alpha1,name=vcloneset.kb.io var ( - // HandlerMap contains admission webhook handlers - HandlerMap = map[string]admission.Handler{ - "validate-apps-kruise-io-v1alpha1-cloneset": &CloneSetCreateUpdateHandler{}, + // HandlerGetterMap contains admission webhook handlers + HandlerGetterMap = map[string]types.HandlerGetter{ + "validate-apps-kruise-io-v1alpha1-cloneset": func(mgr manager.Manager) admission.Handler { + return &CloneSetCreateUpdateHandler{ + Client: mgr.GetClient(), + Decoder: admission.NewDecoder(mgr.GetScheme()), + } + }, } ) diff --git a/pkg/webhook/containerrecreaterequest/mutating/crr_mutating_handler.go b/pkg/webhook/containerrecreaterequest/mutating/crr_mutating_handler.go index fc9d85cbf9..b6494f7e7e 100644 --- a/pkg/webhook/containerrecreaterequest/mutating/crr_mutating_handler.go +++ b/pkg/webhook/containerrecreaterequest/mutating/crr_mutating_handler.go @@ -31,7 +31,6 @@ import ( "k8s.io/apimachinery/pkg/util/sets" kubecontroller "k8s.io/kubernetes/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/runtime/inject" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" @@ -207,19 +206,3 @@ func injectPodIntoContainerRecreateRequest(obj *appsv1alpha1.ContainerRecreateRe return nil } - -var _ inject.Client = &ContainerRecreateRequestHandler{} - -// InjectClient injects the client into the ContainerRecreateRequestHandler -func (h *ContainerRecreateRequestHandler) InjectClient(c client.Client) error { - h.Client = c - return nil -} - -var _ admission.DecoderInjector = &ContainerRecreateRequestHandler{} - -// InjectDecoder injects the decoder into the ContainerRecreateRequestHandler -func (h *ContainerRecreateRequestHandler) InjectDecoder(d *admission.Decoder) error { - h.Decoder = d - return nil -} diff --git a/pkg/webhook/containerrecreaterequest/mutating/webhooks.go b/pkg/webhook/containerrecreaterequest/mutating/webhooks.go index d4ee9ac90b..f255bc231f 100644 --- a/pkg/webhook/containerrecreaterequest/mutating/webhooks.go +++ b/pkg/webhook/containerrecreaterequest/mutating/webhooks.go @@ -17,14 +17,22 @@ limitations under the License. package mutating import ( + "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "github.com/openkruise/kruise/pkg/webhook/types" ) // +kubebuilder:webhook:path=/mutate-apps-kruise-io-v1alpha1-containerrecreaterequest,mutating=true,failurePolicy=fail,sideEffects=None,admissionReviewVersions=v1;v1beta1,groups=apps.kruise.io,resources=containerrecreaterequests,verbs=create;update,versions=v1alpha1,name=mcontainerrecreaterequest.kb.io var ( - // HandlerMap contains admission webhook handlers - HandlerMap = map[string]admission.Handler{ - "mutate-apps-kruise-io-v1alpha1-containerrecreaterequest": &ContainerRecreateRequestHandler{}, + // HandlerGetterMap contains admission webhook handlers + HandlerGetterMap = map[string]types.HandlerGetter{ + "mutate-apps-kruise-io-v1alpha1-containerrecreaterequest": func(mgr manager.Manager) admission.Handler { + return &ContainerRecreateRequestHandler{ + Client: mgr.GetClient(), + Decoder: admission.NewDecoder(mgr.GetScheme()), + } + }, } ) diff --git a/pkg/webhook/customresourcedefinition/validating/crd_handler.go b/pkg/webhook/customresourcedefinition/validating/crd_handler.go index 59f5983e77..bb83c436df 100644 --- a/pkg/webhook/customresourcedefinition/validating/crd_handler.go +++ b/pkg/webhook/customresourcedefinition/validating/crd_handler.go @@ -20,8 +20,6 @@ import ( "context" "net/http" - "github.com/openkruise/kruise/pkg/util" - "github.com/openkruise/kruise/pkg/webhook/util/deletionprotection" admissionv1 "k8s.io/api/admission/v1" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" @@ -29,8 +27,10 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/klog/v2" "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/runtime/inject" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "github.com/openkruise/kruise/pkg/util" + "github.com/openkruise/kruise/pkg/webhook/util/deletionprotection" ) type CRDHandler struct { @@ -91,17 +91,3 @@ func (h *CRDHandler) Handle(ctx context.Context, req admission.Request) admissio } return admission.ValidationResponse(true, "") } - -var _ inject.Client = &CRDHandler{} - -func (h *CRDHandler) InjectClient(c client.Client) error { - h.Client = c - return nil -} - -var _ admission.DecoderInjector = &CRDHandler{} - -func (h *CRDHandler) InjectDecoder(d *admission.Decoder) error { - h.Decoder = d - return nil -} diff --git a/pkg/webhook/customresourcedefinition/validating/webhooks.go b/pkg/webhook/customresourcedefinition/validating/webhooks.go index 6fa1031fd4..a73e3ec9df 100644 --- a/pkg/webhook/customresourcedefinition/validating/webhooks.go +++ b/pkg/webhook/customresourcedefinition/validating/webhooks.go @@ -16,15 +16,25 @@ limitations under the License. package validating -import "sigs.k8s.io/controller-runtime/pkg/webhook/admission" +import ( + "sigs.k8s.io/controller-runtime/pkg/manager" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "github.com/openkruise/kruise/pkg/webhook/types" +) // +kubebuilder:webhook:path=/validate-customresourcedefinition,mutating=false,failurePolicy=fail,sideEffects=None,admissionReviewVersions=v1;v1beta1,groups=apiextensions.k8s.io,resources=customresourcedefinitions,verbs=delete,versions=v1;v1beta1,name=vcustomresourcedefinition.kb.io // +kubebuilder:rbac:groups="*",resources="*",verbs=list var ( - // HandlerMap contains admission webhook handlers - HandlerMap = map[string]admission.Handler{ - "validate-customresourcedefinition": &CRDHandler{}, + // HandlerGetterMap contains admission webhook handlers + HandlerGetterMap = map[string]types.HandlerGetter{ + "validate-customresourcedefinition": func(mgr manager.Manager) admission.Handler { + return &CRDHandler{ + Client: mgr.GetClient(), + Decoder: admission.NewDecoder(mgr.GetScheme()), + } + }, } ) diff --git a/pkg/webhook/daemonset/mutating/daemonset_mutating_handler.go b/pkg/webhook/daemonset/mutating/daemonset_mutating_handler.go index 093a12ca5f..74e0005004 100644 --- a/pkg/webhook/daemonset/mutating/daemonset_mutating_handler.go +++ b/pkg/webhook/daemonset/mutating/daemonset_mutating_handler.go @@ -22,12 +22,13 @@ import ( "net/http" "reflect" - "github.com/openkruise/kruise/apis/apps/defaults" - appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" - "github.com/openkruise/kruise/pkg/util" "k8s.io/apimachinery/pkg/runtime" "k8s.io/klog/v2" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "github.com/openkruise/kruise/apis/apps/defaults" + appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" + "github.com/openkruise/kruise/pkg/util" ) // DaemonSetCreateUpdateHandler handles DaemonSet @@ -76,11 +77,3 @@ func (h *DaemonSetCreateUpdateHandler) Handle(ctx context.Context, req admission // h.Client = c // return nil //} - -var _ admission.DecoderInjector = &DaemonSetCreateUpdateHandler{} - -// InjectDecoder injects the decoder into the DaemonSetCreateUpdateHandler -func (h *DaemonSetCreateUpdateHandler) InjectDecoder(d *admission.Decoder) error { - h.Decoder = d - return nil -} diff --git a/pkg/webhook/daemonset/mutating/webhooks.go b/pkg/webhook/daemonset/mutating/webhooks.go index 54b9a31342..af474d9188 100644 --- a/pkg/webhook/daemonset/mutating/webhooks.go +++ b/pkg/webhook/daemonset/mutating/webhooks.go @@ -17,14 +17,19 @@ limitations under the License. package mutating import ( + "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "github.com/openkruise/kruise/pkg/webhook/types" ) // +kubebuilder:webhook:path=/mutate-apps-kruise-io-v1alpha1-daemonset,mutating=true,failurePolicy=fail,sideEffects=None,admissionReviewVersions=v1;v1beta1,groups=apps.kruise.io,resources=daemonsets,verbs=create;update,versions=v1alpha1,name=mdaemonset.kb.io var ( - // HandlerMap contains admission webhook handlers - HandlerMap = map[string]admission.Handler{ - "mutate-apps-kruise-io-v1alpha1-daemonset": &DaemonSetCreateUpdateHandler{}, + // HandlerGetterMap contains admission webhook handlers + HandlerGetterMap = map[string]types.HandlerGetter{ + "mutate-apps-kruise-io-v1alpha1-daemonset": func(mgr manager.Manager) admission.Handler { + return &DaemonSetCreateUpdateHandler{Decoder: admission.NewDecoder(mgr.GetScheme())} + }, } ) diff --git a/pkg/webhook/daemonset/validating/daemonset_create_update_handler.go b/pkg/webhook/daemonset/validating/daemonset_create_update_handler.go index 819b08baaa..ebe2e9c268 100644 --- a/pkg/webhook/daemonset/validating/daemonset_create_update_handler.go +++ b/pkg/webhook/daemonset/validating/daemonset_create_update_handler.go @@ -94,11 +94,3 @@ func (h *DaemonSetCreateUpdateHandler) Handle(ctx context.Context, req admission return admission.ValidationResponse(true, "") } - -var _ admission.DecoderInjector = &DaemonSetCreateUpdateHandler{} - -// InjectDecoder injects the decoder into the DaemonSetCreateUpdateHandler -func (h *DaemonSetCreateUpdateHandler) InjectDecoder(d *admission.Decoder) error { - h.Decoder = d - return nil -} diff --git a/pkg/webhook/daemonset/validating/daemonset_validation.go b/pkg/webhook/daemonset/validating/daemonset_validation.go index 53269de295..0c1cd0ca7d 100644 --- a/pkg/webhook/daemonset/validating/daemonset_validation.go +++ b/pkg/webhook/daemonset/validating/daemonset_validation.go @@ -62,7 +62,7 @@ func validateDaemonSetSpec(spec *appsv1alpha1.DaemonSetSpec, fldPath *field.Path allErrs = append(allErrs, field.Invalid(fldPath.Root(), spec.Template, fmt.Sprintf("Convert_v1_Volume_To_core_Volume failed: %v", err))) return allErrs } - allErrs = append(allErrs, corevalidation.ValidateReadOnlyPersistentDisks(coreVolumes, fldPath.Child("template", "spec", "volumes"))...) + allErrs = append(allErrs, corevalidation.ValidateReadOnlyPersistentDisks(coreVolumes, nil, fldPath.Child("template", "spec", "volumes"))...) // RestartPolicy has already been first-order validated as per ValidatePodTemplateSpec(). if spec.Template.Spec.RestartPolicy != corev1.RestartPolicyAlways { diff --git a/pkg/webhook/daemonset/validating/webhooks.go b/pkg/webhook/daemonset/validating/webhooks.go index a40cec6489..7ca54ca42f 100644 --- a/pkg/webhook/daemonset/validating/webhooks.go +++ b/pkg/webhook/daemonset/validating/webhooks.go @@ -17,14 +17,19 @@ limitations under the License. package validating import ( + "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "github.com/openkruise/kruise/pkg/webhook/types" ) // +kubebuilder:webhook:path=/validate-apps-kruise-io-v1alpha1-daemonset,mutating=false,failurePolicy=fail,sideEffects=None,admissionReviewVersions=v1;v1beta1,groups=apps.kruise.io,resources=daemonsets,verbs=create;update,versions=v1alpha1,name=vdaemonset.kb.io var ( - // HandlerMap contains admission webhook handlers - HandlerMap = map[string]admission.Handler{ - "validate-apps-kruise-io-v1alpha1-daemonset": &DaemonSetCreateUpdateHandler{}, + // HandlerGetterMap contains admission webhook handlers + HandlerGetterMap = map[string]types.HandlerGetter{ + "validate-apps-kruise-io-v1alpha1-daemonset": func(mgr manager.Manager) admission.Handler { + return &DaemonSetCreateUpdateHandler{Decoder: admission.NewDecoder(mgr.GetScheme())} + }, } ) diff --git a/pkg/webhook/imagelistpulljob/mutating/imagelistpulljob_create_update_handler.go b/pkg/webhook/imagelistpulljob/mutating/imagelistpulljob_create_update_handler.go index a95837c085..2329b073ac 100644 --- a/pkg/webhook/imagelistpulljob/mutating/imagelistpulljob_create_update_handler.go +++ b/pkg/webhook/imagelistpulljob/mutating/imagelistpulljob_create_update_handler.go @@ -22,12 +22,13 @@ import ( "net/http" "reflect" - "github.com/openkruise/kruise/apis/apps/defaults" - appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" - "github.com/openkruise/kruise/pkg/util" "k8s.io/apimachinery/pkg/runtime" "k8s.io/klog/v2" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "github.com/openkruise/kruise/apis/apps/defaults" + appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" + "github.com/openkruise/kruise/pkg/util" ) // ImageListPullJobCreateUpdateHandler handles ImagePullJob @@ -61,11 +62,3 @@ func (h *ImageListPullJobCreateUpdateHandler) Handle(ctx context.Context, req ad return resp } - -var _ admission.DecoderInjector = &ImageListPullJobCreateUpdateHandler{} - -// InjectDecoder injects the decoder into the ImageListPullJobCreateUpdateHandler -func (h *ImageListPullJobCreateUpdateHandler) InjectDecoder(d *admission.Decoder) error { - h.Decoder = d - return nil -} diff --git a/pkg/webhook/imagelistpulljob/mutating/webhooks.go b/pkg/webhook/imagelistpulljob/mutating/webhooks.go index 4f6bf06dfc..4c52e27951 100644 --- a/pkg/webhook/imagelistpulljob/mutating/webhooks.go +++ b/pkg/webhook/imagelistpulljob/mutating/webhooks.go @@ -17,14 +17,19 @@ limitations under the License. package mutating import ( + "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "github.com/openkruise/kruise/pkg/webhook/types" ) // +kubebuilder:webhook:path=/mutate-apps-kruise-io-v1alpha1-imagelistpulljob,mutating=true,failurePolicy=fail,sideEffects=None,admissionReviewVersions=v1;v1beta1,groups=apps.kruise.io,resources=imagelistpulljobs,verbs=create;update,versions=v1alpha1,name=mimagelistpulljob.kb.io var ( - // HandlerMap contains admission webhook handlers - HandlerMap = map[string]admission.Handler{ - "mutate-apps-kruise-io-v1alpha1-imagelistpulljob": &ImageListPullJobCreateUpdateHandler{}, + // HandlerGetterMap contains admission webhook handlers + HandlerGetterMap = map[string]types.HandlerGetter{ + "mutate-apps-kruise-io-v1alpha1-imagelistpulljob": func(mgr manager.Manager) admission.Handler { + return &ImageListPullJobCreateUpdateHandler{Decoder: admission.NewDecoder(mgr.GetScheme())} + }, } ) diff --git a/pkg/webhook/imagelistpulljob/validating/imagelistpulljob_create_update_handler.go b/pkg/webhook/imagelistpulljob/validating/imagelistpulljob_create_update_handler.go index c22a42e35e..47efcb37ce 100644 --- a/pkg/webhook/imagelistpulljob/validating/imagelistpulljob_create_update_handler.go +++ b/pkg/webhook/imagelistpulljob/validating/imagelistpulljob_create_update_handler.go @@ -124,11 +124,3 @@ func validate(obj *appsv1alpha1.ImageListPullJob) error { return nil } - -var _ admission.DecoderInjector = &ImageListPullJobCreateUpdateHandler{} - -// InjectDecoder injects the decoder into the ImageListPullJobCreateUpdateHandler -func (h *ImageListPullJobCreateUpdateHandler) InjectDecoder(d *admission.Decoder) error { - h.Decoder = d - return nil -} diff --git a/pkg/webhook/imagelistpulljob/validating/webhooks.go b/pkg/webhook/imagelistpulljob/validating/webhooks.go index bb04a46cc9..5cfdd16edc 100644 --- a/pkg/webhook/imagelistpulljob/validating/webhooks.go +++ b/pkg/webhook/imagelistpulljob/validating/webhooks.go @@ -17,14 +17,19 @@ limitations under the License. package validating import ( + "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "github.com/openkruise/kruise/pkg/webhook/types" ) // +kubebuilder:webhook:path=/validate-apps-kruise-io-v1alpha1-imagelistpulljob,mutating=false,failurePolicy=fail,sideEffects=None,admissionReviewVersions=v1;v1beta1,groups=apps.kruise.io,resources=imagelistpulljobs,verbs=create;update,versions=v1alpha1,name=vimagelistpulljob.kb.io var ( - // HandlerMap contains admission webhook handlers - HandlerMap = map[string]admission.Handler{ - "validate-apps-kruise-io-v1alpha1-imagelistpulljob": &ImageListPullJobCreateUpdateHandler{}, + // HandlerGetterMap contains admission webhook handlers + HandlerGetterMap = map[string]types.HandlerGetter{ + "validate-apps-kruise-io-v1alpha1-imagelistpulljob": func(mgr manager.Manager) admission.Handler { + return &ImageListPullJobCreateUpdateHandler{Decoder: admission.NewDecoder(mgr.GetScheme())} + }, } ) diff --git a/pkg/webhook/imagepulljob/mutating/imagepulljob_create_update_handler.go b/pkg/webhook/imagepulljob/mutating/imagepulljob_create_update_handler.go index dd0749deed..76f8a76914 100644 --- a/pkg/webhook/imagepulljob/mutating/imagepulljob_create_update_handler.go +++ b/pkg/webhook/imagepulljob/mutating/imagepulljob_create_update_handler.go @@ -22,13 +22,14 @@ import ( "net/http" "reflect" - "github.com/openkruise/kruise/apis/apps/defaults" - appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" - "github.com/openkruise/kruise/pkg/util" admissionv1 "k8s.io/api/admission/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/klog/v2" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "github.com/openkruise/kruise/apis/apps/defaults" + appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" + "github.com/openkruise/kruise/pkg/util" ) // ImagePullJobCreateUpdateHandler handles ImagePullJob @@ -62,11 +63,3 @@ func (h *ImagePullJobCreateUpdateHandler) Handle(ctx context.Context, req admiss return resp } - -var _ admission.DecoderInjector = &ImagePullJobCreateUpdateHandler{} - -// InjectDecoder injects the decoder into the ImagePullJobCreateUpdateHandler -func (h *ImagePullJobCreateUpdateHandler) InjectDecoder(d *admission.Decoder) error { - h.Decoder = d - return nil -} diff --git a/pkg/webhook/imagepulljob/mutating/webhooks.go b/pkg/webhook/imagepulljob/mutating/webhooks.go index 6e4a5c86af..032ae1b661 100644 --- a/pkg/webhook/imagepulljob/mutating/webhooks.go +++ b/pkg/webhook/imagepulljob/mutating/webhooks.go @@ -17,14 +17,19 @@ limitations under the License. package mutating import ( + "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "github.com/openkruise/kruise/pkg/webhook/types" ) // +kubebuilder:webhook:path=/mutate-apps-kruise-io-v1alpha1-imagepulljob,mutating=true,failurePolicy=fail,sideEffects=None,admissionReviewVersions=v1;v1beta1,groups=apps.kruise.io,resources=imagepulljobs,verbs=create;update,versions=v1alpha1,name=mimagepulljob.kb.io var ( - // HandlerMap contains admission webhook handlers - HandlerMap = map[string]admission.Handler{ - "mutate-apps-kruise-io-v1alpha1-imagepulljob": &ImagePullJobCreateUpdateHandler{}, + // HandlerGetterMap contains admission webhook handlers + HandlerGetterMap = map[string]types.HandlerGetter{ + "mutate-apps-kruise-io-v1alpha1-imagepulljob": func(mgr manager.Manager) admission.Handler { + return &ImagePullJobCreateUpdateHandler{Decoder: admission.NewDecoder(mgr.GetScheme())} + }, } ) diff --git a/pkg/webhook/imagepulljob/validating/imagepulljob_create_update_handler.go b/pkg/webhook/imagepulljob/validating/imagepulljob_create_update_handler.go index 7c711933a1..2f4fe82646 100644 --- a/pkg/webhook/imagepulljob/validating/imagepulljob_create_update_handler.go +++ b/pkg/webhook/imagepulljob/validating/imagepulljob_create_update_handler.go @@ -23,13 +23,14 @@ import ( "k8s.io/apimachinery/pkg/util/sets" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/klog/v2" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" daemonutil "github.com/openkruise/kruise/pkg/daemon/util" "github.com/openkruise/kruise/pkg/features" utilfeature "github.com/openkruise/kruise/pkg/util/feature" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/klog/v2" - "sigs.k8s.io/controller-runtime/pkg/webhook/admission" ) // ImagePullJobCreateUpdateHandler handles ImagePullJob @@ -110,11 +111,3 @@ func validate(obj *appsv1alpha1.ImagePullJob) error { return nil } - -var _ admission.DecoderInjector = &ImagePullJobCreateUpdateHandler{} - -// InjectDecoder injects the decoder into the ImagePullJobCreateUpdateHandler -func (h *ImagePullJobCreateUpdateHandler) InjectDecoder(d *admission.Decoder) error { - h.Decoder = d - return nil -} diff --git a/pkg/webhook/imagepulljob/validating/webhooks.go b/pkg/webhook/imagepulljob/validating/webhooks.go index a0f426d247..cae21f148e 100644 --- a/pkg/webhook/imagepulljob/validating/webhooks.go +++ b/pkg/webhook/imagepulljob/validating/webhooks.go @@ -17,14 +17,19 @@ limitations under the License. package validating import ( + "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "github.com/openkruise/kruise/pkg/webhook/types" ) // +kubebuilder:webhook:path=/validate-apps-kruise-io-v1alpha1-imagepulljob,mutating=false,failurePolicy=fail,sideEffects=None,admissionReviewVersions=v1;v1beta1,groups=apps.kruise.io,resources=imagepulljobs,verbs=create;update,versions=v1alpha1,name=vimagepulljob.kb.io var ( - // HandlerMap contains admission webhook handlers - HandlerMap = map[string]admission.Handler{ - "validate-apps-kruise-io-v1alpha1-imagepulljob": &ImagePullJobCreateUpdateHandler{}, + // HandlerGetterMap contains admission webhook handlers + HandlerGetterMap = map[string]types.HandlerGetter{ + "validate-apps-kruise-io-v1alpha1-imagepulljob": func(mgr manager.Manager) admission.Handler { + return &ImagePullJobCreateUpdateHandler{Decoder: admission.NewDecoder(mgr.GetScheme())} + }, } ) diff --git a/pkg/webhook/ingress/validating/ingress_handler.go b/pkg/webhook/ingress/validating/ingress_handler.go index 6e005eb528..b522ac9f5e 100644 --- a/pkg/webhook/ingress/validating/ingress_handler.go +++ b/pkg/webhook/ingress/validating/ingress_handler.go @@ -20,15 +20,15 @@ import ( "context" "net/http" - "github.com/openkruise/kruise/pkg/webhook/util/deletionprotection" admissionv1 "k8s.io/api/admission/v1" networkingv1 "k8s.io/api/networking/v1" networkingv1beta1 "k8s.io/api/networking/v1beta1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/klog/v2" "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/runtime/inject" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "github.com/openkruise/kruise/pkg/webhook/util/deletionprotection" ) type IngressHandler struct { @@ -71,17 +71,3 @@ func (h *IngressHandler) Handle(ctx context.Context, req admission.Request) admi } return admission.ValidationResponse(true, "") } - -var _ inject.Client = &IngressHandler{} - -func (h *IngressHandler) InjectClient(c client.Client) error { - h.Client = c - return nil -} - -var _ admission.DecoderInjector = &IngressHandler{} - -func (h *IngressHandler) InjectDecoder(d *admission.Decoder) error { - h.Decoder = d - return nil -} diff --git a/pkg/webhook/ingress/validating/webhooks.go b/pkg/webhook/ingress/validating/webhooks.go index 4e5c31d9a9..4dc20a62c9 100644 --- a/pkg/webhook/ingress/validating/webhooks.go +++ b/pkg/webhook/ingress/validating/webhooks.go @@ -16,13 +16,23 @@ limitations under the License. package validating -import "sigs.k8s.io/controller-runtime/pkg/webhook/admission" +import ( + "sigs.k8s.io/controller-runtime/pkg/manager" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "github.com/openkruise/kruise/pkg/webhook/types" +) // +kubebuilder:webhook:path=/validate-ingress,mutating=false,failurePolicy=fail,sideEffects=None,admissionReviewVersions=v1;v1beta1,groups=networking.k8s.io,resources=ingresses,verbs=delete,versions=v1;v1beta1,name=vingress.kb.io var ( - // HandlerMap contains admission webhook handlers - HandlerMap = map[string]admission.Handler{ - "validate-ingress": &IngressHandler{}, + // HandlerGetterMap contains admission webhook handlers + HandlerGetterMap = map[string]types.HandlerGetter{ + "validate-ingress": func(mgr manager.Manager) admission.Handler { + return &IngressHandler{ + Client: mgr.GetClient(), + Decoder: admission.NewDecoder(mgr.GetScheme()), + } + }, } ) diff --git a/pkg/webhook/namespace/validating/namespace_handler.go b/pkg/webhook/namespace/validating/namespace_handler.go index f3d6075960..b6a0618d58 100644 --- a/pkg/webhook/namespace/validating/namespace_handler.go +++ b/pkg/webhook/namespace/validating/namespace_handler.go @@ -20,14 +20,14 @@ import ( "context" "net/http" - "github.com/openkruise/kruise/pkg/util" - "github.com/openkruise/kruise/pkg/webhook/util/deletionprotection" admissionv1 "k8s.io/api/admission/v1" v1 "k8s.io/api/core/v1" "k8s.io/klog/v2" "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/runtime/inject" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "github.com/openkruise/kruise/pkg/util" + "github.com/openkruise/kruise/pkg/webhook/util/deletionprotection" ) type NamespaceHandler struct { @@ -59,17 +59,3 @@ func (h *NamespaceHandler) Handle(ctx context.Context, req admission.Request) ad } return admission.ValidationResponse(true, "") } - -var _ inject.Client = &NamespaceHandler{} - -func (h *NamespaceHandler) InjectClient(c client.Client) error { - h.Client = c - return nil -} - -var _ admission.DecoderInjector = &NamespaceHandler{} - -func (h *NamespaceHandler) InjectDecoder(d *admission.Decoder) error { - h.Decoder = d - return nil -} diff --git a/pkg/webhook/namespace/validating/webhooks.go b/pkg/webhook/namespace/validating/webhooks.go index 1e01e88a4f..30135406ff 100644 --- a/pkg/webhook/namespace/validating/webhooks.go +++ b/pkg/webhook/namespace/validating/webhooks.go @@ -16,13 +16,23 @@ limitations under the License. package validating -import "sigs.k8s.io/controller-runtime/pkg/webhook/admission" +import ( + "sigs.k8s.io/controller-runtime/pkg/manager" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "github.com/openkruise/kruise/pkg/webhook/types" +) // +kubebuilder:webhook:path=/validate-namespace,mutating=false,failurePolicy=fail,sideEffects=None,admissionReviewVersions=v1;v1beta1,groups="",resources=namespaces,verbs=delete,versions=v1,name=vnamespace.kb.io var ( - // HandlerMap contains admission webhook handlers - HandlerMap = map[string]admission.Handler{ - "validate-namespace": &NamespaceHandler{}, + // HandlerGetterMap contains admission webhook handlers + HandlerGetterMap = map[string]types.HandlerGetter{ + "validate-namespace": func(mgr manager.Manager) admission.Handler { + return &NamespaceHandler{ + Client: mgr.GetClient(), + Decoder: admission.NewDecoder(mgr.GetScheme()), + } + }, } ) diff --git a/pkg/webhook/nodeimage/mutating/nodeimage_create_update_handler.go b/pkg/webhook/nodeimage/mutating/nodeimage_create_update_handler.go index 2abeab6652..22d43308a1 100644 --- a/pkg/webhook/nodeimage/mutating/nodeimage_create_update_handler.go +++ b/pkg/webhook/nodeimage/mutating/nodeimage_create_update_handler.go @@ -22,13 +22,14 @@ import ( "net/http" "reflect" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/klog/v2" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + "github.com/openkruise/kruise/apis/apps/defaults" appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" "github.com/openkruise/kruise/pkg/util" utilimagejob "github.com/openkruise/kruise/pkg/util/imagejob" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/klog/v2" - "sigs.k8s.io/controller-runtime/pkg/webhook/admission" ) // NodeImageCreateUpdateHandler handles NodeImage @@ -73,11 +74,3 @@ func (h *NodeImageCreateUpdateHandler) Handle(ctx context.Context, req admission return resp } - -var _ admission.DecoderInjector = &NodeImageCreateUpdateHandler{} - -// InjectDecoder injects the decoder into the NodeImageCreateUpdateHandler -func (h *NodeImageCreateUpdateHandler) InjectDecoder(d *admission.Decoder) error { - h.Decoder = d - return nil -} diff --git a/pkg/webhook/nodeimage/mutating/webhooks.go b/pkg/webhook/nodeimage/mutating/webhooks.go index a5de268262..0bd5b2e5ea 100644 --- a/pkg/webhook/nodeimage/mutating/webhooks.go +++ b/pkg/webhook/nodeimage/mutating/webhooks.go @@ -17,14 +17,19 @@ limitations under the License. package mutating import ( + "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "github.com/openkruise/kruise/pkg/webhook/types" ) // +kubebuilder:webhook:path=/mutate-apps-kruise-io-v1alpha1-nodeimage,mutating=true,failurePolicy=fail,sideEffects=None,admissionReviewVersions=v1;v1beta1,groups=apps.kruise.io,resources=nodeimages,verbs=create;update,versions=v1alpha1,name=mnodeimage.kb.io var ( - // HandlerMap contains admission webhook handlers - HandlerMap = map[string]admission.Handler{ - "mutate-apps-kruise-io-v1alpha1-nodeimage": &NodeImageCreateUpdateHandler{}, + // HandlerGetterMap contains admission webhook handlers + HandlerGetterMap = map[string]types.HandlerGetter{ + "mutate-apps-kruise-io-v1alpha1-nodeimage": func(mgr manager.Manager) admission.Handler { + return &NodeImageCreateUpdateHandler{Decoder: admission.NewDecoder(mgr.GetScheme())} + }, } ) diff --git a/pkg/webhook/nodeimage/validating/nodeimage_create_update_handler.go b/pkg/webhook/nodeimage/validating/nodeimage_create_update_handler.go index 095ccc2ae3..f742ccfd80 100644 --- a/pkg/webhook/nodeimage/validating/nodeimage_create_update_handler.go +++ b/pkg/webhook/nodeimage/validating/nodeimage_create_update_handler.go @@ -21,12 +21,13 @@ import ( "fmt" "net/http" - appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" - "github.com/openkruise/kruise/pkg/features" - utilfeature "github.com/openkruise/kruise/pkg/util/feature" "k8s.io/apimachinery/pkg/util/sets" "k8s.io/klog/v2" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" + "github.com/openkruise/kruise/pkg/features" + utilfeature "github.com/openkruise/kruise/pkg/util/feature" ) var ( @@ -99,11 +100,3 @@ func validate(obj *appsv1alpha1.NodeImage) error { return nil } - -var _ admission.DecoderInjector = &NodeImageCreateUpdateHandler{} - -// InjectDecoder injects the decoder into the NodeImageCreateUpdateHandler -func (h *NodeImageCreateUpdateHandler) InjectDecoder(d *admission.Decoder) error { - h.Decoder = d - return nil -} diff --git a/pkg/webhook/nodeimage/validating/webhooks.go b/pkg/webhook/nodeimage/validating/webhooks.go index 888b23ed18..121aa56850 100644 --- a/pkg/webhook/nodeimage/validating/webhooks.go +++ b/pkg/webhook/nodeimage/validating/webhooks.go @@ -17,14 +17,19 @@ limitations under the License. package validating import ( + "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "github.com/openkruise/kruise/pkg/webhook/types" ) // +kubebuilder:webhook:path=/validate-apps-kruise-io-v1alpha1-nodeimage,mutating=false,failurePolicy=fail,sideEffects=None,admissionReviewVersions=v1;v1beta1,groups=apps.kruise.io,resources=nodeimages,verbs=create;update,versions=v1alpha1,name=vnodeimage.kb.io var ( - // HandlerMap contains admission webhook handlers - HandlerMap = map[string]admission.Handler{ - "validate-apps-kruise-io-v1alpha1-nodeimage": &NodeImageCreateUpdateHandler{}, + // HandlerGetterMap contains admission webhook handlers + HandlerGetterMap = map[string]types.HandlerGetter{ + "validate-apps-kruise-io-v1alpha1-nodeimage": func(mgr manager.Manager) admission.Handler { + return &NodeImageCreateUpdateHandler{Decoder: admission.NewDecoder(mgr.GetScheme())} + }, } ) diff --git a/pkg/webhook/persistentpodstate/validating/persistent_create_update_handler.go b/pkg/webhook/persistentpodstate/validating/persistent_create_update_handler.go index 3b68ff8caf..59ce03cfa4 100644 --- a/pkg/webhook/persistentpodstate/validating/persistent_create_update_handler.go +++ b/pkg/webhook/persistentpodstate/validating/persistent_create_update_handler.go @@ -22,14 +22,14 @@ import ( "net/http" "reflect" - appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" - "github.com/openkruise/kruise/pkg/util/configuration" admissionv1 "k8s.io/api/admission/v1" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/util/validation/field" "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/runtime/inject" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" + "github.com/openkruise/kruise/pkg/util/configuration" ) // PersistentPodStateCreateUpdateHandler handles PersistentPodState @@ -146,19 +146,3 @@ func validatePerConflict(pps *appsv1alpha1.PersistentPodState, others []appsv1al } return allErrs } - -var _ inject.Client = &PersistentPodStateCreateUpdateHandler{} - -// InjectClient injects the client into the PersistentPodStateCreateUpdateHandler -func (h *PersistentPodStateCreateUpdateHandler) InjectClient(c client.Client) error { - h.Client = c - return nil -} - -var _ admission.DecoderInjector = &PersistentPodStateCreateUpdateHandler{} - -// InjectDecoder injects the decoder into the PersistentPodStateCreateUpdateHandler -func (h *PersistentPodStateCreateUpdateHandler) InjectDecoder(d *admission.Decoder) error { - h.Decoder = d - return nil -} diff --git a/pkg/webhook/persistentpodstate/validating/persistent_validating_test.go b/pkg/webhook/persistentpodstate/validating/persistent_validating_test.go index 98d8391e82..b7525d36e8 100644 --- a/pkg/webhook/persistentpodstate/validating/persistent_validating_test.go +++ b/pkg/webhook/persistentpodstate/validating/persistent_validating_test.go @@ -24,11 +24,12 @@ import ( corev1 "k8s.io/api/core/v1" - appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/client/fake" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" ) func init() { @@ -121,7 +122,7 @@ func TestValidatingPer(t *testing.T) { }, } - decoder, _ := admission.NewDecoder(scheme) + decoder := admission.NewDecoder(scheme) client := fake.NewClientBuilder().WithScheme(scheme).Build() perHandler := PersistentPodStateCreateUpdateHandler{ Client: client, @@ -212,7 +213,7 @@ func TestPerConflictWithOthers(t *testing.T) { for _, cs := range cases { t.Run(cs.name, func(t *testing.T) { - decoder, _ := admission.NewDecoder(scheme) + decoder := admission.NewDecoder(scheme) client := fake.NewClientBuilder().WithScheme(scheme).Build() for _, pps := range cs.otherPers() { client.Create(context.TODO(), pps) @@ -267,7 +268,7 @@ func TestValidatingUpdatePer(t *testing.T) { }, } - decoder, _ := admission.NewDecoder(scheme) + decoder := admission.NewDecoder(scheme) client := fake.NewClientBuilder().WithScheme(scheme).Build() perHandler := PersistentPodStateCreateUpdateHandler{ Client: client, diff --git a/pkg/webhook/persistentpodstate/validating/webhooks.go b/pkg/webhook/persistentpodstate/validating/webhooks.go index 5ad572a28f..c6960596f2 100644 --- a/pkg/webhook/persistentpodstate/validating/webhooks.go +++ b/pkg/webhook/persistentpodstate/validating/webhooks.go @@ -17,14 +17,22 @@ limitations under the License. package validating import ( + "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "github.com/openkruise/kruise/pkg/webhook/types" ) // +kubebuilder:webhook:path=/validate-apps-kruise-io-persistentpodstate,mutating=false,failurePolicy=fail,sideEffects=None,admissionReviewVersions=v1;v1beta1,groups=apps.kruise.io,resources=persistentpodstates,verbs=create;update,versions=v1alpha1,name=vpersistentpodstate.kb.io var ( - // HandlerMap contains admission webhook handlers - HandlerMap = map[string]admission.Handler{ - "validate-apps-kruise-io-persistentpodstate": &PersistentPodStateCreateUpdateHandler{}, + // HandlerGetterMap contains admission webhook handlers + HandlerGetterMap = map[string]types.HandlerGetter{ + "validate-apps-kruise-io-persistentpodstate": func(mgr manager.Manager) admission.Handler { + return &PersistentPodStateCreateUpdateHandler{ + Client: mgr.GetClient(), + Decoder: admission.NewDecoder(mgr.GetScheme()), + } + }, } ) diff --git a/pkg/webhook/pod/mutating/enhancedlivenessprobe_handler_test.go b/pkg/webhook/pod/mutating/enhancedlivenessprobe_handler_test.go index 468d16bad4..8e113cb3a7 100644 --- a/pkg/webhook/pod/mutating/enhancedlivenessprobe_handler_test.go +++ b/pkg/webhook/pod/mutating/enhancedlivenessprobe_handler_test.go @@ -474,7 +474,7 @@ func TestRemoveAndBackUpPodContainerLivenessProbeLink(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { podIn := tc.pod - decoder, _ := admission.NewDecoder(schema) + decoder := admission.NewDecoder(schema) client := fake.NewClientBuilder().WithScheme(schema).WithObjects(podIn).Build() podOut := podIn.DeepCopy() podHandler := &PodCreateHandler{Decoder: decoder, Client: client} diff --git a/pkg/webhook/pod/mutating/persistent_pod_state_test.go b/pkg/webhook/pod/mutating/persistent_pod_state_test.go index 7964589de8..3c0e04734c 100644 --- a/pkg/webhook/pod/mutating/persistent_pod_state_test.go +++ b/pkg/webhook/pod/mutating/persistent_pod_state_test.go @@ -21,8 +21,6 @@ import ( "reflect" "testing" - appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" - appsv1beta1 "github.com/openkruise/kruise/apis/apps/v1beta1" admissionv1 "k8s.io/api/admission/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -31,6 +29,9 @@ import ( "k8s.io/utils/pointer" "sigs.k8s.io/controller-runtime/pkg/client/fake" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" + appsv1beta1 "github.com/openkruise/kruise/apis/apps/v1beta1" ) const ( @@ -220,7 +221,7 @@ func TestPersistentPodStateMutatingPod(t *testing.T) { for _, cs := range cases { t.Run(cs.name, func(t *testing.T) { podIn := cs.getPod() - decoder, _ := admission.NewDecoder(scheme.Scheme) + decoder := admission.NewDecoder(scheme.Scheme) client := fake.NewClientBuilder().WithScheme(scheme.Scheme).WithObjects(cs.getPodState()).Build() podOut := podIn.DeepCopy() podHandler := &PodCreateHandler{Decoder: decoder, Client: client} diff --git a/pkg/webhook/pod/mutating/pod_create_update_handler.go b/pkg/webhook/pod/mutating/pod_create_update_handler.go index 09c1665616..c9cd6d6270 100644 --- a/pkg/webhook/pod/mutating/pod_create_update_handler.go +++ b/pkg/webhook/pod/mutating/pod_create_update_handler.go @@ -23,11 +23,9 @@ import ( corev1 "k8s.io/api/core/v1" "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/runtime/inject" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" "github.com/openkruise/kruise/pkg/features" - "github.com/openkruise/kruise/pkg/util/controllerfinder" utilfeature "github.com/openkruise/kruise/pkg/util/feature" ) @@ -41,8 +39,6 @@ type PodCreateHandler struct { // Decoder decodes objects Decoder *admission.Decoder - - finder *controllerfinder.ControllerFinder } var _ admission.Handler = &PodCreateHandler{} @@ -126,20 +122,3 @@ func (h *PodCreateHandler) Handle(ctx context.Context, req admission.Request) ad } return admission.PatchResponseFromRaw(original, marshalled) } - -var _ inject.Client = &PodCreateHandler{} - -// InjectClient injects the client into the PodCreateHandler -func (h *PodCreateHandler) InjectClient(c client.Client) error { - h.Client = c - h.finder = controllerfinder.Finder - return nil -} - -var _ admission.DecoderInjector = &PodCreateHandler{} - -// InjectDecoder injects the decoder into the PodCreateHandler -func (h *PodCreateHandler) InjectDecoder(d *admission.Decoder) error { - h.Decoder = d - return nil -} diff --git a/pkg/webhook/pod/mutating/sidecarset_hotupgrade_test.go b/pkg/webhook/pod/mutating/sidecarset_hotupgrade_test.go index 707028f25f..ef2e5fac41 100644 --- a/pkg/webhook/pod/mutating/sidecarset_hotupgrade_test.go +++ b/pkg/webhook/pod/mutating/sidecarset_hotupgrade_test.go @@ -41,7 +41,7 @@ func TestInjectHotUpgradeSidecar(t *testing.T) { func testInjectHotUpgradeSidecar(t *testing.T, sidecarSetIn *appsv1alpha1.SidecarSet) { podIn := pod1.DeepCopy() - decoder, _ := admission.NewDecoder(scheme.Scheme) + decoder := admission.NewDecoder(scheme.Scheme) client := fake.NewClientBuilder().WithObjects(sidecarSetIn).WithIndex( &appsv1alpha1.SidecarSet{}, fieldindex.IndexNameForSidecarSetNamespace, fieldindex.IndexSidecarSet, ).Build() diff --git a/pkg/webhook/pod/mutating/sidecarset_test.go b/pkg/webhook/pod/mutating/sidecarset_test.go index 3057dd167e..d7011b1aaa 100644 --- a/pkg/webhook/pod/mutating/sidecarset_test.go +++ b/pkg/webhook/pod/mutating/sidecarset_test.go @@ -423,7 +423,7 @@ func testPodHasNoMatchedSidecarSet(t *testing.T, sidecarSetIn *appsv1alpha1.Side podIn := pod1.DeepCopy() podIn.Labels["app"] = "doesnt-match" podOut := podIn.DeepCopy() - decoder, _ := admission.NewDecoder(scheme.Scheme) + decoder := admission.NewDecoder(scheme.Scheme) client := fake.NewClientBuilder().WithObjects(sidecarSetIn).WithIndex( &appsv1alpha1.SidecarSet{}, fieldindex.IndexNameForSidecarSetNamespace, fieldindex.IndexSidecarSet, ).Build() @@ -467,7 +467,7 @@ func doMergeSidecarSecretsTest(t *testing.T, sidecarSetIn *appsv1alpha1.SidecarS podIn := pod1.DeepCopy() podIn.Spec.ImagePullSecrets = podImagePullSecrets podOut := podIn.DeepCopy() - decoder, _ := admission.NewDecoder(scheme.Scheme) + decoder := admission.NewDecoder(scheme.Scheme) client := fake.NewClientBuilder().WithObjects(sidecarSetIn).WithIndex( &appsv1alpha1.SidecarSet{}, fieldindex.IndexNameForSidecarSetNamespace, fieldindex.IndexSidecarSet, ).Build() @@ -490,7 +490,7 @@ func testInjectionStrategyPaused(t *testing.T, sidecarIn *appsv1alpha1.SidecarSe podOut := podIn.DeepCopy() sidecarPaused := sidecarIn sidecarPaused.Spec.InjectionStrategy.Paused = true - decoder, _ := admission.NewDecoder(scheme.Scheme) + decoder := admission.NewDecoder(scheme.Scheme) client := fake.NewClientBuilder().WithObjects(sidecarPaused).WithIndex( &appsv1alpha1.SidecarSet{}, fieldindex.IndexNameForSidecarSetNamespace, fieldindex.IndexSidecarSet, ).Build() @@ -530,7 +530,7 @@ func TestInjectMetadata(t *testing.T) { }, }, } - decoder, _ := admission.NewDecoder(scheme.Scheme) + decoder := admission.NewDecoder(scheme.Scheme) client := fake.NewClientBuilder().WithObjects(demo1, demo2).WithIndex( &appsv1alpha1.SidecarSet{}, fieldindex.IndexNameForSidecarSetNamespace, fieldindex.IndexSidecarSet, ).Build() @@ -588,6 +588,7 @@ func TestInjectionStrategyRevision(t *testing.T) { Namespace: webhookutil.GetNamespace(), Name: revisionID, Labels: map[string]string{ + sidecarcontrol.SidecarSetKindName: sidecarSet1.GetName(), appsv1alpha1.SidecarSetCustomVersionLabel: revisionID, }, }, @@ -602,7 +603,7 @@ func TestInjectionStrategyRevision(t *testing.T) { func testInjectionStrategyRevision(t *testing.T, env []client.Object) { podIn := pod1.DeepCopy() podOut := podIn.DeepCopy() - decoder, _ := admission.NewDecoder(scheme.Scheme) + decoder := admission.NewDecoder(scheme.Scheme) client := fake.NewClientBuilder().WithObjects(env...).WithIndex( &appsv1alpha1.SidecarSet{}, fieldindex.IndexNameForSidecarSetNamespace, fieldindex.IndexSidecarSet, ).Build() @@ -625,7 +626,7 @@ func TestSidecarSetPodInjectPolicy(t *testing.T) { func testSidecarSetPodInjectPolicy(t *testing.T, sidecarSetIn *appsv1alpha1.SidecarSet) { podIn := pod1.DeepCopy() - decoder, _ := admission.NewDecoder(scheme.Scheme) + decoder := admission.NewDecoder(scheme.Scheme) client := fake.NewClientBuilder().WithObjects(sidecarSetIn).WithIndex( &appsv1alpha1.SidecarSet{}, fieldindex.IndexNameForSidecarSetNamespace, fieldindex.IndexSidecarSet, ).Build() @@ -704,7 +705,7 @@ func TestSidecarVolumesAppend(t *testing.T) { func testSidecarVolumesAppend(t *testing.T, sidecarSetIn *appsv1alpha1.SidecarSet) { podIn := pod1.DeepCopy() - decoder, _ := admission.NewDecoder(scheme.Scheme) + decoder := admission.NewDecoder(scheme.Scheme) client := fake.NewClientBuilder().WithObjects(sidecarSetIn).WithIndex( &appsv1alpha1.SidecarSet{}, fieldindex.IndexNameForSidecarSetNamespace, fieldindex.IndexSidecarSet, ).Build() @@ -859,7 +860,7 @@ func testPodVolumeMountsAppend(t *testing.T, sidecarSetIn *appsv1alpha1.SidecarS for _, cs := range cases { t.Run(cs.name, func(t *testing.T) { podIn := cs.getPod() - decoder, _ := admission.NewDecoder(scheme.Scheme) + decoder := admission.NewDecoder(scheme.Scheme) client := fake.NewClientBuilder().WithObjects(cs.getSidecarSets()).WithIndex( &appsv1alpha1.SidecarSet{}, fieldindex.IndexNameForSidecarSetNamespace, fieldindex.IndexSidecarSet, ).Build() @@ -905,7 +906,7 @@ func TestSidecarSetTransferEnv(t *testing.T) { func testSidecarSetTransferEnv(t *testing.T, sidecarSetIn *appsv1alpha1.SidecarSet) { podIn := pod1.DeepCopy() - decoder, _ := admission.NewDecoder(scheme.Scheme) + decoder := admission.NewDecoder(scheme.Scheme) client := fake.NewClientBuilder().WithObjects(sidecarSetIn).WithIndex( &appsv1alpha1.SidecarSet{}, fieldindex.IndexNameForSidecarSetNamespace, fieldindex.IndexSidecarSet, ).Build() @@ -941,7 +942,7 @@ func testSidecarSetHashInject(t *testing.T, sidecarSetIn1 *appsv1alpha1.SidecarS sidecarSetIn2 := sidecarsetWithTransferEnv.DeepCopy() sidecarSetIn3 := sidecarSet3.DeepCopy() - decoder, _ := admission.NewDecoder(scheme.Scheme) + decoder := admission.NewDecoder(scheme.Scheme) client := fake.NewClientBuilder().WithObjects(sidecarSetIn1, sidecarSetIn2, sidecarSetIn3).WithIndex( &appsv1alpha1.SidecarSet{}, fieldindex.IndexNameForSidecarSetNamespace, fieldindex.IndexSidecarSet, ).Build() @@ -974,7 +975,7 @@ func TestSidecarSetNameInject(t *testing.T) { func testSidecarSetNameInject(t *testing.T, sidecarSetIn1, sidecarSetIn3 *appsv1alpha1.SidecarSet) { podIn := pod1.DeepCopy() - decoder, _ := admission.NewDecoder(scheme.Scheme) + decoder := admission.NewDecoder(scheme.Scheme) client := fake.NewClientBuilder().WithObjects(sidecarSetIn1, sidecarSetIn3).WithIndex( &appsv1alpha1.SidecarSet{}, fieldindex.IndexNameForSidecarSetNamespace, fieldindex.IndexSidecarSet, ).Build() diff --git a/pkg/webhook/pod/mutating/webhooks.go b/pkg/webhook/pod/mutating/webhooks.go index 7209adf47f..023ed0413c 100644 --- a/pkg/webhook/pod/mutating/webhooks.go +++ b/pkg/webhook/pod/mutating/webhooks.go @@ -17,14 +17,22 @@ limitations under the License. package mutating import ( + "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "github.com/openkruise/kruise/pkg/webhook/types" ) // +kubebuilder:webhook:path=/mutate-pod,mutating=true,failurePolicy=fail,sideEffects=None,admissionReviewVersions=v1;v1beta1,groups="",resources=pods,verbs=create,versions=v1,name=mpod.kb.io var ( - // HandlerMap contains admission webhook handlers - HandlerMap = map[string]admission.Handler{ - "mutate-pod": &PodCreateHandler{}, + // HandlerGetterMap contains admission webhook handlers + HandlerGetterMap = map[string]types.HandlerGetter{ + "mutate-pod": func(mgr manager.Manager) admission.Handler { + return &PodCreateHandler{ + Client: mgr.GetClient(), + Decoder: admission.NewDecoder(mgr.GetScheme()), + } + }, } ) diff --git a/pkg/webhook/pod/validating/pod_create_update_handler.go b/pkg/webhook/pod/validating/pod_create_update_handler.go index e164db40a6..64e92f25af 100644 --- a/pkg/webhook/pod/validating/pod_create_update_handler.go +++ b/pkg/webhook/pod/validating/pod_create_update_handler.go @@ -20,14 +20,13 @@ import ( "context" "net/http" - "github.com/openkruise/kruise/pkg/features" - "github.com/openkruise/kruise/pkg/util/controllerfinder" - utilfeature "github.com/openkruise/kruise/pkg/util/feature" admissionv1 "k8s.io/api/admission/v1" "k8s.io/klog/v2" "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/runtime/inject" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "github.com/openkruise/kruise/pkg/features" + utilfeature "github.com/openkruise/kruise/pkg/util/feature" ) // PodCreateHandler handles Pod @@ -40,8 +39,6 @@ type PodCreateHandler struct { // Decoder decodes objects Decoder *admission.Decoder - - finders *controllerfinder.ControllerFinder } func (h *PodCreateHandler) validatingPodFn(ctx context.Context, req admission.Request) (allowed bool, reason string, err error) { @@ -82,20 +79,3 @@ func (h *PodCreateHandler) Handle(ctx context.Context, req admission.Request) ad } return admission.ValidationResponse(allowed, reason) } - -var _ inject.Client = &PodCreateHandler{} - -// InjectClient injects the client into the PodCreateHandler -func (h *PodCreateHandler) InjectClient(c client.Client) error { - h.Client = c - h.finders = controllerfinder.Finder - return nil -} - -var _ admission.DecoderInjector = &PodCreateHandler{} - -// InjectDecoder injects the decoder into the PodCreateHandler -func (h *PodCreateHandler) InjectDecoder(d *admission.Decoder) error { - h.Decoder = d - return nil -} diff --git a/pkg/webhook/pod/validating/pod_unavailable_budget_test.go b/pkg/webhook/pod/validating/pod_unavailable_budget_test.go index 57bdb9e64a..9533f706cf 100644 --- a/pkg/webhook/pod/validating/pod_unavailable_budget_test.go +++ b/pkg/webhook/pod/validating/pod_unavailable_budget_test.go @@ -22,12 +22,6 @@ import ( "testing" "time" - appspub "github.com/openkruise/kruise/apis/apps/pub" - policyv1alpha1 "github.com/openkruise/kruise/apis/policy/v1alpha1" - "github.com/openkruise/kruise/pkg/control/pubcontrol" - "github.com/openkruise/kruise/pkg/control/sidecarcontrol" - "github.com/openkruise/kruise/pkg/util" - "github.com/openkruise/kruise/pkg/util/controllerfinder" admissionv1 "k8s.io/api/admission/v1" apps "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" @@ -42,6 +36,13 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + appspub "github.com/openkruise/kruise/apis/apps/pub" + policyv1alpha1 "github.com/openkruise/kruise/apis/policy/v1alpha1" + "github.com/openkruise/kruise/pkg/control/pubcontrol" + "github.com/openkruise/kruise/pkg/control/sidecarcontrol" + "github.com/openkruise/kruise/pkg/util" + "github.com/openkruise/kruise/pkg/util/controllerfinder" ) func init() { @@ -473,8 +474,9 @@ func TestValidateUpdatePodForPub(t *testing.T) { for _, cs := range cases { t.Run(cs.name, func(t *testing.T) { - decoder, _ := admission.NewDecoder(scheme) - fClient := fake.NewClientBuilder().WithScheme(scheme).WithObjects(cs.pub()).Build() + decoder := admission.NewDecoder(scheme) + fClient := fake.NewClientBuilder().WithScheme(scheme).WithObjects(cs.pub()). + WithStatusSubresource(&policyv1alpha1.PodUnavailableBudget{}).Build() podHandler := PodCreateHandler{ Client: fClient, Decoder: decoder, @@ -669,8 +671,9 @@ func TestValidateEvictPodForPub(t *testing.T) { for _, cs := range cases { t.Run(cs.name, func(t *testing.T) { - decoder, _ := admission.NewDecoder(scheme) - fClient := fake.NewClientBuilder().WithScheme(scheme).WithObjects(cs.pub(), cs.newPod()).Build() + decoder := admission.NewDecoder(scheme) + fClient := fake.NewClientBuilder().WithScheme(scheme).WithObjects(cs.pub(), cs.newPod()). + WithStatusSubresource(&policyv1alpha1.PodUnavailableBudget{}).Build() podHandler := PodCreateHandler{ Client: fClient, Decoder: decoder, @@ -826,8 +829,9 @@ func TestValidateDeletePodForPub(t *testing.T) { for _, cs := range cases { t.Run(cs.name, func(t *testing.T) { - decoder, _ := admission.NewDecoder(scheme) - fClient := fake.NewClientBuilder().WithScheme(scheme).WithObjects(cs.pub(), cs.newPod()).Build() + decoder := admission.NewDecoder(scheme) + fClient := fake.NewClientBuilder().WithScheme(scheme).WithObjects(cs.pub(), cs.newPod()). + WithStatusSubresource(&policyv1alpha1.PodUnavailableBudget{}).Build() podHandler := PodCreateHandler{ Client: fClient, Decoder: decoder, diff --git a/pkg/webhook/pod/validating/webhooks.go b/pkg/webhook/pod/validating/webhooks.go index cf7261978f..0c3c475197 100644 --- a/pkg/webhook/pod/validating/webhooks.go +++ b/pkg/webhook/pod/validating/webhooks.go @@ -17,15 +17,23 @@ limitations under the License. package validating import ( + "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "github.com/openkruise/kruise/pkg/webhook/types" ) // +kubebuilder:webhook:path=/validate-pod,mutating=false,failurePolicy=fail,sideEffects=None,admissionReviewVersions=v1;v1beta1,groups="",resources=pods,verbs=update;delete,versions=v1,name=vpod.kb.io // +kubebuilder:webhook:path=/validate-pod,mutating=false,failurePolicy=fail,sideEffects=None,admissionReviewVersions=v1;v1beta1,groups="",resources=pods/eviction,verbs=create,versions=v1,name=vpodeviction.kb.io var ( - // HandlerMap contains admission webhook handlers - HandlerMap = map[string]admission.Handler{ - "validate-pod": &PodCreateHandler{}, + // HandlerGetterMap contains admission webhook handlers + HandlerGetterMap = map[string]types.HandlerGetter{ + "validate-pod": func(mgr manager.Manager) admission.Handler { + return &PodCreateHandler{ + Client: mgr.GetClient(), + Decoder: admission.NewDecoder(mgr.GetScheme()), + } + }, } ) diff --git a/pkg/webhook/podprobemarker/validating/probe_create_update_handler.go b/pkg/webhook/podprobemarker/validating/probe_create_update_handler.go index 8111045015..5ea66f97ab 100644 --- a/pkg/webhook/podprobemarker/validating/probe_create_update_handler.go +++ b/pkg/webhook/podprobemarker/validating/probe_create_update_handler.go @@ -38,8 +38,6 @@ import ( validationutil "k8s.io/apimachinery/pkg/util/validation" "k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/kubernetes/pkg/apis/core/validation" - "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/runtime/inject" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" "github.com/openkruise/kruise/apis/apps/pub" @@ -288,18 +286,3 @@ func validatePodProbeMarkerName(name string, prefix bool) (allErrs []string) { } return allErrs } - -var _ inject.Client = &PodProbeMarkerCreateUpdateHandler{} - -// InjectClient injects the client into the PodProbeMarkerCreateUpdateHandler -func (h *PodProbeMarkerCreateUpdateHandler) InjectClient(c client.Client) error { - return nil -} - -var _ admission.DecoderInjector = &PodProbeMarkerCreateUpdateHandler{} - -// InjectDecoder injects the decoder into the PodProbeMarkerCreateUpdateHandler -func (h *PodProbeMarkerCreateUpdateHandler) InjectDecoder(d *admission.Decoder) error { - h.Decoder = d - return nil -} diff --git a/pkg/webhook/podprobemarker/validating/probe_validating_test.go b/pkg/webhook/podprobemarker/validating/probe_validating_test.go index 18d0b8014b..9cc6fc530e 100644 --- a/pkg/webhook/podprobemarker/validating/probe_validating_test.go +++ b/pkg/webhook/podprobemarker/validating/probe_validating_test.go @@ -227,7 +227,7 @@ func TestValidatingPodProbeMarker(t *testing.T) { }, } - decoder, _ := admission.NewDecoder(scheme) + decoder := admission.NewDecoder(scheme) perHandler := PodProbeMarkerCreateUpdateHandler{ Decoder: decoder, } diff --git a/pkg/webhook/podprobemarker/validating/webhooks.go b/pkg/webhook/podprobemarker/validating/webhooks.go index 2cbe717de9..83d349d778 100644 --- a/pkg/webhook/podprobemarker/validating/webhooks.go +++ b/pkg/webhook/podprobemarker/validating/webhooks.go @@ -17,14 +17,19 @@ limitations under the License. package validating import ( + "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "github.com/openkruise/kruise/pkg/webhook/types" ) // +kubebuilder:webhook:path=/validate-apps-kruise-io-podprobemarker,mutating=false,failurePolicy=fail,sideEffects=None,admissionReviewVersions=v1;v1beta1,groups=apps.kruise.io,resources=podprobemarkers,verbs=create;update,versions=v1alpha1,name=vpodprobemarker.kb.io var ( - // HandlerMap contains admission webhook handlers - HandlerMap = map[string]admission.Handler{ - "validate-apps-kruise-io-podprobemarker": &PodProbeMarkerCreateUpdateHandler{}, + // HandlerGetterMap contains admission webhook handlers + HandlerGetterMap = map[string]types.HandlerGetter{ + "validate-apps-kruise-io-podprobemarker": func(mgr manager.Manager) admission.Handler { + return &PodProbeMarkerCreateUpdateHandler{Decoder: admission.NewDecoder(mgr.GetScheme())} + }, } ) diff --git a/pkg/webhook/podunavailablebudget/validating/pub_create_update_handler.go b/pkg/webhook/podunavailablebudget/validating/pub_create_update_handler.go index 5a7818983e..874365d055 100644 --- a/pkg/webhook/podunavailablebudget/validating/pub_create_update_handler.go +++ b/pkg/webhook/podunavailablebudget/validating/pub_create_update_handler.go @@ -36,7 +36,6 @@ import ( "k8s.io/apimachinery/pkg/util/validation/field" appsvalidation "k8s.io/kubernetes/pkg/apis/apps/validation" "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/runtime/inject" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" ) @@ -196,19 +195,3 @@ func validatePubConflict(pub *policyv1alpha1.PodUnavailableBudget, others []poli } return allErrs } - -var _ inject.Client = &PodUnavailableBudgetCreateUpdateHandler{} - -// InjectClient injects the client into the PodUnavailableBudgetCreateUpdateHandler -func (h *PodUnavailableBudgetCreateUpdateHandler) InjectClient(c client.Client) error { - h.Client = c - return nil -} - -var _ admission.DecoderInjector = &PodUnavailableBudgetCreateUpdateHandler{} - -// InjectDecoder injects the decoder into the PodUnavailableBudgetCreateUpdateHandler -func (h *PodUnavailableBudgetCreateUpdateHandler) InjectDecoder(d *admission.Decoder) error { - h.Decoder = d - return nil -} diff --git a/pkg/webhook/podunavailablebudget/validating/pub_validating_test.go b/pkg/webhook/podunavailablebudget/validating/pub_validating_test.go index f29f45c2ea..2d46c01f88 100644 --- a/pkg/webhook/podunavailablebudget/validating/pub_validating_test.go +++ b/pkg/webhook/podunavailablebudget/validating/pub_validating_test.go @@ -184,7 +184,7 @@ func TestValidatingPub(t *testing.T) { }, } - decoder, _ := admission.NewDecoder(scheme) + decoder := admission.NewDecoder(scheme) client := fake.NewClientBuilder().WithScheme(scheme).Build() pubHandler := PodUnavailableBudgetCreateUpdateHandler{ Client: client, @@ -353,7 +353,7 @@ func TestPubConflictWithOthers(t *testing.T) { for _, cs := range cases { t.Run(cs.name, func(t *testing.T) { - decoder, _ := admission.NewDecoder(scheme) + decoder := admission.NewDecoder(scheme) client := fake.NewClientBuilder().WithScheme(scheme).Build() for _, pub := range cs.otherPubs() { client.Create(context.TODO(), pub) @@ -437,7 +437,7 @@ func TestValidatingUpdatePub(t *testing.T) { }, } - decoder, _ := admission.NewDecoder(scheme) + decoder := admission.NewDecoder(scheme) client := fake.NewClientBuilder().WithScheme(scheme).Build() pubHandler := PodUnavailableBudgetCreateUpdateHandler{ Client: client, diff --git a/pkg/webhook/podunavailablebudget/validating/webhooks.go b/pkg/webhook/podunavailablebudget/validating/webhooks.go index 09b1d48103..14ef0a6cca 100644 --- a/pkg/webhook/podunavailablebudget/validating/webhooks.go +++ b/pkg/webhook/podunavailablebudget/validating/webhooks.go @@ -17,14 +17,22 @@ limitations under the License. package validating import ( + "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "github.com/openkruise/kruise/pkg/webhook/types" ) // +kubebuilder:webhook:path=/validate-policy-kruise-io-podunavailablebudget,mutating=false,failurePolicy=fail,sideEffects=None,admissionReviewVersions=v1;v1beta1,groups=policy.kruise.io,resources=podunavailablebudgets,verbs=create;update,versions=v1alpha1,name=vpodunavailablebudget.kb.io var ( - // HandlerMap contains admission webhook handlers - HandlerMap = map[string]admission.Handler{ - "validate-policy-kruise-io-podunavailablebudget": &PodUnavailableBudgetCreateUpdateHandler{}, + // HandlerGetterMap contains admission webhook handlers + HandlerGetterMap = map[string]types.HandlerGetter{ + "validate-policy-kruise-io-podunavailablebudget": func(mgr manager.Manager) admission.Handler { + return &PodUnavailableBudgetCreateUpdateHandler{ + Client: mgr.GetClient(), + Decoder: admission.NewDecoder(mgr.GetScheme()), + } + }, } ) diff --git a/pkg/webhook/resourcedistribution/validating/resourcedistribution_create_update_handler.go b/pkg/webhook/resourcedistribution/validating/resourcedistribution_create_update_handler.go index 74d1394923..49f2f847c7 100755 --- a/pkg/webhook/resourcedistribution/validating/resourcedistribution_create_update_handler.go +++ b/pkg/webhook/resourcedistribution/validating/resourcedistribution_create_update_handler.go @@ -33,7 +33,6 @@ import ( "k8s.io/klog/v2" coreval "k8s.io/kubernetes/pkg/apis/core/validation" "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/runtime/inject" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" ) @@ -162,19 +161,3 @@ func (h *ResourceDistributionCreateUpdateHandler) Handle(ctx context.Context, re } return admission.ValidationResponse(true, "") } - -var _ inject.Client = &ResourceDistributionCreateUpdateHandler{} - -// InjectClient injects the client into the ResourceDistributionCreateUpdateHandler -func (h *ResourceDistributionCreateUpdateHandler) InjectClient(c client.Client) error { - h.Client = c - return nil -} - -var _ admission.DecoderInjector = &ResourceDistributionCreateUpdateHandler{} - -// InjectDecoder injects the decoder into the ResourceDistributionCreateUpdateHandler -func (h *ResourceDistributionCreateUpdateHandler) InjectDecoder(d *admission.Decoder) error { - h.Decoder = d - return nil -} diff --git a/pkg/webhook/resourcedistribution/validating/webhooks.go b/pkg/webhook/resourcedistribution/validating/webhooks.go index a0098365cf..36e85eec60 100755 --- a/pkg/webhook/resourcedistribution/validating/webhooks.go +++ b/pkg/webhook/resourcedistribution/validating/webhooks.go @@ -17,14 +17,22 @@ limitations under the License. package validating import ( + "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "github.com/openkruise/kruise/pkg/webhook/types" ) //+kubebuilder:webhook:path=/validate-apps-kruise-io-v1alpha1-resourcedistribution,mutating=false,failurePolicy=fail,sideEffects=None,admissionReviewVersions=v1;v1beta1,groups=apps.kruise.io,resources=resourcedistributions,verbs=create;update,versions=v1alpha1,name=vresourcedistribution.kb.io var ( - // HandlerMap contains admission webhook handlers - HandlerMap = map[string]admission.Handler{ - "validate-apps-kruise-io-v1alpha1-resourcedistribution": &ResourceDistributionCreateUpdateHandler{}, + // HandlerGetterMap contains admission webhook handlers + HandlerGetterMap = map[string]types.HandlerGetter{ + "validate-apps-kruise-io-v1alpha1-resourcedistribution": func(mgr manager.Manager) admission.Handler { + return &ResourceDistributionCreateUpdateHandler{ + Client: mgr.GetClient(), + Decoder: admission.NewDecoder(mgr.GetScheme()), + } + }, } ) diff --git a/pkg/webhook/server.go b/pkg/webhook/server.go index 01eeb59faf..a0ff5634a4 100644 --- a/pkg/webhook/server.go +++ b/pkg/webhook/server.go @@ -27,27 +27,27 @@ import ( "k8s.io/klog/v2" "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/webhook" - "sigs.k8s.io/controller-runtime/pkg/webhook/admission" "sigs.k8s.io/controller-runtime/pkg/webhook/conversion" - webhookutil "github.com/openkruise/kruise/pkg/webhook/util" + "github.com/openkruise/kruise/pkg/webhook/types" webhookcontroller "github.com/openkruise/kruise/pkg/webhook/util/controller" "github.com/openkruise/kruise/pkg/webhook/util/health" ) type GateFunc func() (enabled bool) +type HandlerPath2GetterMap = map[string]types.HandlerGetter var ( - // HandlerMap contains all admission webhook handlers. - HandlerMap = map[string]admission.Handler{} + // HandlerGetterMap contains all admission webhook handlers. + HandlerMap = HandlerPath2GetterMap{} handlerGates = map[string]GateFunc{} ) -func addHandlers(m map[string]admission.Handler) { +func addHandlers(m HandlerPath2GetterMap) { addHandlersWithGate(m, nil) } -func addHandlersWithGate(m map[string]admission.Handler, fn GateFunc) { +func addHandlersWithGate(m HandlerPath2GetterMap, fn GateFunc) { for path, handler := range m { if len(path) == 0 { klog.Warningf("Skip handler with empty path.") @@ -83,19 +83,16 @@ func filterActiveHandlers() { func SetupWithManager(mgr manager.Manager) error { server := mgr.GetWebhookServer() - server.Host = "0.0.0.0" - server.Port = webhookutil.GetPort() - server.CertDir = webhookutil.GetCertDir() // register admission handlers filterActiveHandlers() - for path, handler := range HandlerMap { - server.Register(path, &webhook.Admission{Handler: handler}) + for path, handlerGetter := range HandlerMap { + server.Register(path, &webhook.Admission{Handler: handlerGetter(mgr)}) klog.V(3).Infof("Registered webhook handler %s", path) } // register conversion webhook - server.Register("/convert", &conversion.Webhook{}) + server.Register("/convert", conversion.NewWebhookHandler(mgr.GetScheme())) // register health handler server.Register("/healthz", &health.Handler{}) diff --git a/pkg/webhook/service/validating/service_handler.go b/pkg/webhook/service/validating/service_handler.go index 6b073f4d96..0c00899a0c 100644 --- a/pkg/webhook/service/validating/service_handler.go +++ b/pkg/webhook/service/validating/service_handler.go @@ -20,13 +20,13 @@ import ( "context" "net/http" - "github.com/openkruise/kruise/pkg/webhook/util/deletionprotection" admissionv1 "k8s.io/api/admission/v1" v1 "k8s.io/api/core/v1" "k8s.io/klog/v2" "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/runtime/inject" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "github.com/openkruise/kruise/pkg/webhook/util/deletionprotection" ) type ServiceHandler struct { @@ -58,17 +58,3 @@ func (h *ServiceHandler) Handle(ctx context.Context, req admission.Request) admi } return admission.ValidationResponse(true, "") } - -var _ inject.Client = &ServiceHandler{} - -func (h *ServiceHandler) InjectClient(c client.Client) error { - h.Client = c - return nil -} - -var _ admission.DecoderInjector = &ServiceHandler{} - -func (h *ServiceHandler) InjectDecoder(d *admission.Decoder) error { - h.Decoder = d - return nil -} diff --git a/pkg/webhook/service/validating/webhooks.go b/pkg/webhook/service/validating/webhooks.go index 9461ffd773..aff9c2ada5 100644 --- a/pkg/webhook/service/validating/webhooks.go +++ b/pkg/webhook/service/validating/webhooks.go @@ -16,13 +16,23 @@ limitations under the License. package validating -import "sigs.k8s.io/controller-runtime/pkg/webhook/admission" +import ( + "sigs.k8s.io/controller-runtime/pkg/manager" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "github.com/openkruise/kruise/pkg/webhook/types" +) // +kubebuilder:webhook:path=/validate-service,mutating=false,failurePolicy=fail,sideEffects=None,admissionReviewVersions=v1;v1beta1,groups="",resources=services,verbs=delete,versions=v1,name=vservice.kb.io var ( - // HandlerMap contains admission webhook handlers - HandlerMap = map[string]admission.Handler{ - "validate-service": &ServiceHandler{}, + // HandlerGetterMap contains admission webhook handlers + HandlerGetterMap = map[string]types.HandlerGetter{ + "validate-service": func(mgr manager.Manager) admission.Handler { + return &ServiceHandler{ + Client: mgr.GetClient(), + Decoder: admission.NewDecoder(mgr.GetScheme()), + } + }, } ) diff --git a/pkg/webhook/sidecarset/mutating/sidecarset_create_update_handler.go b/pkg/webhook/sidecarset/mutating/sidecarset_create_update_handler.go index 8f2ef3ccb0..45e5c364a0 100644 --- a/pkg/webhook/sidecarset/mutating/sidecarset_create_update_handler.go +++ b/pkg/webhook/sidecarset/mutating/sidecarset_create_update_handler.go @@ -22,14 +22,15 @@ import ( "net/http" "reflect" - "github.com/openkruise/kruise/apis/apps/defaults" - appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" - "github.com/openkruise/kruise/pkg/control/sidecarcontrol" - "github.com/openkruise/kruise/pkg/util" admissionv1 "k8s.io/api/admission/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/klog/v2" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "github.com/openkruise/kruise/apis/apps/defaults" + appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" + "github.com/openkruise/kruise/pkg/control/sidecarcontrol" + "github.com/openkruise/kruise/pkg/util" ) // SidecarSetCreateHandler handles SidecarSet @@ -100,11 +101,3 @@ func (h *SidecarSetCreateHandler) Handle(ctx context.Context, req admission.Requ // h.Client = c // return nil //} - -var _ admission.DecoderInjector = &SidecarSetCreateHandler{} - -// InjectDecoder injects the decoder into the SidecarSetCreateHandler -func (h *SidecarSetCreateHandler) InjectDecoder(d *admission.Decoder) error { - h.Decoder = d - return nil -} diff --git a/pkg/webhook/sidecarset/mutating/webhooks.go b/pkg/webhook/sidecarset/mutating/webhooks.go index 2ea47f6763..ba951b6d61 100644 --- a/pkg/webhook/sidecarset/mutating/webhooks.go +++ b/pkg/webhook/sidecarset/mutating/webhooks.go @@ -17,14 +17,19 @@ limitations under the License. package mutating import ( + "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "github.com/openkruise/kruise/pkg/webhook/types" ) // +kubebuilder:webhook:path=/mutate-apps-kruise-io-v1alpha1-sidecarset,mutating=true,failurePolicy=fail,sideEffects=None,admissionReviewVersions=v1;v1beta1,groups=apps.kruise.io,resources=sidecarsets,verbs=create;update,versions=v1alpha1,name=msidecarset.kb.io var ( - // HandlerMap contains admission webhook handlers - HandlerMap = map[string]admission.Handler{ - "mutate-apps-kruise-io-v1alpha1-sidecarset": &SidecarSetCreateHandler{}, + // HandlerGetterMap contains admission webhook handlers + HandlerGetterMap = map[string]types.HandlerGetter{ + "mutate-apps-kruise-io-v1alpha1-sidecarset": func(mgr manager.Manager) admission.Handler { + return &SidecarSetCreateHandler{Decoder: admission.NewDecoder(mgr.GetScheme())} + }, } ) diff --git a/pkg/webhook/sidecarset/validating/sidecarset_create_update_handler.go b/pkg/webhook/sidecarset/validating/sidecarset_create_update_handler.go index 747f8ee976..8b8c2d93c3 100644 --- a/pkg/webhook/sidecarset/validating/sidecarset_create_update_handler.go +++ b/pkg/webhook/sidecarset/validating/sidecarset_create_update_handler.go @@ -43,7 +43,6 @@ import ( corevalidation "k8s.io/kubernetes/pkg/apis/core/validation" "k8s.io/kubernetes/pkg/fieldpath" "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/runtime/inject" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" ) @@ -492,19 +491,3 @@ func (h *SidecarSetCreateUpdateHandler) Handle(ctx context.Context, req admissio } return admission.ValidationResponse(allowed, reason) } - -var _ inject.Client = &SidecarSetCreateUpdateHandler{} - -// InjectClient injects the client into the SidecarSetCreateUpdateHandler -func (h *SidecarSetCreateUpdateHandler) InjectClient(c client.Client) error { - h.Client = c - return nil -} - -var _ admission.DecoderInjector = &SidecarSetCreateUpdateHandler{} - -// InjectDecoder injects the decoder into the SidecarSetCreateUpdateHandler -func (h *SidecarSetCreateUpdateHandler) InjectDecoder(d *admission.Decoder) error { - h.Decoder = d - return nil -} diff --git a/pkg/webhook/sidecarset/validating/webhooks.go b/pkg/webhook/sidecarset/validating/webhooks.go index c029adad6b..4dcd592bef 100644 --- a/pkg/webhook/sidecarset/validating/webhooks.go +++ b/pkg/webhook/sidecarset/validating/webhooks.go @@ -17,14 +17,22 @@ limitations under the License. package validating import ( + "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "github.com/openkruise/kruise/pkg/webhook/types" ) // +kubebuilder:webhook:path=/validate-apps-kruise-io-v1alpha1-sidecarset,mutating=false,failurePolicy=fail,sideEffects=None,admissionReviewVersions=v1;v1beta1,groups=apps.kruise.io,resources=sidecarsets,verbs=create;update,versions=v1alpha1,name=vsidecarset.kb.io var ( - // HandlerMap contains admission webhook handlers - HandlerMap = map[string]admission.Handler{ - "validate-apps-kruise-io-v1alpha1-sidecarset": &SidecarSetCreateUpdateHandler{}, + // HandlerGetterMap contains admission webhook handlers + HandlerGetterMap = map[string]types.HandlerGetter{ + "validate-apps-kruise-io-v1alpha1-sidecarset": func(mgr manager.Manager) admission.Handler { + return &SidecarSetCreateUpdateHandler{ + Client: mgr.GetClient(), + Decoder: admission.NewDecoder(mgr.GetScheme()), + } + }, } ) diff --git a/pkg/webhook/statefulset/mutating/statefulset_create_update_handler.go b/pkg/webhook/statefulset/mutating/statefulset_create_update_handler.go index 90aa7c29a3..d597ccae0a 100644 --- a/pkg/webhook/statefulset/mutating/statefulset_create_update_handler.go +++ b/pkg/webhook/statefulset/mutating/statefulset_create_update_handler.go @@ -23,16 +23,17 @@ import ( "net/http" "reflect" + admissionv1 "k8s.io/api/admission/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/klog/v2" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + "github.com/openkruise/kruise/apis/apps/defaults" appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" appsv1beta1 "github.com/openkruise/kruise/apis/apps/v1beta1" "github.com/openkruise/kruise/pkg/features" "github.com/openkruise/kruise/pkg/util" utilfeature "github.com/openkruise/kruise/pkg/util/feature" - admissionv1 "k8s.io/api/admission/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/klog/v2" - "sigs.k8s.io/controller-runtime/pkg/webhook/admission" ) // StatefulSetCreateUpdateHandler handles StatefulSet @@ -132,11 +133,3 @@ func (h *StatefulSetCreateUpdateHandler) Handle(ctx context.Context, req admissi // h.Client = c // return nil //} - -var _ admission.DecoderInjector = &StatefulSetCreateUpdateHandler{} - -// InjectDecoder injects the decoder into the StatefulSetCreateUpdateHandler -func (h *StatefulSetCreateUpdateHandler) InjectDecoder(d *admission.Decoder) error { - h.Decoder = d - return nil -} diff --git a/pkg/webhook/statefulset/mutating/webhooks.go b/pkg/webhook/statefulset/mutating/webhooks.go index a5d90a58cb..c9124172fd 100644 --- a/pkg/webhook/statefulset/mutating/webhooks.go +++ b/pkg/webhook/statefulset/mutating/webhooks.go @@ -17,14 +17,19 @@ limitations under the License. package mutating import ( + "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "github.com/openkruise/kruise/pkg/webhook/types" ) // +kubebuilder:webhook:path=/mutate-apps-kruise-io-statefulset,mutating=true,failurePolicy=fail,sideEffects=None,admissionReviewVersions=v1;v1beta1,groups=apps.kruise.io,resources=statefulsets,verbs=create;update,versions=v1alpha1;v1beta1,name=mstatefulset.kb.io var ( - // HandlerMap contains admission webhook handlers - HandlerMap = map[string]admission.Handler{ - "mutate-apps-kruise-io-statefulset": &StatefulSetCreateUpdateHandler{}, + // HandlerGetterMap contains admission webhook handlers + HandlerGetterMap = map[string]types.HandlerGetter{ + "mutate-apps-kruise-io-statefulset": func(mgr manager.Manager) admission.Handler { + return &StatefulSetCreateUpdateHandler{Decoder: admission.NewDecoder(mgr.GetScheme())} + }, } ) diff --git a/pkg/webhook/statefulset/validating/statefulset_create_update_handler.go b/pkg/webhook/statefulset/validating/statefulset_create_update_handler.go index a46e2e87f7..d55c21fd6d 100644 --- a/pkg/webhook/statefulset/validating/statefulset_create_update_handler.go +++ b/pkg/webhook/statefulset/validating/statefulset_create_update_handler.go @@ -21,13 +21,14 @@ import ( "fmt" "net/http" + admissionv1 "k8s.io/api/admission/v1" + "k8s.io/klog/v2" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" appsv1beta1 "github.com/openkruise/kruise/apis/apps/v1beta1" "github.com/openkruise/kruise/pkg/util" "github.com/openkruise/kruise/pkg/webhook/util/deletionprotection" - admissionv1 "k8s.io/api/admission/v1" - "k8s.io/klog/v2" - "sigs.k8s.io/controller-runtime/pkg/webhook/admission" ) // StatefulSetCreateUpdateHandler handles StatefulSet @@ -139,11 +140,3 @@ func (h *StatefulSetCreateUpdateHandler) decodeOldObject(req admission.Request, // h.Client = c // return nil //} - -var _ admission.DecoderInjector = &StatefulSetCreateUpdateHandler{} - -// InjectDecoder injects the decoder into the StatefulSetCreateUpdateHandler -func (h *StatefulSetCreateUpdateHandler) InjectDecoder(d *admission.Decoder) error { - h.Decoder = d - return nil -} diff --git a/pkg/webhook/statefulset/validating/webhooks.go b/pkg/webhook/statefulset/validating/webhooks.go index 3061f1245d..4a8372c872 100644 --- a/pkg/webhook/statefulset/validating/webhooks.go +++ b/pkg/webhook/statefulset/validating/webhooks.go @@ -17,14 +17,19 @@ limitations under the License. package validating import ( + "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "github.com/openkruise/kruise/pkg/webhook/types" ) // +kubebuilder:webhook:path=/validate-apps-kruise-io-statefulset,mutating=false,failurePolicy=fail,sideEffects=None,admissionReviewVersions=v1;v1beta1,groups=apps.kruise.io,resources=statefulsets,verbs=create;update;delete,versions=v1alpha1;v1beta1,name=vstatefulset.kb.io var ( - // HandlerMap contains admission webhook handlers - HandlerMap = map[string]admission.Handler{ - "validate-apps-kruise-io-statefulset": &StatefulSetCreateUpdateHandler{}, + // HandlerGetterMap contains admission webhook handlers + HandlerGetterMap = map[string]types.HandlerGetter{ + "validate-apps-kruise-io-statefulset": func(mgr manager.Manager) admission.Handler { + return &StatefulSetCreateUpdateHandler{Decoder: admission.NewDecoder(mgr.GetScheme())} + }, } ) diff --git a/pkg/webhook/types/types.go b/pkg/webhook/types/types.go new file mode 100644 index 0000000000..75de7e9e94 --- /dev/null +++ b/pkg/webhook/types/types.go @@ -0,0 +1,8 @@ +package types + +import ( + "sigs.k8s.io/controller-runtime/pkg/manager" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" +) + +type HandlerGetter = func(manager.Manager) admission.Handler diff --git a/pkg/webhook/uniteddeployment/mutating/uniteddeployment_create_update_handler.go b/pkg/webhook/uniteddeployment/mutating/uniteddeployment_create_update_handler.go index 8a7d3812c5..dd6857ffae 100644 --- a/pkg/webhook/uniteddeployment/mutating/uniteddeployment_create_update_handler.go +++ b/pkg/webhook/uniteddeployment/mutating/uniteddeployment_create_update_handler.go @@ -22,15 +22,16 @@ import ( "net/http" "reflect" + admissionv1 "k8s.io/api/admission/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/klog/v2" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + "github.com/openkruise/kruise/apis/apps/defaults" appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" "github.com/openkruise/kruise/pkg/features" "github.com/openkruise/kruise/pkg/util" utilfeature "github.com/openkruise/kruise/pkg/util/feature" - admissionv1 "k8s.io/api/admission/v1" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/klog/v2" - "sigs.k8s.io/controller-runtime/pkg/webhook/admission" ) // UnitedDeploymentCreateUpdateHandler handles UnitedDeployment @@ -86,11 +87,3 @@ func (h *UnitedDeploymentCreateUpdateHandler) Handle(ctx context.Context, req ad } return resp } - -var _ admission.DecoderInjector = &UnitedDeploymentCreateUpdateHandler{} - -// InjectDecoder injects the decoder into the UnitedDeploymentCreateUpdateHandler -func (h *UnitedDeploymentCreateUpdateHandler) InjectDecoder(d *admission.Decoder) error { - h.Decoder = d - return nil -} diff --git a/pkg/webhook/uniteddeployment/mutating/webhooks.go b/pkg/webhook/uniteddeployment/mutating/webhooks.go index b6fcc4e586..5f9e28787c 100644 --- a/pkg/webhook/uniteddeployment/mutating/webhooks.go +++ b/pkg/webhook/uniteddeployment/mutating/webhooks.go @@ -17,14 +17,19 @@ limitations under the License. package mutating import ( + "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "github.com/openkruise/kruise/pkg/webhook/types" ) // +kubebuilder:webhook:path=/mutate-apps-kruise-io-v1alpha1-uniteddeployment,mutating=true,failurePolicy=fail,sideEffects=None,admissionReviewVersions=v1;v1beta1,groups=apps.kruise.io,resources=uniteddeployments,verbs=create;update,versions=v1alpha1,name=muniteddeployment.kb.io var ( - // HandlerMap contains admission webhook handlers - HandlerMap = map[string]admission.Handler{ - "mutate-apps-kruise-io-v1alpha1-uniteddeployment": &UnitedDeploymentCreateUpdateHandler{}, + // HandlerGetterMap contains admission webhook handlers + HandlerGetterMap = map[string]types.HandlerGetter{ + "mutate-apps-kruise-io-v1alpha1-uniteddeployment": func(mgr manager.Manager) admission.Handler { + return &UnitedDeploymentCreateUpdateHandler{Decoder: admission.NewDecoder(mgr.GetScheme())} + }, } ) diff --git a/pkg/webhook/uniteddeployment/validating/uniteddeployment_create_update_handler.go b/pkg/webhook/uniteddeployment/validating/uniteddeployment_create_update_handler.go index 4ff427d344..0049c078ea 100644 --- a/pkg/webhook/uniteddeployment/validating/uniteddeployment_create_update_handler.go +++ b/pkg/webhook/uniteddeployment/validating/uniteddeployment_create_update_handler.go @@ -21,12 +21,13 @@ import ( "fmt" "net/http" - appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" - "github.com/openkruise/kruise/pkg/util" - "github.com/openkruise/kruise/pkg/webhook/util/deletionprotection" admissionv1 "k8s.io/api/admission/v1" "k8s.io/klog/v2" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" + "github.com/openkruise/kruise/pkg/util" + "github.com/openkruise/kruise/pkg/webhook/util/deletionprotection" ) // UnitedDeploymentCreateUpdateHandler handles UnitedDeployment @@ -86,11 +87,3 @@ func (h *UnitedDeploymentCreateUpdateHandler) Handle(ctx context.Context, req ad return admission.ValidationResponse(true, "") } - -var _ admission.DecoderInjector = &UnitedDeploymentCreateUpdateHandler{} - -// InjectDecoder injects the decoder into the UnitedDeploymentCreateUpdateHandler -func (h *UnitedDeploymentCreateUpdateHandler) InjectDecoder(d *admission.Decoder) error { - h.Decoder = d - return nil -} diff --git a/pkg/webhook/uniteddeployment/validating/uniteddeployment_validation.go b/pkg/webhook/uniteddeployment/validating/uniteddeployment_validation.go index f50e3a39a9..33b84c05cc 100644 --- a/pkg/webhook/uniteddeployment/validating/uniteddeployment_validation.go +++ b/pkg/webhook/uniteddeployment/validating/uniteddeployment_validation.go @@ -339,7 +339,7 @@ func validateSubsetTemplate(template *appsv1alpha1.SubsetTemplate, selector labe allErrs = append(allErrs, field.Invalid(fldPath.Root(), template, fmt.Sprintf("Convert_v1_PodTemplateSpec_To_core_PodTemplateSpec failed: %v", err))) return allErrs } - allErrs = append(allErrs, appsvalidation.ValidatePodTemplateSpecForReplicaSet(coreTemplate, selector, 0, fldPath.Child("deploymentTemplate", "spec", "template"), webhookutil.DefaultPodValidationOptions)...) + allErrs = append(allErrs, appsvalidation.ValidatePodTemplateSpecForReplicaSet(coreTemplate, nil, selector, 0, fldPath.Child("deploymentTemplate", "spec", "template"), webhookutil.DefaultPodValidationOptions)...) } return allErrs diff --git a/pkg/webhook/uniteddeployment/validating/webhooks.go b/pkg/webhook/uniteddeployment/validating/webhooks.go index 2aba9e5140..0ff252ffc7 100644 --- a/pkg/webhook/uniteddeployment/validating/webhooks.go +++ b/pkg/webhook/uniteddeployment/validating/webhooks.go @@ -17,14 +17,19 @@ limitations under the License. package validating import ( + "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "github.com/openkruise/kruise/pkg/webhook/types" ) // +kubebuilder:webhook:path=/validate-apps-kruise-io-v1alpha1-uniteddeployment,mutating=false,failurePolicy=fail,sideEffects=None,admissionReviewVersions=v1;v1beta1,groups=apps.kruise.io,resources=uniteddeployments,verbs=create;update;delete,versions=v1alpha1,name=vuniteddeployment.kb.io var ( - // HandlerMap contains admission webhook handlers - HandlerMap = map[string]admission.Handler{ - "validate-apps-kruise-io-v1alpha1-uniteddeployment": &UnitedDeploymentCreateUpdateHandler{}, + // HandlerGetterMap contains admission webhook handlers + HandlerGetterMap = map[string]types.HandlerGetter{ + "validate-apps-kruise-io-v1alpha1-uniteddeployment": func(mgr manager.Manager) admission.Handler { + return &UnitedDeploymentCreateUpdateHandler{Decoder: admission.NewDecoder(mgr.GetScheme())} + }, } ) diff --git a/pkg/webhook/util/configuration/configuration.go b/pkg/webhook/util/configuration/configuration.go index 58209fc1f7..e4aea3f1cc 100644 --- a/pkg/webhook/util/configuration/configuration.go +++ b/pkg/webhook/util/configuration/configuration.go @@ -27,8 +27,8 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" clientset "k8s.io/client-go/kubernetes" "k8s.io/klog/v2" - "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + "github.com/openkruise/kruise/pkg/webhook/types" webhookutil "github.com/openkruise/kruise/pkg/webhook/util" ) @@ -37,7 +37,7 @@ const ( validatingWebhookConfigurationName = "kruise-validating-webhook-configuration" ) -func Ensure(kubeClient clientset.Interface, handlers map[string]admission.Handler, caBundle []byte) error { +func Ensure(kubeClient clientset.Interface, handlers map[string]types.HandlerGetter, caBundle []byte) error { mutatingConfig, err := kubeClient.AdmissionregistrationV1().MutatingWebhookConfigurations().Get(context.TODO(), mutatingWebhookConfigurationName, metav1.GetOptions{}) if err != nil { return fmt.Errorf("not found MutatingWebhookConfiguration %s", mutatingWebhookConfigurationName) diff --git a/pkg/webhook/util/controller/webhook_controller.go b/pkg/webhook/util/controller/webhook_controller.go index 882844e5dd..196b6943ee 100644 --- a/pkg/webhook/util/controller/webhook_controller.go +++ b/pkg/webhook/util/controller/webhook_controller.go @@ -39,9 +39,9 @@ import ( "k8s.io/client-go/tools/cache" "k8s.io/client-go/util/workqueue" "k8s.io/klog/v2" - "sigs.k8s.io/controller-runtime/pkg/webhook/admission" extclient "github.com/openkruise/kruise/pkg/client" + webhooktypes "github.com/openkruise/kruise/pkg/webhook/types" webhookutil "github.com/openkruise/kruise/pkg/webhook/util" "github.com/openkruise/kruise/pkg/webhook/util/configuration" "github.com/openkruise/kruise/pkg/webhook/util/crd" @@ -70,7 +70,7 @@ func Inited() chan struct{} { type Controller struct { kubeClient clientset.Interface - handlers map[string]admission.Handler + handlers map[string]webhooktypes.HandlerGetter informerFactory informers.SharedInformerFactory crdClient apiextensionsclientset.Interface @@ -81,7 +81,7 @@ type Controller struct { queue workqueue.RateLimitingInterface } -func New(cfg *rest.Config, handlers map[string]admission.Handler) (*Controller, error) { +func New(cfg *rest.Config, handlers map[string]webhooktypes.HandlerGetter) (*Controller, error) { c := &Controller{ kubeClient: extclient.GetGenericClientWithName("webhook-controller").KubeClient, handlers: handlers, diff --git a/pkg/webhook/util/pod_validation.go b/pkg/webhook/util/pod_validation.go index d038807d51..c1f4c0839d 100644 --- a/pkg/webhook/util/pod_validation.go +++ b/pkg/webhook/util/pod_validation.go @@ -20,9 +20,13 @@ import corevalidation "k8s.io/kubernetes/pkg/apis/core/validation" var ( DefaultPodValidationOptions = corevalidation.PodValidationOptions{ - AllowDownwardAPIHugePages: true, AllowInvalidPodDeletionCost: true, - AllowExpandedDNSConfig: true, AllowIndivisibleHugePagesValues: true, + + AllowInvalidLabelValueInSelector: true, + AllowHostIPsField: true, + AllowInvalidTopologySpreadConstraintLabelSelector: true, + AllowMutableNodeSelectorAndNodeAffinity: true, + ResourceIsPod: true, } ) diff --git a/pkg/webhook/workloadspread/validating/webhook.go b/pkg/webhook/workloadspread/validating/webhook.go index 6edf27e767..e927776d56 100644 --- a/pkg/webhook/workloadspread/validating/webhook.go +++ b/pkg/webhook/workloadspread/validating/webhook.go @@ -17,14 +17,22 @@ limitations under the License. package validating import ( + "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" + + "github.com/openkruise/kruise/pkg/webhook/types" ) // +kubebuilder:webhook:path=/validate-apps-kruise-io-v1alpha1-workloadspread,mutating=false,failurePolicy=fail,sideEffects=None,admissionReviewVersions=v1;v1beta1,groups=apps.kruise.io,resources=workloadspreads,verbs=create;update,versions=v1alpha1,name=vworkloadspread.kb.io var ( - // HandlerMap contains admission webhook handlers - HandlerMap = map[string]admission.Handler{ - "validate-apps-kruise-io-v1alpha1-workloadspread": &WorkloadSpreadCreateUpdateHandler{}, + // HandlerGetterMap contains admission webhook handlers + HandlerGetterMap = map[string]types.HandlerGetter{ + "validate-apps-kruise-io-v1alpha1-workloadspread": func(mgr manager.Manager) admission.Handler { + return &WorkloadSpreadCreateUpdateHandler{ + Client: mgr.GetClient(), + Decoder: admission.NewDecoder(mgr.GetScheme()), + } + }, } ) diff --git a/pkg/webhook/workloadspread/validating/workloadspread_create_update_handler.go b/pkg/webhook/workloadspread/validating/workloadspread_create_update_handler.go index b385c6c202..08e53769f0 100644 --- a/pkg/webhook/workloadspread/validating/workloadspread_create_update_handler.go +++ b/pkg/webhook/workloadspread/validating/workloadspread_create_update_handler.go @@ -23,7 +23,6 @@ import ( admissionv1 "k8s.io/api/admission/v1" "sigs.k8s.io/controller-runtime/pkg/client" - "sigs.k8s.io/controller-runtime/pkg/runtime/inject" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" @@ -77,19 +76,3 @@ func (h *WorkloadSpreadCreateUpdateHandler) Handle(ctx context.Context, req admi return admission.ValidationResponse(true, "") } - -var _ inject.Client = &WorkloadSpreadCreateUpdateHandler{} - -// InjectClient injects the client into the WorkloadSpreadCreateUpdateHandler -func (h *WorkloadSpreadCreateUpdateHandler) InjectClient(c client.Client) error { - h.Client = c - return nil -} - -var _ admission.DecoderInjector = &WorkloadSpreadCreateUpdateHandler{} - -// InjectDecoder injects the decoder into the WorkloadSpreadCreateUpdateHandler -func (h *WorkloadSpreadCreateUpdateHandler) InjectDecoder(d *admission.Decoder) error { - h.Decoder = d - return nil -} diff --git a/scripts/generate_client.sh b/scripts/generate_client.sh index da0e441ee8..13ede850b5 100755 --- a/scripts/generate_client.sh +++ b/scripts/generate_client.sh @@ -9,13 +9,16 @@ fi set -e TMP_DIR=$(mktemp -d) mkdir -p "${TMP_DIR}"/src/github.com/openkruise/kruise/pkg/client -cp -r ./{apis,hack,vendor,go.mod} "${TMP_DIR}"/src/github.com/openkruise/kruise/ +cp -r ./{apis,hack,vendor,go.mod,.git} "${TMP_DIR}"/src/github.com/openkruise/kruise/ + +chmod +x "${TMP_DIR}"/src/github.com/openkruise/kruise/vendor/k8s.io/code-generator/generate-internal-groups.sh +echo "tmp_dir: ${TMP_DIR}" (cd "${TMP_DIR}"/src/github.com/openkruise/kruise; \ - GOPATH=${TMP_DIR} GO111MODULE=off /bin/bash vendor/k8s.io/code-generator/generate-groups.sh all \ + GOPATH=${TMP_DIR} GO111MODULE=off /bin/bash vendor/k8s.io/code-generator/generate-groups.sh client,deepcopy,informer,lister \ github.com/openkruise/kruise/pkg/client github.com/openkruise/kruise/apis "apps:v1alpha1 apps:v1beta1 policy:v1alpha1" -h ./hack/boilerplate.go.txt) rm -rf ./pkg/client/{clientset,informers,listers} mv "${TMP_DIR}"/src/github.com/openkruise/kruise/pkg/client/* ./pkg/client -rm -rf vendor +rm -rf vendor diff --git a/test/e2e/apps/sidecarterminator.go b/test/e2e/apps/sidecarterminator.go index 2730f3e961..0714a4c076 100644 --- a/test/e2e/apps/sidecarterminator.go +++ b/test/e2e/apps/sidecarterminator.go @@ -34,7 +34,7 @@ var _ = SIGDescribe("SidecarTerminator", func() { }) framework.KruiseDescribe("SidecarTerminator checker", func() { - ginkgo.It("use kruise-daemon to kill containers", func() { + ginkgo.It("job and broadcast job with sidecar", func() { mainContainer := v1.Container{ Name: "main", Image: "busybox:latest", diff --git a/test/kind-conf-none-fg.yaml b/test/kind-conf-none-fg.yaml new file mode 100644 index 0000000000..25d972d418 --- /dev/null +++ b/test/kind-conf-none-fg.yaml @@ -0,0 +1,7 @@ +kind: Cluster +apiVersion: kind.x-k8s.io/v1alpha4 +nodes: + - role: control-plane + - role: worker + - role: worker + - role: worker \ No newline at end of file diff --git a/tools/hack/create-cluster.sh b/tools/hack/create-cluster.sh index 5f16afe5b6..fc5f9c9e1f 100755 --- a/tools/hack/create-cluster.sh +++ b/tools/hack/create-cluster.sh @@ -17,10 +17,10 @@ set -euo pipefail # Setup default values CLUSTER_NAME=${CLUSTER_NAME:-"ci-testing"} -KIND_NODE_TAG=${KIND_NODE_TAG:-"v1.24.2"} +KIND_NODE_TAG=${KIND_NODE_TAG:-"v1.28.7"} echo "$KIND_NODE_TAG" echo "$CLUSTER_NAME" ## Create kind cluster. -tools/bin/kind create cluster --image "kindest/node:${KIND_NODE_TAG}" --name "${CLUSTER_NAME}" --config=test/kind-conf.yaml +tools/bin/kind create cluster --image "kindest/node:${KIND_NODE_TAG}" --name "${CLUSTER_NAME}" --config=test/kind-conf-none-fg.yaml