in pkg/appgw/backendaddresspools.go [30:81]
func (c appGwConfigBuilder) getPools(cbCtx *ConfigBuilderContext) []n.ApplicationGatewayBackendAddressPool {
if c.mem.pools != nil {
return *c.mem.pools
}
defaultPool := defaultBackendAddressPool(c.appGwIdentifier)
klog.V(3).Infof("Created default backend pool %s", *defaultPool.Name)
managedPoolsByName := map[string]*n.ApplicationGatewayBackendAddressPool{
*defaultPool.Name: &defaultPool,
}
_, _, serviceBackendPairMap, err := c.getBackendsAndSettingsMap(cbCtx)
if err != nil {
klog.Error("Error fetching Backends and Settings: ", err)
}
for backendID, serviceBackendPair := range serviceBackendPairMap {
if pool := c.getBackendAddressPool(backendID, serviceBackendPair, managedPoolsByName); pool != nil {
managedPoolsByName[*pool.Name] = pool
klog.V(3).Infof("Created backend pool %s for service %s", *pool.Name, backendID.serviceKey())
}
}
if cbCtx.EnvVariables.EnableIstioIntegration {
_, _, istioServiceBackendPairMap, _ := c.getIstioDestinationsAndSettingsMap(cbCtx)
for destinationID, serviceBackendPair := range istioServiceBackendPairMap {
if pool := c.getIstioBackendAddressPool(destinationID, serviceBackendPair, managedPoolsByName); pool != nil {
managedPoolsByName[*pool.Name] = pool
klog.V(3).Infof("Created backend pool %s for service %s", *pool.Name, destinationID.serviceKey())
}
}
}
var agicCreatedPools []n.ApplicationGatewayBackendAddressPool
for _, managedPool := range managedPoolsByName {
agicCreatedPools = append(agicCreatedPools, *managedPool)
}
if cbCtx.EnvVariables.EnableBrownfieldDeployment {
er := brownfield.NewExistingResources(c.appGw, cbCtx.ProhibitedTargets, &defaultPool)
// Split the existing pools we obtained from App Gateway into ones AGIC is and is not allowed to change.
existingBlacklisted, existingNonBlacklisted := er.GetBlacklistedPools()
brownfield.LogPools(existingBlacklisted, existingNonBlacklisted, agicCreatedPools)
// MergePools would produce unique list of pools based on Name. Blacklisted pools, which have the same name
// as a managed pool would be overwritten.
return brownfield.MergePools(existingBlacklisted, agicCreatedPools)
}
c.mem.pools = &agicCreatedPools
return agicCreatedPools
}