Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions pkg/agent/dataplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package agent

import (
"errors"
"fmt"
"net/netip"

Expand All @@ -18,6 +19,8 @@ const (
IfVTEP = "vtep"
)

var errInvalidDPConfig = errors.New("invalid dataplane config")

func buildDataplaneConfig(ag *gwintapi.GatewayAgent) (*dataplane.GatewayConfig, error) {
protoIP, err := netip.ParsePrefix(ag.Spec.Gateway.ProtocolIP)
if err != nil {
Expand Down Expand Up @@ -117,10 +120,10 @@ func buildDataplaneConfig(ag *gwintapi.GatewayAgent) (*dataplane.GatewayConfig,
Rule: &dataplane.PeeringIPs_Cidr{Cidr: subnetCIDR},
})
} else {
return nil, fmt.Errorf("unknown VPC subnet %s in peering %s / vpc %s", ipEntry.VPCSubnet, peeringName, vpcName) //nolint:goerr113
return nil, fmt.Errorf("unknown VPC subnet %s in peering %s / vpc %s: %w", ipEntry.VPCSubnet, peeringName, vpcName, errInvalidDPConfig)
}
default:
return nil, fmt.Errorf("invalid IP entry in peering %s / vpc %s: %v", peeringName, vpcName, ipEntry) //nolint:goerr113
return nil, fmt.Errorf("invalid IP entry in peering %s / vpc %s: %v: %w", peeringName, vpcName, ipEntry, errInvalidDPConfig)
}
}

Expand All @@ -136,7 +139,7 @@ func buildDataplaneConfig(ag *gwintapi.GatewayAgent) (*dataplane.GatewayConfig,
Rule: &dataplane.PeeringAs_Not{Not: asEntry.Not},
})
default:
return nil, fmt.Errorf("invalid IP entry in peering %s / vpc %s: %v", peeringName, vpcName, asEntry) //nolint:goerr113
return nil, fmt.Errorf("invalid IP entry in peering %s / vpc %s: %v: %w", peeringName, vpcName, asEntry, errInvalidDPConfig)
}
}

Expand All @@ -152,7 +155,7 @@ func buildDataplaneConfig(ag *gwintapi.GatewayAgent) (*dataplane.GatewayConfig,

if expose.NAT != nil {
if expose.NAT.Stateful != nil && expose.NAT.Stateless != nil {
return nil, fmt.Errorf("invalid NAT entry in peering %s / vpc %s: both Stateful and Stateless set", peeringName, vpcName) //nolint:goerr113
return nil, fmt.Errorf("invalid NAT entry in peering %s / vpc %s: both Stateful and Stateless set: %w", peeringName, vpcName, errInvalidDPConfig)
}

if expose.NAT.Stateful != nil {
Expand Down
Loading