Skip to content

Commit

Permalink
Don't consider license invalid on 503/504 (#2650)
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielseibel1 authored Nov 1, 2023
1 parent 800f6e2 commit abd6a93
Showing 1 changed file with 9 additions and 2 deletions.
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

0 comments on commit abd6a93

Please sign in to comment.