Skip to content

Commit 9bbd6a6

Browse files
[POA-3263] Set drop-nginx-traffic arg at apidump cmd also (#101)
Changes: * `apidump/apidump.go`: Refactored the logic to check for dropping Nginx traffic by directly using the `a.DropNginxTraffic` flag. * `cmd/internal/apidump/apidump.go`: Added the `DropNginxTraffic` flag to the `apidumpRunInternal` function, allowing it to be set via the `viper` configuration.
1 parent 53f9110 commit 9bbd6a6

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

apidump/apidump.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -786,16 +786,12 @@ func (a *apidump) Run() error {
786786
// Eliminate Akita CLI traffic, unless --dogfood has been specified
787787
dropDogfoodTraffic := !viper.GetBool("dogfood")
788788

789-
// Always eliminate Nginx traffic.
790-
// Default value of both flags is true, unless explicitly set to false.
791-
dropNginxTraffic := a.DropNginxTraffic && viper.GetBool("drop-nginx-traffic")
792-
793789
// Construct userTrafficCollector
794-
if dropDogfoodTraffic || dropNginxTraffic {
790+
if dropDogfoodTraffic || a.DropNginxTraffic {
795791
collector = &trace.UserTrafficCollector{
796792
Collector: collector,
797793
DropDogfoodTraffic: dropDogfoodTraffic,
798-
DropNginxTraffic: dropNginxTraffic,
794+
DropNginxTraffic: a.DropNginxTraffic,
799795
}
800796
}
801797

cmd/internal/apidump/apidump.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"github.com/postmanlabs/postman-insights-agent/telemetry"
1919
"github.com/postmanlabs/postman-insights-agent/util"
2020
"github.com/spf13/cobra"
21+
"github.com/spf13/viper"
2122
"golang.org/x/term"
2223
)
2324

@@ -222,6 +223,7 @@ func apidumpRunInternal(cmd *cobra.Command, _ []string) error {
222223
MaxWitnessSize_bytes: maxWitnessSize_bytes,
223224
DockerExtensionMode: dockerExtensionMode,
224225
HealthCheckPort: healthCheckPort,
226+
DropNginxTraffic: viper.GetBool("drop-nginx-traffic"),
225227

226228
// TODO: remove the SendWitnessPayloads flag once all existing users are migrated to new flag.
227229
ReproMode: commonApidumpFlags.EnableReproMode || commonApidumpFlags.SendWitnessPayloads,

cmd/internal/kube/daemonset/kube_events_worker.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/pkg/errors"
1010
"github.com/postmanlabs/postman-insights-agent/deployment"
1111
"github.com/postmanlabs/postman-insights-agent/printer"
12+
"github.com/spf13/viper"
1213
coreV1 "k8s.io/api/core/v1"
1314
)
1415

@@ -258,8 +259,8 @@ func (d *Daemonset) inspectPodForEnvVars(pod coreV1.Pod, podArgs *PodArgs) error
258259
InsightsEnvironment: d.InsightsEnvironment,
259260
}
260261

261-
// Check if Nginx traffic should be dropped, with a default value of true
262-
podArgs.DropNginxTraffic = parseBoolConfig(mainContainerConfig.dropNginxTraffic, "dropNginxTraffic", pod.Name, true)
262+
// Check if Nginx traffic should be dropped, with a default fallback to the DaemonSet config
263+
podArgs.DropNginxTraffic = parseBoolConfig(mainContainerConfig.dropNginxTraffic, "dropNginxTraffic", pod.Name, viper.GetBool("drop-nginx-traffic"))
263264

264265
// Determine ReproMode flag for the apidump process
265266
podArgs.ReproMode = d.InsightsReproModeEnabled

0 commit comments

Comments
 (0)