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

Commit

Permalink
Fix double http in the Spark Driver UI Link (#389)
Browse files Browse the repository at this point in the history
* Fix double http in the Spark Driver UI Link

Signed-off-by: mucahit-kantepe <[email protected]>

* fix test

Signed-off-by: mucahit-kantepe <[email protected]>

* Apply suggestions from code review

Co-authored-by: Ketan Umare <[email protected]>
Signed-off-by: Mücahit Kantepe <[email protected]>

* Update spark.go

Signed-off-by: Mücahit Kantepe <[email protected]>

* fmt

Signed-off-by: mucahit-kantepe <[email protected]>

* updated to append https if neither http or https prefixes spark uri

Signed-off-by: Daniel Rammer <[email protected]>

---------

Signed-off-by: mucahit-kantepe <[email protected]>
Signed-off-by: Mücahit Kantepe <[email protected]>
Signed-off-by: Daniel Rammer <[email protected]>
Co-authored-by: mucahit-kantepe <[email protected]>
Co-authored-by: Mücahit Kantepe <[email protected]>
Co-authored-by: Ketan Umare <[email protected]>
  • Loading branch information
4 people committed Aug 16, 2023
1 parent 03dc9db commit 03f5b5c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
9 changes: 7 additions & 2 deletions go/tasks/plugins/k8s/spark/spark.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,13 @@ func getEventInfoForSpark(pluginContext k8s.PluginContext, sj *sparkOp.SparkAppl
})
}
} else if sj.Status.AppState.State == sparkOp.RunningState && sj.Status.DriverInfo.WebUIIngressAddress != "" {
// Append https as the operator doesn't currently.
customInfoMap[sparkDriverUI] = fmt.Sprintf("https://%s", sj.Status.DriverInfo.WebUIIngressAddress)
// Older versions of spark-operator does not append http:// but newer versions do.
uri := sj.Status.DriverInfo.WebUIIngressAddress
if !strings.HasPrefix(uri, "https://") && !strings.HasPrefix(uri, "http://") {
uri = fmt.Sprintf("https://%s", uri)
}
customInfoMap[sparkDriverUI] = uri

// Custom doesn't work unless the UI has a custom plugin to parse this, hence add to Logs as well.
taskLogs = append(taskLogs, &core.TaskLog{
Uri: customInfoMap[sparkDriverUI],
Expand Down
5 changes: 2 additions & 3 deletions go/tasks/plugins/k8s/spark/spark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package spark

import (
"context"
"fmt"
"os"
"strconv"
"testing"
Expand Down Expand Up @@ -34,7 +33,7 @@ import (
const sparkMainClass = "MainClass"
const sparkApplicationFile = "local:///spark_app.py"
const testImage = "image://"
const sparkUIAddress = "spark-ui.flyte"
const sparkUIAddress = "https://spark-ui.flyte"

var (
dummySparkConf = map[string]string{
Expand Down Expand Up @@ -92,7 +91,7 @@ func TestGetEventInfo(t *testing.T) {
info, err := getEventInfoForSpark(taskCtx, dummySparkApplication(sj.RunningState))
assert.NoError(t, err)
assert.Len(t, info.Logs, 6)
assert.Equal(t, fmt.Sprintf("https://%s", sparkUIAddress), info.CustomInfo.Fields[sparkDriverUI].GetStringValue())
assert.Equal(t, "https://spark-ui.flyte", info.CustomInfo.Fields[sparkDriverUI].GetStringValue())
generatedLinks := make([]string, 0, len(info.Logs))
for _, l := range info.Logs {
generatedLinks = append(generatedLinks, l.Uri)
Expand Down

0 comments on commit 03f5b5c

Please sign in to comment.