Browse Source

Merge pull request #8273 from vrutkovs/papr-3.9-to-3.10-upgrade

PAPR: run upgrade from 3.9 branch
OpenShift Merge Robot 6 years ago
parent
commit
d27fb63df1

+ 1 - 1
.papr.all-in-one.inventory

@@ -29,4 +29,4 @@ ocp-master
 ocp-master
 
 [nodes]
-ocp-master openshift_schedulable=true openshift_node_labels="{'node-role.kubernetes.io/infra':'true'}"
+ocp-master openshift_schedulable=true openshift_node_labels="{'node-role.kubernetes.io/infra':'true'}" ansible_host="{{ lookup('env', 'RHCI_ocp_master_IP') }}"

+ 27 - 7
.papr.sh

@@ -19,7 +19,6 @@ else
 fi
 export target_branch
 
-
 # Need to define some git variables for rebase.
 git config --global user.email "ci@openshift.org"
 git config --global user.name "OpenShift Atomic CI"
@@ -27,16 +26,31 @@ git config --global user.name "OpenShift Atomic CI"
 # Rebase existing branch on the latest code locally, as PAPR running doesn't do merges
 git fetch origin ${target_branch_in} && git rebase origin/${target_branch_in}
 
-pip install -r requirements.txt
-
 PAPR_INVENTORY=${PAPR_INVENTORY:-.papr.inventory}
 PAPR_RUN_UPDATE=${PAPR_RUN_UPDATE:-0}
+PAPR_UPGRADE_FROM=${PAPR_UPGRADE_FROM:-0}
+PAPR_EXTRAVARS=""
+
+# Replace current branch with PAPR_UPGRADE_FROM
+if [[ "${PAPR_UPGRADE_FROM}" != "0" ]]; then
+  git branch new-code
+  git checkout release-${PAPR_UPGRADE_FROM}
+  git clean -fdx
+  PAPR_EXTRAVARS="-e openshift_release=${PAPR_UPGRADE_FROM}"
+fi
+
+pip install -r requirements.txt
 
 # Human-readable output
 export ANSIBLE_STDOUT_CALLBACK=debug
 
 # ping the nodes to check they're responding and register their ostree versions
-ansible -vvv -i $PAPR_INVENTORY nodes -a 'rpm-ostree status'
+ansible -vv -i $PAPR_INVENTORY nodes -a 'rpm-ostree status'
+
+# Make sure hostname -f returns correct node name
+ansible -vv -i $PAPR_INVENTORY nodes -m setup
+ansible -vv -i $PAPR_INVENTORY nodes -a "hostnamectl set-hostname {{ ansible_default_ipv4.address }}"
+ansible -vv -i $PAPR_INVENTORY nodes -m setup -a "gather_subset=min"
 
 upload_journals() {
   mkdir journals
@@ -52,12 +66,18 @@ upload_journals() {
 trap upload_journals ERR
 
 # run the prerequisites play
-ansible-playbook -vvv -i $PAPR_INVENTORY playbooks/prerequisites.yml
+ansible-playbook -vvv -i $PAPR_INVENTORY $PAPR_EXTRAVARS playbooks/prerequisites.yml
 
 # run the actual installer
-ansible-playbook -vvv -i $PAPR_INVENTORY playbooks/deploy_cluster.yml
+ansible-playbook -vvv -i $PAPR_INVENTORY $PAPR_EXTRAVARS playbooks/deploy_cluster.yml
+
+# Restore the branch if needed
+if [[ "${PAPR_UPGRADE_FROM}" != "0" ]]; then
+  git checkout new-code
+  git clean -fdx
+fi
 
-# Run upgrade playbook (to a minor version)
+# Run upgrade playbook
 if [[ "${PAPR_RUN_UPDATE}" != "0" ]]; then
   update_version="$(echo $target_branch | sed 's/\./_/')"
   ansible-playbook -vvv -i $PAPR_INVENTORY playbooks/byo/openshift-cluster/upgrades/v${update_version}/upgrade.yml

+ 17 - 1
.papr.yml

@@ -44,7 +44,7 @@ artifacts:
 
 ---
 inherit: true
-context: 'fedora/27/atomic/update'
+context: 'fedora/27/atomic/upgrade_minor'
 
 cluster:
   hosts:
@@ -60,6 +60,22 @@ env:
 
 ---
 inherit: true
+context: 'fedora/27/atomic/upgrade_major'
+
+cluster:
+  hosts:
+    - name: ocp-master
+      distro: fedora/27/atomic
+      specs:
+        ram: 4096
+  container:
+    image: registry.fedoraproject.org/fedora:27
+env:
+  PAPR_INVENTORY: .papr.all-in-one.inventory
+  PAPR_UPGRADE_FROM: "3.9"
+  PAPR_RUN_UPDATE: "yes"
+---
+inherit: true
 context: 'fedora/27/atomic/master-ha'
 
 cluster:

+ 9 - 0
roles/lib_openshift/library/oc_atomic_container.py

@@ -67,6 +67,7 @@ options:
 
 # pylint: disable=wrong-import-position,too-many-branches,invalid-name,no-name-in-module, import-error
 import json
+import os
 
 from distutils.version import StrictVersion
 
@@ -92,9 +93,17 @@ def _uninstall(module, name):
     rc, out, err = module.run_command(args, check_rc=False)
     return rc, out, err, False
 
+def _ensure_service_file_is_removed(container):
+    '''atomic install won't overwrite existing service file, so it needs to be removed'''
+    service_path = '/etc/systemd/system/{}.service'.format(container)
+    if not os.path.exists(service_path):
+        return
+    os.remove(service_path)
 
 def do_install(module, container, image, values_list):
     ''' install a container and exit the module. '''
+    _ensure_service_file_is_removed(container)
+
     rc, out, err, changed = _install(module, container, image, values_list)
     if rc != 0:
         module.fail_json(rc=rc, msg=err)

+ 9 - 0
roles/lib_openshift/src/ansible/oc_atomic_container.py

@@ -3,6 +3,7 @@
 
 # pylint: disable=wrong-import-position,too-many-branches,invalid-name,no-name-in-module, import-error
 import json
+import os
 
 from distutils.version import StrictVersion
 
@@ -28,9 +29,17 @@ def _uninstall(module, name):
     rc, out, err = module.run_command(args, check_rc=False)
     return rc, out, err, False
 
+def _ensure_service_file_is_removed(container):
+    '''atomic install won't overwrite existing service file, so it needs to be removed'''
+    service_path = '/etc/systemd/system/{}.service'.format(container)
+    if not os.path.exists(service_path):
+        return
+    os.remove(service_path)
 
 def do_install(module, container, image, values_list):
     ''' install a container and exit the module. '''
+    _ensure_service_file_is_removed(container)
+
     rc, out, err, changed = _install(module, container, image, values_list)
     if rc != 0:
         module.fail_json(rc=rc, msg=err)

+ 2 - 2
roles/openshift_control_plane/tasks/static.yml

@@ -58,8 +58,8 @@
     name: "{{ item }}"
     state: absent
   with_items:
-  - /etc/sysconfig/{{ openshift_service_type }}-api
-  - /etc/sysconfig/{{ openshift_service_type }}-controllers
+  - /etc/sysconfig/{{ openshift_service_type }}-master-api
+  - /etc/sysconfig/{{ openshift_service_type }}-master-controllers
 
 - name: Remove temporary directory
   file: