Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[POA-1340] Add a mechanism to randomly _not_ start apidump. #17

Merged
merged 5 commits into from
Jul 3, 2024

Conversation

mgritter
Copy link
Contributor

Controlled by a flag and a new environment variable.

The use case here is that we want to run the agent but some, but not all, of the pods in a critical deployment. This is not a great solution, but it's much easier than the alternatives considered. The deployment can include a probability as an environment variable that any given apidump command will run; those that don't run will just hang forever to avoid any problems caused by container exit.

One downside is that changing the environment variable causes all the pods to be restarted.

Controlled by a flag and a new environment variable.
@mgritter mgritter requested a review from mudit-postman June 28, 2024 22:25
@mgritter
Copy link
Contributor Author

mgritter commented Jul 2, 2024

The environment variable is not working and I can't tell why:

mark@ubuntu:~/akita-cli$ docker run -e POSTMAN_ENV=beta -e POSTMAN_API_KEY=PMAK-xxx -e POSTMAN_AGENT_RANDOM_START=0 postman-insights-agent-release:0.30.8-rc1 apidump --project svc_5xtgTmKcZxgasmGQwsbMR0  --randomized-start=0
[INFO] Postman Insights Agent 0.30.8-rc1
[INFO] Starting trace with probability 0%.
[INFO] This agent instance will not begin capturing data.
^Cmark@ubuntu:~/akita-cli$ docker run -e POSTMAN_ENV=beta -e POSTMAN_API_KEY=PMAK-xxx -e POSTMAN_AGENT_RANDOM_START=0 postman-insights-agent-release:0.30.8-rc1 apidump --project svc_5xtgTmKcZxgasmGQwsbMR0 
[INFO] Postman Insights Agent 0.30.8-rc1
[INFO] Created new trace on Postman Cloud: akita://Mark test 2024-06-25:trace:pickle-neck-04540b68
[INFO] Running learn mode on interfaces lo, eth0
[INFO] --filter flag is not set; capturing all network traffic to and from your services.
[INFO] Send SIGINT (Ctrl-C) to stop...
^C[INFO] Received interrupt, stopping trace collection...

@mgritter
Copy link
Contributor Author

mgritter commented Jul 3, 2024

Another problem here is that Go prior to 1.20 does not seed its RNG automatically. And we use 1.18 to build.

select {}

// Unreachable
os.Exit(0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When will this be called?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never, that's why it's marked unreachable (and the linter will tell you so too.)

I just felt it was more robust to have it here in case the select was later modified.

if prob < 100 {
printer.Stdout.Infof("Starting trace with probability %d%%.\n", prob)

// Pre-1.20, Go does not seed the default Random object :(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should create a ticket to upgrade agent to build on go 1.21

@mgritter mgritter merged commit c196466 into main Jul 3, 2024
2 checks passed
@mgritter mgritter deleted the mgritter/POA-1340-control-rollout branch July 3, 2024 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants