Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions collectoss/application/cli/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ def stop_processes(signal, logger, engine):
cleanup_collection_status_and_rabbit(logger, engine)



def assign_orphan_repos_to_default_user(session):
query = s.sql.text("""
SELECT repo_id FROM repo WHERE repo_id NOT IN (SELECT repo_id FROM operations.user_repos)
Expand Down
12 changes: 9 additions & 3 deletions collectoss/application/service_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,10 @@

logger.info("Clearing all messages from celery queue in rabbitmq")
from collectoss.tasks.init.celery_app import celery_app
celery_app.control.purge()
try:
celery_app.control.purge()
except Exception as e:
logger.warning(f"Failed to purge celery queue (this is usually benign if the queue doesn't exist yet): {e}")

clear_all_message_queues(connection_string)
#rabbitmq_purge_command = f"sudo rabbitmqctl purge_queue celery -p {virtual_host_string}"
Expand All @@ -162,5 +165,8 @@
parsed = urlparse(connection_string)

for q in queues:
curl_cmd = f"curl -i -u {parsed.username}:{parsed.password} -XDELETE http://localhost:15672/api/queues/{virtual_host_string}/{q}"
subprocess.call(curl_cmd.split(" "),stdout=subprocess.PIPE, stderr=subprocess.PIPE)
# Use the hostname from the connection string instead of localhost
# to ensure it works in both docker and non-docker environments
hostname = parsed.hostname or "localhost"
curl_cmd = f"curl -is -u {parsed.username}:{parsed.password} -XDELETE http://{hostname}:15672/api/queues/{virtual_host_string}/{q}"
subprocess.call(curl_cmd.split(" "), stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)

Check notice

Code scanning / Bandit

subprocess call - check for execution of untrusted input. Note

subprocess call - check for execution of untrusted input.
3 changes: 1 addition & 2 deletions collectoss/tasks/init/celery_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import inspect
import celery
from celery import Celery
from celery import current_app
from celery.signals import after_setup_logger


Expand Down Expand Up @@ -264,7 +263,7 @@ def setup_periodic_tasks(sender, **kwargs):
def setup_loggers(*args,**kwargs):
"""Override Celery loggers with our own."""

all_celery_tasks = list(current_app.tasks.keys())
all_celery_tasks = list(celery_app.tasks.keys())

tasks = [task for task in all_celery_tasks if 'celery.' not in task]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
W0621: Redefining name 'tasks' from outer scope (line 64) (redefined-outer-name)


Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ dependencies = [
"Beaker==1.11.0",
"boto3==1.17.57",
"bs4==0.0.1",
"celery~=5.5",
"celery>=5.6.0",
"click~=8.1",
"coloredlogs==15.0",
"emoji==1.2.0",
Expand Down Expand Up @@ -54,7 +54,7 @@ dependencies = [
"python-crfsuite>=0.9.8",
"python-dotenv>=1.2.1",
"pyYaml",
"redis==4.3.3",
"redis>=4.5.3",
"scikit-image==0.19.1",
"scikit-learn==1.5.0",
"requests~=2.32",
Expand Down
52 changes: 26 additions & 26 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading