Merge ~rgildein/charm-prometheus-openstack-exporter:lp2009616 into charm-prometheus-openstack-exporter:master

Proposed by Robert Gildein
Status: Merged
Approved by: Eric Chen
Approved revision: 7a549fffc50cec673512e21e80db445d054061cb
Merged at revision: 0e3e426b3c4d2b07f70fd3f3b1ee2b12ffd152dc
Proposed branch: ~rgildein/charm-prometheus-openstack-exporter:lp2009616
Merge into: charm-prometheus-openstack-exporter:master
Diff against target: 262 lines (+57/-65)
7 files modified
Makefile (+48/-44)
charmcraft.yaml (+1/-2)
src/metadata.yaml (+3/-4)
src/reactive/openstack_exporter.py (+1/-3)
src/tests/functional/tests/bundles/bionic.yaml (+1/-0)
src/tests/functional/tests/bundles/overlays/local-charm-overlay.yaml.j2 (+1/-1)
src/tox.ini (+2/-11)
Reviewer Review Type Date Requested Status
🤖 prod-jenkaas-bootstack (community) continuous-integration Approve
BootStack Reviewers Pending
BootStack Reviewers Pending
Review via email: mp+439145@code.launchpad.net

Commit message

remove flag to be able connect multiple Grafana

Removing unnecessary flag so registration of dashboard is triggered
every time if new relation joined.
Functional test was not working with running `make functional`,
because the wrong env variable was used in local-overlay.

To post a comment you must log in.
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :
review: Approve (continuous-integration)
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision 0e3e426b3c4d2b07f70fd3f3b1ee2b12ffd152dc

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/Makefile b/Makefile
2index 76f44ce..af35fdc 100644
3--- a/Makefile
4+++ b/Makefile
5@@ -1,45 +1,42 @@
6+# This is a template `Makefile` file for reactive charms
7+# This file is managed by bootstack-charms-spec and should not be modified
8+# within individual charm repos. https://launchpad.net/bootstack-charms-spec
9+
10 PYTHON := /usr/bin/python3
11
12 PROJECTPATH=$(dir $(realpath $(MAKEFILE_LIST)))
13-ifndef CHARM_BUILD_DIR
14- CHARM_BUILD_DIR=${PROJECTPATH}/build
15-endif
16-ifndef CHARM_LAYERS_DIR
17- CHARM_LAYERS_DIR=${PROJECTPATH}/layers
18-endif
19-ifndef CHARM_INTERFACES_DIR
20- CHARM_INTERFACES_DIR=${PROJECTPATH}/interfaces
21-endif
22-ifdef CONTAINER
23- BUILD_ARGS="--destructive-mode"
24-endif
25+CHARM_BUILD_DIR:=${PROJECTPATH}.build
26+CHARM_LAYERS_DIR:=${PROJECTPATH}/layers
27+CHARM_INTERFACES_DIR:=${PROJECTPATH}/interfaces
28+RELEASE_CHANNEL:=edge
29 METADATA_FILE="src/metadata.yaml"
30-CHARM_NAME=$(shell cat ${PROJECTPATH}/${METADATA_FILE} | grep -E "^name:" | awk '{print $$2}')
31+CHARM_NAME=$(shell cat ${PROJECTPATH}/${METADATA_FILE} | grep -E '^name:' | awk '{print $$2}')
32
33 help:
34 @echo "This project supports the following targets"
35 @echo ""
36 @echo " make help - show this text"
37- @echo " make clean - remove unneeded files"
38- @echo " make submodules - make sure that the submodules are up-to-date"
39+ @echo " make dev-environment - setup the development environment"
40+ @echo " make pre-commit - run pre-commit checks on all the files"
41+ @echo " make submodules - initialize, fetch, and checkout any nested submodules"
42 @echo " make submodules-update - update submodules to latest changes on remote branch"
43+ @echo " make clean - remove unneeded files and clean charmcraft environment"
44 @echo " make build - build the charm"
45- @echo " make release - run clean, submodules, and build targets"
46- @echo " make lint - run flake8 and black --check"
47- @echo " make black - run black and reformat files"
48 @echo " make proof - run charm proof"
49+ @echo " make release - run clean, build, proof target and upload charm"
50+ @echo " make lint - run lint checkers"
51+ @echo " make reformat - run lint tools to auto format code"
52 @echo " make unittests - run the tests defined in the unittest subdirectory"
53 @echo " make functional - run the tests defined in the functional subdirectory"
54- @echo " make test - run lint, proof, unittests and functional targets"
55+ @echo " make test - run lint, unittests and functional targets"
56 @echo ""
57
58-clean:
59- @echo "Cleaning files"
60- @git clean -ffXd -e '!.idea'
61- @echo "Cleaning existing build"
62- @rm -rf ${PROJECTPATH}/${CHARM_NAME}.charm
63- @rm -rf ${CHARM_BUILD_DIR}/*
64- @charmcraft clean
65+dev-environment:
66+ @echo "Creating virtualenv with pre-commit installed"
67+ @cd src && tox -r -e dev-environment
68+
69+pre-commit:
70+ @cd src && tox -e pre-commit
71
72 submodules:
73 @echo "Cloning submodules"
74@@ -49,40 +46,47 @@ submodules-update:
75 @echo "Pulling latest updates for submodules"
76 @git submodule update --init --recursive --remote --merge
77
78-build:
79- @echo "Building charm to directory ${CHARM_BUILD_DIR}/${CHARM_NAME}"
80- @-git rev-parse --abbrev-ref HEAD > ./src/repo-info
81+clean:
82+ @echo "Cleaning files"
83+ @git clean -ffXd -e '!.idea' -e '!.vscode'
84+ @echo "Cleaning existing build"
85+ @rm -rf ${CHARM_BUILD_DIR}/${CHARM_NAME}
86+ @rm -rf ${PROJECTPATH}/${CHARM_NAME}*.charm
87+ @echo "Cleaning charmcraft"
88+ @charmcraft clean
89+
90+build: clean
91+ @echo "Building charm"
92 @charmcraft -v pack ${BUILD_ARGS}
93 @bash -c ./rename.sh
94+
95+proof: build
96+ @echo "Running charm proof"
97 @mkdir -p ${CHARM_BUILD_DIR}/${CHARM_NAME}
98 @unzip ${PROJECTPATH}/${CHARM_NAME}.charm -d ${CHARM_BUILD_DIR}/${CHARM_NAME}
99-
100-release: clean build
101- @echo "Charm is built at ${PROJECTPATH}/${CHARM_NAME}.charm"
102- @charmcraft upload ${PROJECTPATH}/${CHARM_NAME}.charm --release edge
103+ @charm proof ${CHARM_BUILD_DIR}/${CHARM_NAME}
104+release: proof
105+ @echo "Releasing charm to ${RELEASE_CHANNEL} channel"
106+ @charmcraft upload ${CHARM_NAME}.charm --release ${RELEASE_CHANNEL}
107
108 lint:
109 @echo "Running lint checks"
110 @cd src && tox -e lint
111
112-black:
113- @echo "Reformat files with black"
114- @cd src && tox -e black
115-
116-proof: build
117- @echo "Running charm proof"
118- @charm proof ${CHARM_BUILD_DIR}/${CHARM_NAME}
119+reformat:
120+ @echo "Reformat files with black and isort"
121+ @cd src && tox -e reformat
122
123 unittests:
124 @echo "Running unit tests"
125- @cd src && tox -e unit
126+ @cd src && tox -e unit -- ${UNIT_ARGS}
127
128 functional: build
129- @echo "Executing functional tests in ${CHARM_BUILD_DIR}"
130- @cd src && CHARM_BUILD_DIR=${CHARM_BUILD_DIR} tox -e func
131+ @echo "Executing functional tests using built charm at ${PROJECTPATH}"
132+ @cd src && CHARM_LOCATION=${PROJECTPATH} tox -e func -- ${FUNC_ARGS}
133
134 test: lint proof unittests functional
135 @echo "Tests completed for charm ${CHARM_NAME}."
136
137 # The targets below don't depend on a file
138-.PHONY: help submodules submodules-update clean build release lint black proof unittests functional test
139+.PHONY: help dev-environment pre-commit submodules submodules-update clean build lint reformat proof unittests functional
140diff --git a/charmcraft.yaml b/charmcraft.yaml
141index f8312cc..13dc66a 100644
142--- a/charmcraft.yaml
143+++ b/charmcraft.yaml
144@@ -3,7 +3,7 @@ parts:
145 charm:
146 source: src
147 plugin: reactive
148- # using charm/3.x/stable will cause the charm unable to install on 18.04
149+ # Using charm/3.x/stable will cause the charm unable to install on 18.04
150 # with the following error: "pip requires Python '>=3.7' but the running
151 # Python is 3.6.9". This is because charm/3.x/stable start using system
152 # installation of python instead of a python snap.
153@@ -26,4 +26,3 @@ bases:
154 channel: "18.04"
155 architectures:
156 - amd64
157-
158diff --git a/src/metadata.yaml b/src/metadata.yaml
159index 97a6694..81bec11 100644
160--- a/src/metadata.yaml
161+++ b/src/metadata.yaml
162@@ -4,6 +4,9 @@ summary: Openstack exporter for Prometheus
163 description: |
164 This is an exporter that exposes information gathered from Openstack
165 for use by the Prometheus monitoring system.
166+# Series are needed here only because we use charm/2.x/stable, whose linter will fail
167+# if it doesn't find series here. Bases in charmcraft.yaml are used instead of series.
168+series: []
169 tags:
170 - openstack
171 - monitoring
172@@ -23,10 +26,6 @@ provides:
173 interface: prometheus-rules
174 dashboards:
175 interface: grafana-dashboard
176-series:
177- - bionic
178- - focal
179- - jammy
180 extra-bindings:
181 public:
182 admin:
183diff --git a/src/reactive/openstack_exporter.py b/src/reactive/openstack_exporter.py
184index d38dcbe..b3e77d1 100644
185--- a/src/reactive/openstack_exporter.py
186+++ b/src/reactive/openstack_exporter.py
187@@ -129,7 +129,6 @@ def check_reconfig_exporter():
188 if data_changed("exporter.config", config):
189 set_state("exporter.do-reconfig")
190 remove_state("exporter.do-check-reconfig")
191- set_state("exporter.register-dashboards")
192
193
194 def convert_from_base64(v):
195@@ -316,14 +315,13 @@ def render_prometheus_rules(prometheus_rules):
196
197 @when(
198 "leadership.is_leader",
199+ "prometheus-openstack-exporter-service.available",
200 "endpoint.dashboards.joined",
201- "exporter.register-dashboards",
202 )
203 def register_grafana_dashboards():
204 """Register grafana dashboards."""
205 grafana_endpoint = endpoint_from_flag("endpoint.dashboards.joined")
206 import_grafana_dashboards(grafana_endpoint)
207- remove_state("exporter.register-dashboards")
208
209
210 def render_template(template, context):
211diff --git a/src/tests/functional/tests/bundles/bionic.yaml b/src/tests/functional/tests/bundles/bionic.yaml
212index 64e7bf4..3b18dcc 100644
213--- a/src/tests/functional/tests/bundles/bionic.yaml
214+++ b/src/tests/functional/tests/bundles/bionic.yaml
215@@ -17,6 +17,7 @@ applications:
216 num_units: 1
217 grafana:
218 charm: ch:grafana
219+ series: focal
220 num_units: 1
221
222 relations:
223diff --git a/src/tests/functional/tests/bundles/overlays/local-charm-overlay.yaml.j2 b/src/tests/functional/tests/bundles/overlays/local-charm-overlay.yaml.j2
224index 319de18..3a0b4cb 100644
225--- a/src/tests/functional/tests/bundles/overlays/local-charm-overlay.yaml.j2
226+++ b/src/tests/functional/tests/bundles/overlays/local-charm-overlay.yaml.j2
227@@ -1,3 +1,3 @@
228 applications:
229 prometheus-openstack-exporter:
230- charm: "{{ PROJECTPATH }}/{{ charm_name }}.charm"
231+ charm: "{{ CHARM_LOCATION }}/{{ charm_name }}.charm"
232diff --git a/src/tox.ini b/src/tox.ini
233index 361de8b..c8ed14c 100644
234--- a/src/tox.ini
235+++ b/src/tox.ini
236@@ -10,7 +10,7 @@ setenv =
237 passenv =
238 HOME
239 PATH
240- CHARM_BUILD_DIR
241+ CHARM_*
242 PYTEST_KEEP_MODEL
243 PYTEST_CLOUD_NAME
244 PYTEST_CLOUD_REGION
245@@ -21,16 +21,7 @@ passenv =
246 NO_PROXY
247 SNAP_HTTP_PROXY
248 SNAP_HTTPS_PROXY
249- OS_REGION_NAME
250- OS_AUTH_VERSION
251- OS_AUTH_URL
252- OS_PROJECT_DOMAIN_NAME
253- OS_USERNAME
254- OS_PASSWORD
255- OS_PROJECT_ID
256- OS_USER_DOMAIN_NAME
257- OS_PROJECT_NAME
258- OS_IDENTITY_API_VERSION
259+ OS_*
260
261 [testenv:lint]
262 commands =

Subscribers

People subscribed via source and target branches

to all changes: