Skip to content
Closed
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
45 changes: 45 additions & 0 deletions pkg/test/extensions/binary.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"path"
"path/filepath"
"regexp"
"runtime"
"strings"
"sync"
"syscall"
Expand Down Expand Up @@ -167,6 +168,11 @@ type TestBinary struct {
// The binary path to extract from the image
binaryPath string

// architectures is an optional list of architectures (matching runtime.GOARCH values,
// e.g. "amd64", "arm64", "s390x", "ppc64le") on which this binary is available.
// If empty, the binary is assumed to be available on all architectures.
architectures []string

// Cache the info after gathering it
info *Extension
}
Expand Down Expand Up @@ -313,6 +319,11 @@ var extensionBinaries = []TestBinary{
imageTag: "cluster-authentication-operator",
binaryPath: "/usr/bin/cluster-authentication-operator-tests-ext.gz",
},
{
imageTag: "aws-cloud-controller-manager",
binaryPath: "/usr/bin/aws-cloud-controller-manager-tests-ext.gz",
architectures: []string{"amd64", "arm64"},
},
{
imageTag: "cloud-credential-operator",
binaryPath: "/usr/bin/cloud-credential-tests-ext.gz",
Expand Down Expand Up @@ -586,6 +597,9 @@ func ExtractAllTestBinaries(ctx context.Context, parallelism int) (func(), TestB
// Filter extension binaries based on environment variables
filteredBinaries := filterExtensionBinariesByTags(extensionBinaries)

// Filter out binaries not available on the current architecture
filteredBinaries = filterExtensionBinariesByArchitecture(filteredBinaries)

releaseImage, err := DetermineReleasePayloadImage()
if err != nil {
return nil, nil, nil, errors.WithMessage(err, "couldn't determine release image")
Expand Down Expand Up @@ -1009,6 +1023,22 @@ func filterExtensionBinariesByTags(binaries []TestBinary) []TestBinary {
return filtered
}

// filterExtensionBinariesByArchitecture filters out binaries that are not available on the
// current host architecture. Binaries with no architectures specified are included on all
// architectures.
func filterExtensionBinariesByArchitecture(binaries []TestBinary) []TestBinary {
var filtered []TestBinary
for _, b := range binaries {
if b.supportsCurrentArchitecture() {
filtered = append(filtered, b)
} else {
logrus.Infof("Skipping extension binary %q (image tag %q): not available on %s",
b.binaryPath, b.imageTag, runtime.GOARCH)
}
}
return filtered
}

// filterToApplicableEnvironmentFlags filters the provided envFlags to only those that are applicable to the
// APIVersion of OTE within the external binary.
func (b *TestBinary) filterToApplicableEnvironmentFlags(envFlags EnvironmentFlags) EnvironmentFlags {
Expand Down Expand Up @@ -1104,6 +1134,21 @@ func splitImageStreamTagName(name string) (stream, tag string) {
return name[:idx], name[idx+1:]
}

// supportsCurrentArchitecture returns true if this binary supports the current host
// architecture. If no architectures are specified, the binary is assumed to be available
// on all architectures.
func (b *TestBinary) supportsCurrentArchitecture() bool {
if len(b.architectures) == 0 {
return true
}
for _, arch := range b.architectures {
if arch == runtime.GOARCH {
return true
}
}
return false
}

// truncateLine truncates a string to maxLen characters, adding "..." if truncated.
func truncateLine(s string, maxLen int) string {
if len(s) <= maxLen {
Expand Down