Skip to content

Commit

Permalink
Fix nilpointer if CALICO_NETWORKING_BACKEND=none
Browse files Browse the repository at this point in the history
There is a nil pointer in the configureASNumber function if the networking backend is none (i.e. policy-only mode)

Signed-off-by: Tobias Giese <tobias.giese@mercedes-benz.com>
  • Loading branch information
tobiasgiese committed Jun 28, 2023
1 parent 8234b36 commit d3910ca
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions node/pkg/lifecycle/startup/startup.go
Expand Up @@ -439,7 +439,6 @@ func waitForConnection(ctx context.Context, c client.Interface) {
// is working. Getting a specific Node is a good option, even
// if the Node does not exist.
_, err := c.Nodes().Get(ctx, "foo", options.GetOptions{})

// We only care about a couple of error cases, all others would
// suggest the datastore is accessible.
if err != nil {
Expand Down Expand Up @@ -675,7 +674,6 @@ func evaluateENVBool(envVar string, defaultValue bool) bool {
if isSet {

switch strings.ToLower(envValue) {

case "false", "0", "no", "n", "f":
log.Infof("%s is %t through environment variable", envVar, false)
return false
Expand All @@ -691,6 +689,12 @@ func evaluateENVBool(envVar string, defaultValue bool) bool {
// in the environment, or is a no-op if not specified.
// Returns true if the node object needs to be updated.
func configureASNumber(node *libapi.Node) bool {
// If Calico is running in policy only mode we don't need to write BGP related
// details to the Node.
if os.Getenv("CALICO_NETWORKING_BACKEND") == "none" {
return false
}

// Extract the AS number from the environment
asStr := os.Getenv("AS")
if asStr != "" {
Expand Down Expand Up @@ -861,7 +865,6 @@ func configureIPPools(ctx context.Context, client client.Interface, kubeadmConfi

createIPPool(ctx, client, ipv6Cidr, DEFAULT_IPV6_POOL_NAME, string(api.IPIPModeNever), ipv6VXLANModeEnvVar, outgoingNATEnabled, ipv6BlockSize, ipv6NodeSelector, bgpExportDisabled)
}

}

// createIPPool creates an IP pool using the specified CIDR. This
Expand Down

0 comments on commit d3910ca

Please sign in to comment.