Add progress logging event for pipeline update URLs (#331)

## Changes
<!-- Summary of your changes that are easy to understand -->
Output now: 
```
shreyas.goenka@THW32HFW6T pipeline-progress % bricks bundle run foo
The update can be found at https://e2-dogfood.staging.cloud.databricks.com/#joblist/pipelines/1cc605db-daab-4218-b38a-a63030e3eb03/updates/f92f2159-1141-47de-b1e2-1ca854b7238f

2023-04-12T20:41:19.813Z update_progress INFO "Update f92f21 is INITIALIZING."
2023-04-12T20:41:19.841Z update_progress INFO "Update f92f21 is SETTING_UP_TABLES."
2023-04-12T20:41:21.270Z update_progress INFO "Update f92f21 is RUNNING."
2023-04-12T20:41:21.271Z flow_progress   INFO "Flow 'sales_orders_raw' is QUEUED."
2023-04-12T20:41:21.349Z flow_progress   INFO "Flow 'sales_orders_raw' is STARTING."
2023-04-12T20:41:21.480Z flow_progress   INFO "Flow 'sales_orders_raw' is RUNNING."
2023-04-12T20:41:23.493Z flow_progress   INFO "Flow 'sales_orders_raw' has COMPLETED."
2023-04-12T20:41:25.484Z update_progress INFO "Update f92f21 is COMPLETED."
```

## Tests
<!-- How is this tested? -->
This commit is contained in:
shreyas-goenka 2023-04-14 11:11:30 +02:00 committed by GitHub
parent 6ecf934719
commit 3894d5796d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 2 deletions

View File

@ -172,8 +172,7 @@ func (r *pipelineRunner) Run(ctx context.Context, opts *Options) (RunOutput, err
}
// Log the pipeline update URL as soon as it is available.
updateUrl := fmt.Sprintf("%s/#joblist/pipelines/%s/updates/%s", w.Config.Host, pipelineID, updateID)
log.Infof(ctx, "Update available at %s", updateUrl)
progressLogger.Log(pipeline.NewUpdateUrlEvent(w.Config.Host, updateID, pipelineID))
// Poll update for completion and post status.
// Note: there is no "StartUpdateAndWait" wrapper for this API.

View File

@ -0,0 +1,23 @@
package pipeline
import "fmt"
type UpdateUrlEvent struct {
Type string `json:"type"`
UpdateId string `json:"update_id"`
PipelineId string `json:"pipeline_id"`
Url string `json:"url"`
}
func NewUpdateUrlEvent(host, updateId, pipelineId string) *UpdateUrlEvent {
return &UpdateUrlEvent{
Type: "update_url",
UpdateId: updateId,
PipelineId: pipelineId,
Url: fmt.Sprintf("%s/#joblist/pipelines/%s/updates/%s", host, pipelineId, updateId),
}
}
func (event *UpdateUrlEvent) String() string {
return fmt.Sprintf("The update can be found at %s\n", event.Url)
}