Skip to content

Commit

Permalink
Merge branch 'develop' into add-server-protocol-guard
Browse files Browse the repository at this point in the history
  • Loading branch information
farhatahmad authored Nov 9, 2023
2 parents 79b5ba8 + f2deb3e commit 4ee84eb
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 18 deletions.
2 changes: 1 addition & 1 deletion app/controllers/bigbluebutton_api_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ def get_recordings
raise BBBError.new('missingParameters', 'param meetingID or recordID must be included.')
end

query = Recording.includes(playback_formats: [:thumbnails], metadata: []).left_joins(:metadata)
query = Recording.includes(playback_formats: [:thumbnails], metadata: []).left_joins(:metadata).distinct

query = query.where(metadata: { key: "tenant-id", value: @tenant.id }) if @tenant.present?

Expand Down
9 changes: 2 additions & 7 deletions app/models/meeting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,8 @@ def self.all(tenant_id = nil)
hash = redis.hgetall(key(id))
next if hash.blank?

if tenant_id.present?
# Only fetch meetings for particular Tenant
next if tenant_id != hash['tenant_id']
elsif hash['tenant_id'].present?
next
end
# Only fetch meetings without Tenant
# If tenant_id given, only fetch meetings for particular Tenant
next if tenant_id.present? && hash['tenant_id'] != tenant_id

hash[:id] = id
meetings << new.init_with_attributes(hash)
Expand Down
2 changes: 1 addition & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class Application < Rails::Application
config.x.recording_import_unpublished = ENV.fetch('RECORDING_IMPORT_UNPUBLISHED', 'false').casecmp?('true')

# Multitenancy values
config.x.multitenancy_enabled = ENV.fetch('MULTITENANCY_ENABLED', nil)
config.x.multitenancy_enabled = ENV.fetch('MULTITENANCY_ENABLED', 'false').casecmp?('true')

# Scalelite Host name
config.x.url_host = ENV.fetch('URL_HOST', nil)
Expand Down
18 changes: 17 additions & 1 deletion lib/tasks/poll.rake
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,26 @@ namespace :poll do
next if server.increment_unhealthy < Rails.configuration.x.server_unhealthy_threshold

Rails.logger.warn("Server id=#{server.id} is unhealthy. Panicking and setting offline...")
Rake::Task['servers:panic'].invoke(server.id, true) # Panic server to clear meetings

meetings = Meeting.all.select { |m| m.server_id == server.id }
meetings.each do |meeting|
puts("Clearing Meeting id=#{meeting.id}")
moderator_pw = meeting.try(:moderator_pw)
meeting.destroy!
get_post_req(encode_bbb_uri('end', server.url, server.secret, meetingID: meeting.id, password: moderator_pw))
rescue ApplicationRedisRecord::RecordNotDestroyed => e
raise("ERROR: Could not destroy meeting id=#{meeting.id}: #{e}")
rescue StandardError => e
puts("WARNING: Could not end meeting id=#{meeting.id}: #{e}")
end

server.reset_counters
server.load = nil
server.online = false
server.meetings = 0
server.users = 0
server.largest_meeting = 0
server.videos = 0
ensure
begin
server.save!
Expand Down
7 changes: 7 additions & 0 deletions lib/tasks/servers.rake
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ namespace :servers do
puts('OK')
rescue ApplicationRedisRecord::RecordNotFound
puts("ERROR: No server found with id: #{args.id}")
exit(1)
end

desc 'Remove a BigBlueButton server'
Expand All @@ -71,6 +72,7 @@ namespace :servers do
puts('OK')
rescue ApplicationRedisRecord::RecordNotFound
puts("ERROR: No server found with id: #{args.id}")
exit(1)
end

desc 'Mark a BigBlueButton server as available for scheduling new meetings'
Expand All @@ -81,6 +83,7 @@ namespace :servers do
puts('OK')
rescue ApplicationRedisRecord::RecordNotFound
puts("ERROR: No server found with id: #{args.id}")
exit(1)
end

desc 'Mark a BigBlueButton server as cordoned to stop scheduling new meetings but consider for
Expand All @@ -92,6 +95,7 @@ namespace :servers do
puts('OK')
rescue ApplicationRedisRecord::RecordNotFound
puts("ERROR: No server found with id: #{args.id}")
exit(1)
end

desc 'Mark a BigBlueButton server as unavailable to stop scheduling new meetings'
Expand Down Expand Up @@ -123,6 +127,7 @@ namespace :servers do
puts('OK')
rescue ApplicationRedisRecord::RecordNotFound
puts("ERROR: No server found with id: #{args.id}")
exit(1)
end

desc 'Mark a BigBlueButton server as unavailable, and clear all meetings from it'
Expand All @@ -148,6 +153,7 @@ namespace :servers do
puts('OK')
rescue ApplicationRedisRecord::RecordNotFound
puts("ERROR: No server found with id: #{args.id}")
exit(1)
end

desc 'Set the load-multiplier of a BigBlueButton server'
Expand All @@ -166,6 +172,7 @@ namespace :servers do
puts('OK')
rescue ApplicationRedisRecord::RecordNotFound
puts("ERROR: No server found with id: #{args.id}")
exit(1)
end

desc 'Adds multiple BigBlueButton servers defined in a YAML file passed as an argument'
Expand Down
10 changes: 2 additions & 8 deletions spec/models/meeting_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,8 @@
context 'without tenant_id param' do
let(:meetings) { described_class.all }

it 'fetches correct nb of Meetings' do
expect(meetings.size).to eq 2
end

it 'fetches Meetings with correct tenant_id' do
meetings.each do |meeting|
expect(meeting.tenant_id).to be_nil
end
it 'fetches all Meetings' do
expect(meetings.size).to eq 7
end
end
end
Expand Down

0 comments on commit 4ee84eb

Please sign in to comment.