-
Notifications
You must be signed in to change notification settings - Fork 259
Fix: Delete State From State File (FrontendNIC) #3927
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
Changes from 3 commits
79f3d9a
5d11688
62fa905
5f4f13a
de798b6
5471e5a
d8799cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -1123,6 +1123,8 @@ | |||||||
| service.GetEndpointHandler(w, r) | ||||||||
| case http.MethodPatch: | ||||||||
| service.UpdateEndpointHandler(w, r) | ||||||||
| case http.MethodDelete: | ||||||||
| service.DeleteEndpointStateHandler(w, r) | ||||||||
| default: | ||||||||
| logger.Errorf("[EndpointHandlerAPI] EndpointHandler API expect http Get or Patch method") | ||||||||
| } | ||||||||
|
|
@@ -1327,3 +1329,69 @@ | |||||||
| } | ||||||||
| return nil | ||||||||
| } | ||||||||
|
|
||||||||
| func (service *HTTPRestService) DeleteEndpointStateHandler(w http.ResponseWriter, r *http.Request) { | ||||||||
| opName := "DeleteEndpointStateHandler" | ||||||||
| logger.Printf("[DeleteEndpointStateHandler] DeleteEndpointState for %s", r.URL.Path) | ||||||||
|
Check failure on line 1335 in cns/restserver/ipam.go
|
||||||||
| endpointID := strings.TrimPrefix(r.URL.Path, cns.EndpointPath) | ||||||||
|
|
||||||||
| if service.EndpointStateStore == nil { | ||||||||
| response := cns.Response{ | ||||||||
| ReturnCode: types.UnexpectedError, | ||||||||
| Message: fmt.Sprintf("[DeleteEndpointStateHandler] EndpointStateStore is not initialized"), | ||||||||
|
Check failure on line 1341 in cns/restserver/ipam.go
|
||||||||
| } | ||||||||
| err := common.Encode(w, &response) | ||||||||
| logger.Response(opName, response, response.ReturnCode, err) | ||||||||
|
Check failure on line 1344 in cns/restserver/ipam.go
|
||||||||
| return | ||||||||
| } | ||||||||
|
|
||||||||
| // Decode the request body to get ipInfo if needed | ||||||||
| var req map[string]*IPInfo | ||||||||
| err := common.Decode(w, r, &req) | ||||||||
| if err != nil { | ||||||||
| logger.Printf("[DeleteEndpointStateHandler] Failed to decode request body: %v", err) | ||||||||
|
Check failure on line 1352 in cns/restserver/ipam.go
|
||||||||
| // Continue with deletion even if decode fails, as ipInfo might not be needed | ||||||||
| } | ||||||||
|
|
||||||||
| // Delete the endpoint from state | ||||||||
| err = service.DeleteEndpointStateHelper(endpointID) | ||||||||
|
||||||||
| err = service.DeleteEndpointStateHelper(endpointID) | |
| // Delete the endpoint from state | |
| err := service.DeleteEndpointStateHelper(endpointID) |
Check failure on line 1364 in cns/restserver/ipam.go
GitHub Actions / Lint (1.23.x, ubuntu-latest)
SA1019: logger.Response is deprecated: The global logger is deprecated. Migrate to zap using the cns/logger/v2 package and pass the logger instead. (staticcheck)
Check failure on line 1364 in cns/restserver/ipam.go
GitHub Actions / Lint (1.22.x, ubuntu-latest)
SA1019: logger.Response is deprecated: The global logger is deprecated. Migrate to zap using the cns/logger/v2 package and pass the logger instead. (staticcheck)
Check failure on line 1364 in cns/restserver/ipam.go
GitHub Actions / Lint (1.23.x, windows-latest)
SA1019: logger.Response is deprecated: The global logger is deprecated. Migrate to zap using the cns/logger/v2 package and pass the logger instead. (staticcheck)
Check failure on line 1373 in cns/restserver/ipam.go
GitHub Actions / Lint (1.23.x, ubuntu-latest)
SA1019: logger.Response is deprecated: The global logger is deprecated. Migrate to zap using the cns/logger/v2 package and pass the logger instead. (staticcheck)
Check failure on line 1373 in cns/restserver/ipam.go
GitHub Actions / Lint (1.22.x, ubuntu-latest)
SA1019: logger.Response is deprecated: The global logger is deprecated. Migrate to zap using the cns/logger/v2 package and pass the logger instead. (staticcheck)
Check failure on line 1373 in cns/restserver/ipam.go
GitHub Actions / Lint (1.23.x, windows-latest)
SA1019: logger.Response is deprecated: The global logger is deprecated. Migrate to zap using the cns/logger/v2 package and pass the logger instead. (staticcheck)
Check failure on line 1380 in cns/restserver/ipam.go
GitHub Actions / Lint (1.23.x, ubuntu-latest)
SA1019: logger.Printf is deprecated: The global logger is deprecated. Migrate to zap using the cns/logger/v2 package and pass the logger instead. (staticcheck)
Check failure on line 1380 in cns/restserver/ipam.go
GitHub Actions / Lint (1.22.x, ubuntu-latest)
SA1019: logger.Printf is deprecated: The global logger is deprecated. Migrate to zap using the cns/logger/v2 package and pass the logger instead. (staticcheck)
Check failure on line 1380 in cns/restserver/ipam.go
GitHub Actions / Lint (1.23.x, windows-latest)
SA1019: logger.Printf is deprecated: The global logger is deprecated. Migrate to zap using the cns/logger/v2 package and pass the logger instead. (staticcheck)
Check failure on line 1383 in cns/restserver/ipam.go
GitHub Actions / Lint (1.23.x, ubuntu-latest)
SA1019: logger.Printf is deprecated: The global logger is deprecated. Migrate to zap using the cns/logger/v2 package and pass the logger instead. (staticcheck)
Check failure on line 1383 in cns/restserver/ipam.go
GitHub Actions / Lint (1.22.x, ubuntu-latest)
SA1019: logger.Printf is deprecated: The global logger is deprecated. Migrate to zap using the cns/logger/v2 package and pass the logger instead. (staticcheck)
Check failure on line 1383 in cns/restserver/ipam.go
GitHub Actions / Lint (1.23.x, windows-latest)
SA1019: logger.Printf is deprecated: The global logger is deprecated. Migrate to zap using the cns/logger/v2 package and pass the logger instead. (staticcheck)
Check failure on line 1384 in cns/restserver/ipam.go
GitHub Actions / Lint (1.23.x, ubuntu-latest)
do not define dynamic errors, use wrapped static errors instead: "fmt.Errorf(\"[deleteEndpointState] endpoint %s does not exist in the statefile\", endpointID)" (err113)
Check failure on line 1384 in cns/restserver/ipam.go
GitHub Actions / Lint (1.22.x, ubuntu-latest)
do not define dynamic errors, use wrapped static errors instead: "fmt.Errorf(\"[deleteEndpointState] endpoint %s does not exist in the statefile\", endpointID)" (err113)
Check failure on line 1384 in cns/restserver/ipam.go
GitHub Actions / Lint (1.23.x, windows-latest)
do not define dynamic errors, use wrapped static errors instead: "fmt.Errorf(\"[deleteEndpointState] endpoint %s does not exist in the statefile\", endpointID)" (err113)
Check failure on line 1384 in cns/restserver/ipam.go
GitHub Actions / Lint (1.22.x, windows-latest)
do not define dynamic errors, use wrapped static errors instead: "fmt.Errorf(\"[deleteEndpointState] endpoint %s does not exist in the statefile\", endpointID)" (err113)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please address the Lint erros in the PR