From e41f38a7d8d49ee1a625011c113fcc0a7bda78e5 Mon Sep 17 00:00:00 2001
From: Yue Yang <g1enyy0ung@gmail.com>
Date: Sat, 25 Nov 2023 14:30:24 +0800
Subject: [PATCH 1/3] fix(test): docker command not found (#4258)

Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>
---
 Makefile              | 26 +++++++++++++++-----------
 hack/env-image-tag.sh |  8 ++++----
 2 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/Makefile b/Makefile
index 15138b2dc14..ea4c8d14040 100644
--- a/Makefile
+++ b/Makefile
@@ -50,7 +50,7 @@ endif
 
 endif
 
-BASIC_IMAGE_ENV= IMAGE_DEV_ENV_TAG=$(IMAGE_DEV_ENV_TAG) \
+BASIC_IMAGE_ENV=IMAGE_DEV_ENV_TAG=$(IMAGE_DEV_ENV_TAG) \
 	IMAGE_BUILD_ENV_TAG=$(IMAGE_BUILD_ENV_TAG) \
 	IMAGE_TAG=$(IMAGE_TAG) TARGET_PLATFORM=$(TARGET_PLATFORM) \
 	GO_BUILD_CACHE=$(GO_BUILD_CACHE)
@@ -214,12 +214,24 @@ PAUSE_IMAGE ?= gcr.io/google-containers/pause:latest
 e2e: e2e-build ## Run e2e tests in current kubernetes cluster
 	./e2e-test/image/e2e/bin/ginkgo ${GINKGO_FLAGS} ./e2e-test/image/e2e/bin/e2e.test -- --e2e-image ghcr.io/chaos-mesh/e2e-helper:${IMAGE_TAG} --pause-image ${PAUSE_IMAGE}
 
+define failpoint-ctl
+	find $(ROOT)/* -type d | grep -vE "(\.git|bin|\.cache|ui)" | xargs failpoint-ctl $1
+endef
+
+failpoint-enable: SHELL:=$(RUN_IN_DEV_SHELL)
+failpoint-enable: images/dev-env/.dockerbuilt ## Enable failpoint stub for testing
+	$(call failpoint-ctl,enable)
+
+failpoint-disable: SHELL:=$(RUN_IN_DEV_SHELL)
+failpoint-disable: images/dev-env/.dockerbuilt ## Disable failpoint stub for testing
+	$(call failpoint-ctl,disable)
+
 test: SHELL:=$(RUN_IN_DEV_SHELL)
 test: generate manifests test-utils images/dev-env/.dockerbuilt ## Run unit tests
-	make failpoint-enable
+	$(call failpoint-ctl,enable)
 	CGO_ENABLED=1 $(GOTEST) -p 1 $$($(PACKAGE_LIST)) -coverprofile cover.out.tmp -covermode=atomic
 	cat cover.out.tmp | grep -v "_generated.deepcopy.go" > cover.out
-	make failpoint-disable
+	$(call failpoint-ctl,disable)
 
 ##@ Advanced building targets
 
@@ -303,14 +315,6 @@ bin/chaos-builder: SHELL:=$(RUN_IN_DEV_SHELL)
 bin/chaos-builder: images/dev-env/.dockerbuilt
 	$(CGOENV) go build -ldflags '$(LDFLAGS)' -buildvcs=false -o bin/chaos-builder ./cmd/chaos-builder/...
 
-failpoint-enable: SHELL:=$(RUN_IN_DEV_SHELL)
-failpoint-enable: images/dev-env/.dockerbuilt ## Enable failpoint stub for testing
-	find $(ROOT)/* -type d | grep -vE "(\.git|bin|\.cache|ui)" | xargs failpoint-ctl enable
-
-failpoint-disable: SHELL:=$(RUN_IN_DEV_SHELL)
-failpoint-disable: images/dev-env/.dockerbuilt ## Disable failpoint stub for testing
-	find $(ROOT)/* -type d | grep -vE "(\.git|bin|\.cache|ui)" | xargs failpoint-ctl disable
-
 .PHONY: all image clean test manifests manifests/crd.yaml \
 	boilerplate tidy groupimports fmt vet lint install.sh schedule-migration \
 	config proto \
diff --git a/hack/env-image-tag.sh b/hack/env-image-tag.sh
index 87eaffe96e5..748e44898cd 100755
--- a/hack/env-image-tag.sh
+++ b/hack/env-image-tag.sh
@@ -14,7 +14,7 @@
 # limitations under the License.
 #
 
-# This script would report the tag of build-env and dev-env to use based on configuartion file env-images.yaml.
+# This script would report the tag of build-env and dev-env to use based on configuration file env-images.yaml.
 #
 # Usage:
 # On master branch:
@@ -29,9 +29,9 @@ set -euo pipefail
 DIR="$( cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd )"
 PROJECT_DIR="$(dirname "$DIR")"
 
-if [ "$#" -eq  "0" ]; then
-  echo "Usage: $0 <env-image-name>"
-  exit 1
+if [[ "$#" == "0" ]]; then
+  echo "Usage: $0 <env-image-name: dev-env|build-env>"
+  exit 0
 fi
 
 if [[ "$1" == "dev-env" || "$1" == "build-env"  ]]; then

From 6126b2bea8f570e43179ff8188bd59b55b96c162 Mon Sep 17 00:00:00 2001
From: Ruihang Xia <waynestxia@gmail.com>
Date: Tue, 28 Nov 2023 22:00:00 +0800
Subject: [PATCH 2/3] docs: add greptimedb's adopter story (#4267)

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
---
 ADOPTERS.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ADOPTERS.md b/ADOPTERS.md
index 6ce97bae23f..2897a9d8376 100644
--- a/ADOPTERS.md
+++ b/ADOPTERS.md
@@ -14,7 +14,7 @@ If you are an adopter and are willing to share your Chaos Mesh story, feel free
 | [DataStax](https://www.datastax.com/)                  |DataStax utilized Chaos Mesh to create a tool for running local or large scale remote based distributed correctness, verification and performance tests: [Fallout](https://github.com/datastax/fallout), which they use to test AstraDB, a multi-cloud DBaaS built on Apache Cassandra.            | [Leveraging Chaos Mesh in AstraDB Testing](https://youtu.be/Kw7gMurHJnQ)       |
 | [DigitalChina](http://www.digitalchina.com/en/)                  |To better serve their strategy to transform to cloud infrastructure, DigitalChina uses Chaos Mesh to test the application's ability to maintain business functions and to discover errors and vulnerabilities that may occur under extreme conditions.            |[Develop a Daily Reporting System for Chaos Mesh](https://mp.weixin.qq.com/s/dm6GayOE-4A6Bdz-ucS6Dw)       |
 | [KingNet](https://www.kingnet.com/)                  |KingNet uses Chaos Mesh for testing the availability of multiple data centers and microservice links. Chaos Mesh also helps them with mocking service unavailability or abnormal network conditions.            |To be added.       |
-| [GreptimeDB](https://www.greptime.com/)                  |GreptimeDB uses Chaos Mesh to enhance the correctness and availability of their distributed cluster. Chaos engineering finds lots of corner cases from the database implement to their dependencies.        |To be added.       |
+| [GreptimeDB](https://www.greptime.com/)                  |GreptimeDB uses Chaos Mesh to enhance the correctness and availability of their distributed cluster. Chaos engineering finds lots of corner cases from the database implement to their dependencies.        | [Chaos Engineering - Who's to Blame for the Bug Mess?](https://greptime.com/blogs/2023-11-06-chaos-engineering)       |
 | [NetEase Fuxi Lab](https://fuxi.163.com/fuxi-introduction)                  |Uses Chaos Mesh to improve the stability of their internal hybrid cloud. In addition, their users with cloud platforms also access Chaos Mesh to test the stability of user services.            |[How a Top Game Company Uses Chaos Engineering to Improve Testing](https://chaos-mesh.org/blog/how-a-top-game-company-uses-chaos-engineering-to-improve-testing)       |
 | [Percona](https://www.percona.com/)                  |Percona uses Chaos Mesh to test their Percona Kubernetes Operators, which is used to deploy their own Database-as-Service.            |[Chaos Mesh to Create Chaos in Kubernetes](https://www.percona.com/blog/2020/11/05/chaosmesh-to-create-chaos-in-kubernetes/)       |
 | [PingCAP](https://en.pingcap.com/)                  |Built [TiPocket](https://github.com/pingcap/tipocket) ontop of Chaos Mesh, an automated testing framework to build a full Chaos Engineering testing loop for TiDB, a distributed database.            |[Building an Automated Testing Framework Based on Chaos Mesh and Argo](https://chaos-mesh.org/blog/building_automated_testing_framework/)       |

From ee642585de38e1fa9b4e99787437498f16029eea Mon Sep 17 00:00:00 2001
From: Josh Ferrell <joshuaf@adobe.com>
Date: Tue, 28 Nov 2023 21:26:52 -0500
Subject: [PATCH 3/3] Allow chaos-dns-server affinity to be set in helm values
 (#4260)

Add change log entry for chaos-dns-server pod affinities



Modify install.sh for default pod anti-affinity removal



Set default chaos-dns-server pod affinity

Update install.sh

Signed-off-by: Josh Ferrell <josh.ferrell@gmail.com>
---
 CHANGELOG.md                                  |  1 +
 helm/chaos-mesh/templates/dns-deployment.yaml | 13 +++----------
 helm/chaos-mesh/values.yaml                   | 12 ++++++++++++
 install.sh                                    | 11 ++++++-----
 4 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 968e32bbbd4..73013e942a9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -16,6 +16,7 @@ For more information and how-to, see [RFC: Keep A Changelog](https://github.com/
 - Support for deploying chaos-dashboard with sidecar containers in helm chart [#4164](https://github.com/chaos-mesh/chaos-mesh/pull/4164)
 - Add `values.schema.json` [#4205](https://github.com/chaos-mesh/chaos-mesh/pull/4205)
 - Add [`GreptimeDB`](https://greptime.com) to ADOPTERS.md [#4245](https://github.com/chaos-mesh/chaos-mesh/pull/4245)
+- Support configurable chaos-dns-server pod affinities[#4260](https://github.com/chaos-mesh/chaos-mesh/pull/4260)
 
 ### Changed
 
diff --git a/helm/chaos-mesh/templates/dns-deployment.yaml b/helm/chaos-mesh/templates/dns-deployment.yaml
index 8d9739432f0..2580c6c52fc 100644
--- a/helm/chaos-mesh/templates/dns-deployment.yaml
+++ b/helm/chaos-mesh/templates/dns-deployment.yaml
@@ -42,17 +42,10 @@ spec:
     {{- end }}
     spec:
       serviceAccountName: {{ .Values.dnsServer.serviceAccount }}
+      {{- with .Values.dnsServer.affinity }}
       affinity:
-        podAntiAffinity:
-          preferredDuringSchedulingIgnoredDuringExecution:
-          - weight: 100
-            podAffinityTerm:
-              labelSelector:
-                matchExpressions:
-                  - key: k8s-app
-                    operator: In
-                    values: ["chaos-dns"]
-              topologyKey: kubernetes.io/hostname
+{{ toYaml . | indent 8 }}
+      {{- end }}
       {{- with .Values.dnsServer.tolerations }}
       tolerations:
 {{ toYaml . | indent 8 }}
diff --git a/helm/chaos-mesh/values.yaml b/helm/chaos-mesh/values.yaml
index 4fdf282b3e0..d69fde5b1f5 100644
--- a/helm/chaos-mesh/values.yaml
+++ b/helm/chaos-mesh/values.yaml
@@ -452,6 +452,18 @@ dnsServer:
     LISTEN_HOST: "0.0.0.0"
     # The port of chaos-dns-server listen on
     LISTEN_PORT: 53
+  affinity:
+    podAntiAffinity:
+      preferredDuringSchedulingIgnoredDuringExecution:
+        - podAffinityTerm:
+            labelSelector:
+              matchExpressions:
+                - key: app.kubernetes.io/component
+                  operator: In
+                  values:
+                    - chaos-dns-server
+            topologyKey: kubernetes.io/hostname
+          weight: 100
 
 prometheus:
   # Enable prometheus
diff --git a/install.sh b/install.sh
index 7ddb476e9af..4ebacada9c6 100755
--- a/install.sh
+++ b/install.sh
@@ -1963,14 +1963,15 @@ spec:
       affinity:
         podAntiAffinity:
           preferredDuringSchedulingIgnoredDuringExecution:
-          - weight: 100
-            podAffinityTerm:
+          - podAffinityTerm:
               labelSelector:
                 matchExpressions:
-                  - key: k8s-app
-                    operator: In
-                    values: ["chaos-dns"]
+                - key: app.kubernetes.io/component
+                  operator: In
+                  values:
+                  - chaos-dns-server
               topologyKey: kubernetes.io/hostname
+            weight: 100
       priorityClassName: 
       containers:
       - name: chaos-dns-server