@@ -291,6 +291,7 @@ func (service *HTTPRestService) ReconcileIPAMState(ncReqs []*cns.CreateNetworkCo
291291 }
292292 }
293293
294+ logger .Printf ("Saved NC" )
294295 // index all the secondary IP configs for all the nc reqs, for easier lookup later on.
295296 allSecIPsIdx := make (map [string ]* cns.CreateNetworkContainerRequest )
296297 for i := range ncReqs {
@@ -299,6 +300,8 @@ func (service *HTTPRestService) ReconcileIPAMState(ncReqs []*cns.CreateNetworkCo
299300 }
300301 }
301302
303+ logger .Printf ("0" )
304+
302305 // we now need to reconcile IP assignment.
303306 // considering that a single pod may have multiple ips (such as in dual stack scenarios)
304307 // and that IP assignment in CNS (as done by requestIPConfigsHelper) does not allow
@@ -327,7 +330,10 @@ func (service *HTTPRestService) ReconcileIPAMState(ncReqs []*cns.CreateNetworkCo
327330 return types .UnexpectedError
328331 }
329332
333+ logger .Printf ("1" )
334+
330335 for podKey , podIPs := range podKeyToPodIPs {
336+ logger .Printf ("Pod is %s" , podKey )
331337 var (
332338 desiredIPs []string
333339 ncIDs []string
@@ -378,9 +384,11 @@ func (service *HTTPRestService) ReconcileIPAMState(ncReqs []*cns.CreateNetworkCo
378384 }
379385 }
380386
381- if err := service .MarkExistingIPsAsPendingRelease (nnc .Spec .IPsNotInUse ); err != nil {
382- logger .Errorf ("[Azure CNS] Error. Failed to mark IPs as pending %v" , nnc .Spec .IPsNotInUse )
383- return types .UnexpectedError
387+ if nnc != nil {
388+ if err := service .MarkExistingIPsAsPendingRelease (nnc .Spec .IPsNotInUse ); err != nil {
389+ logger .Errorf ("[Azure CNS] Error. Failed to mark IPs as pending %v" , nnc .Spec .IPsNotInUse )
390+ return types .UnexpectedError
391+ }
384392 }
385393
386394 return 0
@@ -521,16 +529,24 @@ func (service *HTTPRestService) CreateOrUpdateNetworkContainerInternal(req *cns.
521529
522530 // For now only RequestController uses this API which will be initialized only for AKS scenario.
523531 // Validate ContainerType is set as Docker
524- if service .state .OrchestratorType != cns .KubernetesCRD && service .state .OrchestratorType != cns .Kubernetes {
532+ if service .state .OrchestratorType != cns .KubernetesCRD && service .state .OrchestratorType != cns .Kubernetes && service . state . OrchestratorType != cns . KubernetesNodeSubnet {
525533 logger .Errorf ("[Azure CNS] Error. Unsupported OrchestratorType: %s" , service .state .OrchestratorType )
526534 return types .UnsupportedOrchestratorType
527535 }
528536
529- // Validate PrimaryCA must never be empty
530- err := validateIPSubnet (req .IPConfiguration .IPSubnet )
531- if err != nil {
532- logger .Errorf ("[Azure CNS] Error. PrimaryCA is invalid, NC Req: %v" , req )
533- return types .InvalidPrimaryIPConfig
537+ if req .NetworkContainerType == cns .NodeSubnet {
538+ // For NodeSubnet scenarios, Validate PrimaryCA must be empty
539+ if req .IPConfiguration .IPSubnet .IPAddress != "" {
540+ logger .Errorf ("[Azure CNS] Error. PrimaryCA is invalid, NC Req: %v" , req )
541+ return types .InvalidPrimaryIPConfig
542+ }
543+ } else {
544+ // For Swift scenarios, Validate PrimaryCA must never be empty
545+ err := validateIPSubnet (req .IPConfiguration .IPSubnet )
546+ if err != nil {
547+ logger .Errorf ("[Azure CNS] Error. PrimaryCA is invalid, NC Req: %v" , req )
548+ return types .InvalidPrimaryIPConfig
549+ }
534550 }
535551
536552 // Validate SecondaryIPConfig
0 commit comments