Skip to content

Commit

Permalink
fix: make statless CNI to return an empty state when CNI GET API is … (
Browse files Browse the repository at this point in the history
…#2921)

feat: make statless CNI to return an empty state when CNI GET API is invoked
  • Loading branch information
behzad-mir authored Aug 15, 2024
1 parent 9ff0bac commit bd5535e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions cni/network/stateless/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"time"

"github.com/Azure/azure-container-networking/cni"
"github.com/Azure/azure-container-networking/cni/api"
zapLog "github.com/Azure/azure-container-networking/cni/log"
"github.com/Azure/azure-container-networking/cni/network"
"github.com/Azure/azure-container-networking/common"
Expand Down Expand Up @@ -127,6 +128,19 @@ func rootExecute() error {
panic("network plugin start fatal error")
}
}
// dump an empty state in case the API is called for StateMigration or InitilizeCNS from CNI State
if cniCmd == cni.CmdGetEndpointsState {
logger.Debug("returning an empty state")
simpleState := api.AzureCNIState{
ContainerInterfaces: make(map[string]api.PodNetworkInterfaceInfo),
}
err = simpleState.PrintResult()
if err != nil {
logger.Error("Failed to print state result to stdout", zap.Error(err))
}

return errors.Wrap(err, "Get cni state printresult error")
}

if cniCmd == cni.CmdVersion {
return errors.Wrap(err, "Execute netplugin failure")
Expand Down

0 comments on commit bd5535e

Please sign in to comment.