Skip to content

Commit 6110c8f

Browse files
authored
Merge branch 'main' into line-numbers
2 parents 540b017 + ca4956c commit 6110c8f

File tree

13 files changed

+94
-39
lines changed

13 files changed

+94
-39
lines changed

.github/workflows/build-and-push.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ jobs:
1111
steps:
1212
- uses: actions/checkout@v4
1313

14+
- name: git fetch
15+
run: |
16+
git fetch
17+
- name: git checkout
18+
run: |
19+
git checkout ${{ github.head_ref }}
20+
1421
- name: Set up Docker Buildx
1522
uses: docker/setup-buildx-action@v3
1623

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ config.yaml
1919
terraform.tfstate*
2020
.terraform*
2121
tofu/kube.config
22+
ansible/collections/*

ansible/ansible.cfg

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
[defaults]
2-
32
# Better error output
43
stdout_callback=debug
54
stderr_callback=debug
5+
6+
collections_path=./collections/ansible_collections
7+
8+
# we're only using localhost, no need for the warning.
9+
localhost_warning=False
10+
11+
[inventory]
12+
# Only using localhost, so no inventory
13+
inventory_unparsed_warning=False

deploy.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,18 @@ source secrets.sh
2222
python3 -m venv .venv/deploy
2323
source .venv/deploy/bin/activate
2424
pip install ansible==8.1.0 kubernetes==26.1.0
25+
# install helm diff. Needed to keep helm module idempotent
26+
helm plugin install https://github.com/databus23/helm-diff || true
2527

2628
cd tofu
2729
AWS_ACCESS_KEY_ID=${ACCESS_KEY} AWS_SECRET_ACCESS_KEY=${SECRET_KEY} tofu init
2830
AWS_ACCESS_KEY_ID=${ACCESS_KEY} AWS_SECRET_ACCESS_KEY=${SECRET_KEY} tofu apply # -auto-approve
2931
export KUBECONFIG=$(pwd)/kube.config
3032

3133
cd ../ansible
34+
# install collections here to take advantage of ansible.cfg configs
35+
ansible-galaxy collection install -U kubernetes.core -p ./collections
36+
3237
ansible-playbook quarry.yaml
3338
#kubectl create namespace quarry --dry-run=client -o yaml | kubectl apply -f -
3439
#helm -n quarry upgrade --install quarry helm-quarry -f helm-quarry/prod-env.yaml

helm-quarry/prod-config.yaml

79 Bytes
Binary file not shown.

quarry/default_config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ TOOLS_DB_PORT: 3306
4040
TOOLS_DB_USER: ''
4141
TOOLS_DB_PASSWORD: ''
4242

43+
QUARRY_P_HOST: 'db'
44+
QUARRY_P_PORT: 3306
45+
QUARRY_P_USER: ''
46+
QUARRY_P_PASSWORD: ''
47+
4348
OUTPUT_PATH_TEMPLATE: '/results/%s/%s/%s.sqlite'
4449
REDIS_HOST: 'redis'
4550
REDIS_PORT: 6379

quarry/web/replica.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,17 @@ def __init__(self, config):
1313

1414
def _db_name_mangler(self):
1515
self.is_tools_db = False
16+
self.is_quarry_p = False
1617
if self.dbname == "":
1718
raise ReplicaConnectionException(
1819
"Attempting connection before a database is selected"
1920
)
2021
if "__" in self.dbname and self.dbname.endswith("_p"):
2122
self.is_tools_db = True
2223
self.database_p = self.dbname
24+
elif self.dbname == "quarry" or self.dbname == "quarry_p":
25+
self.is_quarry_p = True
26+
self.database_p = "quarry_p"
2327
elif self.dbname == "meta" or self.dbname == "meta_p":
2428
self.database_name = "s7"
2529
self.database_p = "meta_p"
@@ -41,6 +45,8 @@ def _db_name_mangler(self):
4145
def get_host_name(self):
4246
if self.is_tools_db:
4347
return self.config["TOOLS_DB_HOST"]
48+
if self.is_quarry_p:
49+
return self.config["DB_HOST"]
4450
if self.config["REPLICA_DOMAIN"]:
4551
return f"{self.database_name}.{self.config['REPLICA_DOMAIN']}"
4652
return self.database_name
@@ -62,7 +68,12 @@ def connection(self, db):
6268
self.dbname = db
6369
self._db_name_mangler()
6470
host = self.get_host_name()
65-
conf_prefix = "TOOLS_DB" if self.is_tools_db else "REPLICA"
71+
if self.is_tools_db:
72+
conf_prefix = "TOOLS_DB"
73+
elif self.is_quarry_p:
74+
conf_prefix = "QUARRY_P"
75+
else:
76+
conf_prefix = "REPLICA"
6677
port = self.config[f"{conf_prefix}_PORT"]
6778
connect_opts = {
6879
"db": self.database_p,

quarry/web/utils/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44
VALID_DB_NAMES = re.compile(
5-
r"^(?:(?:(?:centralauth|meta|[0-9a-z_]*wik[a-z]+)(?:_p)?)|quarry|s\d+__\w+_p)$"
5+
r"^(?:(?:(?:centralauth|meta|[0-9a-z_]*wik[a-z]+)(?:_p)?)|quarry(?:_p)?|s\d+__\w+_p)$"
66
)
77

88

quarry/web/worker.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,13 @@
2727

2828

2929
def get_replag(cur):
30-
cur.execute("SELECT lag FROM heartbeat_p.heartbeat;")
31-
return int(cur.fetchall()[0][0])
30+
cur.execute("SELECT * FROM information_schema.tables WHERE table_schema='heartbeat_p' and table_name='heartbeat';")
31+
if cur.rowcount:
32+
cur.execute("SELECT lag FROM heartbeat_p.heartbeat;")
33+
return int(cur.fetchall()[0][0])
34+
else:
35+
# there is not a heartbeat table on this database
36+
return 0
3237

3338

3439
@worker_process_init.connect

schema.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,9 @@ CREATE TABLE IF NOT EXISTS star(
5959
CREATE INDEX IF NOT EXISTS star_user_id_index ON star(user_id);
6060
CREATE INDEX IF NOT EXISTS star_query_id_index ON star(query_id);
6161
CREATE UNIQUE INDEX IF NOT EXISTS star_user_query_index ON star(user_id, query_id);
62+
63+
CREATE DATABASE IF NOT EXISTS quarry_p CHARACTER SET utf8;
64+
CREATE VIEW IF NOT EXISTS quarry_p.query AS SELECT * FROM quarry.query;
65+
CREATE VIEW IF NOT EXISTS quarry_p.query_revision AS SELECT * FROM quarry.query_revision;
66+
CREATE VIEW IF NOT EXISTS quarry_p.query_run AS SELECT * FROM quarry.query_run;
67+
CREATE VIEW IF NOT EXISTS quarry_p.star AS SELECT * FROM quarry.star;

0 commit comments

Comments
 (0)