Skip to content

Commit

Permalink
Merge pull request #290 from sjberman/default_pool
Browse files Browse the repository at this point in the history
Remove default pool for Ingress and Routes
  • Loading branch information
f5gary committed Aug 24, 2017
2 parents a966a76 + f109c03 commit 98e5995
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 31 deletions.
26 changes: 3 additions & 23 deletions pkg/appmanager/appManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -1348,8 +1348,9 @@ func (appMgr *Manager) handleConfigForType(
}
}
if !found {
// If multi-service Ingress, remove any pools/rules associated with the
// service, across all stored keys for the Ingress
// If the current cfg has no pool for this service,
// remove any pools associated with the service,
// across all stored keys for the resource
appMgr.resources.Lock()
defer appMgr.resources.Unlock()
cfgs, keys := appMgr.resources.GetAllWithName(rsName)
Expand All @@ -1363,22 +1364,6 @@ func (appMgr *Manager) handleConfigForType(
}
appMgr.resources.Assign(keys[i], rsName, cfg)
}
// If default Virtual pool was removed, update the default pool to one that
// still exists
cfgs, keys = appMgr.resources.GetAllWithName(rsName)
for i, cfg := range cfgs {
var validPoolName bool
for _, pl := range cfg.Pools {
if cfg.Virtual.PoolName == "/"+cfg.Virtual.Partition+"/"+pl.Name {
validPoolName = true
}
}
if !validPoolName && len(cfg.Pools) > 0 {
cfg.Virtual.PoolName = "/" + cfg.Virtual.Partition + "/" +
cfg.Pools[0].Name
appMgr.resources.Assign(keys[i], rsName, cfg)
}
}
return false, vsFound, vsUpdated
}
svcKey := serviceKey{
Expand Down Expand Up @@ -1656,11 +1641,6 @@ func (appMgr *Manager) deleteUnusedRoutes(namespace string) {
cfg.Pools[len(cfg.Pools)-1] = Pool{}
cfg.Pools = cfg.Pools[:len(cfg.Pools)-1]
}
// If we removed the default pool, set a new one
if cfg.Virtual.PoolName == poolName {
cfg.Virtual.PoolName = fmt.Sprintf("/%s/%s",
cfg.Virtual.Partition, cfg.Pools[0].Name)
}
// Delete profile
if routeName != "" {
profileName := fmt.Sprintf("%s/%s-https-cert",
Expand Down
4 changes: 0 additions & 4 deletions pkg/appmanager/resourceConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -569,9 +569,6 @@ func createRSConfigFromIngress(ing *v1beta1.Ingress,
rules := processIngressRules(&ing.Spec, cfg.Pools, cfg.Virtual.Partition)
plcy := createPolicy(*rules, cfg.Virtual.VirtualServerName, cfg.Virtual.Partition)
cfg.SetPolicy(*plcy)
if nil != cfg.Pools {
cfg.Virtual.PoolName = fmt.Sprintf("/%s/%s", cfg.Virtual.Partition, cfg.Pools[0].Name)
}
} else { // single-service
pool := Pool{
Name: cfg.Virtual.VirtualServerName,
Expand Down Expand Up @@ -698,7 +695,6 @@ func createRSConfigFromRoute(
rsCfg.Virtual.VirtualAddress.BindAddr = routeConfig.RouteVSAddr
}
rsCfg.Pools = append(rsCfg.Pools, pool)
rsCfg.Virtual.PoolName = fmt.Sprintf("/%s/%s", rsCfg.Virtual.Partition, pool.Name)

if pStruct.protocol == "http" {
if nil == tls || len(tls.Termination) == 0 {
Expand Down
2 changes: 1 addition & 1 deletion pkg/appmanager/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type (
// Virtual server config
Virtual struct {
VirtualServerName string `json:"name"`
PoolName string `json:"pool"`
PoolName string `json:"pool,omitempty"`
// Mutual parameter, partition
Partition string `json:"partition"`

Expand Down
5 changes: 2 additions & 3 deletions python/bigipconfigdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,8 +507,6 @@ def create_ltm_config_kubernetes(partition, config):

configuration['iapps'].append(iapp)
else:
f5_service['pool'] = {}

# Parse the SSL profile into partition and name
if 'sslProfile' in svc:
# The sslProfile item can be empty or have either
Expand Down Expand Up @@ -550,11 +548,12 @@ def create_ltm_config_kubernetes(partition, config):
'enabled': True,
'ipProtocol': get_protocol(svc['mode']),
'destination': destination,
'pool': "%s" % (svc['pool']),
'sourceAddressTranslation': {'type': 'automap'},
'profiles': profiles,
'policies': policies
})
if 'pool' in svc:
f5_service['pool'] = str(svc['pool'])
f5_services.update({vs_name: f5_service})

if f5_service.get('destination', None) is not None:
Expand Down

0 comments on commit 98e5995

Please sign in to comment.