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

feature: [vmagent] Add service discovery support for OVH Cloud VPS and dedicated server #6160

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jiekun
Copy link
Contributor

@jiekun jiekun commented Apr 20, 2024

Describe Your Changes

related issue: #6071

Added

  • Added service discovery support for OVH Cloud:
    • VPS.
    • Dedicated server.

Docs

  • CHANGELOG.md, sd_configs.md, vmagent.md are updated.

Note

Tested on OVH Cloud VPS and dedicated server.
image

image

Checklist
The following checks are mandatory:

Copy link

codecov bot commented Apr 20, 2024

Codecov Report

Attention: Patch coverage is 64.85507% with 97 lines in your changes are missing coverage. Please review.

Project coverage is 57.22%. Comparing base (8aaa828) to head (ac36e20).
Report is 726 commits behind head on master.

Files Patch % Lines
lib/promscrape/discovery/ovhcloud/common.go 62.50% 21 Missing and 3 partials ⚠️
.../promscrape/discovery/ovhcloud/dedicated_server.go 69.33% 12 Missing and 11 partials ⚠️
lib/promscrape/discovery/ovhcloud/vps.go 74.07% 11 Missing and 10 partials ⚠️
lib/promscrape/discovery/ovhcloud/ovhcloud.go 31.25% 10 Missing and 1 partial ⚠️
lib/promscrape/discovery/ovhcloud/api.go 68.75% 5 Missing and 5 partials ⚠️
lib/promscrape/config.go 0.00% 7 Missing ⚠️
lib/promscrape/scraper.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6160      +/-   ##
==========================================
- Coverage   60.37%   57.22%   -3.15%     
==========================================
  Files         411      609     +198     
  Lines       76609    81208    +4599     
==========================================
+ Hits        46253    46475     +222     
- Misses      27794    31544    +3750     
- Partials     2562     3189     +627     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@hagen1778
Copy link
Collaborator

Hello @jiekun! Sorry for late response( Could you please rebase your PR on top of master branch?

Signed-off-by: Jiekun <jiekun.dev@gmail.com>
@jiekun
Copy link
Contributor Author

jiekun commented May 22, 2024

Thank you for your attention. I've just rebased it.

Copy link
Collaborator

@hagen1778 hagen1778 left a comment

Choose a reason for hiding this comment

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

LGTM!
A few minor comments

ok bool
)
if apiServer, ok = availableEndpoints[sdc.Endpoint]; !ok {
return nil, fmt.Errorf("unsupported endpoint for ovhcloud sd: %s", sdc.Endpoint)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shall we point user to the docs with available endpoints?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure


timeDelta, err := getTimeDelta(cfg)
if err != nil {
return nil, err
Copy link
Collaborator

Choose a reason for hiding this comment

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

please add context to this error

Copy link
Contributor Author

@jiekun jiekun May 23, 2024

Choose a reason for hiding this comment

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

I would like to add context in getServerTime function, and log all possible errors it in upper level getAuthHeaders, wdyt?

"time"
)

func getAuthHeaders(cfg *apiConfig, headers http.Header, endpoint, path string) (http.Header, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It doesn't seem that any caller of this func checks for the error. Is this intended?

Copy link
Contributor Author

@jiekun jiekun May 23, 2024

Choose a reason for hiding this comment

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

This error should have been checked, and the SD HTTP request should be canceled.

However, it appears that GetAPIResponseWithReqParams does not consider the error from RequestCallback func(req *http.Request). As a result, it sends out the service discovery request without the appropriate Auth Headers.

I am returning an error in getAuthHeaders and expecting it to be checked. Should we add a #TODO here or find a way to stop the SD request?


Edit:

return &serverTime, nil
}

func getTimeDelta(cfg *apiConfig) (time.Duration, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would you mind adding a comment explaining that delta should be calculated only once?

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


}

// ParseIPList parses ip list as they can have different formats.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// ParseIPList parses ip list as they can have different formats.


// dedicatedServer struct from API.
// IP addresses are fetched independently.
type dedicatedServer struct {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would be great to have link to the OVH docs with response fields

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Docs are already presented in getVPSDetails and getDedicatedServerDetails. Since multiple APIs are involved, I believe it would be beneficial to provide links to the most important one, as well as the getXxxDetails methods, so developers can easily access and review.

)

// vpsModel struct from API.
type vpsModel struct {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would be great to have link to the OVH docs with response fields

Copy link
Contributor Author

Choose a reason for hiding this comment

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

same as above

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.

None yet

2 participants