Skip to content

Conversation

@stbenjam
Copy link
Member

@stbenjam stbenjam commented Aug 14, 2019

The installer for baremetal is in a separate image as part of the
release, we need to provide awareness to the oc command so we can
actually extract the installer and replace the release image location.

A user would extract the baremetal installer like this:

oc adm release extract --registry-config <pull secret> --command=openshift-baremetal-install --to /tmp

@openshift-ci-robot openshift-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Aug 14, 2019
@stbenjam
Copy link
Member Author

stbenjam commented Aug 14, 2019

@markmc I believe this addresses your concern in #52, but I'm not sure if renaming the binary causes an issue - should be able to test tomorrow.

I'm not sure how we would do it otherwise

@markmc
Copy link
Contributor

markmc commented Aug 14, 2019

Ah, ok - so the binary is extracted as openshift-baremetal-install

The only downside is that ultimately I guess we all hope this support will end up in the stock openshift-install binary, and openshift-baremetal-install going away would be an incompatible change - but again, the platform is experimental, so hopefully that's not a major concern and ok as a simple solution for now

@stbenjam
Copy link
Member Author

@markmc If we would rather not put this code into oc and wait until we have a mechanism to include it in openshift-install's normal distribution method, we could just extract baremetal-installer directly in dev-scripts / KNI install-scripts:

#!/bin/bash
set -e

INSTALLER_IMAGE="registry.svc.ci.openshift.org/origin/4.2:baremetal-installer"
INSTALLER_CONTAINER=$(podman create $INSTALLER_IMAGE)
podman cp $INSTALLER_CONTAINER:/usr/bin/openshift-install .
podman rm $INSTALLER_CONTAINER

What do you think?

@markmc
Copy link
Contributor

markmc commented Aug 14, 2019

I'd prefer if it wasn't so hidden - should be able to get it easily with oc adm release extract IMO

Also oc image extract would be a better fallback than podman cp

@stbenjam
Copy link
Member Author

I'd prefer if it wasn't so hidden - should be able to get it easily with oc adm release extract IMO

Also oc image extract would be a better fallback than podman cp

Ah I didn't realize that was part of oc. Thanks, that's a good fallback if this isn't accepted.

@stbenjam
Copy link
Member Author

Also, even if we need the fallback, it wouldn't be as simple. oc is responsible for replacing the placeholder in the binary with the real release image location: https://github.com/openshift/oc/blob/master/pkg/cli/admin/release/extract_tools.go#L597

We would need to do something similar by hand.

@stbenjam
Copy link
Member Author

/assign @smarterclayton

@markmc
Copy link
Contributor

markmc commented Aug 15, 2019

Also, even if we need the fallback, it wouldn't be as simple. oc is responsible for replacing the placeholder in the binary with the real release image location: https://github.com/openshift/oc/blob/master/pkg/cli/admin/release/extract_tools.go#L597

We would need to do something similar by hand.

Great point. Agree a fallback isn't really viable

@smarterclayton
Copy link
Contributor

This command is used to extract most release tooling by default. If we don’t expect this to be part of GA in 4.2 I think it needs to be more hidden - Ie you need to ask for it explicitly with —command. Also, this command must work against older clusters, so we can’t add a new binary that would fail if used against 4.1.

I’d probably prefer image extract is used in 4.2 rather than adding to release extract. If you can make the case that users won’t be able to succeed with that command, then this PR will need to take the above changes into account.

@openshift-ci-robot openshift-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Aug 15, 2019
@stbenjam
Copy link
Member Author

This command is used to extract most release tooling by default. If we don’t expect this to be part of GA in 4.2 I think it needs to be more hidden - Ie you need to ask for it explicitly with —command. Also, this command must work against older clusters, so we can’t add a new binary that would fail if used against 4.1.

I’d probably prefer image extract is used in 4.2 rather than adding to release extract. If you can make the case that users won’t be able to succeed with that command, then this PR will need to take the above changes into account.

image extract doesn't really work for us, as the binary isn't patched with the release information. We wouldn't be able to directly consume the extracted image. I have updated this PR to exclude the baremetal installer unless explicitly asked for as a command.

I wouldn't expect this to change for 4.2, the earliest we could address the issues that would remove the need for a separate baremetal-installer is 4.3.

@stbenjam
Copy link
Member Author

There is also a related bug I've fixed as a separate PR here: #59

oc conflates the Command with the basepath of the source binary in the imgae, so openshift-baremtal-installer is not extracted by that name.

targets[i].AsArchive = true
targets[i].AsZip = targets[i].OS == "windows"
// Only non-Hidden targets will be included in an archive.
for _, target := range availableTargets {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ideal outcome is:

oc adm release extract —tools

Doesn’t include it, but

oc adm release extract —command openshift-baremetal-installer

Extracts the binary

oc adm release extract —command openshift-baremetal-installer —command-os=*

Creates an archive.

Hence the suggestion for optional - the explicit request overrides optional, rather than the current behavior here with always excluding from archive.

@openshift-ci-robot openshift-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Aug 16, 2019
@stbenjam
Copy link
Member Author

stbenjam commented Aug 16, 2019

@smarterclayton Ok, so I believe this should work as you expect - see below for some examples. Previously --command and --command-os='*' together did not extract into archive(s). I have fixed that. I also had to incorporate the changes from #59 to make this all work correctly.

$ ./oc adm release extract --registry-config /tmp/pull.json --command=openshift-baremetal-install --command-os='*' --to /tmp/foo registry.svc.ci.openshift.org/ocp/release:4.2
$ ls /tmp/foo; rm -rf /tmp/foo/*
openshift-baremetal-install-linux-4.2.0-0.nightly-2019-08-15-232721.tar.gz 
release.txt
sha256sum.txt
$ ./oc adm release extract --registry-config /tmp/pull.json --command=openshift-baremetal-install --to /tmp/foo registry.svc.ci.openshift.org/ocp/release:4.2
$ ls /tmp/foo; rm -rf /tmp/foo/*
openshift-baremetal-install
$ ./oc adm release extract --registry-config /tmp/pull.json --tools --to /tmp/foo registry.svc.ci.openshift.org/ocp/release:4.2
$ ls /tmp/foo; rm -rf /tmp/foo/*
openshift-client-linux-4.2.0-0.nightly-2019-08-15-232721.tar.gz
openshift-install-linux-4.2.0-0.nightly-2019-08-15-232721.tar.gz
release.txt
sha256sum.txt
$ ./oc adm release extract --registry-config /tmp/pull.json --tools --command-os='*' --to /tmp/foo registry.svc.ci.openshift.org/ocp/release:4.2
$ ls /tmp/foo; rm -rf /tmp/foo/*
openshift-client-linux-4.2.0-0.nightly-2019-08-15-232721.tar.gz
openshift-client-windows-4.2.0-0.nightly-2019-08-15-232721.zip
openshift-client-mac-4.2.0-0.nightly-2019-08-15-232721.tar.gz
openshift-install-linux-4.2.0-0.nightly-2019-08-15-232721.tar.gz
openshift-install-mac-4.2.0-0.nightly-2019-08-15-232721.tar.gz
release.txt
sha256sum.txt
$ ./oc adm release extract --registry-config /tmp/pull.json --command='oc' --command-os='*' --to /tmp/foo registry.svc.ci.openshift.org/ocp/release:4.2
$ ls /tmp/foo; rm -rf /tmp/foo/*
openshift-client-linux-4.2.0-0.nightly-2019-08-15-232721.tar.gz
openshift-client-windows-4.2.0-0.nightly-2019-08-15-232721.zip  
openshift-client-mac-4.2.0-0.nightly-2019-08-15-232721.tar.gz
release.txt
sha256sum.txt

@stbenjam
Copy link
Member Author

stbenjam commented Aug 16, 2019

And just for completeness, the behavior of master is broken:

$ ./oc adm release extract --registry-config /tmp/pull.json --command=openshift-install --command-os='*' --to /tmp/foo registry.svc.ci.openshift.org/ocp/release:4.2
$ ls /tmp/foo
openshift-install

@smarterclayton
Copy link
Contributor

smarterclayton commented Aug 19, 2019 via email

@stbenjam
Copy link
Member Author

stbenjam commented Aug 19, 2019

I think it looks ok, except for Windows, it's missing the exe suffix. Will fix that logic.

Archive:  openshift-client-windows-4.2.0-0.nightly-2019-08-19-113631.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
     1024  08-07-2019 19:35   README.md
 74884096  08-07-2019 19:35   oc
---------                     -------
$ tar vtzf openshift-client-mac-4.2.0-0.nightly-2019-08-19-113631.tar.gz
-rw-r--r-- 0/0             954 2019-08-07 19:34 README.md
-rwxr-xr-x 0/0        85865432 2019-08-07 19:34 oc
hrwxr-xr-x 0/0               0 2019-08-07 19:34 kubectl link to oc
$ tar vtzf openshift-client-linux-4.2.0-0.nightly-2019-08-19-113631.tar.gz
-rw-r--r-- 0/0             954 2019-08-18 16:31 README.md
-rwxr-xr-x 0/0        74327960 2019-08-18 16:31 oc
hrwxr-xr-x 0/0               0 2019-08-18 16:31 kubectl link to oc

When extracting commands from a release, the command is typically the
same as the source executable in the image, however if that is not the
case - for example, in the case of the baremetal installer, oc does the
wrong thing.  If the command is `openshift-baremetal-installer` but it
is extracted from `usr/bin/openshift-installer`, oc extracts the file as
openshift-installer.
@stbenjam
Copy link
Member Author

@smarterclayton Fixed

$ tar tfv openshift-client-linux-4.2.0-0.nightly-2019-08-19-161103.tar.gz 
-rw-r--r-- 0/0             954 2019-08-18 16:31 README.md
-rwxr-xr-x 0/0        74327960 2019-08-18 16:31 oc
hrwxr-xr-x 0/0               0 2019-08-18 16:31 kubectl link to oc
$ tar tfv openshift-client-mac-4.2.0-0.nightly-2019-08-19-161103.tar.gz 
-rw-r--r-- 0/0             954 2019-08-07 19:34 README.md
-rwxr-xr-x 0/0        85865432 2019-08-07 19:34 oc
hrwxr-xr-x 0/0               0 2019-08-07 19:34 kubectl link to oc
$ unzip -l openshift-client-windows-4.2.0-0.nightly-2019-08-19-161103.zip 
Archive:  openshift-client-windows-4.2.0-0.nightly-2019-08-19-161103.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
     1024  08-07-2019 19:35   README.md
 74884096  08-07-2019 19:35   oc.exe
---------                     -------
 74885120                     2 files

if len(command) > 0 && currentOS != "*" {
return fmt.Errorf("command %q does not support the operating system %q", o.Command, currentOS)
} else {
return fmt.Errorf("the supported commands are 'oc', and 'openshift-install'")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This error message is inaccurate now (there is no guarantee command has been specified). You should also exit early, and the message should retain its original form.

switch {
case len(command) > 0 && currentOS != "*":
case len(command) > 0:
  return fmt.Errorf("the supported commands are 'oc' and 'openshift-install'")
default:
  return fmt.Errorf("no available commands")
}

to replace this if body.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah good point. Updated.

Although, I assume the first case in your example above shouldn't fall through but return the command %q does not support... error?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, sorry, I meant to add a # add correct error here

@stbenjam stbenjam force-pushed the baremetal branch 2 times, most recently from 52e0659 to 581d645 Compare August 20, 2019 14:01
When specifying --command-os='*' and --command, we should use an archive
as there can be more than one result. This previously didn't work.
The installer for baremetal is in a separate image as part of the
release, we need to provide awareness to the `oc` command so we can
actually extract the installer. This also introduces the concept of an
'optional' command that is not extracted when using --tools.
@stbenjam
Copy link
Member Author

/test e2e-aws

@smarterclayton
Copy link
Contributor

/lgtm

We need to watch carefully after merge to see if this breaks any tooling (such as the archive downloading on openshift-release.svc.ci.openshift.org or ART release tooling generating). @sosiouxme @tbielawa @jwforres be aware

No plans to back port this to 4.1 so should have no impact on z stream, unless ART is accidentally using a 4.2 oc binary with 4.1 builds.

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 21, 2019
@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: smarterclayton, stbenjam

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 21, 2019
@openshift-merge-robot openshift-merge-robot merged commit 38aad26 into openshift:master Aug 21, 2019
@stbenjam stbenjam deleted the baremetal branch August 21, 2019 12:48
@stbenjam
Copy link
Member Author

Looks like this already landed in 4.2.0-0.ci-2019-08-21-125453, and cautiously optimistic that everything looks OK.

https://openshift-release-artifacts.svc.ci.openshift.org/4.2.0-0.ci-2019-08-21-125453/ has the tools extracted correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants