Skip to content
This repository has been archived by the owner on Aug 29, 2018. It is now read-only.

Allow for users to specify Golang and Docker versions and RPM repos #459

Conversation

stevekuznetsov
Copy link
Contributor

In order to allow for better configuration of our AMI builds, four
new flags are added to the vagrant build-origin-base command:
--repofile: to specify repo files to install
--repo: to specify repositories to enable for Golang/Docker
--golang-version: to specify Golang version
--docker-version: to specify Docker version

Any repositories installed from files provided with --repofile
will be enabled only for the installation of Golang and Docker,
and will be enabled for those installs by default, unless the user
provides repositories with --repo to override the default.

The --{golang,docker}-version flags are used to construct package
names for the core package as well as for peripheral packages, for
instance golang and golang-src. Provide these versions with this
behavior in mind.

Signed-off-by: Steve Kuznetsov [email protected]

@danmcp PTAL impl, will test when we agree on it

})
@options[:reponames] << "dockerextra"

File.open("/etc/yum.repos.d/origin-deps-rhel7.repo", "w").write(%{
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't see a good reason to be fetching this file from the web each time, but we can keep that. I like this approach as it's closer to the other hard-coded repo and because converting the wget to Ruby would mean we require 'open-uri' above and I'm not sure if that is totally ok (will that dep always be present?).

@stevekuznetsov stevekuznetsov force-pushed the skuznets/branch-specific-builds branch from 0d29d7a to 876da65 Compare June 10, 2016 15:11
fi
}, :timeout=>60*10, :verbose => false)
# Install base dependencies that we cannot continue without
sudo(@env[:machine], "~/install_dependencies.s", :timeout=>60*30, :verbose => false)
Copy link

Choose a reason for hiding this comment

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

.s?

@stevekuznetsov stevekuznetsov force-pushed the skuznets/branch-specific-builds branch 2 times, most recently from a78c558 to cce7a26 Compare June 10, 2016 17:43
@stevekuznetsov
Copy link
Contributor Author

I changed the behavior slightly. The flags are now:

$ vagrant build-origin-base --help
Usage: vagrant build-origin-base [vm-name]

        --golang.repofile [name]     Path to repository file to use when installing Golang.
        --golang.repo [name]         Name of repository to enable when installing Golang.
        --golang.version [version]   Install the specified Golang version. Leave empty to install latest available.
        --docker.repofile [name]     Path to repository file to use when installing Docker.
        --docker.repo [name]         Name of repository to enable when installing Docker.
        --docker.version [version]   Install the specified Docker version. Leave empty to install latest available.
    -h, --help                       Print this help

The behavior is to use the 'default' repos (which we only have for RHEL7) if no repofiles or reponames are given, or to use only the names of repos given in repofiles if they're given, or to use only the names given in reponames if they are given and no repofiles are given. Giving repofiles and reponames is fobidden.

We install latest from specified repos unless version is given.

To test we want to see:

  • vagrant build-origin-base installs Golang and Docker latest versions from origin-deps-rhel7 and dockerextra
  • vagrant build-origin-base --docker.version <ver> --docker.repo oso-rhui-rhel-server-extras installs whatever non-latest Docker version from oso-rhui-rhel-server-extras
  • vagrant build-origin-base --golang.version <ver> --golang.repo oso-rhui-rhel-server-releases-optional installs whatever non-latest Golang version from oso-rhui-rhel-server-releases-optional
  • vagrant build-origin-base --docker.repofile <file> --docker.version <ver> installs Docker version from the specified repo ... we could just copy the oso-rhui-rhel-server-extras repofile into a local file to use
  • vagrant build-origin-base --golang.repofile <file> --golang.version <ver> installs Golang version from the specified repo ... we could just copy the oso-rhui-rhel-server-releases-optional repofile into a local file to use

@danmcp thoughts?

@stevekuznetsov
Copy link
Contributor Author

Without any flags, I've had the default setting (which is the same as what we had before) go until flake in e2e somewhere, so I'm fairly confident the resource file refactor is solid. Now just to test the logic.

@danmcp
Copy link

danmcp commented Jun 13, 2016

If you specify a golang and docker repo (or repofile) that are the same, will you dedup or add 2 of them?

vagrant build-origin-base installs Golang and Docker latest versions from origin-deps-rhel7 and dockerextra

We should change this case to pull in nothing extra. These should really be special cases already.

@stevekuznetsov
Copy link
Contributor Author

If you specify a golang and docker repo (or repofile) that are the same, will you dedup or add 2 of them?

I'm not particularly interested in adding deduping logic -- what's the long-term support going to be like for this plugin? Once we move away from it as an organization, who's going to be using it? Do they need good UX?

. These should really be special cases already.

I like it. Makes the logic simpler.

@stevekuznetsov stevekuznetsov force-pushed the skuznets/branch-specific-builds branch from 79ae3e2 to 47caf67 Compare June 14, 2016 16:47
@stevekuznetsov
Copy link
Contributor Author

stevekuznetsov commented Jun 15, 2016

For posterity, now that default is special-case, previous default is achieved with:

$ vagrant build-origin-base --golang.repofile="${vagrant-openshift}/lib/vagrant-openshift/resources/origin-deps-rhel7.repo" \
                            --golang.version=1.6.2                                                                          \
                            --docker.repofile="${vagrant-openshift}/lib/vagrant-openshift/resources/dockerextra.repo"       \
                            --docker.repo=oso-rhui-rhel-server-releases                                                     \
                            --docker.version=1.10.3

@stevekuznetsov stevekuznetsov force-pushed the skuznets/branch-specific-builds branch 9 times, most recently from 84603bf to 58b9c3f Compare June 21, 2016 15:27
==== Configuring Docker and Golang versions for tests

If the version of OpenShift that is being tested requires a version
of Golang or Docker that is not default in the RPM streams for the
Copy link

@danmcp danmcp Jun 21, 2016

Choose a reason for hiding this comment

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

Don't reference AMI here or below.

@stevekuznetsov stevekuznetsov force-pushed the skuznets/branch-specific-builds branch from 58b9c3f to e07bc0c Compare June 21, 2016 17:36
@@ -58,6 +58,7 @@ def call(env)
ADD vars/* /etc/yum/vars/
ADD repos/* /etc/yum.repos.d/
ADD certs/* /var/lib/yum/
ADD keys/* /etc/pki/rpm-gpg/
Copy link

Choose a reason for hiding this comment

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

What is this about?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is actually exactly what I was talking about on the call - we're pulling later from repos that use these public keys for GPG package checks... but didn't have the keys

@stevekuznetsov stevekuznetsov force-pushed the skuznets/branch-specific-builds branch from e07bc0c to 1165086 Compare July 6, 2016 19:09
@stevekuznetsov
Copy link
Contributor Author

stevekuznetsov commented Jul 6, 2016

@danmcp testing looks good:

origin/master

$ GOLANG_REPO='http://mirror.openshift.com/pub/openshift-origin/nightly/rhel-7/dependencies/x86_64/'
$ vagrant build-origin-base --golang.version=1.6.2            \
                            --golang.repourl="${GOLANG_REPO}" \
                            --docker.version=1.10.3
...
Jul 06 14:12:08   Installing : golang-1.6.2-1.el7.x86_64                                    3/3
...
Jul 06 14:12:32   Installing : docker-1.10.3-44.el7.x86_64                                  9/9

ose/master

$ GOLANG_REPO='http://mirror.openshift.com/pub/openshift-origin/nightly/rhel-7/dependencies/x86_64/'
$ vagrant build-origin-base --golang.version=1.6.2            \
                            --golang.repourl="${GOLANG_REPO}" \
                            --docker.version=1.10.3
...
Jul 06 14:16:07   Installing : golang-1.6.2-1.el7.x86_64                                    3/3
...
Jul 06 14:16:23   Installing : docker-1.10.3-44.el7.x86_64                                  9/9

ose/enterprise-3.0

$ vagrant build-origin-base --golang.version=1.4.2 \
                            --docker.version=1.8.2
...
Jul 06 14:17:22   Installing : golang-1.4.2-9.el7.x86_64                                    3/4
...
Jul 06 14:17:48   Installing : docker-1.8.2-10.el7.x86_64                                   2/2

ose/enterprise-3.1

$ vagrant build-origin-base --golang.version=1.4.2 \
                            --docker.version=1.8.2
...
Jul 06 14:20:12   Installing : golang-1.4.2-9.el7.x86_64                                    3/4
...
Jul 06 14:20:37   Installing : docker-1.8.2-10.el7.x86_64                                   2/2

ose/enterprise-3.2

$ GOLANG_REPO='http://mirror.openshift.com/pub/openshift-origin/nightly/rhel-7/dependencies/x86_64/'
$ vagrant build-origin-base --golang.version=1.6.2            \
                            --golang.repourl="${GOLANG_REPO}" \
                            --docker.version=1.9.1
...
Jul 06 14:21:50   Installing : golang-1.6.2-1.el7.x86_64                                    3/3
...
Jul 06 14:22:27   Installing : docker-1.9.1-40.el7.x86_64                                   4/4
$ GOLANG_REPO='http://mirror.openshift.com/pub/openshift-origin/nightly/rhel-7/dependencies/x86_64/'
$ vagrant build-origin-base --golang.version=1.6.2            \
                            --golang.repourl="${GOLANG_REPO}" \
                            --docker.version=1.10.3
...
Jul 06 14:23:42   Installing : golang-1.6.2-1.el7.x86_64                                    3/3
...
Jul 06 14:24:06   Installing : docker-1.10.3-44.el7.x86_64                                  9/9

@stevekuznetsov stevekuznetsov force-pushed the skuznets/branch-specific-builds branch 2 times, most recently from 8f7a349 to d2b19e0 Compare November 2, 2016 14:15
@stevekuznetsov
Copy link
Contributor Author

[test] me

@stevekuznetsov stevekuznetsov force-pushed the skuznets/branch-specific-builds branch 3 times, most recently from d9ce05a to 94db4ce Compare November 2, 2016 16:37
@stevekuznetsov stevekuznetsov force-pushed the skuznets/branch-specific-builds branch 14 times, most recently from 20c9304 to 96a625d Compare November 7, 2016 22:23
@stevekuznetsov
Copy link
Contributor Author

@danmcp I've taken the Docker and Golang installation completely out of build-origin-base since we can't do a re-install afterwords. Tests seem to be fine. I'll squash and make this pretty tomorrow, and we can get it installed Monday morning.

@openshift-bot
Copy link

Evaluated for vagrant openshift test up to 96a625d

@openshift-bot
Copy link

Vagrant OpenShift Test Results: SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_requests_vagrant_openshift/83/) (Base Commit: f06be13)

@stevekuznetsov
Copy link
Contributor Author

Green tests, I'll squash and merge. @danmcp FYI

In order to allow each job building an AMI to be able to declare the
Docker and Golang versions that should be present, the Docker and
Golang install paths are separated out so that they live alone and
are not called in the `build-origin-base` command but instead in
specific `install-docker` and `install-golang` commands that can be
run by a user to configfure the version of Docker or Golang installed
on the system.

These new commands have the following flags:
  --{golang,docker}.version to specify the version to install
The following flags determine what repos are enabled during the
installation process:
  --repourl to specify the URL of an RPM repo
  --repo to specify the name of an installed repo

Any repositories installed from URLs  provided with the above flags
will be enabled *only* for the installation of Golang or Docker,
and will be disabled thereafter.

The `--{golang,docker}.version` flags are used to construct package
names for the core package as well as for peripheral packages, for
instance `golang` and `golang-src`. No leading dash is necessary
to specify the version. For instance, a user would specify that they
want `golang-1.6.2` by passing `--golang.version=1.6.2`.

Repositories installed from URLs will have a .repo file created for
them automatically. The name of the repository will be the given
URL with all non-alphanumeric characters (/[^a-zA-Z0-9]/) stripped
out. Then, the URL and name will be inserted into the following
definition:
```
[#{reponame}]
name=#{reponame}
baseurl=#{url}
enabled=1
gpgcheck=0
sslverify=0
sslclientcert=/var/lib/yum/client-cert.pem
sslclientkey=/var/lib/yum/client-key.pem
```

As the sslclient{cert,key} are not used unless the RPM repository
responds to a request with auth headers, these fields are ignored
unless the repository needs them and therefore repositories that
do not need them are not broken and it is safe to append them always.

Signed-off-by: Steve Kuznetsov <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants