From 2022a187edf0a38159872cdea022e85355e301ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9na=C3=AFc=20Huard?= Date: Thu, 28 Nov 2024 11:14:29 +0100 Subject: [PATCH] Revert "Revert "Sanitize the dependencies between K8s fake app pulumi components and the agent" (#1265)" This reverts commit 047dd64128b675c975af49d684903b37170401ac. --- scenarios/aws/eks/run.go | 25 +++++++++++++------------ scenarios/aws/kindvm/run.go | 18 +++++++++--------- scenarios/azure/aks/run.go | 16 ++++++++-------- scenarios/gcp/gke/run.go | 18 +++++++++--------- 4 files changed, 39 insertions(+), 38 deletions(-) diff --git a/scenarios/aws/eks/run.go b/scenarios/aws/eks/run.go index 426110bff..148423c53 100644 --- a/scenarios/aws/eks/run.go +++ b/scenarios/aws/eks/run.go @@ -58,7 +58,8 @@ func Run(ctx *pulumi.Context) error { return err } } - workloadWithCRDDeps := make([]pulumi.Resource, 0) + + var dependsOnDDAgent pulumi.ResourceOption if awsEnv.AgentDeploy() { k8sAgentOptions := make([]kubernetesagentparams.Option, 0) k8sAgentOptions = append( @@ -85,51 +86,51 @@ func Run(ctx *pulumi.Context) error { return err } - workloadWithCRDDeps = append(workloadWithCRDDeps, k8sAgentComponent) - + dependsOnDDAgent = utils.PulumiDependsOn(k8sAgentComponent) } + // Deploy standalone dogstatsd if awsEnv.DogstatsdDeploy() { - if _, err := dogstatsdstandalone.K8sAppDefinition(&awsEnv, cluster.KubeProvider, "dogstatsd-standalone", fakeIntake, true, "", utils.PulumiDependsOn(cluster)); err != nil { + if _, err := dogstatsdstandalone.K8sAppDefinition(&awsEnv, cluster.KubeProvider, "dogstatsd-standalone", fakeIntake, true, ""); err != nil { return err } } // Deploy testing workload if awsEnv.TestingWorkloadDeploy() { - if _, err := nginx.K8sAppDefinition(&awsEnv, cluster.KubeProvider, "workload-nginx", "", true, utils.PulumiDependsOn(workloadWithCRDDeps...)); err != nil { + if _, err := nginx.K8sAppDefinition(&awsEnv, cluster.KubeProvider, "workload-nginx", "", true, dependsOnDDAgent /* for DDM */); err != nil { return err } - if _, err := redis.K8sAppDefinition(&awsEnv, cluster.KubeProvider, "workload-redis", true, utils.PulumiDependsOn(workloadWithCRDDeps...)); err != nil { + if _, err := redis.K8sAppDefinition(&awsEnv, cluster.KubeProvider, "workload-redis", true, dependsOnDDAgent /* for DDM */); err != nil { return err } - if _, err := cpustress.K8sAppDefinition(&awsEnv, cluster.KubeProvider, "workload-cpustress", utils.PulumiDependsOn(cluster)); err != nil { + if _, err := cpustress.K8sAppDefinition(&awsEnv, cluster.KubeProvider, "workload-cpustress"); err != nil { return err } // dogstatsd clients that report to the Agent - if _, err := dogstatsd.K8sAppDefinition(&awsEnv, cluster.KubeProvider, "workload-dogstatsd", 8125, "/var/run/datadog/dsd.socket", utils.PulumiDependsOn(workloadWithCRDDeps...)); err != nil { + if _, err := dogstatsd.K8sAppDefinition(&awsEnv, cluster.KubeProvider, "workload-dogstatsd", 8125, "/var/run/datadog/dsd.socket", dependsOnDDAgent /* for admission */); err != nil { return err } if awsEnv.DogstatsdDeploy() { // dogstatsd clients that report to the dogstatsd standalone deployment - if _, err := dogstatsd.K8sAppDefinition(&awsEnv, cluster.KubeProvider, "workload-dogstatsd-standalone", dogstatsdstandalone.HostPort, dogstatsdstandalone.Socket, utils.PulumiDependsOn(cluster)); err != nil { + if _, err := dogstatsd.K8sAppDefinition(&awsEnv, cluster.KubeProvider, "workload-dogstatsd-standalone", dogstatsdstandalone.HostPort, dogstatsdstandalone.Socket, dependsOnDDAgent /* for admission */); err != nil { return err } } - if _, err := tracegen.K8sAppDefinition(&awsEnv, cluster.KubeProvider, "workload-tracegen", utils.PulumiDependsOn(cluster)); err != nil { + if _, err := tracegen.K8sAppDefinition(&awsEnv, cluster.KubeProvider, "workload-tracegen"); err != nil { return err } - if _, err := prometheus.K8sAppDefinition(&awsEnv, cluster.KubeProvider, "workload-prometheus", utils.PulumiDependsOn(cluster)); err != nil { + if _, err := prometheus.K8sAppDefinition(&awsEnv, cluster.KubeProvider, "workload-prometheus"); err != nil { return err } - if _, err := mutatedbyadmissioncontroller.K8sAppDefinition(&awsEnv, cluster.KubeProvider, "workload-mutated", "workload-mutated-lib-injection", utils.PulumiDependsOn(workloadWithCRDDeps...)); err != nil { + if _, err := mutatedbyadmissioncontroller.K8sAppDefinition(&awsEnv, cluster.KubeProvider, "workload-mutated", "workload-mutated-lib-injection", dependsOnDDAgent /* for admission */); err != nil { return err } } diff --git a/scenarios/aws/kindvm/run.go b/scenarios/aws/kindvm/run.go index 9fc8a3d84..3b6e9eacd 100644 --- a/scenarios/aws/kindvm/run.go +++ b/scenarios/aws/kindvm/run.go @@ -67,8 +67,6 @@ func Run(ctx *pulumi.Context) error { return err } - var dependsOnCrd pulumi.ResourceOption - var fakeIntake *fakeintakeComp.Fakeintake if awsEnv.AgentUseFakeintake() { fakeIntakeOptions := []fakeintake.Option{ @@ -87,6 +85,8 @@ func Run(ctx *pulumi.Context) error { } } + var dependsOnDDAgent pulumi.ResourceOption + // Deploy the agent if awsEnv.AgentDeploy() && !awsEnv.AgentDeployWithOperator() { customValues := ` @@ -121,7 +121,7 @@ agents: return err } - dependsOnCrd = utils.PulumiDependsOn(k8sAgentComponent) + dependsOnDDAgent = utils.PulumiDependsOn(k8sAgentComponent) } // Deploy the operator @@ -152,7 +152,7 @@ agents: return err } - dependsOnCrd = utils.PulumiDependsOn(operatorAgentComponent) + dependsOnDDAgent = utils.PulumiDependsOn(operatorAgentComponent) if err := operatorAgentComponent.Export(awsEnv.Ctx(), nil); err != nil { return err @@ -169,11 +169,11 @@ agents: // Deploy testing workload if awsEnv.TestingWorkloadDeploy() { - if _, err := nginx.K8sAppDefinition(&awsEnv, kindKubeProvider, "workload-nginx", "", true, dependsOnCrd); err != nil { + if _, err := nginx.K8sAppDefinition(&awsEnv, kindKubeProvider, "workload-nginx", "", true, dependsOnDDAgent /* for DDM */); err != nil { return err } - if _, err := redis.K8sAppDefinition(&awsEnv, kindKubeProvider, "workload-redis", true, dependsOnCrd); err != nil { + if _, err := redis.K8sAppDefinition(&awsEnv, kindKubeProvider, "workload-redis", true, dependsOnDDAgent /* for DDM */); err != nil { return err } @@ -182,13 +182,13 @@ agents: } // dogstatsd clients that report to the Agent - if _, err := dogstatsd.K8sAppDefinition(&awsEnv, kindKubeProvider, "workload-dogstatsd", 8125, "/var/run/datadog/dsd.socket"); err != nil { + if _, err := dogstatsd.K8sAppDefinition(&awsEnv, kindKubeProvider, "workload-dogstatsd", 8125, "/var/run/datadog/dsd.socket", dependsOnDDAgent /* for admission */); err != nil { return err } // dogstatsd clients that report to the dogstatsd standalone deployment if awsEnv.DogstatsdDeploy() { - if _, err := dogstatsd.K8sAppDefinition(&awsEnv, kindKubeProvider, "workload-dogstatsd-standalone", dogstatsdstandalone.HostPort, dogstatsdstandalone.Socket); err != nil { + if _, err := dogstatsd.K8sAppDefinition(&awsEnv, kindKubeProvider, "workload-dogstatsd-standalone", dogstatsdstandalone.HostPort, dogstatsdstandalone.Socket, dependsOnDDAgent /* for admission */); err != nil { return err } } @@ -202,7 +202,7 @@ agents: return err } - if _, err := mutatedbyadmissioncontroller.K8sAppDefinition(&awsEnv, kindKubeProvider, "workload-mutated", "workload-mutated-lib-injection"); err != nil { + if _, err := mutatedbyadmissioncontroller.K8sAppDefinition(&awsEnv, kindKubeProvider, "workload-mutated", "workload-mutated-lib-injection", dependsOnDDAgent /* for admission */); err != nil { return err } } diff --git a/scenarios/azure/aks/run.go b/scenarios/azure/aks/run.go index aee5f07a3..e585ff5b7 100644 --- a/scenarios/azure/aks/run.go +++ b/scenarios/azure/aks/run.go @@ -38,7 +38,7 @@ func Run(ctx *pulumi.Context) error { return err } - var dependsOnCrd pulumi.ResourceOption + var dependsOnDDAgent pulumi.ResourceOption // Deploy the agent if env.AgentDeploy() { @@ -87,7 +87,7 @@ providers: return err } - dependsOnCrd = utils.PulumiDependsOn(k8sAgentComponent) + dependsOnDDAgent = utils.PulumiDependsOn(k8sAgentComponent) } // Deploy standalone dogstatsd @@ -99,15 +99,15 @@ providers: // Deploy testing workload if env.TestingWorkloadDeploy() { - if _, err := nginx.K8sAppDefinition(&env, aksCluster.KubeProvider, "workload-nginx", "", true, dependsOnCrd); err != nil { + if _, err := nginx.K8sAppDefinition(&env, aksCluster.KubeProvider, "workload-nginx", "", true, dependsOnDDAgent /* for DDM */); err != nil { return err } - if _, err := nginx.K8sAppDefinition(&env, aksCluster.KubeProvider, "workload-nginx-kata", kataRuntimeClass, true, dependsOnCrd); err != nil { + if _, err := nginx.K8sAppDefinition(&env, aksCluster.KubeProvider, "workload-nginx-kata", kataRuntimeClass, true, dependsOnDDAgent /* for DDM */); err != nil { return err } - if _, err := redis.K8sAppDefinition(&env, aksCluster.KubeProvider, "workload-redis", true, dependsOnCrd); err != nil { + if _, err := redis.K8sAppDefinition(&env, aksCluster.KubeProvider, "workload-redis", true, dependsOnDDAgent /* for DDM */); err != nil { return err } @@ -116,13 +116,13 @@ providers: } // dogstatsd clients that report to the Agent - if _, err := dogstatsd.K8sAppDefinition(&env, aksCluster.KubeProvider, "workload-dogstatsd", 8125, "/var/run/datadog/dsd.socket"); err != nil { + if _, err := dogstatsd.K8sAppDefinition(&env, aksCluster.KubeProvider, "workload-dogstatsd", 8125, "/var/run/datadog/dsd.socket", dependsOnDDAgent /* for admission */); err != nil { return err } if env.DogstatsdDeploy() { // dogstatsd clients that report to the dogstatsd standalone deployment - if _, err := dogstatsd.K8sAppDefinition(&env, aksCluster.KubeProvider, "workload-dogstatsd-standalone", dogstatsdstandalone.HostPort, dogstatsdstandalone.Socket); err != nil { + if _, err := dogstatsd.K8sAppDefinition(&env, aksCluster.KubeProvider, "workload-dogstatsd-standalone", dogstatsdstandalone.HostPort, dogstatsdstandalone.Socket, dependsOnDDAgent /* for admission */); err != nil { return err } } @@ -131,7 +131,7 @@ providers: return err } - if _, err := mutatedbyadmissioncontroller.K8sAppDefinition(&env, aksCluster.KubeProvider, "workload-mutated", "workload-mutated-lib-injection"); err != nil { + if _, err := mutatedbyadmissioncontroller.K8sAppDefinition(&env, aksCluster.KubeProvider, "workload-mutated", "workload-mutated-lib-injection", dependsOnDDAgent /* for admission */); err != nil { return err } } diff --git a/scenarios/gcp/gke/run.go b/scenarios/gcp/gke/run.go index bf1c86c2c..88b22a4b6 100644 --- a/scenarios/gcp/gke/run.go +++ b/scenarios/gcp/gke/run.go @@ -37,7 +37,7 @@ func Run(ctx *pulumi.Context) error { return err } - var dependsOnCrd pulumi.ResourceOption + var dependsOnDDAgent pulumi.ResourceOption // Deploy the agent if env.AgentDeploy() { @@ -75,25 +75,25 @@ func Run(ctx *pulumi.Context) error { return err } - dependsOnCrd = utils.PulumiDependsOn(k8sAgentComponent) + dependsOnDDAgent = utils.PulumiDependsOn(k8sAgentComponent) } // Deploy testing workload if env.TestingWorkloadDeploy() { - if _, err := nginx.K8sAppDefinition(&env, cluster.KubeProvider, "workload-nginx", "", true, dependsOnCrd); err != nil { + if _, err := nginx.K8sAppDefinition(&env, cluster.KubeProvider, "workload-nginx", "", true, dependsOnDDAgent /* for DDM */); err != nil { return err } - if _, err := cpustress.K8sAppDefinition(&env, cluster.KubeProvider, "workload-cpustress", dependsOnCrd); err != nil { + if _, err := cpustress.K8sAppDefinition(&env, cluster.KubeProvider, "workload-cpustress"); err != nil { return err } - if _, err := prometheus.K8sAppDefinition(&env, cluster.KubeProvider, "workload-prometheus", dependsOnCrd); err != nil { + if _, err := prometheus.K8sAppDefinition(&env, cluster.KubeProvider, "workload-prometheus"); err != nil { return err } - if _, err := mutatedbyadmissioncontroller.K8sAppDefinition(&env, cluster.KubeProvider, "workload-mutated", "workload-mutated-lib-injection", dependsOnCrd); err != nil { + if _, err := mutatedbyadmissioncontroller.K8sAppDefinition(&env, cluster.KubeProvider, "workload-mutated", "workload-mutated-lib-injection", dependsOnDDAgent /* for admission */); err != nil { return err } @@ -106,17 +106,17 @@ func Run(ctx *pulumi.Context) error { } // dogstatsd clients that report to the dogstatsd standalone deployment - if _, err := dogstatsd.K8sAppDefinition(&env, cluster.KubeProvider, "workload-dogstatsd-standalone", dogstatsdstandalone.HostPort, dogstatsdstandalone.Socket, dependsOnCrd); err != nil { + if _, err := dogstatsd.K8sAppDefinition(&env, cluster.KubeProvider, "workload-dogstatsd-standalone", dogstatsdstandalone.HostPort, dogstatsdstandalone.Socket, dependsOnDDAgent /* for admission */); err != nil { return err } } // dogstatsd clients that report to the Agent - if _, err := dogstatsd.K8sAppDefinition(&env, cluster.KubeProvider, "workload-dogstatsd", 8125, "/var/run/datadog/dsd.socket", dependsOnCrd); err != nil { + if _, err := dogstatsd.K8sAppDefinition(&env, cluster.KubeProvider, "workload-dogstatsd", 8125, "/var/run/datadog/dsd.socket", dependsOnDDAgent /* for admission */); err != nil { return err } - if _, err := tracegen.K8sAppDefinition(&env, cluster.KubeProvider, "workload-tracegen", dependsOnCrd); err != nil { + if _, err := tracegen.K8sAppDefinition(&env, cluster.KubeProvider, "workload-tracegen"); err != nil { return err } }