Skip to content
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
3 changes: 1 addition & 2 deletions pkg/cmd/drtprod/configs/drt_scale_300.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ targets:
- command: stage
args:
- $CLUSTER
- release
- v25.2.0-rc.1 # for libgeos
- lib # for libgeos
- command: stage
args:
- $CLUSTER
Expand Down
7 changes: 6 additions & 1 deletion pkg/cmd/roachprod/cli/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ components match. For example, the tag "a/b" will match both "a/b" and
local - Use a provided local binary, must provide the path to the binary.`
workloadApp = `
workload - Cockroach workload application.`
libHelp = `
lib - Supplementary Cockroach libraries (libgeos).`
)

var bashCompletion = os.ExpandEnv("$HOME/.roachprod/bash-completion.sh")
Expand Down Expand Up @@ -1330,7 +1332,10 @@ Some examples of usage:
-- Stage customized binary of CockroachDB at version v23.2.0-alpha.2-4375-g7cd2b76ed00
roachprod stage my-cluster customized v23.2.0-alpha.2-4375-g7cd2b76ed00
`, strings.TrimSpace(cockroachApp+workloadApp+releaseApp+customizedApp)),
-- Stage the most recent edge build of the libraries (libgeos):
roachprod stage my-cluster lib
`, strings.TrimSpace(cockroachApp+workloadApp+releaseApp+customizedApp+libHelp)),
Args: cobra.RangeArgs(2, 3),
Run: Wrap(func(cmd *cobra.Command, args []string) error {
versionArg := ""
Expand Down
53 changes: 37 additions & 16 deletions pkg/roachprod/install/staging.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,7 @@ func StageApplication(
return err
}

switch applicationName {
case "cockroach":
err := stageRemoteBinary(
ctx, l, c, applicationName, "cockroach/cockroach", version, archInfo.DebugArchitecture, destDir,
)
if err != nil {
return err
}
stageLibraries := func(failOnNotFound bool) error {
// NOTE: libraries may not be present in older versions.
// Use the sha for the binary to download the same remote library.
for _, library := range crdbLibraries {
Expand All @@ -234,11 +227,23 @@ func StageApplication(
archInfo.DebugArchitecture,
archInfo.LibraryExtension,
destDir,
failOnNotFound,
); err != nil {
return err
}
}
return nil
}

switch applicationName {
case "cockroach":
err := stageRemoteBinary(
ctx, l, c, applicationName, "cockroach/cockroach", version, archInfo.DebugArchitecture, destDir,
)
if err != nil {
return err
}
return stageLibraries(false /* failOnNotFound */)
case "workload":
// N.B. After https://github.com/cockroachdb/cockroach/issues/103563, only arm64 build uses the $os-$arch suffix.
// E.g., workload.LATEST is for linux-amd64, workload.linux-gnu-arm64.LATEST is for linux-arm64.
Expand All @@ -254,6 +259,8 @@ func StageApplication(
return StageCockroachRelease(ctx, l, c, releaseTypeRelease, version, archInfo.ReleaseArchitecture, archInfo.ReleaseArchiveExtension, destDir)
case "customized":
return StageCockroachRelease(ctx, l, c, releaseTypeCustomized, version, archInfo.ReleaseArchitecture, archInfo.ReleaseArchiveExtension, destDir)
case "lib":
return stageLibraries(true /* failOnNotFound */)
default:
return fmt.Errorf("unknown application %s", applicationName)
}
Expand Down Expand Up @@ -355,12 +362,14 @@ func stageRemoteBinary(
// StageOptionalRemoteLibrary downloads a library from the cockroach edge with
// the provided application path to each specified by the cluster to <dir>/lib.
// If no SHA is specified, the latest build of the library is used instead.
// It will not error if the library does not exist on the edge.
// If failOnNotFound is false, it will not error if the library does not exist on the edge.
// If failOnNotFound is true, it will return an error if the library cannot be downloaded.
func StageOptionalRemoteLibrary(
ctx context.Context,
l *logger.Logger,
c *SyncedCluster,
libraryName, urlPathBase, SHA, arch, ext, dir string,
failOnNotFound bool,
) error {
url, err := getEdgeURL(urlPathBase, SHA, arch, ext)
if err != nil {
Expand All @@ -369,14 +378,26 @@ func StageOptionalRemoteLibrary(
libDir := filepath.Join(dir, "lib")
target := filepath.Join(libDir, libraryName+ext)
l.Printf("Resolved library url for %s: %s", libraryName, url)
cmdStr := fmt.Sprintf(
`mkdir -p "%s" && \

var cmdStr string
if failOnNotFound {
cmdStr = fmt.Sprintf(
`mkdir -p "%s" && curl -sfSL -o "%s" "%s"`,
libDir,
target,
url,
)
} else {
cmdStr = fmt.Sprintf(
`mkdir -p "%s" && \
curl -sfSL -o "%s" "%s" 2>/dev/null || echo 'optional library %s not found; continuing...'`,
libDir,
target,
url,
libraryName+ext,
)
libDir,
target,
url,
libraryName+ext,
)
}

return c.Run(
ctx, l, l.Stdout, l.Stderr, WithNodes(c.Nodes), fmt.Sprintf("staging library (%s)", libraryName), cmdStr,
)
Expand Down