Skip to content

Commit 259e932

Browse files
Merge pull request #5785 from cheesesashimi/zzlotnik/revert-pr-5313
NO-ISSUE: Revert "extract oc binary from base OS image after build"
2 parents 15c41cf + d40b228 commit 259e932

File tree

6 files changed

+16
-41
lines changed

6 files changed

+16
-41
lines changed

Dockerfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ RUN if [ "${TAGS}" = "fcos" ]; then \
3434
if ! rpm -q util-linux; then dnf install -y util-linux; fi && \
3535
# We also need to install fuse-overlayfs and cpp for Buildah to work correctly.
3636
if ! rpm -q buildah; then dnf install -y buildah fuse-overlayfs cpp --exclude container-selinux; fi && \
37-
# Install the oc binary.
38-
if ! rpm -q openshift-clients; then dnf install -y openshift-clients; fi && \
3937
# Create the build user which will be used for doing OS image builds. We
4038
# use the username "build" and the uid 1000 since this matches what is in
4139
# the official Buildah image.

Dockerfile.rhel7

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ RUN if [ "${TAGS}" = "fcos" ]; then \
3535
if ! rpm -q util-linux; then dnf install -y util-linux; fi && \
3636
# We also need to install fuse-overlayfs and cpp for Buildah to work correctly.
3737
if ! rpm -q buildah; then dnf install -y buildah fuse-overlayfs cpp --exclude container-selinux; fi && \
38-
# Install the oc binary.
39-
if ! rpm -q openshift-clients; then dnf install -y openshift-clients; fi && \
4038
# Create the build user which will be used for doing OS image builds. We
4139
# use the username "build" and the uid 1000 since this matches what is in
4240
# the official Buildah image.

pkg/controller/build/buildrequest/assets/buildah-build.sh

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -98,16 +98,4 @@ buildah push \
9898
--authfile="$FINAL_IMAGE_PUSH_CREDS" \
9999
--digestfile="/tmp/done/digestfile" \
100100
--cert-dir /var/run/secrets/kubernetes.io/serviceaccount "$TAG"
101-
102-
# If the oc command is not present, then we must extract it from the base OS
103-
# image which we've already pulled to do the build.
104-
if ! command -v "oc" &> /dev/null; then
105-
# Extract the oc binary from the base OS image and place it into the
106-
# /tmp/done path.
107-
container="$(buildah from --authfile="$BASE_IMAGE_PULL_CREDS" "$BASE_OS_IMAGE_PULLSPEC")"
108-
buildah unshare /bin/bash -c 'cp "$(buildah mount "$container")/usr/bin/oc" "/tmp/done/oc"; buildah umount "$container"'
109-
buildah rm "$container"
110-
echo "Extracted oc command from $BASE_OS_IMAGE_PULLSPEC"
111-
fi
112-
113101
EOF

pkg/controller/build/buildrequest/assets/create-digest-cm.sh

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,7 @@
66

77
set -xeuo
88

9-
# Check if the oc command is available.
10-
if command -v "oc" &> /dev/null; then
11-
echo "Using built-in oc command"
12-
else
13-
# If the oc command is not available, check under /tmp/done/oc.
14-
if [[ -x /tmp/done/oc ]]; then
15-
# Add this to our PATH if found.
16-
export PATH="$PATH:/tmp/done"
17-
else
18-
# If it cannot be found, return a non-zero exit code.
19-
echo "oc command not found"
20-
exit 1
21-
fi
22-
fi
9+
# Inject the contents of the digestfile into a ConfigMap.
2310

2411
# Create and label the digestfile ConfigMap
2512
if ! oc create configmap \

pkg/controller/build/buildrequest/buildrequest.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -451,10 +451,6 @@ func (br buildRequestImpl) toBuildahPod() *corev1.Pod {
451451
Name: "NO_PROXY",
452452
Value: noProxy,
453453
},
454-
{
455-
Name: "BASE_OS_IMAGE_PULLSPEC",
456-
Value: br.opts.OSImageURLConfig.BaseOSContainerImage,
457-
},
458454
}
459455

460456
securityContext := &corev1.SecurityContext{}
@@ -564,6 +560,7 @@ func (br buildRequestImpl) toBuildahPod() *corev1.Pod {
564560
VolumeSource: corev1.VolumeSource{
565561
Secret: &corev1.SecretVolumeSource{
566562
SecretName: br.getBasePullSecretName(),
563+
// SecretName: br.opts.MachineOSConfig.Spec.BuildInputs.BaseImagePullSecret.Name,
567564
Items: []corev1.KeyToPath{
568565
{
569566
Key: corev1.DockerConfigJsonKey,
@@ -578,6 +575,7 @@ func (br buildRequestImpl) toBuildahPod() *corev1.Pod {
578575
Name: "final-image-push-creds",
579576
VolumeSource: corev1.VolumeSource{
580577
Secret: &corev1.SecretVolumeSource{
578+
// SecretName: br.opts.MachineOSConfig.Spec.BuildInputs.RenderedImagePushSecret.Name,
581579
SecretName: br.getFinalPushSecretName(),
582580
Items: []corev1.KeyToPath{
583581
{
@@ -589,11 +587,14 @@ func (br buildRequestImpl) toBuildahPod() *corev1.Pod {
589587
},
590588
},
591589
{
592-
// Provides a way for the "image-build" container to pass the digested
593-
// pullspec and oc binary to the "create-digest-configmap" container.
590+
// Provides a way for the "image-build" container to signal that it
591+
// finished so that the "wait-for-done" container can retrieve the
592+
// iamge SHA.
594593
Name: "done",
595594
VolumeSource: corev1.VolumeSource{
596-
EmptyDir: &corev1.EmptyDirVolumeSource{},
595+
EmptyDir: &corev1.EmptyDirVolumeSource{
596+
Medium: corev1.StorageMediumMemory,
597+
},
597598
},
598599
},
599600
{
@@ -670,7 +671,7 @@ func (br buildRequestImpl) toBuildahPod() *corev1.Pod {
670671
// us to avoid parsing log files.
671672
Name: "create-digest-configmap",
672673
Command: append(command, digestCMScript),
673-
Image: br.opts.Images.MachineConfigOperator,
674+
Image: br.opts.OSImageURLConfig.BaseOSContainerImage,
674675
Env: env,
675676
ImagePullPolicy: corev1.PullAlways,
676677
SecurityContext: securityContext,

pkg/controller/build/buildrequest/buildrequest_test.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,6 @@ func assertSecretInCorrectFormat(t *testing.T, secret *corev1.Secret) {
211211
}
212212

213213
func assertBuildJobIsCorrect(t *testing.T, buildJob *batchv1.Job, opts BuildRequestOpts) {
214-
t.Helper()
215-
216214
etcRpmGpgKeysOpts := optsForEtcRpmGpgKeys()
217215
assertBuildJobMatchesExpectations(t, opts.HasEtcPkiRpmGpgKeys, buildJob,
218216
etcRpmGpgKeysOpts.envVar(),
@@ -235,7 +233,12 @@ func assertBuildJobIsCorrect(t *testing.T, buildJob *batchv1.Job, opts BuildRequ
235233
)
236234

237235
assert.Equal(t, buildJob.Spec.Template.Spec.InitContainers[0].Image, mcoImagePullspec)
238-
assert.Equal(t, buildJob.Spec.Template.Spec.Containers[0].Image, mcoImagePullspec)
236+
expectedPullspecs := []string{
237+
"base-os-image-from-machineosconfig",
238+
fixtures.OSImageURLConfig().BaseOSContainerImage,
239+
}
240+
241+
assert.Contains(t, expectedPullspecs, buildJob.Spec.Template.Spec.Containers[0].Image)
239242

240243
assertPodHasVolume(t, buildJob.Spec.Template.Spec, corev1.Volume{
241244
Name: "final-image-push-creds",

0 commit comments

Comments
 (0)