Skip to content

Commit 50712a0

Browse files
Merge pull request #5407 from cheesesashimi/zzlotnik/backport-e2e-gcp-ocl-fix-pr
[release-4.20] OCPBUGS-65509: e2e gcp ocl PR backport
2 parents f353bfb + 1d87d4d commit 50712a0

File tree

14 files changed

+1371
-446
lines changed

14 files changed

+1371
-446
lines changed

Makefile

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,18 @@ else
109109
GO111MODULE=on go build -o $(GOPATH)/bin/golangci-lint ./vendor/github.com/golangci/golangci-lint/cmd/golangci-lint
110110
endif
111111

112+
SKOPEO := $(shell command -v skopeo 2> /dev/null)
113+
install-skopeo:
114+
ifdef SKOPEO
115+
@echo "Found skopeo"
116+
skopeo --version
117+
else
118+
@echo "Installing skopeo"
119+
./hack/install-skopeo.sh
120+
endif
121+
122+
# install-skopeo is purposely omitted from this target because it is only
123+
# needed for a single test target (test-e2e-ocl).
112124
install-tools: install-golangci-lint install-go-junit-report install-setup-envtest
113125

114126
# Runs golangci-lint
@@ -203,8 +215,9 @@ test-e2e-techpreview: install-go-junit-report
203215
test-e2e-single-node: install-go-junit-report
204216
set -o pipefail; go test -tags=$(GOTAGS) -failfast -timeout 120m -v$${WHAT:+ -run="$$WHAT"} ./test/e2e-single-node/ | ./hack/test-with-junit.sh $(@)
205217

206-
test-e2e-ocl: install-go-junit-report
207-
set -o pipefail; go test -tags=$(GOTAGS) -failfast -timeout 120m -v$${WHAT:+ -run="$$WHAT"} ./test/e2e-ocl/ | ./hack/test-with-junit.sh $(@)
218+
test-e2e-ocl: install-go-junit-report install-skopeo
219+
# Temporarily include /tmp/skopeo/bin in our PATH variable so that the test suite can find skopeo.
220+
set -o pipefail; PATH="$(PATH):/tmp/skopeo/bin" go test -tags=$(GOTAGS) -failfast -timeout 190m -v$${WHAT:+ -run="$$WHAT"} ./test/e2e-ocl/ | ./hack/test-with-junit.sh $(@)
208221

209222
bootstrap-e2e: install-go-junit-report install-setup-envtest
210223
@echo "Setting up KUBEBUILDER_ASSETS"

devex/cmd/mco-builder/local.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"github.com/openshift/machine-config-operator/devex/internal/pkg/utils"
1616
ctrlcommon "github.com/openshift/machine-config-operator/pkg/controller/common"
1717
"github.com/openshift/machine-config-operator/test/framework"
18+
"github.com/openshift/machine-config-operator/test/helpers"
1819
"github.com/spf13/cobra"
1920
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2021
aggerrs "k8s.io/apimachinery/pkg/util/errors"
@@ -192,7 +193,7 @@ func buildLocallyAndPushIntoCluster(cs *framework.ClientSet, buildOpts localBuil
192193
}
193194
}()
194195

195-
extHostname, err := rollout.ExposeClusterImageRegistry(cs)
196+
extHostname, err := helpers.ExposeClusterImageRegistry(context.TODO(), cs)
196197
if err != nil {
197198
return err
198199
}

devex/cmd/mco-builder/revert.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/openshift/machine-config-operator/devex/internal/pkg/rollout"
88
ctrlcommon "github.com/openshift/machine-config-operator/pkg/controller/common"
99
"github.com/openshift/machine-config-operator/test/framework"
10+
"github.com/openshift/machine-config-operator/test/helpers"
1011
"github.com/spf13/cobra"
1112
apierrs "k8s.io/apimachinery/pkg/api/errors"
1213
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -34,7 +35,7 @@ func doRevert(_ *cobra.Command, _ []string) error {
3435
return fmt.Errorf("could not revert to original MCO image: %w", err)
3536
}
3637

37-
if err := rollout.UnexposeClusterImageRegistry(cs); err != nil {
38+
if err := helpers.UnexposeClusterImageRegistry(context.TODO(), cs); err != nil {
3839
return fmt.Errorf("could not unexpose cluster image registry: %w", err)
3940
}
4041

devex/internal/pkg/rollout/external.go

Lines changed: 0 additions & 125 deletions
This file was deleted.

hack/install-skopeo.sh

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/usr/bin/env bash
2+
3+
set -xeuo
4+
5+
# This is an installation script for skopeo. skopeo is needed by the
6+
# e2e-gcp-op-ocl test suite since it pushes and pulls images around.
7+
#
8+
# Using a build-root image for this is the preferred approach (see:
9+
# https://docs.ci.openshift.org/docs/architecture/ci-operator/#build-root-image)
10+
# since skopeo can be installed via dnf at build-time. However, that process is
11+
# a bit more involved. While it would ultimately pay off, it is not in-scope
12+
# with the bug that is being resolved.
13+
#
14+
# Because of limitations within the builder container image and the context it
15+
# runs in, certain adaptations must be made:
16+
# - The builder image does not run as a privileged user and is denied privilege
17+
# escalation. This means that running dnf install -y skopeo cannot be done.
18+
# - The builder image does not have jq installed. This means we need to use
19+
# Python for any JSON parsing we need to perform instead.
20+
# - Because this runs as a non-privileged user, we cannot run the make install
21+
# step for skopeo. Instead, we need to append /tmp/skopeo/bin to the PATH. This
22+
# is done in the Makefile and only for the go test invocation.
23+
24+
OPENSHIFT_CI="${OPENSHIFT_CI:-""}"
25+
26+
install_skopeo() {
27+
# If we've already built skopeo once, check if it works and then return.
28+
if [ -f /tmp/skopeo/bin/skopeo ]; then
29+
echo "Prebuilt skopeo found at /tmp/skopeo/bin/skopeo, skipping installation"
30+
/tmp/skopeo/bin/skopeo --version
31+
return 0
32+
fi
33+
34+
# Get the most recent tagged version of skopeo.
35+
skopeo_version="$(curl -s https://api.github.com/repos/containers/skopeo/releases/latest | python3 -c 'import sys, json; print(json.load(sys.stdin)["tag_name"])')"
36+
37+
echo "Installing skopeo $skopeo_version from source"
38+
39+
skopeo_clone_dir="/tmp/skopeo"
40+
41+
mkdir -p "$skopeo_clone_dir"
42+
43+
# Shallow-clone the skopeo repo to the local repo dir.
44+
git clone --branch "$skopeo_version" --depth 1 https://github.com/containers/skopeo.git "$skopeo_clone_dir"
45+
46+
cd "$skopeo_clone_dir"
47+
48+
# Build skopeo
49+
make bin/skopeo
50+
}
51+
52+
# Check if we have skopeo installed first.
53+
if command -v skopeo >/dev/null 2>&1 ; then
54+
# If we do, just output its version.
55+
skopeo --version
56+
else
57+
# Check if we're running in CI.
58+
if [ "$OPENSHIFT_CI" == "true" ]; then
59+
# Only when we're in CI should we install skopeo.
60+
install_skopeo
61+
else
62+
# Otherwise, we should exit with a clear error.
63+
echo "Missing required binary 'skopeo'"
64+
exit 1
65+
fi
66+
fi

0 commit comments

Comments
 (0)