Skip to content

Commit 8a0f029

Browse files
Repair all keyspaces (#15)
1 parent 81e61dd commit 8a0f029

File tree

3 files changed

+8
-21
lines changed

3 files changed

+8
-21
lines changed

README.md

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Ansible role to install an Apache Cassandra cluster supervised by systemd. Inclu
55
* Some OS tuning options such as installing jemalloc, setting max_map_count and tcp_keepalive, disabling swap.
66
* Bootstraps nodes using the IPs of the servers in the `cassandra_seed` (configurable) inventory group.
77
* Weekly scheduled repairs via cron jobs that are non-overlapping (see `cassandra_repair_slots`).
8-
* requires setting `cassandra_keyspaces` (default `[]` will have no effect)
8+
* Note that **all** keyspaces will be scheduled for repairs
99
* Incremental and full backup scripts as well as a restore script. (disabled by default, optional) (NOTE: needs better testing)
1010
* backup/restore requires access to S3.
1111
* prometheus-style metrics using jmx-exporter
@@ -42,12 +42,6 @@ Give your cluster a better name:
4242
cassandra_cluster_name: default
4343
```
4444
45-
You should override the keyspaces to match keyspaces on which you wish to run weekly repairs:
46-
47-
```yaml
48-
cassandra_keyspaces: []
49-
```
50-
5145
You may wish to override the following defaults to enable backups:
5246
5347
```yaml
@@ -108,8 +102,6 @@ Then the following should work and start your cluster:
108102
vars:
109103
# set cluster_name before running the playbook for the first time; never change it afterwards
110104
cassandra_cluster_name: my_cluster
111-
cassandra_keyspaces:
112-
- my_keyspace1
113105
# set installed java package version manually. required when using Ubuntu 18.04. see: [A note on Java 8 and Ubuntu 18.04](#a-note-on-Java-8-and-Ubuntu-18.04)
114106
java_packages: openjdk-8-jdk
115107
roles:

defaults/main.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ cassandra_env: dev
4545
cassandra_cluster_name: default
4646
cassandra_role: 'cassandra_{{ cassandra_cluster_name }}'
4747
cassandra_seed_role: '{{ cassandra_role }}_seed'
48-
cassandra_keyspaces: []
4948
cassandra_metrics_prefix: 'cassandra_{{ cassandra_cluster_name }}'
5049

5150
cassandra_snitch: '{% if is_aws_environment %}Ec2Snitch{% else %}SimpleSnitch{% endif %}'

templates/cassandra_repair.j2

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,45 +11,41 @@ metrics_file=${metrics_dir}/cassandra_repair.prom
1111
metrics_tmpl='
1212
# TYPE cassandra_repair counter
1313
# HELP cassandra_repair Counts the number of repairs and the status
14-
cassandra_repair{status="%s",errno="%d",keyspace="%s"} 1 %d
14+
cassandra_repair{status="%s",errno="%d"} 1 %d
1515
1616
# TYPE cassandra_repair_duration_seconds gauge
1717
# HELP cassandra_repair_duration_seconds Track the duration of the repair task, in seconds
18-
cassandra_repair_duration_seconds{status="%s",keyspace="%s"} %d %d
18+
cassandra_repair_duration_seconds{status="%s"} %d %d
1919
'
2020

2121
started_at=$(date +%s%3N)
2222

2323
function report_metrics {
2424
status=$1
2525
errno=$2
26-
keyspace=$3
2726

2827
now=$(date +%s%3N)
2928

3029
# nb. the date must be milliseconds since the epoch
3130
printf "$metrics_tmpl" \
32-
$status $errno $keyspace $now $status $keyspace $(((now-started_at)/1000)) $now > ${metrics_file}.$$
31+
$status $errno $now $status $(((now-started_at)/1000)) $now > ${metrics_file}.$$
3332
mv -v ${metrics_file}.$$ ${metrics_file} || true
3433
}
3534

36-
{% for keyspace in cassandra_keyspaces %}
3735
# Check if a repair is still running
38-
if ps -u cassandra -f | grep "repair {{ keyspace }}" > /dev/null
36+
if ps -u cassandra -f | grep "repair" > /dev/null
3937
then
40-
report_metrics "aborted" 255 "{{ keyspace }}"
38+
report_metrics "aborted" 255
4139
exit 255;
4240
fi
4341

4442
# Run repair
4543
su - {{ cassandra_user }} \
46-
-c '/opt/cassandra/bin/nodetool repair {{ keyspace }} -full -pr'
44+
-c '/opt/cassandra/bin/nodetool repair -full -pr'
4745

4846
if [ $? -ne 0 ]; then
4947
st="failed"
5048
else
5149
st="succeeded"
5250
fi
53-
report_metrics $st $? "{{ keyspace }}"
54-
55-
{% endfor %}
51+
report_metrics $st $?

0 commit comments

Comments
 (0)