Skip to content

Commit

Permalink
Fix upload results logs (#159)
Browse files Browse the repository at this point in the history
* fix UploadResults*LogAsync logic

* fix results api requests
  • Loading branch information
ChristopherHX authored Sep 2, 2023
1 parent 6316f0a commit 14812d8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions protocol/logger/job_logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,8 @@ func (logger *JobLogger) update() error {
logger.ChangeId++
updatereq := &results.StepsUpdateRequest{}
updatereq.ChangeOrder = logger.ChangeId
updatereq.WorkflowJobRunBackendID = logger.JobRequest.Plan.PlanID
updatereq.WorkflowRunBackendID = logger.TimelineRecords.Value[0].ID
updatereq.WorkflowRunBackendID = logger.JobRequest.Plan.PlanID
updatereq.WorkflowJobRunBackendID = logger.TimelineRecords.Value[0].ID
updatereq.Steps = make([]results.Step, len(logger.TimelineRecords.Value)-1)
for i, rec := range logger.TimelineRecords.Value[1:] {
updatereq.Steps[i] = results.ConvertTimelineRecordToStep(*rec)
Expand Down
4 changes: 2 additions & 2 deletions protocol/results/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type GetSignedStepLogsURLRequest struct {
type GetSignedStepLogsURLResponse struct {
LogsUrl string `json:"logs_url,omitempty"`
BlobStorageType string `json:"blob_storage_type,omitempty"`
SoftSizeLimit int64 `json:"soft_size_limit,omitempty"`
// SoftSizeLimit int64 `json:"soft_size_limit,omitempty"` // a string in the backend?
}

type JobLogsMetadataCreate struct {
Expand Down Expand Up @@ -119,7 +119,7 @@ func ConvertTimestamp(s *string) string {
if s == nil || *s == "" {
return ""
}
if t, err := time.Parse(protocol.TimestampInputFormat, *s); err != nil {
if t, err := time.Parse(protocol.TimestampInputFormat, *s); err == nil {
return t.Format(TimestampOutputFormat)
}
return ""
Expand Down
8 changes: 4 additions & 4 deletions protocol/results/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (rs *ResultsService) UploadResultsStepSummaryAsync(ctx context.Context, pla
req := &GetSignedStepSummaryURLRequest{
WorkflowRunBackendId: planId,
WorkflowJobRunBackendId: jobId,
StepBackendId: jobId,
StepBackendId: stepId,
}
uploadUrlResponse := &GetSignedStepSummaryURLResponse{}
url, err := rs.Connection.BuildURL(GetStepSummarySignedBlobURL, nil, nil)
Expand Down Expand Up @@ -120,7 +120,7 @@ func (rs *ResultsService) UploadResultsStepLogAsync(ctx context.Context, planId
req := &GetSignedStepLogsURLRequest{
WorkflowRunBackendId: planId,
WorkflowJobRunBackendId: jobId,
StepBackendId: jobId,
StepBackendId: stepId,
}
uploadUrlResponse := &GetSignedStepLogsURLResponse{}
url, err := rs.Connection.BuildURL(GetStepLogsSignedBlobURL, nil, nil)
Expand All @@ -133,7 +133,7 @@ func (rs *ResultsService) UploadResultsStepLogAsync(ctx context.Context, planId
if uploadUrlResponse.LogsUrl == "" {
return fmt.Errorf("failed to get step log upload url")
}
if !firstBlock {
if firstBlock {
err := rs.CreateAppendFileAsync(ctx, uploadUrlResponse.LogsUrl, uploadUrlResponse.BlobStorageType)
if err != nil {
return err
Expand Down Expand Up @@ -179,7 +179,7 @@ func (rs *ResultsService) UploadResultsJobLogAsync(ctx context.Context, planId s
if uploadUrlResponse.LogsUrl == "" {
return fmt.Errorf("failed to get step log upload url")
}
if !firstBlock {
if firstBlock {
err := rs.CreateAppendFileAsync(ctx, uploadUrlResponse.LogsUrl, uploadUrlResponse.BlobStorageType)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion protocol/results/timestamp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ func TestConvertTimestamp(t *testing.T) {
}

for _, i := range table {
assert.Equal(t, i.Output, ConvertTimestamp(i.Input))
assert.Equal(t, i.Output, ConvertTimestamp(&i.Input))
}
}

0 comments on commit 14812d8

Please sign in to comment.