Skip to content

Commit

Permalink
change the default warm_ip_target back to one, add config check
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviassss committed Nov 9, 2023
1 parent 3c3c9ad commit beab647
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ Type: Integer

Default: None

Specifies the number of free IP addresses that the `ipamd` daemon should attempt to keep available for pod assignment on the node. Setting this to a non-positive value is the same as setting this to 0.
Specifies the number of free IP addresses that the `ipamd` daemon should attempt to keep available for pod assignment on the node. Setting this to a non-positive value is the same as setting this to 0 or not setting the variable.
With `ENABLE_PREFIX_DELEGATION` set to `true` then `ipamd` daemon will check if the existing (/28) prefixes are enough to maintain the
`WARM_IP_TARGET` if it is not sufficient then more prefixes will be attached.

Expand Down
11 changes: 7 additions & 4 deletions cmd/aws-vpc-cni/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const (
defaultEnPrefixDelegation = false
defaultIPCooldownPeriod = 30
defaultDisablePodV6 = false
defaultWarmIPTarget = 1
defaultWarmIPTarget = 0
defaultMinIPTarget = 0
defaultWarmPrefixTarget = 0

Expand Down Expand Up @@ -389,24 +389,27 @@ func validateEnvVars() bool {
prefixDelegationEn := utils.GetBoolAsStringEnvVar(envEnPrefixDelegation, defaultEnPrefixDelegation)
warmIPTarget, err, input := utils.GetIntFromStringEnvVar(envWarmIPTarget, defaultWarmIPTarget)
if err != nil {
log.Errorf("error when trying to get envWarmIPTarget: %s; input is %v", err, input)
log.Errorf("error when trying to get env WARM_IP_TARGET: %s; input is %v", err, input)
return false
}
warmPrefixTarget, err, input := utils.GetIntFromStringEnvVar(envWarmPrefixTarget, defaultWarmPrefixTarget)
if err != nil {
log.Errorf("error when trying to get envWarmPrefixTarget: %s; input is %v", err, input)
log.Errorf("error when trying to get env WARM_PREFIX_TARGET: %s; input is %v", err, input)
return false
}
minimumIPTarget, err, input := utils.GetIntFromStringEnvVar(envMinIPTarget, defaultMinIPTarget)
if err != nil {
log.Errorf("error when trying to get envMinIPTarget: %s; input is %v", err, input)
log.Errorf("error when trying to get env MINIMUM_IP_TARGET: %s; input is %v", err, input)
return false
}

// Note that these string values should probably be cast to integers, but the comparison for values greater than 0 works either way
if prefixDelegationEn && (warmIPTarget <= 0 && warmPrefixTarget <= 0 && minimumIPTarget <= 0) {
log.Errorf("Setting WARM_PREFIX_TARGET = 0 is not supported while WARM_IP_TARGET/MINIMUM_IP_TARGET is not set. Please configure either one of the WARM_{PREFIX/IP}_TARGET or MINIMUM_IP_TARGET env variables")
return false
} else if warmIPTarget <= 0 && minimumIPTarget > 0 {
log.Errorf("Setting WARM_IP_TARGET = 0 is not supported while MINIMUM_IP_TARGET is set, as it leads to no new ENIs being allocated after minimum threshold is meet, please configure properly")
return false
}
return true
}
Expand Down

0 comments on commit beab647

Please sign in to comment.