mirror of https://github.com/databricks/cli.git
Log pipeline update errors using progress logger (#338)
## Changes Logs error message for all exceptions ## Tests Manually and using unit tests
This commit is contained in:
parent
59eee11989
commit
d0872b45e2
|
@ -13,7 +13,6 @@ type ProgressEvent pipelines.PipelineEvent
|
||||||
|
|
||||||
func (event *ProgressEvent) String() string {
|
func (event *ProgressEvent) String() string {
|
||||||
result := strings.Builder{}
|
result := strings.Builder{}
|
||||||
|
|
||||||
result.WriteString(event.Timestamp + " ")
|
result.WriteString(event.Timestamp + " ")
|
||||||
|
|
||||||
// Print event type with some padding to make output more pretty
|
// Print event type with some padding to make output more pretty
|
||||||
|
@ -22,6 +21,12 @@ func (event *ProgressEvent) String() string {
|
||||||
result.WriteString(event.Level.String() + " ")
|
result.WriteString(event.Level.String() + " ")
|
||||||
result.WriteString(fmt.Sprintf(`"%s"`, event.Message))
|
result.WriteString(fmt.Sprintf(`"%s"`, event.Message))
|
||||||
|
|
||||||
|
// construct error string
|
||||||
|
if event.Error != nil {
|
||||||
|
for _, exception := range event.Error.Exceptions {
|
||||||
|
result.WriteString(fmt.Sprintf("\n%s", exception.Message))
|
||||||
|
}
|
||||||
|
}
|
||||||
return result.String()
|
return result.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ func NewPipelineUpdateUrlEvent(host, updateId, pipelineId string) *PipelineUpdat
|
||||||
}
|
}
|
||||||
|
|
||||||
func (event *PipelineUpdateUrlEvent) String() string {
|
func (event *PipelineUpdateUrlEvent) String() string {
|
||||||
return fmt.Sprintf("The pipeline update can be found at %s\n", event.Url)
|
return fmt.Sprintf("Update URL: %s\n", event.Url)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (event *PipelineUpdateUrlEvent) IsInplaceSupported() bool {
|
func (event *PipelineUpdateUrlEvent) IsInplaceSupported() bool {
|
||||||
|
|
|
@ -34,3 +34,24 @@ func TestUpdateProgressEventToString(t *testing.T) {
|
||||||
}
|
}
|
||||||
assert.Equal(t, `2023-03-27T23:30:36.122Z update_progress ERROR "my_message"`, event.String())
|
assert.Equal(t, `2023-03-27T23:30:36.122Z update_progress ERROR "my_message"`, event.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestUpdateErrorEventToString(t *testing.T) {
|
||||||
|
event := ProgressEvent{
|
||||||
|
EventType: "update_progress",
|
||||||
|
Message: "failed to update pipeline",
|
||||||
|
Level: pipelines.EventLevelError,
|
||||||
|
Origin: &pipelines.Origin{
|
||||||
|
FlowName: "my_flow",
|
||||||
|
PipelineName: "my_pipeline",
|
||||||
|
},
|
||||||
|
Timestamp: "2023-03-27T23:30:36.122Z",
|
||||||
|
Error: &pipelines.ErrorDetail{
|
||||||
|
Exceptions: []pipelines.SerializedException{
|
||||||
|
{
|
||||||
|
Message: "parsing error",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
assert.Equal(t, "2023-03-27T23:30:36.122Z update_progress ERROR \"failed to update pipeline\"\nparsing error", event.String())
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue