Skip to content

Commit c098515

Browse files
committed
Merge remote-tracking branch 'upstream/main' into retain-float-format-docs
2 parents 0c85740 + 0cd61db commit c098515

File tree

6 files changed

+122
-44
lines changed

6 files changed

+122
-44
lines changed

components/clp-package-utils/clp_package_utils/scripts/stop_clp.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,12 @@
3434
logger = logging.getLogger(__file__)
3535

3636

37-
def stop_running_container(container_name: str, already_exited_containers: List[str], force: bool):
37+
def stop_running_container(
38+
container_name: str, already_exited_containers: List[str], force: bool, timeout: int = 10
39+
):
3840
if is_container_running(container_name):
3941
logger.info(f"Stopping {container_name}...")
40-
cmd = ["docker", "stop", container_name]
42+
cmd = ["docker", "stop", "--timeout", str(timeout), container_name]
4143
subprocess.run(cmd, stdout=subprocess.DEVNULL, check=True)
4244

4345
logger.info(f"Removing {container_name}...")
@@ -148,9 +150,6 @@ def main(argv):
148150
if target in (ALL_TARGET_NAME, QUERY_WORKER_COMPONENT_NAME):
149151
container_name = f"clp-{QUERY_WORKER_COMPONENT_NAME}-{instance_id}"
150152
stop_running_container(container_name, already_exited_containers, force)
151-
if target in (ALL_TARGET_NAME, COMPRESSION_WORKER_COMPONENT_NAME):
152-
container_name = f"clp-{COMPRESSION_WORKER_COMPONENT_NAME}-{instance_id}"
153-
stop_running_container(container_name, already_exited_containers, force)
154153
if target in (ALL_TARGET_NAME, CONTROLLER_TARGET_NAME, QUERY_SCHEDULER_COMPONENT_NAME):
155154
container_name = f"clp-{QUERY_SCHEDULER_COMPONENT_NAME}-{instance_id}"
156155
stop_running_container(container_name, already_exited_containers, force)
@@ -164,11 +163,14 @@ def main(argv):
164163
COMPRESSION_SCHEDULER_COMPONENT_NAME,
165164
):
166165
container_name = f"clp-{COMPRESSION_SCHEDULER_COMPONENT_NAME}-{instance_id}"
167-
stop_running_container(container_name, already_exited_containers, force)
166+
stop_running_container(container_name, already_exited_containers, force, timeout=300)
168167

169168
container_config_file_path = logs_dir / f"{container_name}.yml"
170169
if container_config_file_path.exists():
171170
container_config_file_path.unlink()
171+
if target in (ALL_TARGET_NAME, COMPRESSION_WORKER_COMPONENT_NAME):
172+
container_name = f"clp-{COMPRESSION_WORKER_COMPONENT_NAME}-{instance_id}"
173+
stop_running_container(container_name, already_exited_containers, force, timeout=60)
172174
if target in (ALL_TARGET_NAME, CONTROLLER_TARGET_NAME, REDIS_COMPONENT_NAME):
173175
container_name = f"clp-{REDIS_COMPONENT_NAME}-{instance_id}"
174176
stop_running_container(container_name, already_exited_containers, force)

components/job-orchestration/job_orchestration/executor/compress/compression_task.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from contextlib import closing
77
from typing import Any, Dict, List, Optional, Tuple
88

9+
from celery import signals
910
from celery.app.task import Task
1011
from celery.utils.log import get_task_logger
1112
from clp_py_utils.clp_config import (
@@ -523,6 +524,11 @@ def run_clp(
523524
return CompressionTaskStatus.FAILED, worker_output
524525

525526

527+
@signals.worker_shutdown.connect
528+
def worker_shutdown_handler(signal=None, sender=None, **kwargs):
529+
logger.info("Shutdown signal received.")
530+
531+
526532
@app.task(bind=True)
527533
def compress(
528534
self: Task,

components/job-orchestration/job_orchestration/scheduler/compress/compression_scheduler.py

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import datetime
33
import logging
44
import os
5+
import signal
56
import sys
67
import time
78
from contextlib import closing
@@ -55,6 +56,14 @@
5556

5657
scheduled_jobs = {}
5758

59+
received_sigterm = False
60+
61+
62+
def sigterm_handler(signal_number, frame):
63+
global received_sigterm
64+
received_sigterm = True
65+
logger.info("Received SIGTERM.")
66+
5867

5968
def fetch_new_jobs(db_cursor):
6069
db_cursor.execute(
@@ -451,6 +460,10 @@ def poll_running_jobs(db_conn, db_cursor):
451460
for job_id in jobs_to_delete:
452461
del scheduled_jobs[job_id]
453462

463+
if received_sigterm and 0 == len(scheduled_jobs):
464+
logger.info("Recieved SIGTERM and there're no more running jobs. Exiting.")
465+
sys.exit(0)
466+
454467

455468
def main(argv):
456469
args_parser = argparse.ArgumentParser()
@@ -466,6 +479,9 @@ def main(argv):
466479
# Update logging level based on config
467480
set_logging_level(logger, os.getenv("CLP_LOGGING_LEVEL"))
468481

482+
# Register the SIGTERM handler
483+
signal.signal(signal.SIGTERM, sigterm_handler)
484+
469485
# Load configuration
470486
config_path = Path(args.config)
471487
try:
@@ -500,16 +516,17 @@ def main(argv):
500516
# Start Job Processing Loop
501517
while True:
502518
try:
503-
search_and_schedule_new_tasks(
504-
clp_config,
505-
db_conn,
506-
db_cursor,
507-
clp_metadata_db_connection_config,
508-
)
519+
if not received_sigterm:
520+
search_and_schedule_new_tasks(
521+
clp_config,
522+
db_conn,
523+
db_cursor,
524+
clp_metadata_db_connection_config,
525+
)
509526
poll_running_jobs(db_conn, db_cursor)
510527
time.sleep(clp_config.compression_scheduler.jobs_poll_delay)
511528
except KeyboardInterrupt:
512-
logger.info("Gracefully shutting down")
529+
logger.info("Forcefully shutting down")
513530
return -1
514531
except Exception:
515532
logger.exception(f"Error in scheduling.")

components/webui/client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"@webui/common": "*",
2626
"antd": "^5.24.5",
2727
"antlr4": "^4.13.2",
28-
"axios": "^1.7.9",
28+
"axios": "^1.12.2",
2929
"chart.js": "^4.4.9",
3030
"chartjs-adapter-dayjs-4": "^1.0.4",
3131
"chartjs-plugin-zoom": "^2.2.0",

components/webui/package-lock.json

Lines changed: 5 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/src/user-docs/guides-using-presto.md

Lines changed: 78 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -33,27 +33,60 @@ Using Presto with CLP requires:
3333

3434
1. Follow the [quick-start](quick-start/index.md) guide to download and extract the CLP package,
3535
but don't start the package just yet.
36-
2. Before starting the package, update the package's config as follows:
36+
2. Before starting the package, update the package's config file (`etc/clp-config.yml`) as follows:
3737

38-
* Open `etc/clp-config.yml` located within the package.
39-
* Uncomment the `database` section.
40-
* Change `database.host` value to a non-localhost hostname/IP.
41-
* After the change, the `database` section should look something like this:
38+
* Set the `package.query_engine` key to `"presto"`.
4239

4340
```yaml
44-
database:
45-
type: "mariadb" # "mariadb" or "mysql"
46-
host: "<new-IP-address>"
47-
port: 3306
48-
name: "clp-db"
41+
package:
42+
storage_engine: "clp-s"
43+
query_engine: "presto"
4944
```
5045
51-
:::{note}
52-
This change is necessary since the Presto containers run on a Docker network, whereas CLP's
53-
database runs on the host network. So `localhost` refers to two different entities in those
54-
networks. This limitation will be addressed in the future when we unify Presto and CLP's
55-
deployment infrastructure.
56-
:::
46+
* Set the `database.host` key to a non-localhost hostname/IP.
47+
48+
```yaml
49+
database:
50+
# type: "mariadb"
51+
host: "<non-local-ip-address>"
52+
# port: 3306
53+
# name: "clp-db"
54+
```
55+
56+
:::{note}
57+
This change is necessary because the Presto containers run on a Docker network, and CLP's
58+
database runs on the host network. `localhost` will refer to a different entity in each of
59+
those contexts. This limitation will be addressed in the future when we unify Presto and CLP's
60+
deployment infrastructure.
61+
:::
62+
63+
* Set the `results_cache.retention_period` key to `null` since the CLP + Presto integration
64+
doesn't yet support garbage collection.
65+
66+
```yaml
67+
results_cache:
68+
# host: "localhost"
69+
# port: 27017
70+
# db_name: "clp-query-results"
71+
# stream_collection_name: "stream-files"
72+
#
73+
# # Retention period for search results, in minutes. Set to null to disable automatic deletion.
74+
retention_period: null
75+
```
76+
77+
* Update the `presto` key with the host and port of the Presto cluster. If you follow the
78+
[Setting up Presto](#setting-up-presto) section, the host is `localhost` and the port is
79+
`8889`.
80+
81+
```yaml
82+
presto:
83+
host: "<ip-address>"
84+
port: <port>
85+
```
86+
87+
:::{note}
88+
Presto doesn't need to be running before you start CLP.
89+
:::
5790

5891
3. If you'd like to store your compressed logs on S3, follow the
5992
[using object storage](guides-using-object-storage/index.md) guide.
@@ -115,7 +148,7 @@ Using Presto with CLP requires:
115148
5. Start a Presto cluster by running:
116149

117150
```bash
118-
docker compose up
151+
docker compose up --detach
119152
```
120153

121154
* To use more than one Presto worker, you can use the `--scale` option as follows:
@@ -128,24 +161,22 @@ Using Presto with CLP requires:
128161

129162
### Stopping the Presto cluster
130163

131-
To stop the Presto cluster, use CTRL + C.
164+
To stop the Presto cluster:
165+
166+
```bash
167+
docker compose stop
168+
```
132169

133170
To clean up the Presto cluster entirely:
134171

135172
```bash
136-
docker compose rm
173+
docker compose down
137174
```
138175

139176
## Querying your logs through Presto
140177

141-
To query your logs through Presto, you can use the Presto CLI:
142-
143-
```bash
144-
docker compose exec presto-coordinator \
145-
presto-cli \
146-
--catalog clp \
147-
--schema default
148-
```
178+
You can query your compressed logs in your browser from [CLP's UI](#querying-from-clps-ui), or
179+
from the command line using the [Presto CLI](#querying-from-the-presto-cli).
149180

150181
Each dataset in CLP shows up as a table in Presto. To show all available datasets:
151182

@@ -179,6 +210,26 @@ contain the field `foo.bar`, you can query it using:
179210
SELECT foo.bar FROM default LIMIT 1;
180211
```
181212

213+
### Querying from CLP's UI
214+
215+
CLP's UI should be available at [http://localhost:4000](http://localhost:4000) (if you changed
216+
`webui.host` or `webui.port` in `etc/clp-config.yml`, use the new values).
217+
218+
:::{note}
219+
The UI can only run one query at a time, and queries must not end with a `;`.
220+
:::
221+
222+
### Querying from the Presto CLI
223+
224+
To access the Presto CLI, navigate to the `tools/deployment/presto-clp` directory and run:
225+
226+
```bash
227+
docker compose exec presto-coordinator \
228+
presto-cli \
229+
--catalog clp \
230+
--schema default
231+
```
232+
182233
## Limitations
183234

184235
The Presto CLP integration has the following limitations at present:

0 commit comments

Comments
 (0)