Skip to content

Commit

Permalink
add query to remove dangling docker images
Browse files Browse the repository at this point in the history
  • Loading branch information
var77 committed Jul 24, 2024
1 parent f5ace4a commit 1f9242b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
12 changes: 12 additions & 0 deletions migrate/20240724_lantern_doctor_queries.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

Sequel.migration do
up do
# check duplicate sources for embedding jobs
run "INSERT INTO lantern_doctor_query (id, name, db_name, schedule, condition, fn_label, type, severity, response_type)
VALUES ('0e5fab85-71f6-89b7-96cf-f1e8e1074389', 'Cleanup dangling docker images', 'postgres', '0 9 * * *', 'unknown', 'remove_dangling_images', 'system', 'error', 'rows')"

# Create semaphores for all lantern doctors to sync system queries
run "INSERT INTO semaphore (id, strand_id, name) SELECT gen_random_uuid(), id, 'sync_system_queries' FROM strand s WHERE s.prog = 'Lantern::LanternDoctorNexus'"
end
end
9 changes: 9 additions & 0 deletions rhizome/lantern/bin/doctor/run_query
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,15 @@ SQL

output
end

def self.remove_dangling_images(_db, _query_user)
r("sudo docker image prune -af")
""
end

def self.remove_dangling_index_files(_db, _query_user)
r("sudo find /var/lib/lantern-data/data/ -name 'ldb-index*' -type f -mmin +240 -delete >/tmp/ldb-index-cleanup-logs 2>&1 && echo "" || cat /tmp/ldb-index-cleanup-logs").chomp.strip
end
end

exit_code = 0
Expand Down

0 comments on commit 1f9242b

Please sign in to comment.