-
Notifications
You must be signed in to change notification settings - Fork 90
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
s3 publisher errors should root from base error #4401
Changes from all commits
b7edf08
c4e9ac8
62f9a2d
0f0fe07
7a22883
f5dc730
af77b2f
3548a73
3336679
4de9f18
6b8d0b3
c7a7dde
2df4031
a568d89
7ec8f2c
a1a68c3
33f5490
09f5421
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
package job | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"strconv" | ||
"time" | ||
|
@@ -147,7 +148,7 @@ func (o *ExecutionOptions) run(cmd *cobra.Command, args []string, api client.API | |
}, | ||
}) | ||
if err != nil { | ||
return err | ||
return errors.New(err.Error()) | ||
Comment on lines
-150
to
+151
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. please revert this, either do: |
||
} | ||
|
||
if err = output.Output(cmd, executionColumns, o.OutputOptions, response.Items); err != nil { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
package job | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"time" | ||
|
||
|
@@ -160,7 +161,7 @@ func (o *HistoryOptions) run(cmd *cobra.Command, args []string, api client.API) | |
}, | ||
}) | ||
if err != nil { | ||
return err | ||
return errors.New(err.Error()) | ||
Comment on lines
-163
to
+164
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. similar comment as stated elsewhere. |
||
} | ||
|
||
if err = output.Output(cmd, historyColumns, o.OutputOptions, response.Items); err != nil { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ package util | |
import ( | ||
"context" | ||
"encoding/json" | ||
"errors" | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
|
@@ -33,7 +34,7 @@ func DownloadResultsHandler( | |
JobID: jobID, | ||
}) | ||
if err != nil { | ||
Fatal(cmd, fmt.Errorf("could not get results for job %s: %w", jobID, err), 1) | ||
return errors.New(err.Error()) | ||
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. similar comment as stated elsewhere. |
||
} | ||
|
||
if len(response.Items) == 0 { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ import ( | |
"github.com/bacalhau-project/bacalhau/pkg/lib/marshaller" | ||
"github.com/bacalhau-project/bacalhau/pkg/lib/math" | ||
"github.com/bacalhau-project/bacalhau/pkg/models" | ||
"github.com/bacalhau-project/bacalhau/pkg/publicapi/apimodels" | ||
"github.com/bacalhau-project/bacalhau/pkg/util" | ||
"github.com/bacalhau-project/bacalhau/pkg/util/idgen" | ||
) | ||
|
@@ -167,6 +168,7 @@ func (b *BoltJobStore) GetJob(ctx context.Context, id string) (models.Job, error | |
} | ||
|
||
func (b *BoltJobStore) getJob(tx *bolt.Tx, jobID string) (models.Job, error) { | ||
|
||
var job models.Job | ||
|
||
jobID, err := b.reifyJobID(tx, jobID) | ||
|
@@ -176,7 +178,7 @@ func (b *BoltJobStore) getJob(tx *bolt.Tx, jobID string) (models.Job, error) { | |
|
||
data := GetBucketData(tx, NewBucketPath(BucketJobs, jobID), SpecKey) | ||
if data == nil { | ||
return job, bacerrors.NewJobNotFound(jobID) | ||
return job, apimodels.NewJobNotFound(jobID) | ||
Comment on lines
-179
to
+181
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. I think we can used |
||
} | ||
|
||
err = b.marshaller.Unmarshal(data, &job) | ||
|
@@ -189,7 +191,7 @@ func (b *BoltJobStore) reifyJobID(tx *bolt.Tx, jobID string) (string, error) { | |
if idgen.ShortUUID(jobID) == jobID { | ||
bktJobs, err := NewBucketPath(BucketJobs).Get(tx, false) | ||
if err != nil { | ||
return "", err | ||
return "", jobstore.NewBoltDbError(err.Error()) | ||
} | ||
|
||
found := make([]string, 0, 1) | ||
|
@@ -202,11 +204,11 @@ func (b *BoltJobStore) reifyJobID(tx *bolt.Tx, jobID string) (string, error) { | |
|
||
switch len(found) { | ||
case 0: | ||
return "", bacerrors.NewJobNotFound(jobID) | ||
return "", jobstore.NewErrJobNotFound(jobID) | ||
case 1: | ||
return found[0], nil | ||
default: | ||
return "", bacerrors.NewMultipleJobsFound(jobID, found) | ||
return "", jobstore.NewErrMultipleJobsFound(jobID) | ||
} | ||
} | ||
|
||
|
@@ -223,7 +225,7 @@ func (b *BoltJobStore) getExecution(tx *bolt.Tx, id string) (models.Execution, e | |
} | ||
|
||
if bkt, err := NewBucketPath(BucketJobs, key, BucketJobExecutions).Get(tx, false); err != nil { | ||
return exec, err | ||
return exec, jobstore.NewBoltDbError(err.Error()) | ||
} else { | ||
data := bkt.Get([]byte(id)) | ||
if data == nil { | ||
|
@@ -242,11 +244,11 @@ func (b *BoltJobStore) getExecution(tx *bolt.Tx, id string) (models.Execution, e | |
func (b *BoltJobStore) getExecutionJobID(tx *bolt.Tx, id string) (string, error) { | ||
keys, err := b.executionsIndex.List(tx, []byte(id)) | ||
if err != nil { | ||
return "", err | ||
return "", jobstore.NewBoltDbError(err.Error()) | ||
} | ||
|
||
if len(keys) != 1 { | ||
return "", fmt.Errorf("too many leaf nodes in execution index") | ||
return "", jobstore.NewJobStoreError("too many leaf nodes in execution index") | ||
} | ||
|
||
return string(keys[0]), nil | ||
|
@@ -297,7 +299,7 @@ func (b *BoltJobStore) getExecutions(tx *bolt.Tx, options jobstore.GetExecutions | |
|
||
bkt, err := NewBucketPath(BucketJobs, jobID, BucketJobExecutions).Get(tx, false) | ||
if err != nil { | ||
return nil, err | ||
return nil, jobstore.NewBoltDbError(err.Error()) | ||
} | ||
|
||
var execs []models.Execution | ||
|
@@ -421,20 +423,20 @@ func (b *BoltJobStore) getJobsInitialSet(tx *bolt.Tx, query jobstore.JobQuery) ( | |
if query.ReturnAll || query.Namespace == "" { | ||
bkt, err := NewBucketPath(BucketJobs).Get(tx, false) | ||
if err != nil { | ||
return nil, err | ||
return nil, jobstore.NewBoltDbError(err.Error()) | ||
} | ||
|
||
err = bkt.ForEachBucket(func(k []byte) error { | ||
jobSet[string(k)] = struct{}{} | ||
return nil | ||
}) | ||
if err != nil { | ||
return nil, err | ||
return nil, jobstore.NewBoltDbError(err.Error()) | ||
} | ||
} else { | ||
ids, err := b.namespacesIndex.List(tx, []byte(query.Namespace)) | ||
if err != nil { | ||
return nil, err | ||
return nil, jobstore.NewBoltDbError(err.Error()) | ||
} | ||
|
||
for _, k := range ids { | ||
|
@@ -455,7 +457,7 @@ func (b *BoltJobStore) getJobsIncludeTags(tx *bolt.Tx, jobSet map[string]struct{ | |
tagLabel := []byte(strings.ToLower(tag)) | ||
ids, err := b.tagsIndex.List(tx, tagLabel) | ||
if err != nil { | ||
return nil, err | ||
return nil, jobstore.NewBoltDbError(err.Error()) | ||
} | ||
|
||
for _, k := range ids { | ||
|
@@ -483,7 +485,7 @@ func (b *BoltJobStore) getJobsExcludeTags(tx *bolt.Tx, jobSet map[string]struct{ | |
tagLabel := []byte(strings.ToLower(tag)) | ||
ids, err := b.tagsIndex.List(tx, tagLabel) | ||
if err != nil { | ||
return nil, err | ||
return nil, jobstore.NewBoltDbError(err.Error()) | ||
} | ||
|
||
for _, k := range ids { | ||
|
@@ -584,7 +586,7 @@ func (b *BoltJobStore) getInProgressJobs(tx *bolt.Tx, jobType string) ([]models. | |
|
||
keys, err := b.inProgressIndex.List(tx) | ||
if err != nil { | ||
return nil, err | ||
return nil, jobstore.NewBoltDbError(err.Error()) | ||
} | ||
|
||
for _, jobIDKey := range keys { | ||
|
@@ -758,7 +760,7 @@ func (b *BoltJobStore) CreateJob(ctx context.Context, job models.Job) error { | |
job.Normalize() | ||
err := job.Validate() | ||
if err != nil { | ||
return err | ||
return jobstore.NewJobStoreError(err.Error()) | ||
} | ||
return b.update(ctx, func(tx *bolt.Tx) (err error) { | ||
return b.createJob(tx, job) | ||
|
@@ -777,7 +779,7 @@ func (b *BoltJobStore) update(ctx context.Context, update func(tx *bolt.Tx) erro | |
tx, externalTx = txFromContext(ctx) | ||
if externalTx { | ||
if !tx.Writable() { | ||
return fmt.Errorf("readonly transaction provided in context for update operation") | ||
return jobstore.NewBoltDbError("readonly transaction provided in context for update operation") | ||
} | ||
} else { | ||
tx, err = b.database.Begin(true) | ||
|
@@ -817,7 +819,7 @@ func (b *BoltJobStore) view(ctx context.Context, view func(tx *bolt.Tx) error) e | |
if !externalTx { | ||
tx, err = b.database.Begin(false) | ||
if err != nil { | ||
return err | ||
return jobstore.NewBoltDbError(err.Error()) | ||
} | ||
} | ||
|
||
|
@@ -844,21 +846,21 @@ func (b *BoltJobStore) createJob(tx *bolt.Tx, job models.Job) error { | |
|
||
jobIDKey := []byte(job.ID) | ||
if bkt, err := NewBucketPath(BucketJobs, job.ID).Get(tx, true); err != nil { | ||
return err | ||
return jobstore.NewBoltDbError(err.Error()) | ||
} else { | ||
// Create the evaluations and executions buckets and so forth | ||
if _, err := bkt.CreateBucketIfNotExists([]byte(BucketJobExecutions)); err != nil { | ||
return err | ||
} | ||
if _, err := bkt.CreateBucketIfNotExists([]byte(BucketJobEvaluations)); err != nil { | ||
return err | ||
return jobstore.NewBoltDbError(err.Error()) | ||
} | ||
if _, err := bkt.CreateBucketIfNotExists([]byte(BucketJobHistory)); err != nil { | ||
return err | ||
return jobstore.NewBoltDbError(err.Error()) | ||
} | ||
|
||
if _, err := bkt.CreateBucketIfNotExists([]byte(BucketExecutionHistory)); err != nil { | ||
return err | ||
return jobstore.NewBoltDbError(err.Error()) | ||
} | ||
} | ||
|
||
|
@@ -869,7 +871,7 @@ func (b *BoltJobStore) createJob(tx *bolt.Tx, job models.Job) error { | |
} | ||
|
||
if bkt, err := NewBucketPath(BucketJobs, job.ID).Get(tx, false); err != nil { | ||
return err | ||
return jobstore.NewBoltDbError(err.Error()) | ||
} else { | ||
if err = bkt.Put(SpecKey, jobData); err != nil { | ||
return err | ||
|
@@ -879,11 +881,11 @@ func (b *BoltJobStore) createJob(tx *bolt.Tx, job models.Job) error { | |
// Create a composite key for the in progress index | ||
jobkey := createInProgressIndexKey(&job) | ||
if err = b.inProgressIndex.Add(tx, []byte(jobkey)); err != nil { | ||
return err | ||
return jobstore.NewBoltDbError(err.Error()) | ||
} | ||
|
||
if err = b.namespacesIndex.Add(tx, jobIDKey, []byte(job.Namespace)); err != nil { | ||
return err | ||
return jobstore.NewBoltDbError(err.Error()) | ||
} | ||
|
||
// Write sentinels keys for specific tags | ||
|
@@ -909,7 +911,7 @@ func (b *BoltJobStore) deleteJob(tx *bolt.Tx, jobID string) error { | |
|
||
job, err := b.getJob(tx, jobID) | ||
if err != nil { | ||
return bacerrors.NewJobNotFound(jobID) | ||
apimodels.NewJobNotFound(jobID) | ||
} | ||
|
||
tx.OnCommit(func() { | ||
|
@@ -918,7 +920,7 @@ func (b *BoltJobStore) deleteJob(tx *bolt.Tx, jobID string) error { | |
|
||
// Delete the Job bucket (and everything within it) | ||
if bkt, err := NewBucketPath(BucketJobs).Get(tx, false); err != nil { | ||
return err | ||
return jobstore.NewBoltDbError(err.Error()) | ||
} else { | ||
if err = bkt.DeleteBucket([]byte(jobID)); err != nil { | ||
return err | ||
|
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 assume this is being removed since the
Get
method's error already contains a detailed description?