Skip to content

Commit

Permalink
GROUNDWORK-3440: sanitize service names
Browse files Browse the repository at this point in the history
  • Loading branch information
VladislavSenkevich committed Nov 12, 2024
1 parent 5adfcda commit 72fa265
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion connectors/databricks/utils/clusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package utils

import (
"fmt"
"regexp"

"github.com/rs/zerolog/log"

Expand All @@ -18,7 +19,10 @@ func GetClustersServices(databricksClient *client.DatabricksClient, host string)

services := make([]transit.MonitoredService, 0, len(clusters))
for _, cluster := range clusters {
service, err := connectors.CreateService(cluster.Name, host)
service, err := connectors.CreateService(
regexp.MustCompile(`[^a-zA-Z0-9]+`).ReplaceAllString(cluster.Name, "_"),
host,
)
if err != nil {
log.Error().Err(err).Str("cluster_name", cluster.Name).Msg("failed to create service")
continue
Expand Down
3 changes: 3 additions & 0 deletions connectors/databricks/utils/jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package utils

import (
"fmt"
"regexp"
"slices"
"time"

Expand All @@ -24,6 +25,8 @@ func GetJobsServices(
for _, runs := range jobsRuns {
if len(runs) > 0 {
for _, run := range runs {
run.RunName = regexp.MustCompile(`[^a-zA-Z0-9]+`).ReplaceAllString(run.RunName, "_")

output := run.Status.TerminationDetails.Message
status := transit.ServicePending
if run.Status.State == "TERMINATED" {
Expand Down

0 comments on commit 72fa265

Please sign in to comment.