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

fix monitor to only start the monitor in json format when requested #10358

Merged
merged 3 commits into from
Jun 7, 2021

Conversation

dhiaayachi
Copy link
Collaborator

when starting a new monitor we were starting (in case of json monitor) a json monitor and then overwrite it with a line monitor.
This will start one or the other.
Fix #10357

@github-actions github-actions bot added the theme/cli Flags and documentation for the CLI interface label Jun 7, 2021
@dhiaayachi dhiaayachi requested a review from a team June 7, 2021 14:54
@dhiaayachi dhiaayachi added type/bug Feature does not function as expected and removed type/bug Feature does not function as expected labels Jun 7, 2021
@vercel vercel bot temporarily deployed to Preview – consul-ui-staging June 7, 2021 15:00 Inactive
@vercel vercel bot temporarily deployed to Preview – consul June 7, 2021 15:00 Inactive
@dnephin dnephin added backport/1.10 type/bug Feature does not function as expected labels Jun 7, 2021
Copy link
Contributor

@dnephin dnephin left a comment

Choose a reason for hiding this comment

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

LGTM!

@vercel vercel bot temporarily deployed to Preview – consul June 7, 2021 15:52 Inactive
@vercel vercel bot temporarily deployed to Preview – consul-ui-staging June 7, 2021 15:52 Inactive
@dhiaayachi dhiaayachi merged commit dda3e68 into master Jun 7, 2021
@dhiaayachi dhiaayachi deleted the dhia/monitor-json-fix branch June 7, 2021 16:08
Comment on lines +179 to +180
case ret := <-exitCode:
if ret != 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

There are two goroutines sending to this chan, but this only checks the return value once, which seems like it could easily pass even when one of the goroutines fails.

Instead of running the assertion in a goroutine, could we use a bufio.Scanner in the main thread? We could then read lines, and assert some number of log lines is json encoded. Once it successfully we can shutdown the agent and goroutines.

Maybe we'll need to run another goroutine to perform a couple operations to ensure that the agent is producing logs.


// Read the logs and try to json marshall it
go func() {
time.Sleep(1 * time.Second)
Copy link
Contributor

Choose a reason for hiding this comment

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

Generally I try to avoid any sleeps in a test, and 1 second is a pretty long sleep. I think with the suggestion below we can remove this sleep.

@hc-github-team-consul-core
Copy link
Collaborator

🍒 If backport labels were added before merging, cherry-picking will start automatically.

To retroactively trigger a backport after merging, add backport labels and re-run https://circleci.com/gh/hashicorp/consul/381703.

@hc-github-team-consul-core
Copy link
Collaborator

🍒✅ Cherry pick of commit dda3e68 onto release/1.10.x succeeded!

hc-github-team-consul-core pushed a commit that referenced this pull request Jun 7, 2021
…10358)

* fix monitor to only start the monitor in json format when requested

* add release notes

* add test to validate json format when requested
hc-github-team-consul-core pushed a commit that referenced this pull request Jun 7, 2021
…10358)

* fix monitor to only start the monitor in json format when requested

* add release notes

* add test to validate json format when requested
@hc-github-team-consul-core
Copy link
Collaborator

🍒✅ Cherry pick of commit dda3e68 onto release/1.9.x succeeded!

@hc-github-team-consul-core
Copy link
Collaborator

🍒✅ Cherry pick of commit dda3e68 onto release/1.8.x succeeded!

hc-github-team-consul-core pushed a commit that referenced this pull request Jun 7, 2021
…10358)

* fix monitor to only start the monitor in json format when requested

* add release notes

* add test to validate json format when requested
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme/cli Flags and documentation for the CLI interface type/bug Feature does not function as expected
Projects
None yet
Development

Successfully merging this pull request may close these issues.

consul monitor log-json do not produce json format logs
3 participants