azure-container-networking
azure-container-networking copied to clipboard
Fix CNS logs bytes when printing HNS Endpoint
This PR addresses the issue where CNS was directly logging HNS Endpoints with %+v, which resulted in printing byte arrays as raw bytes in the logs.
Changes made:
-
Updated the log statement in
configureHostNCApipaEndpointto print only relevant endpoint fields:// Old logger.Printf("[Azure CNS] Configured HostNCApipaEndpoint: %+v", endpoint) // New logger.Printf("[Azure CNS] Configured HostNCApipaEndpoint with ID: %s, Name: %s, Network: %s", endpoint.Id, endpoint.Name, endpoint.HostComputeNetwork) -
Updated the error formatting in
deleteEndpointByNameHnsV2:// Old return fmt.Errorf("Failed to delete endpoint: %+v. Error: %v", endpoint, err) // New return fmt.Errorf("Failed to delete endpoint: %s (%s). Error: %v", endpoint.Name, endpoint.Id, err) -
Updated the log statement in
deleteEndpointByNameHnsV2:// Old logger.Errorf("[Azure CNS] Successfully deleted endpoint: %+v", endpoint) // New logger.Errorf("[Azure CNS] Successfully deleted endpoint with ID: %s, Name: %s", endpoint.Id, endpoint.Name)
These changes ensure that only the relevant string fields (ID, Name, Network) are logged instead of the entire endpoint structure which contained byte arrays.
Fixes #3550.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.