Skip to content

Commit ac5fca8

Browse files
Merge pull request #421 from CodeNow/SAN-3951-network-canary
split cron into only 2 tasks
2 parents b64ac97 + bd2c7fc commit ac5fca8

7 files changed

Lines changed: 23 additions & 54 deletions

File tree

ansible/group_vars/alpha-khronos.yml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,23 @@ npm_version: 2
88

99
# for cron job
1010
# this is the list of queues we want to enqueue a job into
11-
cron_queues: khronos:containers:orphan:prune khronos:context-versions:prune-expired khronos:images:prune khronos:weave:prune
11+
main_cron_queues: "\
12+
khronos:containers:orphan:prune \
13+
khronos:context-versions:prune-expired \
14+
khronos:images:prune \
15+
khronos:weave:prune"
16+
17+
canary_cron_queues: "\
18+
khronos:canary:build \
19+
khronos:canary:github-branch \
20+
khronos:canary:log \
21+
khronos:canary:network \
22+
khronos:metrics:container-status"
23+
1224
# a nice version of the rabbitmq host
1325
cron_rabbit_host_address: "{{ rabbit_host_address }}:{{ rabbit_port }}"
1426
# a quick version of authentication for rabbit for cron
1527
cron_rabbit_auth: --username {{ rabbit_username }} --password {{ rabbit_password }}
16-
# this is the command we want to run in the container.
17-
cron_command: "bash -c \"for QUEUE in {{ cron_queues }}; do /khronos/bin/cli.js --queue \\$QUEUE --job '{}' --host {{ cron_rabbit_host_address }} {{ cron_rabbit_auth }}; done\""
18-
# This is the build canary cron command
19-
cron_build_canary_command: "/khronos/bin/cli.js --queue khronos:canary:build --job '{}' --host {{ cron_rabbit_host_address }} {{ cron_rabbit_auth }}"
20-
# This is the log canary cron command
21-
cron_log_canary_command: "/khronos/bin/cli.js --queue khronos:canary:log --job '{}' --host {{ cron_rabbit_host_address }} {{ cron_rabbit_auth }}"
22-
# This is the github-branch canary cron command
23-
cron_github_branch_canary_command: "/khronos/bin/cli.js --queue khronos:canary:github-branch --job '{}' --host {{ cron_rabbit_host_address }} {{ cron_rabbit_auth }}"
24-
cron_container_metrics_command: "/khronos/bin/cli.js --queue khronos:metrics:container-status --job '{}' --host {{ cron_rabbit_host_address }} {{ cron_rabbit_auth }}"
2528

2629
# for container settings
2730
container_envs: >
@@ -61,5 +64,3 @@ container_run_opts: >
6164
-v /opt/ssl/mongo-client:/opt/ssl/mongo-client:ro
6265
--memory=1500m
6366
{{container_envs}}
64-
65-
npm_start_command: run start-json-output

ansible/roles/khronos/tasks/main.yml

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,12 @@
22
become: yes
33
tags: cron
44
template:
5-
src: "{{ item }}"
5+
src: "khronos-cron.sh"
66
mode: 0744
7-
dest: /opt/runnable/{{ item }}
7+
dest: /opt/runnable/{{ item.script }}
88
with_items:
9-
- khronos-cron.sh
10-
- build-canary.sh
11-
- log-canary.sh
12-
- github-branch-canary.sh
13-
- container-metrics.sh
9+
- { cron_queues: "{{ main_cron_queues }}", script: "main-cron.sh"}
10+
- { cron_queues: "{{ canary_cron_queues }}", script: "canary-cron.sh"}
1411

1512
- name: Put Khronos script into crontab
1613
become: yes
@@ -25,22 +22,10 @@
2522
- name: Khronos CLI - Daily Cleanup
2623
minute: 13
2724
hour: 1,7,13,19
28-
script: khronos-cron.sh
25+
script: main-cron.sh
2926
- name: Khronos CLI - Canary
3027
minute: "*/5"
31-
script: build-canary.sh
32-
state: "{% if node_env == 'production-delta' %}present{% else %}absent{% endif %}"
33-
- name: Khronos CLI - Github Branch Canary
34-
minute: "*/5"
35-
script: github-branch-canary.sh
36-
state: "{% if node_env == 'production-delta' %}present{% else %}absent{% endif %}"
37-
- name: Khronos CLI - Log Canary
38-
minute: "*/5"
39-
script: log-canary.sh
40-
state: "{% if node_env == 'production-delta' %}present{% else %}absent{% endif %}"
41-
- name: Container Metrics
42-
minute: "*/5"
43-
script: container-metrics.sh
28+
script: canary-cron.sh
4429
state: "{% if node_env == 'production-delta' %}present{% else %}absent{% endif %}"
4530

4631
- name: make directory for mongo certificates

ansible/roles/khronos/templates/build-canary.sh

Lines changed: 0 additions & 5 deletions
This file was deleted.

ansible/roles/khronos/templates/container-metrics.sh

Lines changed: 0 additions & 5 deletions
This file was deleted.

ansible/roles/khronos/templates/github-branch-canary.sh

Lines changed: 0 additions & 5 deletions
This file was deleted.

ansible/roles/khronos/templates/khronos-cron.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@
22
# THIS FILE IS MANAGED BY ANSIBLE. PLEASE DO NOT MODIFY. MODIFICATIONS WILL NOT BE SAVED.
33
# AUTHOR: BRYAN KENDALL
44

5-
docker run --rm {{ container_image }}:{{ container_tag }} {{ cron_command }}
5+
docker run --rm {{ container_image }}:{{ container_tag }} bash -c " \
6+
for QUEUE in {{ item.cron_queues }}; do \
7+
/khronos/bin/cli.js --queue \$QUEUE --job '{}' --host {{ cron_rabbit_host_address }} {{ cron_rabbit_auth }}; \
8+
done"

ansible/roles/khronos/templates/log-canary.sh

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)