From f6654de4f9cc8a653af9be786f9166946c0e9650 Mon Sep 17 00:00:00 2001 From: Sam Azouzi Date: Tue, 15 Nov 2022 11:08:37 -0500 Subject: [PATCH] use ubuntu:jammy, use var/consts where applicable, update readme --- dogfood/README.md | 6 +- dogfood/client/Dockerfile | 2 +- dogfood/server/Dockerfile | 2 +- dogfood/tester/Dockerfile | 2 +- dogfood/tester/disruptions.go | 132 +++++++++++++++------------------- 5 files changed, 65 insertions(+), 79 deletions(-) diff --git a/dogfood/README.md b/dogfood/README.md index 2246a1601..fef5b097e 100644 --- a/dogfood/README.md +++ b/dogfood/README.md @@ -1,4 +1,4 @@ - # Installing protoc +# Installing protoc Run `brew install protobuf` or `make install-protobuf` @@ -107,8 +107,8 @@ For gRPC disruption, you can follow these [detailed steps](../docs/grpc_disrupti ### Sending Metrics to Datadog For the purposes of testing disruptions/workflows, you should make sure that the datadog agent is properly installed -on the cluster that the client and server are running on. 3 of the major disruptive resources properly send metrics -to Datadog (CPU, Network, Disk). The client contains computation related to these disruptions and can be tested using +on the cluster that the client and server are running on. The Datadog Agent should be posting metrics related to CPU, +Network, and Disk which are all necessary to test the related disruptions. The client contains computation related to these disruptions and can be tested using the disruptions mentioned. ### Clean up diff --git a/dogfood/client/Dockerfile b/dogfood/client/Dockerfile index ed36a32f3..3ad815f5a 100644 --- a/dogfood/client/Dockerfile +++ b/dogfood/client/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:focal as client +FROM ubuntu:jammy as client COPY built_go_client /usr/local/bin/dogfood_client diff --git a/dogfood/server/Dockerfile b/dogfood/server/Dockerfile index 0ed91258b..b0900ca46 100644 --- a/dogfood/server/Dockerfile +++ b/dogfood/server/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:focal as client +FROM ubuntu:jammy as client COPY built_go_server /usr/local/bin/dogfood_server diff --git a/dogfood/tester/Dockerfile b/dogfood/tester/Dockerfile index 206980fb3..516443c1e 100644 --- a/dogfood/tester/Dockerfile +++ b/dogfood/tester/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:focal as client +FROM ubuntu:jammy as client COPY built_go_client /usr/local/bin/dogfood_tester diff --git a/dogfood/tester/disruptions.go b/dogfood/tester/disruptions.go index be465107f..2ff179cb9 100644 --- a/dogfood/tester/disruptions.go +++ b/dogfood/tester/disruptions.go @@ -6,6 +6,7 @@ package main import ( + "fmt" "github.com/DataDog/chaos-controller/api/v1beta1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" @@ -14,30 +15,39 @@ import ( // Globals var SELECTOR = []string{"app", "chaos-dogfood-client"} -var CONTAINER = "client-deploy" + +const CONTAINER = "client-deploy" +const NAMESPACE = "chaos-engineering" +const NAME_PREFIX = "e2etest-" +const DURATION v1beta1.DisruptionDuration = "3m" +const DISK_PRESSURE_PATH = "/mnt/data" + +var COUNT = &intstr.IntOrString{Type: intstr.Int, IntVal: 1} +var UNSAFEMODE = &v1beta1.UnsafemodeSpec{ + DisableAll: true, +} +var NETWORK_HOST_SPEC = []v1beta1.NetworkDisruptionHostSpec{ + { + Host: fmt.Sprintf("chaos-dogfood-server.%s.svc.cluster.local", NAMESPACE), + Port: 50051, + Protocol: "tcp", + }, +} // Network Disruptions var network1 = v1beta1.Disruption{ ObjectMeta: metav1.ObjectMeta{ - Name: "e2etest-network1", - Namespace: "chaos-engineering", + Name: fmt.Sprint(NAME_PREFIX, "network-drop30"), + Namespace: NAMESPACE, }, Spec: v1beta1.DisruptionSpec{ - Count: &intstr.IntOrString{Type: intstr.Int, IntVal: 1}, - Unsafemode: &v1beta1.UnsafemodeSpec{ - DisableAll: true, - }, + Count: COUNT, + Unsafemode: UNSAFEMODE, Selector: map[string]string{SELECTOR[0]: SELECTOR[1]}, Containers: []string{CONTAINER}, - Duration: "3m", + Duration: DURATION, Network: &v1beta1.NetworkDisruptionSpec{ - Hosts: []v1beta1.NetworkDisruptionHostSpec{ - { - Host: "chaos-dogfood-server.chaos-demo.svc.cluster.local", - Port: 50051, - Protocol: "tcp", - }, - }, + Hosts: NETWORK_HOST_SPEC, Drop: 30, Corrupt: 0, Delay: 0, @@ -48,25 +58,17 @@ var network1 = v1beta1.Disruption{ var network2 = v1beta1.Disruption{ ObjectMeta: metav1.ObjectMeta{ - Name: "e2etest-network2", - Namespace: "chaos-engineering", + Name: fmt.Sprint(NAME_PREFIX, "network-drop70"), + Namespace: NAMESPACE, }, Spec: v1beta1.DisruptionSpec{ - Count: &intstr.IntOrString{Type: intstr.Int, IntVal: 1}, - Unsafemode: &v1beta1.UnsafemodeSpec{ - DisableAll: true, - }, + Count: COUNT, + Unsafemode: UNSAFEMODE, Selector: map[string]string{SELECTOR[0]: SELECTOR[1]}, Containers: []string{CONTAINER}, - Duration: "3m", + Duration: DURATION, Network: &v1beta1.NetworkDisruptionSpec{ - Hosts: []v1beta1.NetworkDisruptionHostSpec{ - { - Host: "chaos-dogfood-server.chaos-demo.svc.cluster.local", - Port: 50051, - Protocol: "tcp", - }, - }, + Hosts: NETWORK_HOST_SPEC, Drop: 70, Corrupt: 0, Delay: 0, @@ -77,25 +79,17 @@ var network2 = v1beta1.Disruption{ var network3 = v1beta1.Disruption{ ObjectMeta: metav1.ObjectMeta{ - Name: "e2etest-network3", - Namespace: "chaos-engineering", + Name: fmt.Sprint(NAME_PREFIX, "network-delay1000"), + Namespace: NAMESPACE, }, Spec: v1beta1.DisruptionSpec{ - Count: &intstr.IntOrString{Type: intstr.Int, IntVal: 1}, - Unsafemode: &v1beta1.UnsafemodeSpec{ - DisableAll: true, - }, + Count: COUNT, + Unsafemode: UNSAFEMODE, Selector: map[string]string{SELECTOR[0]: SELECTOR[1]}, Containers: []string{CONTAINER}, - Duration: "3m", + Duration: DURATION, Network: &v1beta1.NetworkDisruptionSpec{ - Hosts: []v1beta1.NetworkDisruptionHostSpec{ - { - Host: "chaos-dogfood-server.chaos-demo.svc.cluster.local", - Port: 50051, - Protocol: "tcp", - }, - }, + Hosts: NETWORK_HOST_SPEC, Drop: 0, Corrupt: 0, Delay: 1000, @@ -111,19 +105,17 @@ var diskReadsThresholds = []int{1024, 2048, 4098} var disk1 = v1beta1.Disruption{ ObjectMeta: metav1.ObjectMeta{ - Name: "e2etest-disk1", - Namespace: "chaos-engineering", + Name: fmt.Sprint(NAME_PREFIX, "disk-read1024"), + Namespace: NAMESPACE, }, Spec: v1beta1.DisruptionSpec{ - Count: &intstr.IntOrString{Type: intstr.Int, IntVal: 1}, - Unsafemode: &v1beta1.UnsafemodeSpec{ - DisableAll: true, - }, + Count: COUNT, + Unsafemode: UNSAFEMODE, Selector: map[string]string{SELECTOR[0]: SELECTOR[1]}, Containers: []string{CONTAINER}, - Duration: "3m", + Duration: DURATION, DiskPressure: &v1beta1.DiskPressureSpec{ - Path: "/mnt/data", + Path: DISK_PRESSURE_PATH, Throttling: v1beta1.DiskPressureThrottlingSpec{ ReadBytesPerSec: &diskReadsThresholds[0], }, @@ -133,19 +125,17 @@ var disk1 = v1beta1.Disruption{ var disk2 = v1beta1.Disruption{ ObjectMeta: metav1.ObjectMeta{ - Name: "e2etest-disk2", - Namespace: "chaos-engineering", + Name: fmt.Sprint(NAME_PREFIX, "disk-write2048"), + Namespace: NAMESPACE, }, Spec: v1beta1.DisruptionSpec{ - Count: &intstr.IntOrString{Type: intstr.Int, IntVal: 1}, - Unsafemode: &v1beta1.UnsafemodeSpec{ - DisableAll: true, - }, + Count: COUNT, + Unsafemode: UNSAFEMODE, Selector: map[string]string{SELECTOR[0]: SELECTOR[1]}, Containers: []string{CONTAINER}, - Duration: "3m", + Duration: DURATION, DiskPressure: &v1beta1.DiskPressureSpec{ - Path: "/mnt/data", + Path: DISK_PRESSURE_PATH, Throttling: v1beta1.DiskPressureThrottlingSpec{ WriteBytesPerSec: &diskReadsThresholds[1], }, @@ -155,17 +145,15 @@ var disk2 = v1beta1.Disruption{ var disk3 = v1beta1.Disruption{ ObjectMeta: metav1.ObjectMeta{ - Name: "e2etest-disk3", - Namespace: "chaos-engineering", + Name: fmt.Sprint(NAME_PREFIX, "disk-write4098"), + Namespace: NAMESPACE, }, Spec: v1beta1.DisruptionSpec{ - Count: &intstr.IntOrString{Type: intstr.Int, IntVal: 1}, - Unsafemode: &v1beta1.UnsafemodeSpec{ - DisableAll: true, - }, + Count: COUNT, + Unsafemode: UNSAFEMODE, Selector: map[string]string{SELECTOR[0]: SELECTOR[1]}, Containers: []string{CONTAINER}, - Duration: "3m", + Duration: DURATION, DiskPressure: &v1beta1.DiskPressureSpec{ Path: "/mnt/data", Throttling: v1beta1.DiskPressureThrottlingSpec{ @@ -181,17 +169,15 @@ var DISK_DISRUPTIONS = []v1beta1.Disruption{disk1, disk2, disk3} var cpu1 = v1beta1.Disruption{ ObjectMeta: metav1.ObjectMeta{ - Name: "e2etest-cpu1", - Namespace: "chaos-engineering", + Name: fmt.Sprint(NAME_PREFIX, "cpu-cores4"), + Namespace: NAMESPACE, }, Spec: v1beta1.DisruptionSpec{ - Count: &intstr.IntOrString{Type: intstr.Int, IntVal: 1}, - Unsafemode: &v1beta1.UnsafemodeSpec{ - DisableAll: true, - }, + Count: COUNT, + Unsafemode: UNSAFEMODE, Selector: map[string]string{SELECTOR[0]: SELECTOR[1]}, Containers: []string{CONTAINER}, - Duration: "3m", + Duration: DURATION, CPUPressure: &v1beta1.CPUPressureSpec{ Count: &intstr.IntOrString{IntVal: 4}, },