Skip to content

Commit

Permalink
Add misc operations and queries for lantern
Browse files Browse the repository at this point in the history
  • Loading branch information
var77 committed Apr 29, 2024
1 parent e973ee4 commit 7ad744f
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 1 deletion.
2 changes: 1 addition & 1 deletion loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
end

autoload_normal.call("model", flat: true)
%w[lib clover.rb clover_web.rb clover_api.rb routes/clover_base.rb routes/clover_error.rb].each { autoload_normal.call(_1) }
%w[lib clover.rb clover_web.rb clover_api.rb routes/clover_base.rb routes/clover_error.rb misc/misc_queries.rb misc/misc_operations.rb].each { autoload_normal.call(_1) }
%w[scheduling prog serializers serializers/web serializers/api].each { autoload_normal.call(_1, include_first: true) }

AUTOLOAD_CONSTANTS.freeze
Expand Down
37 changes: 37 additions & 0 deletions misc/misc_operations.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# frozen_string_literal: true

def update_rhizome(sshable, target_folder, user)
tar = StringIO.new
Gem::Package::TarWriter.new(tar) do |writer|
base = Config.root + "/rhizome"
Dir.glob(["Gemfile", "Gemfile.lock", "common/**/*", "#{target_folder}/**/*"], base: base).map do |file|
full_path = base + "/" + file
stat = File.stat(full_path)
if stat.directory?
writer.mkdir(file, stat.mode)
elsif stat.file?
writer.add_file(file, stat.mode) do |tf|
File.open(full_path, "rb") do
IO.copy_stream(_1, tf)
end
end
else
# :nocov:
fail "BUG"
# :nocov:
end
end
end
payload = tar.string.freeze
sshable.cmd("tar xf -", stdin: payload)

sshable.cmd("bundle config set --local path vendor/bundle")
sshable.cmd("bundle install")
puts "updated rhizome"
end

class MiscOperations
def self.update_rhizome_from_local(vm, target_folder: "lantern", user: "lantern")
update_rhizome(vm.sshable, target_folder, user)
end
end
12 changes: 12 additions & 0 deletions misc/misc_queries.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

class MiscQueries
def self.update_collation_on_all_databases
# https://postgresql.verite.pro/blog/2018/08/27/glibc-upgrade.html
# We didn't need to update rebuild indexes this time as we didn't have any indexes with collation coming from libc
resources = LanternResource.all
resources.each do |resource|
resource.representative_server.run_query("ALTER DATABASE template1 REFRESH COLLATION VERSION")
end
end
end
1 change: 1 addition & 0 deletions spec/coverage_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# rhizome (dataplane) and controlplane should have separate coverage reports.
# They will have different coverage suites in future.
add_filter "/rhizome"
add_filter "/misc"

# No need to check coverage for them
add_filter "/migrate/"
Expand Down

0 comments on commit 7ad744f

Please sign in to comment.