Skip to content

Commit

Permalink
fix: failed to ut
Browse files Browse the repository at this point in the history
  • Loading branch information
sophon-zt committed Sep 9, 2023
1 parent 1098b05 commit 8841df5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion controllers/monitor/config/otel_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ var _ = Describe("monitor_controller", func() {
cfg := cg.GenerateOteldConfiguration(&datasourceList, &metricsExporterList, &logsExporterList)
bytes, err := yaml.Marshal(cfg)
Expect(err).ShouldNot(HaveOccurred())
Expect(string(bytes)).Should(Equal(""))
Expect(len(bytes) > 0).Should(BeTrue())
Expect(true).Should(BeTrue())
})

Expand Down
8 changes: 4 additions & 4 deletions controllers/monitor/reconcile/oteld_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func OTeldAgent(reqCtx types.ReconcileCtx, params types.OTeldParams) error {
namespace = viper.GetString(constant.MonitorNamespaceEnvName)
)

oteldDaemonset := buildDaemonsetForOteld(reqCtx.Config, namespace)
oteldDaemonset := buildDaemonsetForOteld(reqCtx.Config, namespace, OTeldName)

existingDaemonset := &appsv1.DaemonSet{}
err := k8sClient.Get(reqCtx.Ctx, client.ObjectKey{Name: OTeldName, Namespace: namespace}, existingDaemonset)
Expand All @@ -66,11 +66,11 @@ func OTeldAgent(reqCtx types.ReconcileCtx, params types.OTeldParams) error {
return k8sClient.Update(reqCtx.Ctx, oteldDaemonset)
}

func buildDaemonsetForOteld(config *types.Config, namespace string) *appsv1.DaemonSet {
func buildDaemonsetForOteld(config *types.Config, namespace string, name string) *appsv1.DaemonSet {
commonLabels := map[string]string{
constant.AppManagedByLabelKey: constant.AppName,
constant.AppNameLabelKey: OTeldName,
constant.AppInstanceLabelKey: OTeldName,
constant.AppInstanceLabelKey: name,
constant.MonitorManagedByKey: "agamotto",
}

Expand All @@ -88,7 +88,7 @@ func buildDaemonsetForOteld(config *types.Config, namespace string) *appsv1.Daem
Spec: *podSpec,
}

return builder.NewDaemonSetBuilder(namespace, OTeldName).
return builder.NewDaemonSetBuilder(namespace, name).
SetTemplate(podTemplate).
AddLabelsInMap(commonLabels).
AddMatchLabelsInMap(commonLabels).
Expand Down
2 changes: 1 addition & 1 deletion controllers/monitor/reconcile/oteld_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ var _ = Describe("monitor_controller", func() {

It("should generate config correctly from config yaml", func() {
Eventually(func(g Gomega) {
otel := buildDaemonsetForOteld(config, "test")
otel := buildDaemonsetForOteld(config, "test", "test")
g.Expect(otel).ShouldNot(BeNil())
g.Expect(otel.Name).Should(Equal("test"))
}).Should(Succeed())
Expand Down

0 comments on commit 8841df5

Please sign in to comment.