-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split up Environment into BuildDirectory and Runner
When support for multiple runners for a single worker as added, we ran into a pretty serious design flaw: the cardinality between the number of build directories and runners had changed: 1:1 -> 1:*. Back then we sort of ignored this issue, which led interesting bugs, such as cleaning of the build directory not working properly in multi-runner setups. We eventually worked around this by disabling this feature. Some TODOs in cmd/bb_worker/main.go remained. The goal of this change is to finally tackle that problem by basically kicking out the Environment interface, which caused the 1:1 coupling. It introduces separate BuildDirectory and Runner types. LocalBuildExecutor now takes individual copies of each. Because of this decoupling, we can also fix #20. Builds are no longer performed in the build directory itself. Instead, they are run inside a subdirectory called "root". This makes it possible to use the top level directory for other purposes (e.g., storing stdout and stderr logs). It also partially addresses #23. The runner protocol has been extended to explicitly pass on the input root directory, so that a runner could chroot into it.
- Loading branch information
1 parent
e44cc90
commit 94b9fb6
Showing
40 changed files
with
1,114 additions
and
1,045 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package builder | ||
|
||
import ( | ||
"context" | ||
|
||
re_filesystem "github.com/buildbarn/bb-remote-execution/pkg/filesystem" | ||
"github.com/buildbarn/bb-storage/pkg/digest" | ||
"github.com/buildbarn/bb-storage/pkg/filesystem" | ||
) | ||
|
||
// BuildDirectory is a filesystem.Directory that may be used for the | ||
// purpose of running build actions. BuildDirectory has a couple of | ||
// special operations that implementations may use to run actions in a | ||
// more efficient and manageable way. | ||
type BuildDirectory interface { | ||
filesystem.DirectoryCloser | ||
|
||
// Identical to EnterDirectory(), except that it returns a | ||
// BuildDirectory object. | ||
EnterBuildDirectory(name string) (BuildDirectory, error) | ||
|
||
// Installs a set of hooks into the directory to intercept I/O | ||
// operations. The FilePool may be used to allocate storage | ||
// space. Implementations of BuildDirectory are free to let this | ||
// be a no-op, with the disadvantage that they cannot apply | ||
// resource limits or provide rich I/O error messages. | ||
InstallHooks(filePool re_filesystem.FilePool) | ||
|
||
// Recursively merges the contents of a Directory stored in the | ||
// Content Addressable Storage into a local directory. | ||
MergeDirectoryContents(ctx context.Context, digest digest.Digest) error | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package builder | ||
|
||
import ( | ||
"github.com/buildbarn/bb-storage/pkg/digest" | ||
) | ||
|
||
// BuildDirectoryCreator is used by LocalBuildExecutor to obtain build | ||
// directories in which build actions are executed. | ||
type BuildDirectoryCreator interface { | ||
GetBuildDirectory(actionDigest digest.Digest, mayRunInParallel bool) (BuildDirectory, string, error) | ||
} |
Oops, something went wrong.