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: prometheus input plugin run outside k8s cluster err #9960

Closed
wants to merge 1 commit into from

Conversation

yahaa
Copy link
Contributor

@yahaa yahaa commented Oct 20, 2021

Required for all PRs:

resolves #

fix prometheus input plugin run outside k8s cluster err.

@telegraf-tiger
Copy link
Contributor

Thanks so much for the pull request!
🤝 ✒️ Just a reminder that the CLA has not yet been signed, and we'll need it before merging. Please sign the CLA when you get a chance, then post a comment here saying !signed-cla

@telegraf-tiger telegraf-tiger bot added the fix pr to fix corresponding bug label Oct 20, 2021
@telegraf-tiger
Copy link
Contributor

Thanks so much for the pull request!
🤝 ✒️ Just a reminder that the CLA has not yet been signed, and we'll need it before merging. Please sign the CLA when you get a chance, then post a comment here saying !signed-cla

@yahaa
Copy link
Contributor Author

yahaa commented Oct 20, 2021

!signed-cla

@yahaa yahaa changed the title fix prometheus input plugin run outside k8s cluster err fix: prometheus input plugin run outside k8s cluster err Oct 20, 2021
@yahaa yahaa force-pushed the fix-prometheus-input-plugin branch 2 times, most recently from bc0f232 to e07fb44 Compare October 20, 2021 08:30
@sspaink
Copy link
Contributor

sspaink commented Oct 20, 2021

@yahaa thanks for the pull request, can you add more detail on the error this is trying to resolve?
I noticed you resolved the issue where watcher is being called before the error is checked, so that is great.

The CI is failing because github.com/imdario/mergo and github.com/spf13/pflag aren't in the right place in the LICENSE_OF_DEPENDENCIES.md it is kind of picky, it needs to be in alphabetical order.

@yahaa
Copy link
Contributor Author

yahaa commented Oct 21, 2021

@yahaa thanks for the pull request, can you add more detail on the error this is trying to resolve? I noticed you resolved the issue where watcher is being called before the error is checked, so that is great.

The CI is failing because github.com/imdario/mergo and github.com/spf13/pflag aren't in the right place in the LICENSE_OF_DEPENDENCIES.md it is kind of picky, it needs to be in alphabetical order.

The first one, when we run telegra in outside of a kubernetes cluster the line config, err := rest.InClusterConfig() will be always get an error.

The second one, the method of getting rest.Config instance in loadClient function will be cause kubernetes client has error materURL, and this error can be reproduced by using the following UT:

// add this UT into plugins/inputs/prometheus/kubernetes_test.go
func TestLoadClient(t *testing.T) {
	kubeconfig := "/path_to_your_kubeconfig"
	client, err := loadClient(kubeconfig)
	if err != nil {
		t.Errorf("got err: %v", err)
		return
	}

	watcher, err := client.CoreV1().Pods("kube-system").Watch(context.TODO(), metav1.ListOptions{
		LabelSelector: "app=debug",
	})
	if err != nil {
		t.Errorf("watch pod got err: %v", err)
		return
	}
	defer watcher.Stop()
}

this UT can got watch pod got err: Get "http://localhost/api/v1/namespaces/kube-system/pods?labelSelector=app%3Ddebug&watch=true": dial tcp 127.0.0.1:80: connect: connection refused error.

@yahaa yahaa force-pushed the fix-prometheus-input-plugin branch from e07fb44 to 5addf2b Compare October 21, 2021 02:45
@yahaa
Copy link
Contributor Author

yahaa commented Oct 22, 2021

@sspaink Please help me review this PR, thanks!

Copy link
Contributor

@powersj powersj left a comment

Choose a reason for hiding this comment

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

Hi,

Thanks for this PR! If you are still interested in landing this, can you please rebase this on master, resolve the conflicts, and answer my question about the check-deps changes?

Thanks!


grep '^-' docs/LICENSE_OF_DEPENDENCIES.md | grep -v github.com/DataDog/datadog-agent | cut -f 2 -d' ' > "${tmpdir}/LICENSE_OF_DEPENDENCIES.md"
grep '^-' docs/LICENSE_OF_DEPENDENCIES.md | grep -v github.com/DataDog/datadog-agent | cut -f 2 -d' ' | sort -n > "${tmpdir}/LICENSE_OF_DEPENDENCIES.md"
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are these changes required for this PR? Seems odd to sort numerically.

Copy link
Contributor Author

@yahaa yahaa Nov 12, 2021

Choose a reason for hiding this comment

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

Ok, Thanks for your feedback, i have rebase and resolve the conflicts.

It is difficult to add github.com/imdario/mergo and github.com/spf13/pflag in the right place in the LICENSE_OF_DEPENDENCIES.md because we need to ensure it in alphabetical order.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm go mod tidy did not handle that for you? I am still seeing a conflict.

Copy link
Contributor

Choose a reason for hiding this comment

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

@yahaa I'd prefer if we kept the dependency licenses in alphabetical order opposed to numerical, would you mind removing this change? We could always consider this in a separate pull request.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@yahaa I'd prefer if we kept the dependency licenses in alphabetical order opposed to numerical, would you mind removing this change? We could always consider this in a separate pull request.

Sorry, forgot to reply you. I also think a single pr would be better.

@yahaa yahaa force-pushed the fix-prometheus-input-plugin branch from 5addf2b to cfd8046 Compare November 12, 2021 08:52
@yahaa yahaa force-pushed the fix-prometheus-input-plugin branch from cfd8046 to 598438c Compare November 12, 2021 09:07
@yahaa yahaa requested a review from powersj November 12, 2021 09:21
@telegraf-tiger
Copy link
Contributor

@yahaa yahaa force-pushed the fix-prometheus-input-plugin branch from 88129a5 to 598438c Compare November 16, 2021 03:39
@sspaink sspaink added the waiting for response waiting for response from contributor label Jun 21, 2022
@yahaa yahaa closed this Jul 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix pr to fix corresponding bug waiting for response waiting for response from contributor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants