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

avoid text file busy error on track #2494

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions cmd/networkcmd/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,13 @@ func TrackSubnet(
}

pluginPath := filepath.Join(app.GetPluginsDir(), vmID.String())
if err := utils.FileCopy(vmBin, pluginPath); err != nil {
return err
}
if err := os.Chmod(pluginPath, constants.DefaultPerms755); err != nil {
return err
if !utils.IsExecutable(pluginPath) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we be checking if the file exists before creating a new copy, and then checking if it's not already executable before doing the chmod?

Copy link
Collaborator Author

@felipemadero felipemadero Dec 20, 2024

Choose a reason for hiding this comment

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

If the file exists and is not executable it is sign of a problem in the previous setup. It can be a partial copy for
example. So probably it is best to copy it again.
Also, if it is not executable, there is not risk of encountering text file busy error during copy
because that happens when the binary is being executed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Gotcha, could you add a comment explaining that context here? 🙏

if err := utils.FileCopy(vmBin, pluginPath); err != nil {
return err
}
if err := os.Chmod(pluginPath, constants.DefaultPerms755); err != nil {
return err
}
}

cli, err := binutils.NewGRPCClientWithEndpoint(
Expand Down
13 changes: 8 additions & 5 deletions pkg/node/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,15 @@ func TrackSubnetWithLocalMachine(
return fmt.Errorf("unknown vm: %s", sc.VM)
}
rootDir := app.GetLocalDir(clusterName)

pluginPath := filepath.Join(rootDir, "node1", "plugins", vmID.String())
if err := utils.FileCopy(vmBin, pluginPath); err != nil {
return err
}
if err := os.Chmod(pluginPath, constants.DefaultPerms755); err != nil {
return err
if !utils.IsExecutable(pluginPath) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we make a unit for these code paths?

if err := utils.FileCopy(vmBin, pluginPath); err != nil {
return err
}
if err := os.Chmod(pluginPath, constants.DefaultPerms755); err != nil {
return err
}
}

cli, err := binutils.NewGRPCClientWithEndpoint(
Expand Down
Loading