Skip to content

Commit 6cceb51

Browse files
authored
Merge pull request #1735 from rackerlabs/argo-multi-flexVol-event
feat(argo): Added Argo Events pipeline for Cinder volume type access events
2 parents 5985e2e + 7e8b556 commit 6cceb51

5 files changed

Lines changed: 136 additions & 1 deletion

File tree

components/cinder/cinder-rabbitmq-queue.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ metadata:
5151
spec:
5252
name: cinder-notifications-ttl # name of the policy
5353
vhost: "cinder" # default to '/' if not provided
54-
pattern: "^notifications.*" # regex used to match queues and exchanges
54+
pattern: "^(notifications|argo_notifications).*" # regex used to match queues and exchanges
5555
applyTo: "queues" # set to 'queues', 'exchanges', or 'all'
5656
priority: 1 # defaults to 0
5757
definition: # policy definition
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
apiVersion: argoproj.io/v1alpha1
3+
kind: EventSource
4+
metadata:
5+
name: openstack-cinder
6+
spec:
7+
amqp:
8+
# this is our eventName
9+
notifications:
10+
# amqp server url
11+
url: amqp://rabbitmq-server-0.rabbitmq-nodes.openstack.svc.cluster.local:5672/cinder
12+
# jsonBody specifies that all event body payload coming from this
13+
# source will be JSON
14+
jsonBody: true
15+
# name of the exchange.
16+
# NOTE: Unlike other services (ironic, keystone, neutron) which use their
17+
# service name as the exchange, Cinder uses "openstack" as the exchange name.
18+
# Confirmed via: rabbitmqadmin -V cinder list exchanges
19+
# The only topic exchange in the cinder vhost is named "openstack", not "cinder".
20+
exchangeName: openstack
21+
exchangeType: topic
22+
exchangeDeclare:
23+
durable: true
24+
# routing key for messages within the exchange
25+
routingKey: 'notifications.info'
26+
# queue settings, if not provided defaults are used
27+
queueDeclare:
28+
name: argo_notifications
29+
durable: true
30+
exclusive: false
31+
autoDelete: false
32+
noWait: true
33+
# optional consume settings
34+
# if not provided, default values will be used
35+
consume:
36+
consumerTag: "argo-events"
37+
autoAck: true
38+
exclusive: false
39+
noLocal: false
40+
# username and password for authentication
41+
# use secret selectors
42+
auth:
43+
username:
44+
name: argo-cinder-user-credentials
45+
key: username
46+
password:
47+
name: argo-cinder-user-credentials
48+
key: password
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
apiVersion: rabbitmq.com/v1beta1
3+
kind: User
4+
metadata:
5+
name: argo-cinder
6+
spec:
7+
rabbitmqClusterReference:
8+
name: rabbitmq
9+
namespace: openstack
10+
---
11+
apiVersion: rabbitmq.com/v1beta1
12+
kind: Permission
13+
metadata:
14+
name: argo-cinder
15+
spec:
16+
vhost: "cinder"
17+
userReference:
18+
name: "argo-cinder"
19+
permissions:
20+
write: ".*"
21+
configure: ".*"
22+
read: ".*"
23+
rabbitmqClusterReference:
24+
name: rabbitmq
25+
namespace: openstack

components/site-workflows/kustomization.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ kind: Kustomization
44
resources:
55
- eventbus/eventbus-default.yaml
66
- eventbus/poddisruptionbudget-eventbus-default-pdb.yaml
7+
- eventsources/eventsource-openstack-cinder.yaml
78
- eventsources/eventsource-openstack-ironic.yaml
89
- eventsources/eventsource-openstack-nova.yaml
910
- eventsources/eventsource-openstack-keystone.yaml
1011
- eventsources/eventsource-openstack-neutron.yaml
12+
- eventsources/rabbitmq-user-argo-cinder.yaml
1113
- eventsources/rabbitmq-user-argo-ironic.yaml
1214
- eventsources/rabbitmq-user-argo-nova.yaml
1315
- eventsources/rabbitmq-user-argo-keystone.yaml
@@ -25,6 +27,7 @@ resources:
2527
- sensors/sensor-ironic-reclean.yaml
2628
- sensors/sensor-ironic-node-port.yaml
2729
- sensors/sensor-ironic-node-portgroup.yaml
30+
- sensors/sensor-cinder-oslo-event.yaml
2831
- sensors/sensor-ironic-oslo-event.yaml
2932
- sensors/sensor-nova-oslo-event.yaml
3033

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
apiVersion: argoproj.io/v1alpha1
3+
kind: Sensor
4+
metadata:
5+
name: cinder-oslo-event
6+
annotations:
7+
workflows.argoproj.io/title: Process oslo_events for cinder volume type access
8+
workflows.argoproj.io/description: |+
9+
Triggers on the following Cinder Events:
10+
11+
- volume_type_project.access.add
12+
- volume_type_project.access.remove
13+
14+
Submits workflow using workflowtemplate/openstack-oslo-event
15+
16+
Defined in `components/site-workflows/sensors/sensor-cinder-oslo-event.yaml`
17+
spec:
18+
dependencies:
19+
- eventName: notifications
20+
eventSourceName: openstack-cinder
21+
name: oslo-event-type
22+
transform:
23+
# the event is a string-ified JSON so we need to decode it
24+
jq: '{body: (.body["oslo.message"] | fromjson)}'
25+
filters:
26+
dataLogicalOperator: "and"
27+
data:
28+
- path: body.event_type
29+
type: "string"
30+
# any of the values will trigger
31+
value:
32+
- "volume_type_project.access.add"
33+
- "volume_type_project.access.remove"
34+
template:
35+
serviceAccountName: sensor-submit-workflow
36+
triggers:
37+
- template:
38+
name: cinder-oslo-event
39+
k8s:
40+
operation: create
41+
parameters:
42+
# first parameter is the parsed oslo.message
43+
- dest: spec.arguments.parameters.0.value
44+
src:
45+
dataKey: body
46+
dependencyName: oslo-event-type
47+
source:
48+
resource:
49+
apiVersion: argoproj.io/v1alpha1
50+
kind: Workflow
51+
metadata:
52+
generateName: cinder-oslo-event-
53+
namespace: argo-events
54+
spec:
55+
arguments:
56+
parameters:
57+
- name: event-json
58+
workflowTemplateRef:
59+
name: openstack-oslo-event

0 commit comments

Comments
 (0)