Skip to content

Conversation

fyuan1316
Copy link
Contributor

@fyuan1316 fyuan1316 commented May 25, 2023

Description:

Add k8s service resolver for exporter/loadbalancingexporter

The exporter/loadbalancingexporter component currently supports both static and dns resolvers, and does not currently support the ability to load balance pods when the collector application is running in a kubernetes environment. (Backends address discovery is achieved by monitoring kubernetes endpoints resources). This pr provides that capability.

Link to tracking Issue:
suitable for scenarios where services are located in a k8s cluster #18412

Testing:

Documentation:

@fyuan1316 fyuan1316 requested a review from a team May 25, 2023 10:29
@fyuan1316 fyuan1316 requested a review from jpkrohling as a code owner May 25, 2023 10:29
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented May 25, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: fyuan1316 / name: fyuan1316 (d201b41)

@fyuan1316
Copy link
Contributor Author

@codeboten Hi 😄 I submitted a pull request a few days ago and have not heard back from you, do you need more information or have another request? Thank you for your time!

@github-actions
Copy link
Contributor

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Jun 14, 2023
@fyuan1316
Copy link
Contributor Author

@jpkrohling
I would like to know if it is feasible to add a k8s resolver? If there are other better ways to support this scenario, I'd love to learn more.
I'm new here, any feedback and guidance would be greatly appreciated.

@github-actions github-actions bot removed the Stale label Jun 15, 2023
Copy link
Contributor

@codeboten codeboten left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @fyuan1316, pinging @jpkrohling as the code owner to review the code

Copy link
Member

@jpkrohling jpkrohling left a comment

Choose a reason for hiding this comment

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

This looks really cool, thank you! There are a few comments, and I couldn't test it manually as I couldn't build this due to:

go: open /home/jpkroehling/Projects/github.com/open-telemetry/opentelemetry-collector-contrib/connector/routingconnector/go.mod: no such file or directory
go: open /home/jpkroehling/Projects/github.com/open-telemetry/opentelemetry-collector-contrib/connector/routingconnector/go.mod: no such file or directory
go test -race -timeout 300s -parallel 4 --tags="" ./...
go: open /home/jpkroehling/Projects/github.com/open-telemetry/opentelemetry-collector-contrib/connector/routingconnector/go.mod: no such file or directory
make: *** [Makefile.Common:98: test] Error 1

I'll give it another try once you rebase this.

Copy link
Member

Choose a reason for hiding this comment

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

You can remove this one

Copy link
Member

Choose a reason for hiding this comment

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

If both tests are using the same value(nil), you don't need it here.

Copy link
Member

Choose a reason for hiding this comment

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

You can replace the if/else here with:

assert.Equal(t, tt.wantErr)

Copy link
Member

Choose a reason for hiding this comment

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

If this happens, you definitely want to know about. Log a warn here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done ( log warn in unsupported branch. )

Copy link
Member

Choose a reason for hiding this comment

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

Either a Background(), or something with a timeout. Same on other similar places.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Member

Choose a reason for hiding this comment

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

Instead of storing a map[string]string, you could store a map[string]bool, and set this value here to true. You'd save some space with that, while still having the semantics you need.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Member

@jpkrohling