Skip to content

Commit 1dfc973

Browse files
committed
fix the untagged server selection
1 parent 664fbe2 commit 1dfc973

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

app/models/server.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ def self.find_available(tags_arg = nil)
292292
tags_required = false
293293
if !tags_arg.nil? && tags_arg[-1] == '!'
294294
tags_arg = tags_arg[0..-2].presence # always returns String, if tag is String
295-
tags_required = true
295+
tags_required = true unless tags_arg.nil?
296296
end
297297
tags = tags_arg&.split(',')
298298

@@ -307,14 +307,14 @@ def self.find_available(tags_arg = nil)
307307
tags.each do |tag|
308308
ids_loads_tagged.concat ids_loads.select { |myid, _| redis.hget(key(myid), 'tag') == tag }
309309
end
310-
ids_loads_tagged.sort_by { |id_load| id_load[1] }
311-
if ids_loads_tagged.blank?
312-
raise BBBErrors::ServerTagUnavailableError, tags_arg if tags_required
313-
tags = nil # fall back to servers without tag
314-
ids_loads_tagged = ids_loads.select { |myid, _| redis.hget(key(myid), 'tag').nil? }
315-
end
316-
ids_loads = ids_loads_tagged
310+
ids_loads_tagged.sort_by! { |id_load| id_load[1] }
311+
end
312+
if ids_loads_tagged.blank?
313+
raise BBBErrors::ServerTagUnavailableError, tags_arg if tags_required
314+
tags = nil # fall back to servers without tag
315+
ids_loads_tagged = ids_loads.select { |myid, _| redis.hget(key(myid), 'tag').nil? }
317316
end
317+
ids_loads = ids_loads_tagged
318318

319319
# try to select the server with lowest load
320320
id, load, hash = ids_loads.each do |id, load|

0 commit comments

Comments
 (0)