Skip to content

Commit

Permalink
Bug fix: weighted services for source (#203)
Browse files Browse the repository at this point in the history
* fix: local fqdn not updated within same cluster for bluegreen

Signed-off-by: nbn01 <nandan_bn@intuit.com>

* fix: wrong local FQDN updated for canary with weights
If the canary rollout present in both east and west

Signed-off-by: nbn01 <nandan_bn@intuit.com>

Co-authored-by: nbn01 <nandan_bn@intuit.com>
Signed-off-by: sa <sushanth_a@intuit.com>
  • Loading branch information
2 people authored and sa committed Jul 21, 2022
1 parent f3efea2 commit a9e6a65
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions admiral/pkg/clusters/serviceentry.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ func modifyServiceEntryForNewServiceOrPod(event admiral.EventType, env string, s

//create a service entry, destination rule and virtual service in the local cluster
sourceServices := make(map[string]*k8sV1.Service)
sourceWeightedServices := make(map[string]map[string]*WeightedService)
sourceDeployments := make(map[string]*k8sAppsV1.Deployment)
sourceRollouts := make(map[string]*argo.Rollout)

Expand Down Expand Up @@ -120,6 +121,7 @@ func modifyServiceEntryForNewServiceOrPod(event admiral.EventType, env string, s
remoteRegistry.AdmiralCache.CnameClusterCache.Put(cname, rc.ClusterID, rc.ClusterID)
remoteRegistry.AdmiralCache.CnameIdentityCache.Store(cname, sourceIdentity)
sourceServices[rc.ClusterID] = serviceInstance
sourceWeightedServices[rc.ClusterID] = weightedServices
}

util.LogElapsedTimeSince("BuildServiceEntry", sourceIdentity, env, "", start)
Expand Down Expand Up @@ -159,18 +161,18 @@ func modifyServiceEntryForNewServiceOrPod(event admiral.EventType, env string, s
// Update endpoints with locafqdn for active and preview se of bluegreen rollout
if isBlueGreenStrategy {
oldPorts := ep.Ports
updateEndpointsForBlueGreen(sourceRollouts[sourceCluster], weightedServices, cnames, ep, sourceCluster, key)
updateEndpointsForBlueGreen(sourceRollouts[sourceCluster], sourceWeightedServices[sourceCluster], cnames, ep, sourceCluster, key)

AddServiceEntriesWithDr(remoteRegistry.AdmiralCache, map[string]string{sourceCluster: sourceCluster}, remoteRegistry.RemoteControllers,
map[string]*networking.ServiceEntry{key: serviceEntry})
//swap it back to use for next iteration
ep.Address = clusterIngress
ep.Ports = oldPorts
// see if we have weighted services (rollouts with canary strategy)
} else if len(weightedServices) > 1 {
} else if len(sourceWeightedServices[sourceCluster]) > 1 {
//add one endpoint per each service, may be modify
var se = copyServiceEntry(serviceEntry)
updateEndpointsForWeightedServices(se, weightedServices, clusterIngress, meshPorts)
updateEndpointsForWeightedServices(se, sourceWeightedServices[sourceCluster], clusterIngress, meshPorts)
AddServiceEntriesWithDr(remoteRegistry.AdmiralCache, map[string]string{sourceCluster: sourceCluster}, remoteRegistry.RemoteControllers,
map[string]*networking.ServiceEntry{key: se})
} else {
Expand Down

0 comments on commit a9e6a65

Please sign in to comment.