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

[tmpnet] Deploy collectors with golang to simplify cross-repo use #3692

Open
wants to merge 10 commits into
base: tmpnet-simplify-monitoring-action
Choose a base branch
from

Conversation

maru-ava
Copy link
Contributor

@maru-ava maru-ava commented Feb 2, 2025

Why this should be merged

Previously, prometheus and promtail for collecting from local tmpnet networks were installed and launched by bash scripts. Migrating installation to nix and launch to golang simplifies reuse from subnet-evm and hypersdk. No more having to copy and maintain copies of the scripts in multiple repos.

How this works

  • migrates scripts launching prometheus and promtail to golang
  • configures collector start by via the tmpnet e2e flag --start-collectors
  • enables start and stop of collectors via tmpnetctl

How this was tested

Need to be documented in RELEASES.md?

N/A

TODO

@maru-ava maru-ava added testing This primarily focuses on testing ci This focuses on changes to the CI process labels Feb 2, 2025
@maru-ava maru-ava self-assigned this Feb 2, 2025
@maru-ava maru-ava force-pushed the tmpnet-managed-collectors branch 2 times, most recently from 59e5357 to 15c496b Compare February 2, 2025 04:57
Comment on lines 182 to 184
// TODO(marun) Figure out a way to redirect stdout and stderr of a detached child process without a bash shell
cmd := exec.Command("bash", "-c", fullCmd)
configureDetachedProcess(cmd) // Ensure the child process will outlive its parent
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe you can create the command and set Stdout and Stderr to nil directly (according to the docs)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please give it a try and get back to me, because my attempts to create a child process that outlives its parent and configured with stdout and stderr redirected to a file created and opened by that parent were entirely unsuccessful.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added a comment detailing why I took this approach, PTAL.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I may be wrong here, just remembered reading the documentation around this, so thought I'd provide the suggestion. May not behave as I expected from reading the docs (either due to a misread or incorrect docs).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Re-reading your original comment, what is the intended result of setting Stdout and Stderr to nil? I need to send the output to a file, otherwise in CI I won't be able to collect the logs for troubleshooting (from the same tmpnet dir artifacts that contain the networks).

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think that I thought you were trying to ignore the output here:

// TODO(marun) Figure out a way to redirect stdout and stderr of a detached child process without a bash shell
, but you actually wanted to write it to the specified file. I think you could still do this by setting Stdout and Stderr to the corresponding file and avoid constructing a bash command.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I attempted to do just that, but the following combination did not result in a log file that the child was writing to:

  • child process that will outlife its parent
  • child process configured with stderr and stdout set to a file opened by the parent

Base automatically changed from nix to master February 17, 2025 16:56
@maru-ava maru-ava force-pushed the tmpnet-managed-collectors branch from 15c496b to ccd3382 Compare February 22, 2025 08:20
@maru-ava maru-ava changed the base branch from master to tmpnet-simplify-monitoring-action February 22, 2025 08:20
@maru-ava maru-ava force-pushed the tmpnet-simplify-monitoring-action branch from 757b07a to 6060ccd Compare February 22, 2025 10:28
@maru-ava maru-ava force-pushed the tmpnet-managed-collectors branch from a8099ea to 34a8689 Compare February 22, 2025 10:50
@maru-ava maru-ava force-pushed the tmpnet-simplify-monitoring-action branch from 6060ccd to d857661 Compare February 22, 2025 10:51
@maru-ava maru-ava force-pushed the tmpnet-managed-collectors branch 15 times, most recently from 01300b7 to 266cdb9 Compare February 22, 2025 19:48
@maru-ava maru-ava force-pushed the tmpnet-simplify-monitoring-action branch from 0c9fe11 to b1e800e Compare February 22, 2025 19:50
@maru-ava maru-ava force-pushed the tmpnet-managed-collectors branch from 266cdb9 to 194a2d3 Compare February 22, 2025 19:52
@maru-ava maru-ava marked this pull request as ready for review February 22, 2025 19:56
@maru-ava maru-ava force-pushed the tmpnet-managed-collectors branch 3 times, most recently from 5547800 to 0790dd1 Compare February 24, 2025 13:07
@maru-ava maru-ava force-pushed the tmpnet-simplify-monitoring-action branch from b1e800e to 260259e Compare February 24, 2025 13:08
@maru-ava maru-ava force-pushed the tmpnet-managed-collectors branch 5 times, most recently from 4daa019 to 31be45a Compare February 24, 2025 13:35
loki_password: ${{ secrets.LOKI_PASSWORD || '' }}
```

The action assumes a nix flake file in the repo root that enables
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess the multiple apostrophes (') above are causing this formatting issue? I'm not inclined to try to fix this, since the above is verbatim how the action is expected to be used.

@maru-ava maru-ava force-pushed the tmpnet-managed-collectors branch from 91b64a7 to 4dce5a1 Compare February 24, 2025 15:34
func (v *FlagVars) NetworkShutdownDelay() time.Duration {
if v.delayNetworkShutdown {
if v.startCollectors {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is startCollectors replacing delayNetworkShutdown and being used in NetworkShutdownDelay() ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah ok, the network shutdown delay was added to account for a final network scrape, so we are removing the old flag and checking startCollectors to decide whether we need a non-zero network shutdown delay.

env:
LOKI_USERNAME: ${{ inputs.loki_username }}
LOKI_PASSWORD: ${{ inputs.loki_password }}
# TODO(marun) Stop emitting this annotation so that any annotation that appears can be assumed to be actionable
Copy link
Collaborator

Choose a reason for hiding this comment

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

What annotation is this referring to?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The script that this step calls creates a github actions 'annotation' that appears on the summary page of the run. But I'm thinking it does more harm than good since the only other annotations are typically warnings from actions warning of deprecations that we need to notice and respond to.

Comment on lines 182 to 184
// TODO(marun) Figure out a way to redirect stdout and stderr of a detached child process without a bash shell
cmd := exec.Command("bash", "-c", fullCmd)
configureDetachedProcess(cmd) // Ensure the child process will outlive its parent
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think that I thought you were trying to ignore the output here:

// TODO(marun) Figure out a way to redirect stdout and stderr of a detached child process without a bash shell
, but you actually wanted to write it to the specified file. I think you could still do this by setting Stdout and Stderr to the corresponding file and avoid constructing a bash command.

@maru-ava maru-ava force-pushed the tmpnet-simplify-monitoring-action branch from 260259e to af785f9 Compare February 24, 2025 21:32
Previously, prometheus and promtail were installed and launched by
with bash scripts. Migrating installation to nix and launch to golang
enables directly sharing the functionality with subnet-evm and
hypersdk. No more having to copy and maintain copies of the scripts in
multiple repos.
 - ensure started/stopped -> start/stop collectors
 - use the same helpers between collector start and node process
@maru-ava maru-ava force-pushed the tmpnet-managed-collectors branch from 4dce5a1 to 1a5222c Compare February 24, 2025 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci This focuses on changes to the CI process testing This primarily focuses on testing
Projects
Status: In Review 👀
Development

Successfully merging this pull request may close these issues.

2 participants