Skip to content

Commit

Permalink
Added a config option to double-check file staging (off by default).
Browse files Browse the repository at this point in the history
  • Loading branch information
jeff-cohere committed Dec 11, 2024
1 parent f7e2b1e commit 5ac151b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
3 changes: 3 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ type serviceConfig struct {
DeleteAfter int `json:"delete_after" yaml:"delete_after"`
// flag indicating whether debug logging and other tools are enabled
Debug bool `json:"debug" yaml:"debug"`
// flag indicating whether an endpoint double-checks that files are staged
// (if not set, the endpoint will trust a database for staging status)
DoubleCheckStaging bool `json:"double_check_staging" yaml:"double_check_staging"`
}

// global config variables
Expand Down
27 changes: 15 additions & 12 deletions tasks/subtask.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/google/uuid"

"github.com/kbase/dts/auth"
"github.com/kbase/dts/config"
"github.com/kbase/dts/databases"
"github.com/kbase/dts/endpoints"
)
Expand Down Expand Up @@ -116,18 +117,20 @@ func (subtask *transferSubtask) checkStaging() error {
}

if subtask.StagingStatus == databases.StagingStatusSucceeded { // staged!
// the database thinks the files are staged. Does its endpoint agree?
endpoint, err := endpoints.NewEndpoint(subtask.SourceEndpoint)
if err != nil {
return err
}
staged, err := endpoint.FilesStaged(subtask.Resources)
if err != nil {
return err
}
if !staged {
return fmt.Errorf("Database %s reports staged files, but endpoint %s cannot see them. Is the endpoint's root set properly?",
subtask.Source, subtask.SourceEndpoint)
if config.Service.DoubleCheckStaging {
// the database thinks the files are staged. Does its endpoint agree?
endpoint, err := endpoints.NewEndpoint(subtask.SourceEndpoint)
if err != nil {
return err
}
staged, err := endpoint.FilesStaged(subtask.Resources)
if err != nil {
return err
}
if !staged {
return fmt.Errorf("Database %s reports staged files, but endpoint %s cannot see them. Is the endpoint's root set properly?",
subtask.Source, subtask.SourceEndpoint)
}
}
return subtask.beginTransfer() // move along
}
Expand Down

0 comments on commit 5ac151b

Please sign in to comment.