Skip to content

Commit

Permalink
Merge pull request #192 from liwenwu-amazon/pod-eni-opt
Browse files Browse the repository at this point in the history
Do not watch eniconfig CRD if cni is not configured to use pod config
  • Loading branch information
liwenwu-amazon authored Oct 4, 2018
2 parents a91e807 + de0b667 commit 7cfcd20
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 5 additions & 4 deletions ipamd/ipamd.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ func (c *IPAMContext) retryAllocENIIP() {
log.Infof("Failed to retrieve ENI IP limit: %v", err)
return
}
eni := c.dataStore.GetENINeedsIP(maxIPLimit, useCustomNetworkCfg())
eni := c.dataStore.GetENINeedsIP(maxIPLimit, UseCustomNetworkCfg())
if eni != nil {
log.Debugf("Attempt again to allocate IP address for eni :%s", eni.ID)
var err error
Expand Down Expand Up @@ -428,7 +428,7 @@ func (c *IPAMContext) increaseIPPool() {

var securityGroups []*string
var subnet string
customNetworkCfg := useCustomNetworkCfg()
customNetworkCfg := UseCustomNetworkCfg()

if customNetworkCfg {
eniCfg, err := c.eniConfig.MyENIConfig()
Expand Down Expand Up @@ -786,7 +786,8 @@ func (c *IPAMContext) eniIPPoolReconcile(ipPool map[string]*datastore.AddressInf

}

func useCustomNetworkCfg() bool {
// UseCustomerNetworkCfg() return whether Pods needs to use pod specific config
func UseCustomNetworkCfg() bool {
defaultValue := false
if strValue := os.Getenv(envCustomNetworkCfg); strValue != "" {
parsedValue, err := strconv.ParseBool(strValue)
Expand Down Expand Up @@ -836,6 +837,6 @@ func GetConfigForDebug() map[string]interface{} {
return map[string]interface{}{
envWarmIPTarget: getWarmIPTarget(),
envWarmENITarget: getWarmENITarget(),
envCustomNetworkCfg: useCustomNetworkCfg(),
envCustomNetworkCfg: UseCustomNetworkCfg(),
}
}
4 changes: 3 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ func _main() int {
go discoverController.DiscoverK8SPods()

eniConfigController := eniconfig.NewENIConfigController()
go eniConfigController.Start()
if ipamd.UseCustomNetworkCfg() {
go eniConfigController.Start()
}

awsK8sAgent, err := ipamd.New(discoverController, eniConfigController)

Expand Down

0 comments on commit 7cfcd20

Please sign in to comment.