Skip to content

Commit

Permalink
NCSFM-15209: FSS operator retries for token expiry
Browse files Browse the repository at this point in the history
  • Loading branch information
tyiying committed Feb 20, 2024
1 parent 83a46e0 commit e566a9e
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion pkg/fssclient/fssclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ func (f *FssClient) GET(path string) (int, []byte, error) {

// DELETE implements DELETE method
func (f *FssClient) DELETE(path string) (int, []byte, error) {
return f.DELETE_with_retries(path, 0)
}

// DELETE implements DELETE method with retries

Check warning on line 131 in pkg/fssclient/fssclient.go

View workflow job for this annotation

GitHub Actions / test (1.20.x, ubuntu-latest)

comment on exported method FssClient.DELETE_with_retries should be of the form "DELETE_with_retries ..."
func (f *FssClient) DELETE_with_retries(path string, nbOfRetries int) (int, []byte, error) {

Check warning on line 132 in pkg/fssclient/fssclient.go

View workflow job for this annotation

GitHub Actions / test (1.20.x, ubuntu-latest)

don't use underscores in Go names; method DELETE_with_retries should be DELETEWithRetries
err := f.GetAccessToken()
if err != nil {
return 0, nil, err
Expand All @@ -151,6 +156,13 @@ func (f *FssClient) DELETE(path string) (int, []byte, error) {
if err != nil {
return response.StatusCode, nil, err
}
if response.StatusCode == 401 {
klog.Errorf("POST API with token expiry, retry %d times", nbOfRetries)
f.accessTokenExpiry = time.Now()
if nbOfRetries < 2 {
return f.DELETE_with_retries(path, nbOfRetries + 1)
}
}
return response.StatusCode, jsonRespData, err
}

Expand Down Expand Up @@ -193,6 +205,8 @@ func (f *FssClient) POST_with_retries(path string, jsonReqData []byte, nbOfRetri
return response.StatusCode, nil, err
}
if response.StatusCode == 401 {
klog.Errorf("POST API with token expiry, retry %d times", nbOfRetries)
f.accessTokenExpiry = time.Now()
if nbOfRetries < 2 {
return f.POST_with_retries(path, jsonReqData, nbOfRetries + 1)
}
Expand Down Expand Up @@ -1030,9 +1044,11 @@ func (f *FssClient) DeleteSubnetInterface(fssWorkloadEvpnID string, fssSubnetID
return err
}
if statusCode != 204 {
klog.Errorf("Delete hostPortLabel %s failed with status=%d", hostPortLabelID, statusCode)
result = fmt.Errorf("Delete hostPortLabel failed with status=%d", statusCode)
} else {
klog.Infof("HostPortLabel %s is deleted", hostPortLabelID)
}
klog.Infof("HostPortLabel %s is deleted", hostPortLabelID)
} else {
klog.Infof("HostPortLabel %s does not exists", hostPortLabelID)
}
Expand Down

0 comments on commit e566a9e

Please sign in to comment.