Skip to content
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

fix migration, tests for more repo types #4398

Merged
merged 6 commits into from
Sep 12, 2024
Merged

Conversation

frrist
Copy link
Member

@frrist frrist commented Sep 10, 2024

@frrist frrist requested a review from wdbaruni September 10, 2024 18:31
@frrist frrist self-assigned this Sep 10, 2024
Comment on lines 144 to 151
// we still need to write a node name to the system_metadata.yaml file.
nodeID, err := config.GetNodeID(context.Background(), types.Default.NameProvider)
if err != nil {
return err
}
if err := r.WriteNodeName(nodeID); err != nil {
return fmt.Errorf("migrating node name: %w", err)
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the event the repo being migrated doesn't have a config file - resulting from a command like bacalhau version, then we need to create a node name here while migrating here as there isn't one in the config file to read from.

Comment on lines +166 to +169
if _, err := os.Stat(oldExecutionStorePath); err == nil {
newExecutionStorePath := filepath.Join(oldComputeDir, "state_boltdb.db")
if err := os.Rename(oldExecutionStorePath, newExecutionStorePath); err != nil {
return err
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ensures a store is present before attempting to migrate it.

Comment on lines +194 to +198
if _, err := os.Stat(oldJobStorePath); err == nil {
newJobStorePath := filepath.Join(oldOrchestratorDir, "state_boltdb.db")
if err := os.Rename(oldJobStorePath, newJobStorePath); err != nil {
return err
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ensures a store is present before attempting to migrate it.

@@ -40,7 +40,8 @@ func TestV3MigrationsTestSuite(t *testing.T) {
suite.Run(t, new(V3MigrationsTestSuite))
}

func (suite *V3MigrationsTestSuite) TestV3MigrationWithDefaultRepo() {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've increased test coverage for a variety of possible repos:

  • repo generated from bacalhau serve --node-type=requester,compute
  • repo generated from bacalhau serve --node-type=requester
  • repo generated from bacalhau serve --node-type=compute
  • repo generated from bacalhau version

@@ -249,3 +252,25 @@ func KeyAsEnvVar(key string) string {
fmt.Sprintf("%s_%s", environmentVariablePrefix, environmentVariableReplace.Replace(key)),
)
}

func GetNodeID(ctx context.Context, nodeNameProviderType string) (string, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: better to name it GenerateNodeID to avoid confusing it with getting the actual node name

Comment on lines 144 to 145
// we still need to write a node name to the system_metadata.yaml file.
nodeID, err := config.GetNodeID(context.Background(), types.Default.NameProvider)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't assign a new node name while migrating. If the repo doesn't have a node name, then we shouldn't assign one during migration. It should be treated the same as starting a node with empty or partial repo, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have moved this logic to the serve command and will create a node name if one isn't present when the node starts.

will create a bacalhau node name and persist it if one is not present
@frrist frrist requested a review from wdbaruni September 12, 2024 18:35
Comment on lines -97 to -104
// if it takes longer than 5 seconds to get the node name from a provider, fail
nameCtx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
nodeName, err := getNodeID(nameCtx, cfg.NameProvider)
if err != nil {
return err
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since a node name is only needed by the serve command I have removed this code, it's now only done in cmd/cli/serve.go

@frrist frrist merged commit c70dff2 into main Sep 12, 2024
4 checks passed
@frrist frrist deleted the frrist/fix/migration-3_4 branch September 12, 2024 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Repo migration is failing
2 participants