From 50ed458e5661dc91ccddc8a30cff6f3d6d3fb24c Mon Sep 17 00:00:00 2001 From: Honnix Date: Tue, 25 Aug 2020 18:27:30 +0200 Subject: [PATCH] Fix Stackdriver log link (#79) This PR fixes Stackdriver log link using `resource.labels.pod_name` as `advancedFilter` instead of `logName`. Signed-off-by: Eduardo Apolinario --- flyteidl/clients/go/coreutils/logs/stackdriver.go | 6 +++--- flyteidl/clients/go/coreutils/logs/stackdriver_test.go | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/flyteidl/clients/go/coreutils/logs/stackdriver.go b/flyteidl/clients/go/coreutils/logs/stackdriver.go index 4ba06e65f79..dc154757162 100644 --- a/flyteidl/clients/go/coreutils/logs/stackdriver.go +++ b/flyteidl/clients/go/coreutils/logs/stackdriver.go @@ -6,10 +6,10 @@ import ( "github.com/lyft/flyteidl/gen/pb-go/flyteidl/core" ) -// TL;DR Log links in Stackdriver for configured GCP project and log Resource - Assumption: logName = podName +// TL;DR Log links in Stackdriver for configured GCP project and log Resource // // This is a simple stackdriver log plugin that creates a preformatted log link for a given project and logResource -// assuming that the logName is the name of the pod in kubernetes +// using resource.labels.pod_name as advancedFilter type stackdriverLogPlugin struct { // the name of the project in GCP that the logs are being published under gcpProject string @@ -20,7 +20,7 @@ type stackdriverLogPlugin struct { func (s *stackdriverLogPlugin) GetTaskLog(podName, namespace, containerName, containerID, logName string) (core.TaskLog, error) { return core.TaskLog{ Uri: fmt.Sprintf( - "https://console.cloud.google.com/logs/viewer?project=%s&angularJsUrl=%%2Flogs%%2Fviewer%%3Fproject%%3D%s&resource=%s&advancedFilter=logName:%s", + "https://console.cloud.google.com/logs/viewer?project=%s&angularJsUrl=%%2Flogs%%2Fviewer%%3Fproject%%3D%s&resource=%s&advancedFilter=resource.labels.pod_name%%3D%s", s.gcpProject, s.gcpProject, s.logResource, diff --git a/flyteidl/clients/go/coreutils/logs/stackdriver_test.go b/flyteidl/clients/go/coreutils/logs/stackdriver_test.go index 41ddcafde75..3ef0a1c0597 100644 --- a/flyteidl/clients/go/coreutils/logs/stackdriver_test.go +++ b/flyteidl/clients/go/coreutils/logs/stackdriver_test.go @@ -30,13 +30,13 @@ func Test_stackdriverLogPlugin_GetTaskLog(t *testing.T) { "podName-proj1", fields{gcpProject: "test-gcp-project", logResource: "aws_ec2_instance"}, args{podName: "podName"}, - core.TaskLog{Uri: "https://console.cloud.google.com/logs/viewer?project=test-gcp-project&angularJsUrl=%2Flogs%2Fviewer%3Fproject%3Dtest-gcp-project&resource=aws_ec2_instance&advancedFilter=logName:podName", MessageFormat: core.TaskLog_JSON}, false, + core.TaskLog{Uri: "https://console.cloud.google.com/logs/viewer?project=test-gcp-project&angularJsUrl=%2Flogs%2Fviewer%3Fproject%3Dtest-gcp-project&resource=aws_ec2_instance&advancedFilter=resource.labels.pod_name%3DpodName", MessageFormat: core.TaskLog_JSON}, false, }, { "podName2-proj2", fields{gcpProject: "proj2", logResource: "res1"}, args{podName: "long-pod-name-xyyyx"}, - core.TaskLog{Uri: "https://console.cloud.google.com/logs/viewer?project=proj2&angularJsUrl=%2Flogs%2Fviewer%3Fproject%3Dproj2&resource=res1&advancedFilter=logName:long-pod-name-xyyyx", MessageFormat: core.TaskLog_JSON}, false, + core.TaskLog{Uri: "https://console.cloud.google.com/logs/viewer?project=proj2&angularJsUrl=%2Flogs%2Fviewer%3Fproject%3Dproj2&resource=res1&advancedFilter=resource.labels.pod_name%3Dlong-pod-name-xyyyx", MessageFormat: core.TaskLog_JSON}, false, }, } for _, tt := range tests {