Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not watch eniconfig CRD if cni is not configured to use pod config #192

Merged
merged 1 commit into from
Oct 4, 2018
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
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