From 01375de4e3109656b0eb4549d65645b8a6b51fb9 Mon Sep 17 00:00:00 2001 From: Fanny Jiang Date: Mon, 16 Dec 2024 20:48:03 -0500 Subject: [PATCH] fix conflicting resource names for dda w/operator --- components/datadog/agent/kubernetes_operator.go | 6 +++--- components/datadog/operator/helm.go | 14 +++++++------- scenarios/aws/kindvm/run.go | 6 +++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/components/datadog/agent/kubernetes_operator.go b/components/datadog/agent/kubernetes_operator.go index c04b0b3ee..304effe40 100644 --- a/components/datadog/agent/kubernetes_operator.go +++ b/components/datadog/agent/kubernetes_operator.go @@ -17,15 +17,15 @@ func NewDDAWithOperator(e config.Env, resourceName string, kubeProvider *kuberne return err } - pulumiResourceOptions := append(ddaParams.PulumiResourceOptions, pulumi.Parent(comp)) + ddaParams.PulumiResourceOptions = append(ddaParams.PulumiResourceOptions, pulumi.Parent(comp)) - _, err = dda.K8sAppDefinition(e, kubeProvider, ddaParams, pulumiResourceOptions...) + _, err = dda.K8sAppDefinition(e, kubeProvider, ddaParams, ddaParams.PulumiResourceOptions...) if err != nil { return err } - baseName := "dda-linux" + baseName := "dda-with-operator-linux" comp.LinuxNodeAgent, err = componentskube.NewKubernetesObjRef(e, baseName+"-nodeAgent", ddaParams.Namespace, "Pod", pulumi.String("").ToStringOutput(), pulumi.String("datadoghq/v2alpha1").ToStringOutput(), map[string]string{"app.kubernetes.io/instance": ddaParams.DDAConfig.Name + "-agent"}) diff --git a/components/datadog/operator/helm.go b/components/datadog/operator/helm.go index 7bda78e3b..6a80abda8 100644 --- a/components/datadog/operator/helm.go +++ b/components/datadog/operator/helm.go @@ -39,7 +39,7 @@ type HelmComponent struct { func NewHelmInstallation(e config.Env, args HelmInstallationArgs, opts ...pulumi.ResourceOption) (*HelmComponent, error) { apiKey := e.AgentAPIKey() appKey := e.AgentAPPKey() - baseName := "dda" + opts = append(opts, pulumi.Providers(args.KubeProvider), e.WithProviders(config.ProviderRandom), pulumi.DeletedWith(args.KubeProvider)) helmComponent := &HelmComponent{} @@ -64,7 +64,7 @@ func NewHelmInstallation(e config.Env, args HelmInstallationArgs, opts ...pulumi secret, err := corev1.NewSecret(e.Ctx(), "datadog-credentials", &corev1.SecretArgs{ Metadata: metav1.ObjectMetaArgs{ Namespace: ns.Metadata.Name(), - Name: pulumi.Sprintf("%s-datadog-credentials", baseName), + Name: pulumi.String("dda-datadog-credentials"), }, StringData: pulumi.StringMap{ "api-key": apiKey, @@ -93,9 +93,9 @@ func NewHelmInstallation(e config.Env, args HelmInstallationArgs, opts ...pulumi operatorImagePath = args.OperatorFullImagePath } operatorImagePath, operatorImageTag := utils.ParseImageReference(operatorImagePath) - linuxInstallName := baseName + "-operator-linux" + linuxInstallName := "datadog-operator-linux" - values := buildLinuxHelmValues(baseName, operatorImagePath, operatorImageTag) + values := buildLinuxHelmValues(operatorImagePath, operatorImageTag) values.configureImagePullSecret(imgPullSecret) defaultYAMLValues := values.toYAMLPulumiAssetOutput() @@ -132,10 +132,10 @@ func NewHelmInstallation(e config.Env, args HelmInstallationArgs, opts ...pulumi type HelmValues pulumi.Map -func buildLinuxHelmValues(baseName string, operatorImagePath string, operatorImageTag string) HelmValues { +func buildLinuxHelmValues(operatorImagePath string, operatorImageTag string) HelmValues { return HelmValues{ - "apiKeyExistingSecret": pulumi.String(baseName + "-datadog-credentials"), - "appKeyExistingSecret": pulumi.String(baseName + "-datadog-credentials"), + "apiKeyExistingSecret": pulumi.String("dda-datadog-credentials"), + "appKeyExistingSecret": pulumi.String("dda-datadog-credentials"), "image": pulumi.Map{ "repository": pulumi.String(operatorImagePath), "tag": pulumi.String(operatorImageTag), diff --git a/scenarios/aws/kindvm/run.go b/scenarios/aws/kindvm/run.go index f58e2cb39..aa369a3c2 100644 --- a/scenarios/aws/kindvm/run.go +++ b/scenarios/aws/kindvm/run.go @@ -180,15 +180,15 @@ spec: ) } - operatorAgentComponent, err := agent.NewDDAWithOperator(&awsEnv, awsEnv.CommonNamer().ResourceName("dd-operator-agent"), kindKubeProvider, ddaOptions...) + k8sAgentWithOperatorComp, err := agent.NewDDAWithOperator(&awsEnv, awsEnv.CommonNamer().ResourceName("datadog-agent-with-operator"), kindKubeProvider, ddaOptions...) if err != nil { return err } - dependsOnCrd = utils.PulumiDependsOn(operatorAgentComponent) + dependsOnCrd = utils.PulumiDependsOn(k8sAgentWithOperatorComp) - if err := operatorAgentComponent.Export(awsEnv.Ctx(), nil); err != nil { + if err := k8sAgentWithOperatorComp.Export(awsEnv.Ctx(), nil); err != nil { return err }