Skip to content

Commit 160347f

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Add Zuul job to test Loki backend with DevStack support"
2 parents 287cb26 + 7f05513 commit 160347f

File tree

4 files changed

+98
-0
lines changed

4 files changed

+98
-0
lines changed

.zuul.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,17 @@
144144
CLOUDKITTY_STORAGE_BACKEND: opensearch
145145
CLOUDKITTY_STORAGE_VERSION: 2
146146

147+
- job:
148+
name: cloudkitty-tempest-full-v2-storage-loki
149+
parent: base-cloudkitty-v2-api-tempest-job
150+
description: |
151+
Job testing cloudkitty installation on devstack with python 3 and the
152+
Loki v2 storage driver and running tempest tests
153+
vars:
154+
devstack_localrc:
155+
CLOUDKITTY_STORAGE_BACKEND: loki
156+
CLOUDKITTY_LOKI_URL: http://127.0.0.1:3100
157+
147158
- job:
148159
name: cloudkitty-tox-bandit
149160
parent: openstack-tox
@@ -183,6 +194,7 @@
183194
- cloudkitty-tempest-full-v2-storage-elasticsearch
184195
- cloudkitty-tempest-full-v2-storage-opensearch
185196
- cloudkitty-tempest-full-v1-storage-sqlalchemy
197+
- cloudkitty-tempest-full-v2-storage-loki
186198
- cloudkitty-tempest-full-ipv6-only
187199
- cloudkitty-tox-bandit:
188200
voting: false
@@ -194,5 +206,6 @@
194206
- cloudkitty-tempest-full-v2-storage-elasticsearch
195207
- cloudkitty-tempest-full-v2-storage-opensearch
196208
- cloudkitty-tempest-full-v1-storage-sqlalchemy
209+
- cloudkitty-tempest-full-v2-storage-loki
197210
- cloudkitty-tempest-full-ipv6-only
198211
- cloudkitty-grenade-job

devstack/files/loki-config.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
auth_enabled: false
2+
3+
server:
4+
http_listen_port: 3100
5+
6+
common:
7+
instance_addr: 0.0.0.0
8+
path_prefix: /opt/stack/data/loki
9+
storage:
10+
filesystem:
11+
chunks_directory: /opt/stack/data/loki/chunks
12+
rules_directory: /opt/stack/data/loki/rules
13+
replication_factor: 1
14+
ring:
15+
kvstore:
16+
store: inmemory
17+
18+
schema_config:
19+
configs:
20+
- from: 2020-10-24
21+
store: tsdb
22+
object_store: filesystem
23+
schema: v13
24+
index:
25+
prefix: index_
26+
period: 24h
27+
28+
limits_config:
29+
max_query_length: 745h

devstack/plugin.sh

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,10 @@ function configure_cloudkitty {
167167
iniset $CLOUDKITTY_CONF storage_${CLOUDKITTY_STORAGE_BACKEND} index_name ${CLOUDKITTY_OPENSEARCH_INDEX}
168168
fi
169169

170+
if [ "$CLOUDKITTY_STORAGE_BACKEND" == "loki" ]; then
171+
iniset $CLOUDKITTY_CONF storage_loki url ${CLOUDKITTY_LOKI_URL}
172+
fi
173+
170174
# collect
171175
iniset $CLOUDKITTY_CONF collect collector $CLOUDKITTY_COLLECTOR
172176
iniset $CLOUDKITTY_CONF "collector_${CLOUDKITTY_COLLECTOR}" auth_section authinfos
@@ -366,6 +370,53 @@ function install_opensearch {
366370
sudo systemctl start opensearch || sudo systemctl restart opensearch
367371
}
368372

373+
function start_loki {
374+
LOKI_SYSTEMD_SERVICE="devstack@loki.service"
375+
loki_command="$CLOUDKITTY_BIN_DIR/loki"
376+
loki_command+=" --config.file=${CLOUDKITTY_DIR}/devstack/files/loki-config.yaml"
377+
378+
write_user_unit_file $LOKI_SYSTEMD_SERVICE "$loki_command" "" "$STACK_USER"
379+
380+
enable_service $LOKI_SYSTEMD_SERVICE
381+
start_service $LOKI_SYSTEMD_SERVICE
382+
}
383+
384+
function install_loki_ubuntu {
385+
local loki_url="https://github.com/grafana/loki/releases/download/v3.5.4/loki-linux-amd64.zip"
386+
local loki_tmp="/tmp/loki-linux-amd64.zip"
387+
388+
sudo apt-get install -y unzip wget
389+
390+
wget -O ${loki_tmp} ${loki_url}
391+
unzip -o ${loki_tmp} -d /tmp
392+
sudo mv /tmp/loki-linux-amd64 $CLOUDKITTY_BIN_DIR/loki
393+
sudo chmod +x $CLOUDKITTY_BIN_DIR/loki
394+
}
395+
396+
function install_loki_fedora {
397+
local loki_url="https://github.com/grafana/loki/releases/download/v3.5.4/loki-linux-amd64.zip"
398+
local loki_tmp="/tmp/loki-linux-amd64.zip"
399+
400+
sudo dnf install -y unzip wget
401+
402+
wget -O ${loki_tmp} ${loki_url}
403+
unzip -o ${loki_tmp} -d /tmp
404+
sudo mv /tmp/loki-linux-amd64 $CLOUDKITTY_BIN_DIR/loki
405+
sudo chmod +x $CLOUDKITTY_BIN_DIR/loki
406+
}
407+
408+
function install_loki {
409+
if is_ubuntu; then
410+
install_loki_ubuntu
411+
elif is_fedora; then
412+
install_loki_fedora
413+
else
414+
die $LINENO "Distribution must be Debian or Fedora-based"
415+
fi
416+
# Start Loki service
417+
start_loki
418+
}
419+
369420
# install_cloudkitty() - Collect source and prepare
370421
function install_cloudkitty {
371422
git_clone $CLOUDKITTY_REPO $CLOUDKITTY_DIR $CLOUDKITTY_BRANCH
@@ -378,6 +429,8 @@ function install_cloudkitty {
378429
install_elasticsearch
379430
elif [ $CLOUDKITTY_STORAGE_BACKEND == 'opensearch' ]; then
380431
install_opensearch
432+
elif [ $CLOUDKITTY_STORAGE_BACKEND == "loki" ]; then
433+
install_loki
381434
fi
382435
if [ ${CLOUDKITTY_USE_UWSGI,,} == 'true' ]; then
383436
pip_install uwsgi

devstack/settings

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,6 @@ CLOUDKITTY_ELASTICSEARCH_INDEX=${CLOUDKITTY_ELASTICSEARCH_INDEX:-"cloudkitty"}
8484
# Set opensearch info
8585
CLOUDKITTY_OPENSEARCH_HOST=${CLOUDKITTY_OPENSEARCH_HOST:-"http://localhost:9200"}
8686
CLOUDKITTY_OPENSEARCH_INDEX=${CLOUDKITTY_OPENSEARCH_INDEX:-"cloudkitty"}
87+
88+
# Set loki info
89+
CLOUDKITTY_LOKI_URL=${CLOUDKITTY_LOKI_URL:-"http://localhost:3100"}

0 commit comments

Comments
 (0)