Skip to content

Commit

Permalink
node.Obtain(): Fix `panic: failed to parse CIDR : invalid CIDR addr…
Browse files Browse the repository at this point in the history
…ess:`
  • Loading branch information
lippserd committed Apr 12, 2024
1 parent fcc4ebb commit 120b4e5
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pkg/schema/v1/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,13 @@ func (n *Node) Obtain(k8s kmetav1.Object) {

n.Id = types.Checksum(n.Namespace + "/" + n.Name)
n.PodCIDR = node.Spec.PodCIDR
_, cidr, err := net.ParseCIDR(n.PodCIDR)
if err != nil {
panic(errors.Wrapf(err, "failed to parse CIDR %s", n.PodCIDR))
if n.PodCIDR != "" {
_, cidr, err := net.ParseCIDR(n.PodCIDR)
if err != nil {
panic(errors.Wrapf(err, "failed to parse CIDR %s", n.PodCIDR))
}
n.NumIps = knet.RangeSize(cidr) - 2
}
n.NumIps = knet.RangeSize(cidr) - 2
n.Unschedulable = types.Bool{
Bool: node.Spec.Unschedulable,
Valid: true,
Expand Down

0 comments on commit 120b4e5

Please sign in to comment.