From 3d7c5c6fd545112d87fa09e4a8c3f3cbc1cda1ee Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Wed, 28 Oct 2015 15:29:52 -0300 Subject: First cut at checking available disk space for etcd backup. --- playbooks/adhoc/upgrades/upgrade.yml | 27 ++++++++++++++++++++++++++- utils/src/ooinstall/cli_installer.py | 15 ++++++++++++++- utils/src/ooinstall/install_transactions.py | 1 - utils/src/ooinstall/variants.py | 5 ++++- 4 files changed, 44 insertions(+), 4 deletions(-) diff --git a/playbooks/adhoc/upgrades/upgrade.yml b/playbooks/adhoc/upgrades/upgrade.yml index e8d6a335d..c2c1d57e8 100644 --- a/playbooks/adhoc/upgrades/upgrade.yml +++ b/playbooks/adhoc/upgrades/upgrade.yml @@ -1,5 +1,5 @@ --- -- name: Verify deployment type +- name: Verify upgrade can proceed hosts: masters tasks: # Checking the global deployment type rather than host facts, this is about @@ -7,6 +7,31 @@ - fail: msg="Deployment type enterprise not supported for upgrade" when: deployment_type == "enterprise" +- name: Backup etcd + hosts: masters + vars: + embedded_etcd: "{{ openshift.master.embedded_etcd }}" + roles: + - openshift_facts + tasks: + - name: display all variables set for the current host + debug: + var: hostvars[inventory_hostname] + - debug: var=embedded_etcd + - name: Check available data dir disk space + shell: > + df --output=avail -k {{ openshift.common.data_dir }} | tail -n 1 + register: avail_disk + when: embedded_etcd | bool + - debug: var=avail_disk.stdout + - name: Check current etcd disk usage + shell: > + df --output=avail -k /var/lib/openshift/openshift.local.etcd/ | tail -n 1 + register: etc_disk_usage + when: embedded_etcd | bool + - debug: var=etc_disk_usage.stdout + - fail: msg="All done for now." + - name: Re-Run cluster configuration to apply latest configuration changes include: ../../common/openshift-cluster/config.yml vars: diff --git a/utils/src/ooinstall/cli_installer.py b/utils/src/ooinstall/cli_installer.py index e22217fdb..daac5e388 100644 --- a/utils/src/ooinstall/cli_installer.py +++ b/utils/src/ooinstall/cli_installer.py @@ -191,7 +191,7 @@ Notes: facts_confirmed = click.confirm("Do the above facts look correct?") if not facts_confirmed: message = """ -Edit %s with the desired values and rerun oo-install with --unattended . +Edit %s with the desired values and re-run with --unattended . """ % oo_cfg.config_path click.echo(message) # Make sure we actually write out the config file. @@ -477,6 +477,19 @@ def upgrade(ctx): if not proceed: click.echo("Upgrade cancelled.") sys.exit(0) + + # Update config to reflect the version we're targetting, we'll write + # to disk once ansible completes successfully, not before. + old_variant = oo_cfg.settings['variant'] + old_version = oo_cfg.settings['variant_version'] + if oo_cfg.settings['variant'] == 'enterprise': + oo_cfg.settings['variant'] = 'openshift-enterprise' + variant, version = find_variant(oo_cfg.settings['variant']) + oo_cfg.settings['variant_version'] = version.name + click.echo("Upgrading from %s %s to %s %s" % ( + old_variant, old_version, oo_cfg.settings['variant'], + oo_cfg.settings['variant_version'])) + install_transactions.run_upgrade_playbook() diff --git a/utils/src/ooinstall/install_transactions.py b/utils/src/ooinstall/install_transactions.py index 60b0f3d9f..1d1dbe340 100644 --- a/utils/src/ooinstall/install_transactions.py +++ b/utils/src/ooinstall/install_transactions.py @@ -14,7 +14,6 @@ def set_config(cfg): CFG = cfg def generate_inventory(hosts): - print hosts global CFG base_inventory_path = CFG.settings['ansible_inventory_path'] base_inventory = open(base_inventory_path, 'w') diff --git a/utils/src/ooinstall/variants.py b/utils/src/ooinstall/variants.py index ed98429fc..219af6cd2 100644 --- a/utils/src/ooinstall/variants.py +++ b/utils/src/ooinstall/variants.py @@ -29,6 +29,9 @@ class Variant(object): self.versions = versions + def latest_version(self): + return self.versions[-1] + # WARNING: Keep the versions ordered, most recent last: OSE = Variant('openshift-enterprise', 'OpenShift Enterprise', @@ -58,7 +61,7 @@ def find_variant(name, version=None): for prod in SUPPORTED_VARIANTS: if prod.name == name: if version is None: - return (prod, prod.versions[-1]) + return (prod, prod.latest_version()) for v in prod.versions: if v.name == version: return (prod, v) -- cgit v1.2.3