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

hcloud discovery: Add testcase for key only labels #9028

Merged
merged 5 commits into from
Jul 2, 2021

Conversation

LKaemmerling
Copy link
Contributor

This adds a test case for the hcloud discovery with key only labels.

Key Only Labels should already be possible as they are returned from the hcloud API {"key":""}

Fixes #9023

Signed-off-by: Lukas Kämmerling <lukas.kaemmerling@hetzner-cloud.de>
Signed-off-by: Lukas Kämmerling <lukas.kaemmerling@hetzner-cloud.de>
@roidelapluie
Copy link
Member

This should be a new label, which is there for all the labels.

@roidelapluie
Copy link
Member

(the new label should have labelpresent instead of label), see kubernetes_sd doc.

Signed-off-by: Lukas Kämmerling <lukas.kaemmerling@hetzner-cloud.de>
@LKaemmerling
Copy link
Contributor Author

(the new label should have labelpresent instead of label), see kubernetes_sd doc.

@roidelapluie i changed it, thank you!

Copy link
Member

@roidelapluie roidelapluie left a comment

Choose a reason for hiding this comment

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

Thanks! It should be for every label.

discovery/hetzner/hcloud.go Outdated Show resolved Hide resolved
docs/configuration/configuration.md Outdated Show resolved Hide resolved
@LKaemmerling
Copy link
Contributor Author

@roidelapluie changed :)

presentLabel := model.LabelName(hetznerLabelHcloudLabelPresent + strutil.SanitizeLabelName(labelKey))
labels[presentLabel] = model.LabelValue("true")
if labelValue == "" {
label := model.LabelName(hetznerLabelHcloudLabel + strutil.SanitizeLabelName(labelKey))
Copy link
Member

Choose a reason for hiding this comment

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

this if should go away. We should have the label for every hcloud label.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This doesn't make sense, why should the label be there if prometheus skips it at all?

Copy link
Member

Choose a reason for hiding this comment

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

ooh it is the normal label :)

Any way works, I just prefer less if branches.

@roidelapluie
Copy link
Member

I guess the tests should fail and you will need to rebase to fix the DCO.

Thanks!

Signed-off-by: Lukas Kämmerling <lukas.kaemmerling@hetzner-cloud.de>
Copy link
Member

@roidelapluie roidelapluie left a comment

Choose a reason for hiding this comment

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

Last nits: Can you remove the if branch, and add another (filled) label in the tests?

@LKaemmerling
Copy link
Contributor Author

@roidelapluie i added this case :)

Signed-off-by: Lukas Kämmerling <lukas.kaemmerling@hetzner-cloud.de>
@roidelapluie roidelapluie merged commit 263847e into prometheus:main Jul 2, 2021
@roidelapluie
Copy link
Member

Thanks!

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.

Hetzner discovery doesn't discover labels with empty values.
2 participants