Drop RabbitMQ support

Drop support for sending sync status messages to a RMQ exchange.

This was used by conjure-up which is no longer maintained so
drop the supporting code, metadata and options and remove
RabbitMQ from all test bundles.

Change-Id: I504508a64e50a9d331f6c5d69b292d9ccc20da3d
Func-Test-PR: https://github.com/openstack-charmers/zaza-openstack-tests/pull/321
This commit is contained in:
James Page 2020-06-17 05:50:47 +01:00
parent fd3d2b7610
commit 9698b5ca2a
15 changed files with 46 additions and 301 deletions

View File

@ -67,14 +67,6 @@ options:
Currently the only available substitution is "region". Any
other attempted substitutions will break the sync script.
rabbit-user:
default: glance-simplestreams-sync
type: string
description: Username to request access on rabbitmq-server.
rabbit-vhost:
default: openstack
type: string
description: RabbitMQ virtual host to request access on rabbitmq-server.
ssl_ca:
type: string
default:

View File

@ -23,12 +23,22 @@
# juju relation to keystone. However, it does not execute in a
# juju hook context itself.
import atexit
import base64
import copy
import fcntl
import logging
import os
import shutil
import sys
import subprocess
import tempfile
import time
import yaml
from keystoneclient.v2_0 import client as keystone_client
from keystoneclient.v3 import client as keystone_v3_client
from keystoneclient import exceptions as keystone_exceptions
def setup_logging():
@ -54,19 +64,6 @@ def setup_logging():
log = setup_logging()
import atexit
import fcntl
from keystoneclient.v2_0 import client as keystone_client
from keystoneclient.v3 import client as keystone_v3_client
import keystoneclient.exceptions as keystone_exceptions
import kombu
import sys
import time
import traceback
import yaml
import subprocess
KEYRING = '/usr/share/keyrings/ubuntu-cloudimage-keyring.gpg'
CONF_FILE_DIR = '/etc/glance-simplestreams-sync'
PID_FILE_DIR = '/var/run'
@ -228,7 +225,7 @@ def set_openstack_env(id_conf, charm_conf):
os.environ['OS_TENANT_NAME'] = id_conf['admin_tenant_name']
def do_sync(charm_conf, status_exchange):
def do_sync(charm_conf):
# NOTE(beisner): the user_agent variable was an unused assignment (lint).
# It may be worth re-visiting its usage, intent and benefit with the
@ -374,96 +371,6 @@ def update_endpoint_urls(region, publicurl, adminurl, internalurl):
juju_run_cmd(_cmd)
class StatusExchange:
"""Wrapper for rabbitmq status exchange connection.
If no connection exists, this attempts to create a connection
before sending each message.
"""
def __init__(self):
self.conn = None
self.exchange = None
self._setup_connection()
def _setup_connection(self):
"""Returns True if a valid connection exists already, or if one can be
created."""
if self.conn:
return True
id_conf = read_conf(ID_CONF_FILE_NAME)
# The indentity.yaml file contains either a singular string variable
# 'rabbit_host', or a comma separated list in the plural variable
# 'rabbit_hosts'
host = None
hosts = id_conf.get('rabbit_hosts', None)
if hosts is not None:
host = hosts.split(",")[0]
else:
host = id_conf.get('rabbit_host', None)
if host is None:
log.warning("no host info in configuration, can't set up rabbit.")
return False
try:
# amqp:// implies librabbitmq if available, otherwise pyamqp
# librabbitmq doesn't support SSL
# use pyamqp:// explicitly for SSL
url = "pyamqp://{}:{}@{}/{}".format(
id_conf['rabbit_userid'], id_conf['rabbit_password'],
host, id_conf['rabbit_virtual_host'])
ssl = None
if 'rabbit_use_ssl' in id_conf:
if 'ssl_ca' in id_conf:
cacert = CACERT_FILE
else:
cacert = SYSTEM_CACERT_FILE
try:
os.makedirs('/usr/local/share/ca-certificates')
except os.error:
# ignore existence of already created directory
pass
with open('/usr/local/share/ca-certificates/'
'glance-simplestreams-sync.crt', 'wb') as f:
f.write(
base64.b64decode(id_conf['kombu_ssl_ca_certs']))
subprocess.check_call(
['/usr/sbin/update-ca-certificates', '--fresh'])
ssl = {'ca_certs': cacert}
self.conn = kombu.BrokerConnection(url, ssl=ssl)
self.exchange = kombu.Exchange("glance-simplestreams-sync-status")
status_queue = kombu.Queue("glance-simplestreams-sync-status",
exchange=self.exchange)
status_queue(self.conn.channel()).declare()
except: # noqa
log.exception("Exception during kombu setup")
return False
return True
def send_message(self, msg):
if not self._setup_connection():
log.warning("No rabbitmq connection available for msg"
"{}. Message will be lost.".format(str(msg)))
return
with self.conn.Producer(exchange=self.exchange) as producer:
producer.publish(msg)
def close(self):
if self.conn:
self.conn.close()
def cleanup():
try:
os.unlink(SYNC_RUNNING_FLAG_FILE_NAME)
@ -515,23 +422,14 @@ def main():
else:
log.info("Not updating product streams service.")
status_exchange = StatusExchange()
log.info("Beginning image sync")
status_set('maintenance', 'Synchronising images')
status_exchange.send_message({"status": "Started",
"message": "Sync starting."})
do_sync(charm_conf, status_exchange)
do_sync(charm_conf)
ts = time.strftime("%x %X")
# "Unit is ready" is one of approved message prefixes
# Prefix the message with it will help zaza to understand the status.
completed_msg = "Unit is ready. Sync completed at {}".format(ts)
status_exchange.send_message({"status": "Done",
"message": completed_msg})
status_set('active', completed_msg)
status_exchange.close()
status_set('active', "Unit is ready (Sync completed at {})".format(ts))
# If this is an initial per-minute sync attempt, delete it on success.
if os.path.exists(CRON_POLL_FILENAME):
@ -547,8 +445,6 @@ def main():
log.info("Glance endpoint not found, will continue polling.")
except Exception:
log.exception("Exception during syncing:")
status_exchange.send_message(
{"status": "Error", "message": traceback.format_exc()})
status_set('blocked', 'Image sync failed, retrying soon.')
log.info("sync done.")

View File

@ -1 +0,0 @@
hooks.py

View File

@ -1 +0,0 @@
hooks.py

View File

@ -37,8 +37,7 @@ from charmhelpers.fetch.snap import snap_install
from charmhelpers.core import hookenv
from charmhelpers.payload.execd import execd_preinstall
from charmhelpers.contrib.openstack.context import (AMQPContext,
IdentityServiceContext,
from charmhelpers.contrib.openstack.context import (IdentityServiceContext,
OSContextGenerator)
from charmhelpers.contrib.openstack.utils import (
get_os_codename_package,
@ -80,12 +79,10 @@ ERR_FILE_EXISTS = 17
PACKAGES = ['python-glanceclient',
'python-yaml', 'python-keystoneclient',
'python-kombu',
'python-swiftclient', 'ubuntu-cloudimage-keyring', 'snapd']
PY3_PACKAGES = ['python3-glanceclient',
'python3-yaml', 'python3-keystoneclient',
'python3-kombu',
'python3-swiftclient']
JUJU_CA_CERT = "/usr/local/share/ca-certificates/keystone_juju_ca_cert.crt"
@ -187,7 +184,6 @@ def get_configs():
configs.register(MIRRORS_CONF_FILE_NAME, [MirrorsConfigServiceContext()])
configs.register(ID_CONF_FILE_NAME, [SSLIdentityServiceContext(),
AMQPContext(),
UnitNameContext()])
return configs
@ -342,22 +338,6 @@ def upgrade_charm():
ensure_perms()
@hooks.hook('amqp-relation-joined')
def amqp_joined():
conf = hookenv.config()
hookenv.relation_set(username=conf['rabbit-user'],
vhost=conf['rabbit-vhost'])
@hooks.hook('amqp-relation-changed')
def amqp_changed():
configs = get_configs()
if 'amqp' not in configs.complete_contexts():
hookenv.log('amqp relation incomplete. Peer not ready?')
return
configs.write(ID_CONF_FILE_NAME)
@hooks.hook('nrpe-external-master-relation-joined',
'nrpe-external-master-relation-changed')
def update_nrpe_config():

View File

@ -25,7 +25,5 @@ provides:
requires:
identity-service:
interface: keystone
amqp:
interface: rabbitmq
certificates:
interface: tls-certificates

View File

@ -19,26 +19,3 @@ ssl_ca: |
admin_domain_name: {{ admin_domain_name }}
{% endif -%}
unit_name: {{ unit_name }}
{% if rabbitmq_host or rabbitmq_hosts -%}
rabbit_userid: {{ rabbitmq_user }}
rabbit_virtual_host: {{ rabbitmq_virtual_host }}
rabbit_password: {{ rabbitmq_password }}
{% if rabbitmq_hosts -%}
rabbit_hosts: {{ rabbitmq_hosts }}
{% if rabbitmq_ha_queues -%}
rabbit_ha_queues: True
rabbit_durable_queues: False
{% endif -%}
{% else -%}
rabbit_host: {{ rabbitmq_host }}
{% endif -%}
{% if rabbit_ssl_port -%}
rabbit_use_ssl: True
rabbit_port: {{ rabbit_ssl_port }}
{% if rabbit_ssl_ca -%}
kombu_ssl_ca_certs: |
{{ rabbit_ssl_ca | indent( width=2, indentfirst=True) }}
{% endif -%}
{% endif -%}
{% endif -%}

View File

@ -5,19 +5,15 @@ comment:
machines:
'0':
constraints: mem=3072M
'1':
'2':
'3':
'4':
'5':
relations:
- ['vault:shared-db', 'mysql:shared-db']
- ['keystone:shared-db', 'mysql:shared-db']
- ['glance:shared-db', 'mysql:shared-db']
- ['glance:amqp', 'rabbitmq-server:amqp']
- ['glance-simplestreams-sync:amqp', 'rabbitmq-server:amqp']
- ['keystone:certificates', 'vault:certificates']
- ['glance:certificates', 'vault:certificates']
- ['glance-simplestreams-sync:certificates', 'vault:certificates']
@ -30,33 +26,25 @@ applications:
num_units: 1
to:
- '0'
rabbitmq-server:
charm: cs:~openstack-charmers-next/rabbitmq-server
num_units: 1
options:
ssl: 'on' # must be str(in quote), otherwise it's bool
to:
- '1'
vault:
charm: cs:~openstack-charmers-next/vault
num_units: 1
to:
- '2'
- '1'
keystone:
charm: cs:~openstack-charmers-next/keystone
num_units: 1
to:
- '3'
- '2'
glance:
charm: cs:~openstack-charmers-next/glance
num_units: 1
to:
- '4'
- '3'
glance-simplestreams-sync:
charm: ../../glance-simplestreams-sync
num_units: 1
options:
source: ppa:simplestreams-dev/trunk
use_swift: False
to:
- '5'
- '4'

View File

@ -5,19 +5,15 @@ comment:
machines:
'0':
constraints: mem=3072M
'1':
'2':
'3':
'4':
'5':
relations:
- ['vault:shared-db', 'mysql:shared-db']
- ['keystone:shared-db', 'mysql:shared-db']
- ['glance:shared-db', 'mysql:shared-db']
- ['glance:amqp', 'rabbitmq-server:amqp']
- ['glance-simplestreams-sync:amqp', 'rabbitmq-server:amqp']
- ['keystone:certificates', 'vault:certificates']
- ['glance:certificates', 'vault:certificates']
- ['glance-simplestreams-sync:certificates', 'vault:certificates']
@ -30,37 +26,29 @@ applications:
num_units: 1
to:
- '0'
rabbitmq-server:
charm: cs:~openstack-charmers-next/rabbitmq-server
num_units: 1
options:
ssl: 'on' # must be str(in quote), otherwise it's bool
to:
- '1'
vault:
charm: cs:~openstack-charmers-next/vault
num_units: 1
to:
- '2'
- '1'
keystone:
charm: cs:~openstack-charmers-next/keystone
num_units: 1
options:
openstack-origin: cloud:bionic-rocky
to:
- '3'
- '2'
glance:
charm: cs:~openstack-charmers-next/glance
num_units: 1
options:
openstack-origin: cloud:bionic-rocky
to:
- '4'
- '3'
glance-simplestreams-sync:
charm: ../../glance-simplestreams-sync
num_units: 1
options:
source: ppa:simplestreams-dev/trunk
use_swift: False
to:
- '5'
- '4'

View File

@ -5,19 +5,15 @@ comment:
machines:
'0':
constraints: mem=3072M
'1':
'2':
'3':
'4':
'5':
relations:
- ['vault:shared-db', 'mysql:shared-db']
- ['keystone:shared-db', 'mysql:shared-db']
- ['glance:shared-db', 'mysql:shared-db']
- ['glance:amqp', 'rabbitmq-server:amqp']
- ['glance-simplestreams-sync:amqp', 'rabbitmq-server:amqp']
- ['keystone:certificates', 'vault:certificates']
- ['glance:certificates', 'vault:certificates']
- ['glance-simplestreams-sync:certificates', 'vault:certificates']
@ -30,18 +26,11 @@ applications:
num_units: 1
to:
- '0'
rabbitmq-server:
charm: cs:~openstack-charmers-next/rabbitmq-server
num_units: 1
options:
ssl: 'on' # must be str(in quote), otherwise it's bool
to:
- '1'
vault:
charm: cs:~openstack-charmers-next/vault
num_units: 1
to:
- '2'
- '1'
keystone:
series: bionic
charm: cs:~openstack-charmers-next/keystone
@ -49,19 +38,18 @@ applications:
options:
openstack-origin: cloud:bionic-stein
to:
- '3'
- '2'
glance:
charm: cs:~openstack-charmers-next/glance
num_units: 1
options:
openstack-origin: cloud:bionic-stein
to:
- '4'
- '3'
glance-simplestreams-sync:
charm: ../../glance-simplestreams-sync
num_units: 1
options:
source: ppa:simplestreams-dev/trunk
use_swift: False
to:
- '5'
- '4'

View File

@ -5,19 +5,15 @@ comment:
machines:
'0':
constraints: mem=3072M
'1':
'2':
'3':
'4':
'5':
relations:
- ['vault:shared-db', 'mysql:shared-db']
- ['keystone:shared-db', 'mysql:shared-db']
- ['glance:shared-db', 'mysql:shared-db']
- ['glance:amqp', 'rabbitmq-server:amqp']
- ['glance-simplestreams-sync:amqp', 'rabbitmq-server:amqp']
- ['keystone:certificates', 'vault:certificates']
- ['glance:certificates', 'vault:certificates']
- ['glance-simplestreams-sync:certificates', 'vault:certificates']
@ -30,18 +26,11 @@ applications:
num_units: 1
to:
- '0'
rabbitmq-server:
charm: cs:~openstack-charmers-next/rabbitmq-server
num_units: 1
options:
ssl: 'on' # must be str(in quote), otherwise it's bool
to:
- '1'
vault:
charm: cs:~openstack-charmers-next/vault
num_units: 1
to:
- '2'
- '1'
keystone:
series: bionic
charm: cs:~openstack-charmers-next/keystone
@ -49,19 +38,18 @@ applications:
options:
openstack-origin: cloud:bionic-train
to:
- '3'
- '2'
glance:
charm: cs:~openstack-charmers-next/glance
num_units: 1
options:
openstack-origin: cloud:bionic-train
to:
- '4'
- '3'
glance-simplestreams-sync:
charm: ../../glance-simplestreams-sync
num_units: 1
options:
source: ppa:simplestreams-dev/trunk
use_swift: False
to:
- '5'
- '4'

View File

@ -9,14 +9,11 @@ machines:
'2':
'3':
'4':
'5':
relations:
- ['vault:shared-db', 'mysql:shared-db']
- ['keystone:shared-db', 'mysql:shared-db']
- ['glance:shared-db', 'mysql:shared-db']
- ['glance:amqp', 'rabbitmq-server:amqp']
- ['glance-simplestreams-sync:amqp', 'rabbitmq-server:amqp']
- ['keystone:certificates', 'vault:certificates']
- ['glance:certificates', 'vault:certificates']
- ['glance-simplestreams-sync:certificates', 'vault:certificates']
@ -29,18 +26,11 @@ applications:
num_units: 1
to:
- '0'
rabbitmq-server:
charm: cs:~openstack-charmers-next/rabbitmq-server
num_units: 1
options:
ssl: 'on' # must be str(in quote), otherwise it's bool
to:
- '1'
vault:
charm: cs:~openstack-charmers-next/vault
num_units: 1
to:
- '2'
- '1'
keystone:
series: bionic
charm: cs:~openstack-charmers-next/keystone
@ -48,18 +38,18 @@ applications:
options:
openstack-origin: cloud:bionic-ussuri
to:
- '3'
- '2'
glance:
charm: cs:~openstack-charmers-next/glance
num_units: 1
options:
openstack-origin: cloud:bionic-ussuri
to:
- '4'
- '3'
glance-simplestreams-sync:
charm: ../../glance-simplestreams-sync
num_units: 1
options:
use_swift: False
to:
- '5'
- '4'

View File

@ -14,7 +14,6 @@ machines:
'4':
'5':
'6':
'7':
applications:
@ -35,20 +34,11 @@ applications:
- '1'
- '2'
rabbitmq-server:
charm: cs:~openstack-charmers-next/rabbitmq-server
num_units: 1
options:
source: *openstack-origin
ssl: 'on' # must be str(in quote), otherwise it's bool
to:
- '3'
vault:
charm: cs:~openstack-charmers-next/vault
num_units: 1
to:
- '4'
- '3'
keystone:
charm: cs:~openstack-charmers-next/keystone
@ -56,7 +46,7 @@ applications:
options:
openstack-origin: *openstack-origin
to:
- '5'
- '4'
glance:
charm: cs:~openstack-charmers-next/glance
@ -64,23 +54,19 @@ applications:
options:
openstack-origin: *openstack-origin
to:
- '6'
- '5'
glance-simplestreams-sync:
charm: ../../glance-simplestreams-sync
num_units: 1
options:
source: ppa:simplestreams-dev/trunk
use_swift: False
to:
- '7'
- '6'
relations:
- ['glance:amqp', 'rabbitmq-server:amqp']
- ['glance-simplestreams-sync:amqp', 'rabbitmq-server:amqp']
- ['keystone:certificates', 'vault:certificates']
- ['glance:certificates', 'vault:certificates']
- ['rabbitmq-server:certificates', 'vault:certificates']
- ['glance-simplestreams-sync:certificates', 'vault:certificates']
- ['glance:identity-service', 'keystone:identity-service']
- ['glance-simplestreams-sync:identity-service', 'keystone:identity-service']

View File

@ -5,19 +5,15 @@ comment:
machines:
'0':
constraints: mem=3072M
'1':
'2':
'3':
'4':
'5':
relations:
- ['vault:shared-db', 'mysql:shared-db']
- ['keystone:shared-db', 'mysql:shared-db']
- ['glance:shared-db', 'mysql:shared-db']
- ['glance:amqp', 'rabbitmq-server:amqp']
- ['glance-simplestreams-sync:amqp', 'rabbitmq-server:amqp']
- ['keystone:certificates', 'vault:certificates']
- ['glance:certificates', 'vault:certificates']
- ['glance-simplestreams-sync:certificates', 'vault:certificates']
@ -30,33 +26,25 @@ applications:
num_units: 1
to:
- '0'
rabbitmq-server:
charm: cs:~openstack-charmers-next/rabbitmq-server
num_units: 1
options:
ssl: 'on' # must be str(in quote), otherwise it's bool
to:
- '1'
vault:
charm: cs:~openstack-charmers-next/vault
num_units: 1
to:
- '2'
- '1'
keystone:
charm: cs:~openstack-charmers-next/keystone
num_units: 1
to:
- '3'
- '2'
glance:
charm: cs:~openstack-charmers-next/glance
num_units: 1
to:
- '4'
- '3'
glance-simplestreams-sync:
charm: ../../glance-simplestreams-sync
num_units: 1
options:
source: ppa:simplestreams-dev/trunk
use_swift: False
to:
- '5'
- '4'

View File

@ -5,19 +5,15 @@ comment:
machines:
'0':
constraints: mem=3072M
'1':
'2':
'3':
'4':
'5':
relations:
- ['vault:shared-db', 'mysql:shared-db']
- ['keystone:shared-db', 'mysql:shared-db']
- ['glance:shared-db', 'mysql:shared-db']
- ['glance:amqp', 'rabbitmq-server:amqp']
- ['glance-simplestreams-sync:amqp', 'rabbitmq-server:amqp']
- ['keystone:certificates', 'vault:certificates']
- ['glance:certificates', 'vault:certificates']
- ['glance-simplestreams-sync:certificates', 'vault:certificates']
@ -30,37 +26,29 @@ applications:
num_units: 1
to:
- '0'
rabbitmq-server:
charm: cs:~openstack-charmers-next/rabbitmq-server
num_units: 1
options:
ssl: 'on' # must be str(in quote), otherwise it's bool
to:
- '1'
vault:
charm: cs:~openstack-charmers-next/vault
num_units: 1
to:
- '2'
- '1'
keystone:
charm: cs:~openstack-charmers-next/keystone
num_units: 1
options:
openstack-origin: cloud:xenial-queens
to:
- '3'
- '2'
glance:
charm: cs:~openstack-charmers-next/glance
num_units: 1
options:
openstack-origin: cloud:xenial-queens
to:
- '4'
- '3'
glance-simplestreams-sync:
charm: ../../glance-simplestreams-sync
num_units: 1
options:
source: ppa:simplestreams-dev/trunk
use_swift: False
to:
- '5'
- '4'