Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

Commit

Permalink
Merge pull request #3642 from steeling/785-add-cluster-domain
Browse files Browse the repository at this point in the history
feat(pkg/*) Add local cluster domain to mesh service.
  • Loading branch information
snehachhabria authored Jun 23, 2021
2 parents 05f9f15 + db538a1 commit 477ee77
Show file tree
Hide file tree
Showing 37 changed files with 790 additions and 486 deletions.
173 changes: 99 additions & 74 deletions pkg/catalog/inbound_traffic_policies_test.go

Large diffs are not rendered by default.

183 changes: 129 additions & 54 deletions pkg/catalog/ingress_test.go

Large diffs are not rendered by default.

20 changes: 14 additions & 6 deletions pkg/catalog/outbound_traffic_policies.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/pkg/errors"
access "github.com/servicemeshinterface/smi-sdk-go/pkg/apis/access/v1alpha3"

"github.com/openservicemesh/osm/pkg/constants"
"github.com/openservicemesh/osm/pkg/identity"
"github.com/openservicemesh/osm/pkg/kubernetes"
"github.com/openservicemesh/osm/pkg/service"
Expand Down Expand Up @@ -62,8 +63,9 @@ func (mc *MeshCatalog) listOutboundTrafficPoliciesForTrafficSplits(sourceNamespa
apexServices := mapset.NewSet()
for _, split := range mc.meshSpec.ListTrafficSplits() {
svc := service.MeshService{
Name: kubernetes.GetServiceFromHostname(split.Spec.Service),
Namespace: split.Namespace,
Name: kubernetes.GetServiceFromHostname(split.Spec.Service),
Namespace: split.Namespace,
ClusterDomain: constants.LocalDomain,
}

locality := service.LocalCluster
Expand All @@ -79,7 +81,11 @@ func (mc *MeshCatalog) listOutboundTrafficPoliciesForTrafficSplits(sourceNamespa

var weightedClusters []service.WeightedCluster
for _, backend := range split.Spec.Backends {
ms := service.MeshService{Name: backend.Service, Namespace: split.ObjectMeta.Namespace}
ms := service.MeshService{
Name: backend.Service,
Namespace: split.ObjectMeta.Namespace,
ClusterDomain: constants.LocalDomain,
}
wc := service.WeightedCluster{
ClusterName: service.ClusterName(ms.String()),
Weight: backend.Weight,
Expand Down Expand Up @@ -282,7 +288,8 @@ func (mc *MeshCatalog) GetWeightedClustersForUpstream(upstream service.MeshServi
continue
}
backendCluster := service.WeightedCluster{
ClusterName: service.ClusterName(split.Namespace + "/" + backend.Service),
// TODO(steeling) splits only work in the local cluster as of now.
ClusterName: service.ClusterName(split.Namespace + "/" + backend.Service + "/" + constants.LocalDomain.String()),
Weight: backend.Weight,
}
weightedClusters = append(weightedClusters, backendCluster)
Expand Down Expand Up @@ -327,8 +334,9 @@ func (mc *MeshCatalog) ListMeshServicesForIdentity(identity identity.ServiceIden
if backend.Service == upstreamSvc.Name {
rootServiceName := kubernetes.GetServiceFromHostname(split.Spec.Service)
rootMeshService := service.MeshService{
Namespace: split.Namespace,
Name: rootServiceName,
Namespace: split.Namespace,
Name: rootServiceName,
ClusterDomain: constants.LocalDomain,
}

// Add this root service into the set
Expand Down
Loading

0 comments on commit 477ee77

Please sign in to comment.