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

[ACC-426] Don't consider license invalid on 503/504 #2650

Merged
merged 1 commit into from
Nov 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions pro/license.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,15 @@ func validateLicenseKey(encryptedData []byte, publicKey *[32]byte) ([]byte, erro
slog.Warn("proceeding with cached response, Netmaker API may be down")
} else {
defer validateResponse.Body.Close()
if validateResponse.StatusCode != 200 {
return nil, fmt.Errorf("could not validate license, got status code %d", validateResponse.StatusCode)
if validateResponse.StatusCode != http.StatusOK {
err := fmt.Errorf("could not validate license, got status code %d", validateResponse.StatusCode)
// if it's a temp error, just log it, don't consider license invalid
if validateResponse.StatusCode == http.StatusServiceUnavailable ||
validateResponse.StatusCode == http.StatusGatewayTimeout {
slog.Warn(err.Error())
return nil, nil
}
return nil, err
} // if you received a 200 cache the response locally

body, err = io.ReadAll(validateResponse.Body)
Expand Down