-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve logging when operator failed before generating artifact #1252
Changes from 2 commits
076aaf8
9ec1142
9ad500c
3775dde
84ad3bf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ package artifact | |
import ( | ||
"context" | ||
"encoding/json" | ||
"fmt" | ||
|
||
"github.com/aqueducthq/aqueduct/lib/database" | ||
"github.com/aqueducthq/aqueduct/lib/models" | ||
|
@@ -207,9 +208,7 @@ func (a *ArtifactImpl) updateArtifactResultAfterComputation( | |
execState *shared.ExecutionState, | ||
) { | ||
changes := map[string]interface{}{ | ||
models.ArtifactResultStatus: execState.Status, | ||
models.ArtifactResultExecState: execState, | ||
models.ArtifactResultMetadata: nil, | ||
models.ArtifactResultMetadata: nil, | ||
} | ||
|
||
if a.Computed(ctx) { | ||
|
@@ -222,11 +221,18 @@ func (a *ArtifactImpl) updateArtifactResultAfterComputation( | |
) | ||
if err != nil { | ||
log.Errorf("Unable to read artifact result metadata from storage and unmarshal: %v", err) | ||
return | ||
execState.Error.Context = fmt.Sprintf( | ||
"%s\nError reading metadata: %v", | ||
execState.Error.Context, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah that's a good catch, we should check the pointer state before assigning values |
||
err, | ||
) | ||
} | ||
changes[models.ArtifactResultMetadata] = &artifactResultMetadata | ||
} | ||
|
||
changes[models.ArtifactResultStatus] = execState.Status | ||
changes[models.ArtifactResultExecState] = execState | ||
|
||
_, err := a.resultRepo.Update( | ||
ctx, | ||
a.resultID, | ||
|
@@ -322,12 +328,15 @@ func (a *ArtifactImpl) GetMetadata(ctx context.Context) (*shared.ArtifactResultM | |
return nil, nil | ||
} | ||
|
||
var metadata shared.ArtifactResultMetadata | ||
err := utils.ReadFromStorage(ctx, a.storageConfig, a.execPaths.ArtifactMetadataPath, &metadata) | ||
if err != nil { | ||
return nil, err | ||
// If the path is not provided, we assume the data is not available. | ||
if a.execPaths.ArtifactMetadataPath != "" { | ||
var metadata shared.ArtifactResultMetadata | ||
err := utils.ReadFromStorage(ctx, a.storageConfig, a.execPaths.ArtifactMetadataPath, &metadata) | ||
if err != nil { | ||
return nil, err | ||
} | ||
a.resultMetadata = &metadata | ||
} | ||
a.resultMetadata = &metadata | ||
} | ||
|
||
return a.resultMetadata, nil | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious, is this error ever expected in any cases? If it's a really fatal error we should probably also add a Tip to the execution state?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And make it a system error or something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This issue is often triggered by the upstream op failed without creating the metadata file. I don't really want to update the exec status here since in most cases the artifact should be canceled, and caller decides. The main goal here is to prevent this from returning an err object to caller which often gives us the false signal on real failure (the op failure). So I think logging it in the context for now is fine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can add a comment here