Skip to content

Commit

Permalink
check if ipv4Addr or ipv6Addr is empty before calling AnnotatePod() (#…
Browse files Browse the repository at this point in the history
…2702)

Co-authored-by: Zach Dorame-Barajas <doramebz@amazon.com>
  • Loading branch information
zachdorame and zachdorame committed Dec 14, 2023
1 parent a9ef991 commit 3c97b82
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions pkg/ipamd/rpc_handler.go
Expand Up @@ -203,9 +203,16 @@ func (s *server) AddNetwork(ctx context.Context, in *rpc.AddNetworkRequest) (*rp

if s.ipamContext.enablePodIPAnnotation {
// On ADD, we pass empty string as there is no IP being released
err = s.ipamContext.AnnotatePod(in.K8S_POD_NAME, in.K8S_POD_NAMESPACE, vpccniPodIPKey, ipv4Addr, "")
if err != nil {
log.Errorf("Failed to add the pod annotation: %v", err)
if ipv4Addr != "" {
err = s.ipamContext.AnnotatePod(in.K8S_POD_NAME, in.K8S_POD_NAMESPACE, vpccniPodIPKey, ipv4Addr, "")
if err != nil {
log.Errorf("Failed to add the pod annotation: %v", err)
}
} else if ipv6Addr != "" {
err = s.ipamContext.AnnotatePod(in.K8S_POD_NAME, in.K8S_POD_NAMESPACE, vpccniPodIPKey, ipv6Addr, "")
if err != nil {
log.Errorf("Failed to add the pod annotation: %v", err)
}
}
}
resp := rpc.AddNetworkReply{
Expand Down

0 comments on commit 3c97b82

Please sign in to comment.