vagrant-openshift 3.0.8 → 3.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +6 -1
  3. data/Gemfile +5 -1
  4. data/README.asciidoc +65 -78
  5. data/hack/test.sh +135 -0
  6. data/hack/update.sh +32 -0
  7. data/lib/vagrant-openshift.rb +1 -0
  8. data/lib/vagrant-openshift/action.rb +83 -12
  9. data/lib/vagrant-openshift/action/build_origin_images.rb +2 -2
  10. data/lib/vagrant-openshift/action/create_yum_repositories.rb +1 -1
  11. data/lib/vagrant-openshift/action/download_artifacts_origin_console.rb +2 -2
  12. data/lib/vagrant-openshift/action/download_artifacts_origin_metrics.rb +67 -0
  13. data/lib/vagrant-openshift/action/install_docker.rb +54 -0
  14. data/lib/vagrant-openshift/action/install_golang.rb +52 -0
  15. data/lib/vagrant-openshift/action/install_origin_asset_dependencies.rb +6 -3
  16. data/lib/vagrant-openshift/action/install_origin_base_dependencies.rb +22 -237
  17. data/lib/vagrant-openshift/action/install_origin_rhel7.rb +29 -6
  18. data/lib/vagrant-openshift/action/push_openshift_images.rb +26 -37
  19. data/lib/vagrant-openshift/action/run_customer_diagnostics_tests.rb +79 -0
  20. data/lib/vagrant-openshift/action/run_origin_asset_tests.rb +1 -3
  21. data/lib/vagrant-openshift/action/run_origin_metrics_tests.rb +83 -0
  22. data/lib/vagrant-openshift/action/run_origin_tests.rb +9 -4
  23. data/lib/vagrant-openshift/command/checkout_repositories.rb +1 -3
  24. data/lib/vagrant-openshift/command/create_local_yum_repo.rb +2 -2
  25. data/lib/vagrant-openshift/command/download_artifacts_origin_metrics.rb +49 -0
  26. data/lib/vagrant-openshift/command/install_docker.rb +68 -0
  27. data/lib/vagrant-openshift/command/install_golang.rb +68 -0
  28. data/lib/vagrant-openshift/command/repo_sync_customer_diagnostics.rb +71 -0
  29. data/lib/vagrant-openshift/command/repo_sync_origin_metrics.rb +71 -0
  30. data/lib/vagrant-openshift/command/test_customer_diagnostics.rb +69 -0
  31. data/lib/vagrant-openshift/command/test_origin_image.rb +1 -1
  32. data/lib/vagrant-openshift/command/test_origin_metrics.rb +67 -0
  33. data/lib/vagrant-openshift/constants.rb +8 -2
  34. data/lib/vagrant-openshift/helper/command_helper.rb +63 -39
  35. data/lib/vagrant-openshift/helper/install_helper.rb +139 -0
  36. data/lib/vagrant-openshift/plugin.rb +37 -2
  37. data/lib/vagrant-openshift/resources/configure_docker.sh +53 -0
  38. data/lib/vagrant-openshift/resources/configure_system.sh +23 -0
  39. data/lib/vagrant-openshift/resources/install_chrome.sh +22 -0
  40. data/lib/vagrant-openshift/resources/install_dependencies.sh +58 -0
  41. data/lib/vagrant-openshift/resources/install_nonessential.sh +6 -0
  42. data/lib/vagrant-openshift/resources/install_rhaos_repos.sh +11 -0
  43. data/lib/vagrant-openshift/resources/reconfigure_network_fedora.sh +13 -0
  44. data/lib/vagrant-openshift/resources/rhaos31.repo +13 -0
  45. data/lib/vagrant-openshift/resources/rhaos32.repo +13 -0
  46. data/lib/vagrant-openshift/resources/rhaos33.repo +13 -0
  47. data/lib/vagrant-openshift/resources/rhaos34.repo +13 -0
  48. data/lib/vagrant-openshift/version.rb +1 -1
  49. metadata +29 -3
@@ -50,6 +50,14 @@ module Vagrant
50
50
  end
51
51
  }
52
52
 
53
+ # if verbose output is requested, we don't mess with vagrant's built-in SSH error handling
54
+ # otherwise, we ask for muted SSH error handling to reduce the clutter
55
+ if options[:verbose]
56
+ opts = nil
57
+ else
58
+ opts = { :error_key => :ssh_bad_exit_status_muted }
59
+ end
60
+
53
61
  (0..options[:retries]).each do |retry_count|
54
62
  begin
55
63
  if options[:verbose]
@@ -59,9 +67,9 @@ module Vagrant
59
67
  end
60
68
  Timeout::timeout(options[:timeout]) do
61
69
  if options[:sudo]
62
- rc = machine.communicate.sudo(command, nil, &execute)
70
+ rc = machine.communicate.sudo(command, opts, &execute)
63
71
  else
64
- rc = machine.communicate.execute(command, nil, &execute)
72
+ rc = machine.communicate.execute(command, opts, &execute)
65
73
  end
66
74
  end
67
75
  rescue Timeout::Error
@@ -135,49 +143,65 @@ popd
135
143
 
136
144
  def repo_checkout_bash_command(repo, url)
137
145
  repo_path = File.expand_path(repo)
138
- command = ""
139
- if Pathname.new(repo_path).exist?
140
- if @options[:replace]
141
- command += %{
142
- echo 'Replacing: #{repo_path}'
143
- pushd #{repo_path}
144
- git fetch origin
145
- git reset --hard origin/master
146
- git clean -fdx
147
- set +e
148
- git branch | grep -ve " master$" | xargs git branch -D
149
- set -e
150
- popd
151
- }
152
- else
153
- command += "echo 'Already cloned: #{repo}'\n"
154
- end
155
- else
156
- command += %{
157
- cloned=false
158
- echo 'Cloning #{repo} ...'
159
- }
160
-
161
- if @options[:user]
162
- user_repo_url="git@github.com:#{@options[:user]}/#{repo}"
163
- command += %{
164
- echo 'Cloning #{user_repo_url}'
165
- git clone --quiet --recurse-submodules #{user_repo_url}
166
- if [ $? -eq 0 ]; then
167
- cloned=true
168
- (cd #{repo} && git remote add upstream #{url} && git fetch upstream)
146
+ branch = @options[:branch] || 'master'
147
+ command = %{
148
+ set -e
149
+ clone_repo=false
150
+ if [ -d "#{repo_path}" ]
151
+ then
152
+ replace_repo=#{@options[:replace] ? "true" : "false"}
153
+ echo 'Checking repo integrity for #{repo_path}'
154
+ if (pushd #{repo_path} && git fsck && popd)
155
+ then
156
+ if [ "${replace_repo}" = "true" ]
157
+ then
158
+ echo 'Replacing: #{repo_path}'
159
+ pushd #{repo_path}
160
+ git fetch origin
161
+ git fetch --prune origin +refs/tags/*:refs/tags/*
162
+ git reset --merge
163
+ git checkout #{branch}
164
+ git reset --hard origin/#{branch}
165
+ git clean -fdx
166
+ set +e
167
+ git branch | grep -ve " #{branch}$" | xargs git branch -D
168
+ set -e
169
+ git gc --prune=all
170
+ popd
171
+ else
172
+ echo 'Already cloned: #{repo}'
173
+ fi
174
+ else
175
+ rm -rf #{repo_path}
176
+ clone_repo=true
177
+ fi
169
178
  else
170
- echo 'Fork of repo #{repo} not found. Cloning read-only copy from upstream'
179
+ clone_repo=true
171
180
  fi
172
- }
173
181
 
174
- end
182
+ if [ "${clone_repo}" = "true" ]
183
+ then
184
+ cloned=false
185
+ echo 'Cloning #{repo} ...'
186
+ }
187
+ if @options[:user]
188
+ user_repo_url="git@github.com:#{@options[:user]}/#{repo}"
175
189
  command += %{
176
- [ $cloned != true ] && git clone --quiet --recurse-submodules #{url}
177
- ( cd #{repo} && git checkout #{@options[:branch]} &>/dev/null)
190
+ echo 'Cloning #{user_repo_url}'
191
+ if git clone --quiet --recurse-submodules #{user_repo_url}
192
+ then
193
+ cloned=true
194
+ (cd #{repo} && git remote add upstream #{url} && git fetch upstream)
195
+ else
196
+ echo 'Fork of repo #{repo} not found. Cloning read-only copy from upstream'
197
+ fi
178
198
  }
179
199
  end
180
-
200
+ command += %{
201
+ [ "${cloned}" != true ] && git clone --quiet --recurse-submodules #{url}
202
+ (cd #{repo} && git checkout #{branch} &>/dev/null)
203
+ fi
204
+ }
181
205
  command
182
206
  end
183
207
 
@@ -0,0 +1,139 @@
1
+ #--
2
+ # Copyright 2016 Red Hat, Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #++
16
+
17
+ module Vagrant
18
+ module Openshift
19
+ module InstallHelper
20
+ include CommandHelper
21
+
22
+ # install_from_url installs an RPM repository from the given URL
23
+ # SSL client certs and keys are installed and provided, but won't
24
+ # be used unless they are necessary, so repositories that do not
25
+ # use them can still function correctly with one .repo defenition
26
+ def install_from_url(url)
27
+ reponame = url.gsub(/[^a-zA-Z0-9]/,'')
28
+
29
+ remote_write(@env[:machine], "/etc/yum.repos.d/#{reponame}.repo") {%{
30
+ [#{reponame}]
31
+ name=#{reponame}
32
+ baseurl=#{url}
33
+ enabled=1
34
+ gpgcheck=0
35
+ sslverify=0
36
+ sslclientcert=/var/lib/yum/client-cert.pem
37
+ sslclientkey=/var/lib/yum/client-key.pem
38
+ }}
39
+
40
+ return reponame
41
+ end
42
+
43
+ # assemble_reponames assembles a list of repository names for use
44
+ # with `yum install`, or provides `*` if no repository names are
45
+ # provided
46
+ def assemble_reponames(fresh_install, pre_existing)
47
+ reponames = []
48
+
49
+ # If the user didn't specify any names or install any custom
50
+ # repositories, default to use all of the normally available
51
+ # repositories on the system.
52
+ if fresh_install.empty?() && pre_existing.empty?()
53
+ reponames << '"*"'
54
+ else
55
+ reponames = fresh_install + pre_existing
56
+ end
57
+
58
+ return "--enablerepo=#{reponames.join(" --enablerepo=")}"
59
+ end
60
+
61
+ # format_versioned_package formats a pacakge name with a version
62
+ # to allow for better UX on the command line. For instance, a
63
+ # package `docker` should be called `docker` without a version but
64
+ # `docker-1.11.3` with one, but the user only wants to provide the
65
+ # `1.11.3` version, not the dash as well, so a simple concat is not
66
+ # possible
67
+ def format_versioned_package(name, version)
68
+ if version
69
+ "#{name}-#{version}"
70
+ else
71
+ name
72
+ end
73
+ end
74
+
75
+ # uninstall_safely tries to uninstall the given package, but it
76
+ # will fail if it fails to confirm that only the single package
77
+ # given will be the removed
78
+ def uninstall_safely(machine, package, force)
79
+ stdout, stderr, _ = sudo(machine, "yum remove --assumeno -q #{package}", :timeout=>60, fail_on_error: false)
80
+
81
+ # we want to match output like:
82
+ # Remove 1 Package
83
+ # Remove 20 Packages
84
+ # Remove 1 Package (+1 Dependent package)
85
+ # Remove 20 Packages (+20 Dependent packages)
86
+ amount_pattern = /Remove\s+([0-9]+)\s+Packages?(\s+\(\+([0-9]+)\s+Dependent\s+packages?\))?/
87
+ match = amount_pattern.match((stdout+stderr).join(""))
88
+
89
+ unless match
90
+ raise "Package removal statistics not found in `yum` output."
91
+ end
92
+
93
+ # if we can tell there's more than one package being removed, or if
94
+ # there's any dependent packages being removed, we need to fail the
95
+ # uninstall process unless the force flag has been set
96
+ if (match.captures[0].to_i > 1 || match.captures[2]) && !force
97
+ raise "Removing #{package} would also remove other packages, this is disabled by default for safety."
98
+ end
99
+
100
+ sudo(machine, "yum autoremove -y #{package}", :timeout=>60)
101
+ end
102
+
103
+ # isolated_install runs a full isolated installation of a package,
104
+ # trying to remove previous versions if possible, setting up and
105
+ # tearing down extra repositories, etc.
106
+ def isolated_install(machine, package, version, repourls, reponames, force)
107
+ # if the package is already installed and we can cleanly uninstall it, we should
108
+ if machine.communicate.test("yum list installed #{package}")
109
+ begin
110
+ uninstall_safely(machine, package, force)
111
+ rescue Exception => e
112
+ $stderr.puts "Could not complete #{package} installation process, a previous #{package} install exists and removing it would not be clean:"
113
+ $stderr.puts e.message
114
+ $stderr.puts "If you want to continue anyway, try running the vagrant command again with `--force`"
115
+ exit 1
116
+ end
117
+ end
118
+
119
+ # Install user-specified repositories
120
+ extra_repositories = []
121
+ repourls.each do |url|
122
+ extra_repositories << install_from_url(url)
123
+ end
124
+
125
+ # Install the package
126
+ yum_config=%{-y --disablerepo="*"}
127
+ yum_config+=%{ #{assemble_reponames(extra_repositories, reponames)}}
128
+ yum_config+=%{ #{format_versioned_package(package, version)}}
129
+ sudo(machine, "yum install #{yum_config}", :timeout=>60*30)
130
+
131
+ # Disable all repositories that were installed for the express purpose of giving us the package
132
+ extra_repositories.each do |repo|
133
+ sudo(machine, "yum-config-manager --disable #{repo}", :timeout=>60*30)
134
+ end
135
+ end
136
+
137
+ end
138
+ end
139
+ end
@@ -87,6 +87,16 @@ module Vagrant
87
87
  Commands::InstallOrigin
88
88
  end
89
89
 
90
+ command "install-docker" do
91
+ require_relative "command/install_docker"
92
+ Commands::InstallDocker
93
+ end
94
+
95
+ command "install-golang" do
96
+ require_relative "command/install_golang"
97
+ Commands::InstallGolang
98
+ end
99
+
90
100
  command "install-origin-assets-base" do
91
101
  require_relative "command/install_origin_assets_base"
92
102
  Commands::InstallOriginAssetsBase
@@ -130,7 +140,7 @@ module Vagrant
130
140
  command "test-origin-console" do
131
141
  require_relative "command/test_origin_console"
132
142
  Commands::TestOriginConsole
133
- end
143
+ end
134
144
 
135
145
  command "test-sti" do
136
146
  require_relative "command/test_sti"
@@ -142,6 +152,16 @@ module Vagrant
142
152
  Commands::TestOriginAggregatedLogging
143
153
  end
144
154
 
155
+ command "test-origin-metrics" do
156
+ require_relative "command/test_origin_metrics"
157
+ Commands::TestOriginMetrics
158
+ end
159
+
160
+ command "test-customer-diagnostics" do
161
+ require_relative "command/test_customer_diagnostics"
162
+ Commands::TestCustomerDiagnostics
163
+ end
164
+
145
165
  command "download-artifacts-origin" do
146
166
  require_relative "command/download_artifacts_origin"
147
167
  Commands::DownloadArtifactsOrigin
@@ -150,13 +170,18 @@ module Vagrant
150
170
  command "download-artifacts-origin-console" do
151
171
  require_relative "command/download_artifacts_origin_console"
152
172
  Commands::DownloadArtifactsOriginConsole
153
- end
173
+ end
154
174
 
155
175
  command "download-artifacts-origin-aggregated-logging" do
156
176
  require_relative "command/download_artifacts_origin_aggregated_logging"
157
177
  Commands::DownloadArtifactsOriginAggregatedLogging
158
178
  end
159
179
 
180
+ command "download-artifacts-origin-metrics" do
181
+ require_relative "command/download_artifacts_origin_metrics"
182
+ Commands::DownloadArtifactsOriginAggregatedLogging
183
+ end
184
+
160
185
  command "download-artifacts-sti" do
161
186
  require_relative "command/download_artifacts_sti"
162
187
  Commands::DownloadArtifactsSti
@@ -197,6 +222,16 @@ module Vagrant
197
222
  Commands::RepoSyncOriginAggregatedLogging
198
223
  end
199
224
 
225
+ command "sync-origin-metrics" do
226
+ require_relative "command/repo_sync_origin_metrics"
227
+ Commands::RepoSyncOriginMetrics
228
+ end
229
+
230
+ command "sync-customer-diagnostics" do
231
+ require_relative "command/repo_sync_customer_diagnostics"
232
+ Commands::RepoSyncCustomerDiagnostics
233
+ end
234
+
200
235
  provisioner(:openshift) do
201
236
  require_relative "provisioner"
202
237
  Provisioner
@@ -0,0 +1,53 @@
1
+ #!/bin/bash
2
+
3
+ set -o errexit
4
+ set -o nounset
5
+ set -o pipefail
6
+
7
+ groupadd -f docker
8
+ usermod -a -G docker "${SSH_USER}"
9
+
10
+ ADDITIONAL_OPTIONS='--insecure-registry=172.30.0.0/16 --insecure-registry=ci.dev.openshift.redhat.com:5000'
11
+ sed -i "s,^OPTIONS='\\(.*\\)',OPTIONS='${ADDITIONAL_OPTIONS} \\1'," /etc/sysconfig/docker
12
+ sed -i "s,^OPTIONS=-\\(.*\\),OPTIONS='${ADDITIONAL_OPTIONS} -\\1'," /etc/sysconfig/docker
13
+ sed -i "s,^ADD_REGISTRY='\\(.*\\)',#ADD_REGISTRY='--add-registry=docker.io \\1'," /etc/sysconfig/docker
14
+
15
+ if lvdisplay docker-vg >/dev/null 2>&1; then
16
+ VG="docker-vg"
17
+ elif lvdisplay vg_vagrant >/dev/null 2>&1; then
18
+ VG="vg_vagrant"
19
+ elif lvdisplay fedora >/dev/null 2>&1; then
20
+ VG="fedora"
21
+ elif lvdisplay centos >/dev/null 2>&1; then
22
+ VG="centos"
23
+ fi
24
+
25
+ if [[ -n "${VG}" ]]; then
26
+ lvcreate -n docker-data -l 70%FREE /dev/${VG}
27
+ lvcreate -n docker-metadata -l 17%FREE /dev/${VG}
28
+ lvcreate -n openshift-xfs-vol-dir -l 100%FREE /dev/${VG}
29
+ mkfs.xfs /dev/${VG}/openshift-xfs-vol-dir
30
+ mkdir -p /mnt/openshift-xfs-vol-dir
31
+ echo /dev/${VG}/openshift-xfs-vol-dir /mnt/openshift-xfs-vol-dir xfs gquota 1 1 >> /etc/fstab
32
+ mount /mnt/openshift-xfs-vol-dir
33
+ chown -R "${SSH_USER}:${SSH_USER}" /mnt/openshift-xfs-vol-dir
34
+
35
+ DOCKER_STORAGE_OPTIONS=" -s devicemapper"
36
+ DOCKER_STORAGE_OPTIONS+=" --storage-opt dm.datadev=/dev/${VG}/docker-data"
37
+ DOCKER_STORAGE_OPTIONS+=" --storage-opt dm.metadatadev=/dev/${VG}/docker-metadata"
38
+ if [[ "$(repoquery --pkgnarrow=installed --qf '%{version}' docker)" =~ ^1\.[0-9]{2}\..* ]]; then
39
+ # after Docker 1.10 we need to amend the devicemapper options
40
+ DOCKER_STORAGE_OPTIONS+=" --storage-opt dm.use_deferred_removal=true"
41
+ DOCKER_STORAGE_OPTIONS+=" --storage-opt dm.use_deferred_deletion=true"
42
+ fi
43
+ sed -i "s,^DOCKER_STORAGE_OPTIONS=.*,DOCKER_STORAGE_OPTIONS='${DOCKER_STORAGE_OPTIONS}'," /etc/sysconfig/docker-storage
44
+ fi
45
+
46
+ # Docker 1.8.2 now sets a TimeoutStartSec of 1 minute. Unfortunately, for some
47
+ # reason the initial docker start up is now taking > 5 minutes. Until that is fixed need this.
48
+ sed -i 's,TimeoutStartSec=.*,TimeoutStartSec=10min,' /usr/lib/systemd/system/docker.service
49
+
50
+ systemctl daemon-reexec
51
+ systemctl daemon-reload
52
+ systemctl enable docker
53
+ time systemctl start docker
@@ -0,0 +1,23 @@
1
+ #!/bin/bash
2
+
3
+ set -o errexit
4
+ set -o nounset
5
+ set -o pipefail
6
+
7
+ if [[ ! -e /etc/fedora-release ]]; then
8
+ sed -i 's,^SELINUX=.*,SELINUX=permissive,' /etc/selinux/config
9
+ setenforce 0
10
+ fi
11
+
12
+ systemctl enable ntpd
13
+
14
+ # Force socket reuse
15
+ echo 1 > /proc/sys/net/ipv4/tcp_tw_reuse
16
+
17
+ mkdir -p /data/src
18
+ mkdir -p /data/pkg
19
+ mkdir -p /data/bin
20
+
21
+ chown -R "${SSH_USER}:${SSH_USER}" /data
22
+
23
+ sed -i "s,^#DefaultTimeoutStartSec=.*,DefaultTimeoutStartSec=240s," /etc/systemd/system.conf
@@ -0,0 +1,22 @@
1
+ #!/bin/bash
2
+
3
+ set -o errexit
4
+
5
+ cd /tmp
6
+
7
+ # Add signing key for Chrome repo
8
+ wget https://dl.google.com/linux/linux_signing_key.pub
9
+ rpm --import linux_signing_key.pub
10
+
11
+ # Add Chrome yum repo
12
+ yum-config-manager --add-repo=http://dl.google.com/linux/chrome/rpm/stable/x86_64
13
+
14
+ # Install chrome
15
+ yum install -y google-chrome-stable
16
+
17
+ # Install chromedriver
18
+ wget https://chromedriver.storage.googleapis.com/2.16/chromedriver_linux64.zip
19
+ unzip chromedriver_linux64.zip
20
+ mv chromedriver /usr/bin/chromedriver
21
+ chown root /usr/bin/chromedriver
22
+ chmod 755 /usr/bin/chromedriver