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 prometheusreceiver TA/scrape_config validation logic #30135

Closed

Conversation

Aneurysm9
Copy link
Member

Description: Fixes faulty logic regarding requirement that either Prometheus scrape_configs or target allocator configuration be provided.

Testing: Tests are added that ensure valid combinations are accepted.

Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
Copy link
Member

@bogdandrutu bogdandrutu left a comment

Choose a reason for hiding this comment

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

Though, I don't agree with the overall approach of forcing this PR before the refactoring PR that showed this problem just because the author blocked the other PR, I am ok approving since this fixes a problem.

receiver/prometheusreceiver/config.go Show resolved Hide resolved
if (promConfig == nil || len(promConfig.ScrapeConfigs) == 0) && cfg.TargetAllocator == nil {
return errors.New("no Prometheus scrape_configs or target_allocator set")
}

if promConfig != nil {
Copy link
Member

Choose a reason for hiding this comment

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

I would suggest moving this to the validatePromConfig simplifies indentation.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's where it was and you told me to move it.

Copy link
Member

Choose a reason for hiding this comment

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

I told to move the following code in the config.Validate

	if (promConfig == nil || len(promConfig.ScrapeConfigs) == 0) && cfg.TargetAllocator == nil {
		return errors.New("no Prometheus scrape_configs or target_allocator set")
	}

And in this comment I asked to move in the validatePromConfig

	if promConfig == nil {
		return nil
	}

@Aneurysm9 Aneurysm9 added the ready to merge Code review completed; ready to merge by maintainers label Dec 21, 2023
Copy link
Member

@bogdandrutu bogdandrutu left a comment

Choose a reason for hiding this comment

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

Author ignored reviewer comments, please at least disagree with them, not just mark them as resolve like #30135 (comment)

if (promConfig == nil || len(promConfig.ScrapeConfigs) == 0) && cfg.TargetAllocator == nil {
return errors.New("no Prometheus scrape_configs or target_allocator set")
}

if promConfig != nil {
Copy link
Member

Choose a reason for hiding this comment

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

I told to move the following code in the config.Validate

	if (promConfig == nil || len(promConfig.ScrapeConfigs) == 0) && cfg.TargetAllocator == nil {
		return errors.New("no Prometheus scrape_configs or target_allocator set")
	}

And in this comment I asked to move in the validatePromConfig

	if promConfig == nil {
		return nil
	}

@bogdandrutu bogdandrutu removed the ready to merge Code review completed; ready to merge by maintainers label Dec 21, 2023
bogdandrutu added a commit to bogdandrutu/opentelemetry-collector-contrib that referenced this pull request Dec 22, 2023
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
bogdandrutu added a commit that referenced this pull request Dec 22, 2023
This PR is a fork from #30135 where the author did not respond to the
comments. I applied all suggestions because as a maintainer is my
responsibility to ensure we fix bugs and merge PRs.

Thanks @Aneurysm9 for the first commit.

---------

Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
Co-authored-by: Anthony J Mirabella <a9@aneurysm9.com>
@bogdandrutu
Copy link
Member

PR forked and comments fixed in #30181.

@Aneurysm9
Copy link
Member Author

@bogdandrutu I was on vacation when you took it upon yourself to fork this to make irrelevant changes. You approved the exact same code you later blocked. I took that to mean that the comments you made were not required to be addressed and they did not appear to me to be relevant or useful in light of the in-flight refactoring PR you have open. In the future if you expect that comments will lead to changes perhaps don't also indicate your approval.

@bogdandrutu
Copy link
Member

bogdandrutu commented Jan 9, 2024

@bogdandrutu I was on vacation when you took it upon yourself to fork this to make irrelevant changes.

I would kindly ask you to avoid calling changes asked by peers/reviewers as "irrelevant".

You approved the exact same code you later blocked.

I did approve the change with some comments, for me that means that I trust you will resolve the comments, but they are not significant to require a new review.

I took that to mean that the comments you made were not required to be addressed and they did not appear to me to be relevant or useful in light of the in-flight #29901 you have open. In the future if you expect that comments will lead to changes perhaps don't also indicate your approval.

Thank you for your feedback, I will not approve in the future any PR until all comments are reviewed (with other approvers/maintainers I assume that they will understand myself as I want this changes, but I trust them to do the changes and because they are simple enough I don't need a re-review).

cparkins pushed a commit to AmadeusITGroup/opentelemetry-collector-contrib that referenced this pull request Jan 10, 2024
…try#30181)

This PR is a fork from open-telemetry#30135 where the author did not respond to the
comments. I applied all suggestions because as a maintainer is my
responsibility to ensure we fix bugs and merge PRs.

Thanks @Aneurysm9 for the first commit.

---------

Signed-off-by: Anthony J Mirabella <a9@aneurysm9.com>
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
Co-authored-by: Anthony J Mirabella <a9@aneurysm9.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
receiver/prometheus Prometheus receiver
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants