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

retry for other region #315

Merged

Conversation

tnsetting2023
Copy link
Collaborator

@tnsetting2023 tnsetting2023 commented Sep 26, 2024

Description

currently vehicle command will retry commands if tesla host return 421. We want to share the same behavior for other proxied request as well.

Fixes # (issue)

Type of change

Please select all options that apply to this change:

  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Bug fix (non-breaking change which fixes an issue)
  • Documentation update

Checklist:

Confirm you have completed the following steps:

  • My code follows the style of this project.
  • I have performed a self-review of my code.
  • I have made corresponding updates to the documentation.
  • I have added/updated unit tests to cover my changes.

@tnsetting2023 tnsetting2023 force-pushed the redirect_for_other_endpoint branch 2 times, most recently from 62f4395 to ba1f786 Compare September 26, 2024 07:02
pkg/proxy/proxy.go Outdated Show resolved Hide resolved
pkg/proxy/proxy.go Outdated Show resolved Hide resolved
@tnsetting2023 tnsetting2023 force-pushed the redirect_for_other_endpoint branch 2 times, most recently from 1d04436 to a514512 Compare October 10, 2024 02:59
pkg/proxy/proxy.go Outdated Show resolved Hide resolved
pkg/proxy/proxy.go Outdated Show resolved Hide resolved
pkg/proxy/proxy.go Outdated Show resolved Hide resolved
pkg/proxy/proxy.go Outdated Show resolved Hide resolved
pkg/proxy/proxy.go Outdated Show resolved Hide resolved
@tnsetting2023 tnsetting2023 force-pushed the redirect_for_other_endpoint branch 2 times, most recently from 00bec7c to a81d234 Compare October 15, 2024 11:52
pkg/proxy/proxy.go Outdated Show resolved Hide resolved
pkg/proxy/proxy.go Outdated Show resolved Hide resolved
@tnsetting2023 tnsetting2023 merged commit 611f3d7 into teslamotors:main Oct 18, 2024
1 check passed
proxyReq.URL.Host = acct.Host
log.Debug("Forwarding request to %s", proxyReq.URL.String())
client := http.Client{}
result, err := client.Do(proxyReq)
Copy link

@elffjs elffjs Oct 18, 2024

Choose a reason for hiding this comment

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

Sorry to resurrect this but I worry this isn't going to work. This proxyReq is assigned a request body of req.Body at the start of the function on line 182, but on line 213 we drain req.Body completely, so I think we're never going to send a body here.

In testing, stuff like fleet_status is failing every time when Tesla validates the request body. Just GET-ing data is working, however.

Sorry, I should have noticed this earlier.

Copy link

@elffjs elffjs Oct 18, 2024

Choose a reason for hiding this comment

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

Maybe on line 218 we should write

		proxyReq.Body = io.NopCloser(bytes.NewBuffer(requestBody))

?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for testing this out. Indeed. the proxyReq is the real request being sent out. Will fxi it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@tnsetting2023 tnsetting2023 mentioned this pull request Oct 19, 2024
8 tasks
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.

5 participants