Skip to content

Commit 70f1cd1

Browse files
authored
Merge pull request #14 from inuits/unsetenv
Empty unset service environment files
2 parents fd9dd5b + 17ab650 commit 70f1cd1

File tree

5 files changed

+33
-9
lines changed

5 files changed

+33
-9
lines changed

molecule/services/playbook.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@
4242
backend: filesystem
4343
filesystem:
4444
dir: /tmp/blocks
45+
compactor:
46+
server:
47+
http_listen_port: 9011
48+
grpc_listen_port: 9097
49+
storage:
50+
engine: blocks
51+
blocks_storage:
52+
backend: filesystem
53+
filesystem:
54+
dir: /tmp/blocks
4555
cortex_env_variables:
4656
ingester:
4757
KAEGER_AGENT_HOST: localhost

molecule/services/tests/test_services.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,13 @@ def test_directories(host, dirs):
2727

2828
@pytest.mark.parametrize("files", [
2929
"/cortex/cortex-ingester.yml",
30+
"/cortex/cortex-compactor.yml",
31+
"/cortex/cortex-readpath.yml",
3032
"/etc/systemd/system/[email protected]",
3133
"/usr/local/bin/cortex-linux-amd64",
3234
"/etc/default/cortex-ingester",
35+
"/etc/default/cortex-readpath",
36+
"/etc/default/cortex-compactor",
3337
])
3438
def test_files(host, files):
3539
f = host.file(files)
@@ -42,13 +46,18 @@ def test_user(host):
4246
assert host.user("vortex").exists
4347

4448

45-
def test_service(host):
46-
s = host.service("cortex@ingester")
47-
# assert s.is_enabled
49+
@pytest.mark.parametrize("service", [
50+
"ingester",
51+
"readpath",
52+
"compactor",
53+
])
54+
def test_service(host, service):
55+
s = host.service("cortex@%s" % service)
56+
assert s.is_enabled
4857
assert s.is_running
4958

5059

51-
@pytest.mark.parametrize("port", [9009, 9010, 9095, 9096])
60+
@pytest.mark.parametrize("port", [9009, 9010, 9095, 9096, 9011, 9097])
5261
def test_socket(host, port):
5362
s = host.socket("tcp://0.0.0.0:%d" % port)
5463
assert s.is_listening
@@ -66,15 +75,20 @@ def test_config_file_explicit_target(host):
6675
assert config["target"] == "querier,store-gateway"
6776

6877

69-
def test_string(host):
78+
def test_env_ingester(host):
7079
f = host.file("/etc/default/cortex-ingester")
7180
assert "KAEGER_AGENT_HOST=localhost\n" in f.content_string
7281
assert "KAEGER_SAMPLER_PARAM=0\n" in f.content_string
7382
assert "KAEGER_SAMPLER_TYPE=const\n" in f.content_string
7483

7584

76-
def test_string2(host):
85+
def test_env_readpath(host):
7786
f = host.file("/etc/default/cortex-readpath")
7887
assert "KAEGER_SAMPLER_TYPE=probabilistic\n" in f.content_string
7988
assert "KAEGER_SAMPLER_PARAM=0.1\n" in f.content_string
8089
assert "KAEGER_SAMPLER_TYPE=probabilistic\n" in f.content_string
90+
91+
92+
def test_env_compactor(host):
93+
f = host.file("/etc/default/cortex-compactor")
94+
assert "=" not in f.content_string

tasks/configure.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,5 @@
4747
dest: "{{ cortex_environment_location }}/cortex-{{ item.key }}"
4848
mode: 0644
4949
notify: reload cortex
50-
loop: "{{ cortex_env_variables | dict2items }}"
50+
loop: "{{ dict(cortex_services.keys() | zip_longest([], fillvalue={}) | list) | combine(cortex_env_variables) | dict2items }}"
5151
when: not cortex_all_in_one

templates/cortex.service.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ StartLimitIntervalSec=0
1010
Type=simple
1111
User={{ cortex_system_user }}
1212
Group={{ cortex_system_group }}
13-
EnvironmentFile=-{{ cortex_environment_location }}/cortex
13+
EnvironmentFile={{ cortex_environment_location }}/cortex
1414
ExecReload=/bin/kill -HUP $MAINPID
1515
ExecStart={{ _cortex_binary_install_dir }}/cortex-linux-amd64 -config.file={{ cortex_config_dir }}/cortex.yml
1616
WorkingDirectory={{ cortex_db_dir }}

templates/[email protected]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ StartLimitIntervalSec=0
99
[Service]
1010
Type=simple
1111
User={{ cortex_system_user }}
12-
EnvironmentFile=-{{ cortex_environment_location }}/cortex-%i
12+
EnvironmentFile={{ cortex_environment_location }}/cortex-%i
1313
Group={{ cortex_system_group }}
1414
ExecReload=/bin/kill -HUP $MAINPID
1515
ExecStart={{ _cortex_binary_install_dir }}/cortex-linux-amd64 -config.file={{ cortex_config_dir }}/cortex-%i.yml

0 commit comments

Comments
 (0)