88
99 "github.com/golang/protobuf/ptypes/duration"
1010 pb "github.com/linkerd/linkerd2-proxy-api/go/destination"
11+ meta "github.com/linkerd/linkerd2-proxy-api/go/meta"
12+ "github.com/linkerd/linkerd2/controller/api/destination/watcher"
1113 sp "github.com/linkerd/linkerd2/controller/gen/apis/serviceprofile/v1alpha2"
1214 "github.com/linkerd/linkerd2/pkg/profiles"
1315 "github.com/linkerd/linkerd2/pkg/util"
@@ -22,6 +24,7 @@ const millisPerDecimilli = 10
2224type profileTranslator struct {
2325 fullyQualifiedName string
2426 port uint32
27+ parentRef * meta.Metadata
2528
2629 stream pb.Destination_GetProfileServer
2730 endStream chan struct {}
@@ -43,10 +46,23 @@ var profileUpdatesQueueOverflowCounter = promauto.NewCounterVec(
4346 },
4447)
4548
46- func newProfileTranslator (stream pb.Destination_GetProfileServer , log * logging.Entry , fqn string , port uint32 , endStream chan struct {}) * profileTranslator {
49+ func newProfileTranslator (serviceID watcher.ServiceID , stream pb.Destination_GetProfileServer , log * logging.Entry , fqn string , port uint32 , endStream chan struct {}) * profileTranslator {
50+ parentRef := & meta.Metadata {
51+ Kind : & meta.Metadata_Resource {
52+ Resource : & meta.Resource {
53+ Group : "core" ,
54+ Kind : "Service" ,
55+ Name : serviceID .Name ,
56+ Namespace : serviceID .Namespace ,
57+ Port : port ,
58+ },
59+ },
60+ }
61+
4762 return & profileTranslator {
4863 fullyQualifiedName : fqn ,
4964 port : port ,
65+ parentRef : parentRef ,
5066
5167 stream : stream ,
5268 endStream : endStream ,
@@ -154,6 +170,19 @@ func toDuration(d time.Duration) *duration.Duration {
154170// createDestinationProfile returns a Proxy API DestinationProfile, given a
155171// ServiceProfile.
156172func (pt * profileTranslator ) createDestinationProfile (profile * sp.ServiceProfile ) (* pb.DestinationProfile , error ) {
173+ var profileRef * meta.Metadata
174+ if profile != nil {
175+ profileRef = & meta.Metadata {
176+ Kind : & meta.Metadata_Resource {
177+ Resource : & meta.Resource {
178+ Group : sp .SchemeGroupVersion .Group ,
179+ Kind : profile .Kind ,
180+ Name : profile .Name ,
181+ Namespace : profile .Namespace ,
182+ },
183+ },
184+ }
185+ }
157186 routes := make ([]* pb.Route , 0 )
158187 for _ , route := range profile .Spec .Routes {
159188 pbRoute , err := toRoute (profile , route )
@@ -177,6 +206,8 @@ func (pt *profileTranslator) createDestinationProfile(profile *sp.ServiceProfile
177206 _ , opaqueProtocol = profile .Spec .OpaquePorts [pt .port ]
178207 }
179208 return & pb.DestinationProfile {
209+ ParentRef : pt .parentRef ,
210+ ProfileRef : profileRef ,
180211 Routes : routes ,
181212 RetryBudget : budget ,
182213 DstOverrides : toDstOverrides (profile .Spec .DstOverrides , pt .port ),
0 commit comments