@@ -5,7 +5,6 @@ package oob
55
66import (
77 "context"
8- "encoding/hex"
98 "encoding/json"
109 "fmt"
1110 "net"
@@ -90,7 +89,7 @@ func (k K8sClient) getIp(
9089 if len (subnetNames ) == 0 {
9190 return nil , errors .New ("No OOB subnets found" )
9291 } else {
93- log .Infof ("%d OOB subnets found: %s" , len (subnetNames ), strings .Join (subnetNames , " " ))
92+ log .Debugf ("%d OOB subnets found: %s" , len (subnetNames ), strings .Join (subnetNames , " " ))
9493 subnetMatch := false
9594 for _ , subnetName := range subnetNames {
9695 subnet , err := k .getMatchingSubnet (subnetName , ipaddr )
@@ -100,7 +99,7 @@ func (k K8sClient) getIp(
10099 if subnet == nil {
101100 continue
102101 }
103- log .Infof ("Selecting subnet %s/%s" , k .Namespace , subnetName )
102+ log .Debugf ("Selecting subnet %s/%s" , k .Namespace , subnetName )
104103 subnetMatch = true
105104
106105 ipamIP , err = k .prepareCreateIpamIP (subnetName , macKey )
@@ -241,7 +240,7 @@ func (k K8sClient) doCreateIpamIP(
241240 } else {
242241 ipamIP , err = k .waitForCreation (ipamIP )
243242 if err != nil {
244- return nil , fmt .Errorf ("failed to create IP %s/%s: %w" , ipamIP . Namespace , ipamIP . Name , err )
243+ return nil , fmt .Errorf ("failed to create IP %w" , err )
245244 } else {
246245 log .Infof ("New IP %s (%s/%s) created in subnet %s" , ipamIP .Status .Reserved .String (),
247246 ipamIP .Namespace , ipamIP .Name , ipamIP .Spec .Subnet .Name )
@@ -321,7 +320,7 @@ func (k K8sClient) waitForCreation(ipamIP *ipamv1alpha1.IP) (*ipamv1alpha1.IP, e
321320 }
322321 }
323322 }
324- return ipamIP , errors .New ("Timeout reached, IP not created" )
323+ return nil , errors .New ("Timeout reached, IP not created" )
325324}
326325
327326func (k K8sClient ) getOOBNetworks (subnetType ipamv1alpha1.SubnetAddressType ) []string {
@@ -334,12 +333,10 @@ func (k K8sClient) getOOBNetworks(subnetType ipamv1alpha1.SubnetAddressType) []s
334333 if err != nil {
335334 log .Errorf ("Error listing OOB subnets: %v" , err )
336335 }
337- fmt .Printf ("OobLabel: %s" , k .OobLabel )
338- fmt .Printf ("subnet-list: %v" , subnetList )
336+
339337 oobSubnetNames := []string {}
340338 for _ , subnet := range subnetList .Items {
341339 if subnet .Status .Type == subnetType {
342- fmt .Printf ("subnet-names: %s" , subnet .Name )
343340 oobSubnetNames = append (oobSubnetNames , subnet .Name )
344341 }
345342 }
@@ -360,18 +357,11 @@ func (k K8sClient) getMatchingSubnet(subnetName string, ipaddr net.IP) (*ipamv1a
360357 return nil , fmt .Errorf ("failed to get subnet %s/%s: %w" , k .Namespace , subnetName , err )
361358 }
362359 if apierrors .IsNotFound (err ) {
363- log .Infof ("Cannot select subnet %s/%s, does not exist" , k .Namespace , subnetName )
360+ log .Debugf ("Cannot select subnet %s/%s, does not exist" , k .Namespace , subnetName )
364361 return nil , nil
365362 }
366363 if ! checkIPInCIDR (ipaddr , existingSubnet .Status .Reserved .String ()) && ipaddr .String () != UNKNOWN_IP {
367- log .Infof ("Cannot select subnet %s/%s, CIDR mismatch, subnet reserved: %s, ipaddr: %s" , k .Namespace , subnetName , existingSubnet .Status .Reserved .String (), ipaddr .String ())
368- log .Infof ("IP Type: %T, Value: %v" , ipaddr , ipaddr )
369- decodedIP , err := hex .DecodeString (ipaddr .String ())
370- if err != nil {
371- log .Errorf ("Failed to decode IP: %v" , err )
372- } else {
373- log .Infof ("Decoded IP Address: %s" , string (decodedIP ))
374- }
364+ log .Debugf ("Cannot select subnet %s/%s, CIDR mismatch" , k .Namespace , subnetName )
375365 return nil , nil
376366 }
377367
@@ -424,7 +414,7 @@ func checkIPInCIDR(ip net.IP, cidrStr string) bool {
424414 // Parse the CIDR string
425415 _ , cidrNet , err := net .ParseCIDR (cidrStr )
426416 if err != nil {
427- log .Infof ("Error parsing CIDR: %v\n " , err )
417+ log .Errorf ("Error parsing CIDR: %v\n " , err )
428418 return false
429419 }
430420
0 commit comments