Skip to content

Commit

Permalink
Merge branch 'main' into frrist/fix/datadir-path
Browse files Browse the repository at this point in the history
  • Loading branch information
frrist committed Sep 25, 2024
2 parents d0e6642 + d004042 commit 979d7a1
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 99 deletions.
8 changes: 6 additions & 2 deletions cmd/cli/devstack/devstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/spf13/viper"
"k8s.io/kubectl/pkg/util/i18n"

"github.com/bacalhau-project/bacalhau/cmd/util/flags/cliflags"
"github.com/bacalhau-project/bacalhau/cmd/util/flags/configflags"
"github.com/bacalhau-project/bacalhau/pkg/config/types"
"github.com/bacalhau-project/bacalhau/pkg/config_legacy"
Expand Down Expand Up @@ -82,7 +83,6 @@ func NewCmd() *cobra.Command {
RunE: func(cmd *cobra.Command, _ []string) error {
// ensure we either use a temp repo for the devstack, or the repo path provided
// by the specific devstack flag. Never use the default bacalhau repo.
v := viper.GetViper()
repoPath := ODs.ConfigurationRepo
if repoPath == "" {
// We need to clean up the repo when the node shuts down, but we can ONLY
Expand All @@ -94,8 +94,12 @@ func NewCmd() *cobra.Command {
// a different path to the one we've just created. Presumably a default.
defer os.RemoveAll(repoPath)
}

v := viper.GetViper()
configMap := v.GetStringMap(cliflags.RootCommandConfigValues)
configMap[types.DataDirKey] = repoPath
v.Set(cliflags.RootCommandConfigValues, configMap)
// override the repo path set in the root command with the derived path.
v.Set("repo", repoPath)
cfg, err := util.SetupConfig(cmd)
if err != nil {
return fmt.Errorf("setting up config: %w", err)
Expand Down
8 changes: 0 additions & 8 deletions pkg/config/types/default_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import (

"github.com/rs/zerolog"
"github.com/rs/zerolog/log"

"github.com/bacalhau-project/bacalhau/pkg/publisher/local"
)

const (
Expand Down Expand Up @@ -73,9 +71,6 @@ var Default = Bacalhau{
CPU: "500m",
Memory: "1Gb",
},
Publisher: DefaultPublisherConfig{
Config: *local.NewSpecConfig(),
},
},
},
Ops: BatchJobDefaultsConfig{
Expand All @@ -85,9 +80,6 @@ var Default = Bacalhau{
CPU: "500m",
Memory: "1Gb",
},
Publisher: DefaultPublisherConfig{
Config: *local.NewSpecConfig(),
},
},
},
Daemon: LongRunningJobDefaultsConfig{
Expand Down
6 changes: 6 additions & 0 deletions pkg/jobstore/boltdb/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,12 @@ func (b *BoltJobStore) getJobHistory(tx *bolt.Tx, jobID string, query jobstore.J

bkt, err := NewBucketPath(BucketJobs, jobID, BucketJobHistory).Get(tx, false)
if err != nil {
// If the bucket doesn't exist, then we return an empty response to maintain compatibility
// with < v1.5.0 versions as the history bucket name was renamed in v1.5.0 without migration
// as migration is not worth the complexity
if errors.Is(err, bolt.ErrBucketNotFound) {
return &jobstore.JobHistoryQueryResponse{}, nil
}
return nil, NewBoltDbError(err)
}

Expand Down
9 changes: 7 additions & 2 deletions pkg/node/config_defaults.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package node

import (
"flag"
"os"
"path"
"runtime"
"strings"
"time"

"github.com/bacalhau-project/bacalhau/pkg/bidstrategy/semantic"
compute_system "github.com/bacalhau-project/bacalhau/pkg/compute/capacity/system"
"github.com/bacalhau-project/bacalhau/pkg/config/types"
legacy_types "github.com/bacalhau-project/bacalhau/pkg/config_legacy/types"
"github.com/bacalhau-project/bacalhau/pkg/models"
"github.com/bacalhau-project/bacalhau/pkg/system"
)

func NewDefaultComputeParam(storagePath string) ComputeConfigParams {
Expand Down Expand Up @@ -113,7 +115,10 @@ var TestRequesterConfig = RequesterConfigParams{
}

func getRequesterConfigParams() RequesterConfigParams {
if system.GetEnvironment() == system.EnvironmentTest {
if strings.Contains(os.Args[0], "/_test/") ||
strings.HasSuffix(os.Args[0], ".test") ||
flag.Lookup("test.v") != nil ||
flag.Lookup("test.run") != nil {
return TestRequesterConfig
}
return DefaultRequesterConfig
Expand Down
2 changes: 1 addition & 1 deletion pkg/publicapi/endpoint/orchestrator/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ func (e *Endpoint) getJob(c echo.Context) error { //nolint: gocyclo
continue
}
jobHistoryQueryResponse, err := e.store.GetJobHistory(ctx, jobID, jobstore.JobHistoryQuery{})
history := jobHistoryQueryResponse.JobHistory
if err != nil {
return err
}
history := jobHistoryQueryResponse.JobHistory
response.History = &apimodels.ListJobHistoryResponse{
Items: make([]*models.JobHistory, len(history)),
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/repo/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ func (fsr *FsRepo) Init() error {
if err := fsr.WriteVersion(Version4); err != nil {
return fmt.Errorf("failed to persist repo version: %w", err)
}
if err := fsr.WriteLegacyVersion(Version4); err != nil {
return fmt.Errorf("failed to persist legacy repo version: %w", err)
}

return nil
}
Expand Down
61 changes: 0 additions & 61 deletions pkg/system/environment.go

This file was deleted.

20 changes: 1 addition & 19 deletions pkg/telemetry/tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
oteltrace "go.opentelemetry.io/otel/trace"

_ "github.com/bacalhau-project/bacalhau/pkg/logger"
"github.com/bacalhau-project/bacalhau/pkg/system"
)

// ----------------------------------------
Expand All @@ -33,23 +32,11 @@ func NewSpan(ctx context.Context, t oteltrace.Tracer, name string, opts ...otelt
))
}
}
opts = append(opts, oteltrace.WithAttributes(
attribute.String("environment", system.GetEnvironment().String()),
))

return t.Start(ctx, name, opts...)
}

func NewRootSpan(ctx context.Context, t oteltrace.Tracer, name string) (context.Context, oteltrace.Span) {
// Always include environment info in spans:
environment := system.GetEnvironment().String()
m0, _ := baggage.NewMember("environment", environment)
b, _ := baggage.New(m0)
ctx = baggage.ContextWithBaggage(ctx, b)

return t.Start(ctx, name, oteltrace.WithAttributes(
attribute.String("environment", environment),
))
return t.Start(ctx, name)
}

// Span creates and starts a new span, and a context containing it.
Expand All @@ -61,11 +48,6 @@ func NewRootSpan(ctx context.Context, t oteltrace.Tracer, name string) (context.
// spanName: the name of the span, inside the service
// opts: additional options to configure the span from trace.SpanStartOption
func Span(ctx context.Context, spanName string, opts ...oteltrace.SpanStartOption) (context.Context, oteltrace.Span) {
// Always include environment info in spans:
opts = append(opts, oteltrace.WithAttributes(
attribute.String("environment", system.GetEnvironment().String()),
))

return GetTracer().Start(ctx, spanName, opts...)
}

Expand Down
6 changes: 0 additions & 6 deletions pkg/test/devstack/default_publisher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ func TestDefaultPublisherSuite(t *testing.T) {
}

func (s *DefaultPublisherSuite) TestNoDefaultPublisher() {
s.Config.JobDefaults.Batch.Task.Publisher.Config.Type = ""
s.Config.JobDefaults.Batch.Task.Publisher.Config.Params = make(map[string]interface{})
stack := &scenario.StackConfig{}
stack.RequesterConfig.JobDefaults.Batch.Task.Publisher.Config.Type = ""
stack.RequesterConfig.JobDefaults.Batch.Task.Publisher.Config.Params = make(map[string]interface{})
testcase := scenario.Scenario{
Job: &models.Job{
Name: s.T().Name(),
Expand All @@ -49,7 +44,6 @@ func (s *DefaultPublisherSuite) TestNoDefaultPublisher() {
},
},
},
Stack: stack,
ResultsChecker: expectResultsNone,
JobCheckers: []scenario.StateChecks{
scenario.WaitForSuccessfulCompletion(),
Expand Down

0 comments on commit 979d7a1

Please sign in to comment.