Skip to content

Conversation

mugeshsp
Copy link

Reason for Change:
This PR implements a comprehensive DeleteEndpointState API in CNS (Container Network Service) to improve endpoint lifecycle management in stateless CNI scenarios. The changes include creating the Delete Endpoint State API, handler, and helper functions, along with integrating the functionality into the network manager with proper validation for FrontendNIC scenarios.

Requirements:

Notes:

  • feat: Add conditional check for NIC type (FrontendNic) - Enhanced the deletion of state file logic to specifically target
  • NodeNetworkInterfaceFrontendNIC types, ensuring only appropriate endpoints are cleaned up through the CNS API
  • Added DeleteEndpointState method to enable HTTP DELETE requests to the CNS endpoint API
  • Implemented DeleteEndpointStateHandler and DeleteEndpointStateHelper and to handle HTTP DELETE requests for endpoint cleanup
  • Tested and confirmed that the deletion of endpoints takes place in the environment

@mugeshsp mugeshsp requested a review from behzad-mir October 13, 2025 23:19
@mugeshsp mugeshsp self-assigned this Oct 13, 2025
@mugeshsp mugeshsp requested review from a team as code owners October 13, 2025 23:19
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements a comprehensive DeleteEndpointState API in CNS (Container Network Service) to improve endpoint lifecycle management in stateless CNI scenarios. The implementation includes creating the Delete Endpoint State API, handler, and helper functions, along with integrating the functionality into the network manager with proper validation for FrontendNIC scenarios.

  • Added conditional endpoint deletion logic in network manager for FrontendNIC types
  • Implemented HTTP DELETE endpoint handler and helper functions in CNS REST server
  • Created client-side DeleteEndpointState method to support HTTP DELETE requests

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
network/manager.go Added conditional endpoint deletion logic for FrontendNIC types in stateless CNI mode
cns/restserver/ipam.go Implemented DeleteEndpointStateHandler and helper functions with merge conflict markers
cns/client/client.go Added DeleteEndpointState client method for HTTP DELETE requests
Comments suppressed due to low confidence (1)

cns/restserver/ipam.go:1

  • Git merge conflict markers are present in the code. These need to be resolved by removing the conflict markers and keeping the appropriate code sections.
// Copyright 2017 Microsoft. All rights reserved.

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +1414 to +1421
// 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) //nolint:staticcheck // reason: using deprecated call until migration to new API
// Continue with deletion even if decode fails, as ipInfo might not be needed
}

Copy link

Copilot AI Oct 13, 2025

Choose a reason for hiding this comment

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

The code decodes a request body for a DELETE operation but then ignores any decode errors and doesn't use the decoded data. Since DELETE operations typically don't require a request body and the endpointID is extracted from the URL path, this decode logic should be removed.

Suggested change
// 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) //nolint:staticcheck // reason: using deprecated call until migration to new API
// Continue with deletion even if decode fails, as ipInfo might not be needed
}

Copilot uses AI. Check for mistakes.

@mugeshsp mugeshsp removed their assignment Oct 14, 2025
@rbtr
Copy link
Collaborator

rbtr commented Oct 15, 2025

is this AI generated? the copilot comment is exactly the description - it usually summarizes differently

Pull Request Overview
This PR implements a comprehensive DeleteEndpointState API in CNS (Container Network Service) to improve endpoint lifecycle management in stateless CNI scenarios.

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.

2 participants