Skip to content

Commit

Permalink
Rename WebSocketWorker to RemoteConsoleWorker
Browse files Browse the repository at this point in the history
  • Loading branch information
skateman committed Jan 8, 2019
1 parent 97c8dba commit e518b13
Show file tree
Hide file tree
Showing 18 changed files with 73 additions and 73 deletions.
2 changes: 1 addition & 1 deletion .rubocop_local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ GlobalVars:
- $scvmm_log
- $vcloud_log
- $vim_log
- $websocket_log
- $remote_console_log
- $nuage_log
- $redfish_log
Rails/Exit:
Expand Down
6 changes: 3 additions & 3 deletions Procfile.example
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
# So, the first ui worker will get PORT=3000 while the next will get PORT=3001
# The first api worker will get PORT=3100 and the next will get PORT=3101

# ui: env PORT=$PORT ruby lib/workers/bin/run_single_worker.rb MiqUiWorker
# api: env PORT=$PORT ruby lib/workers/bin/run_single_worker.rb MiqWebServiceWorker
# websocket: env PORT=$PORT ruby lib/workers/bin/run_single_worker.rb MiqWebsocketWorker
# ui: env PORT=$PORT ruby lib/workers/bin/run_single_worker.rb MiqUiWorker
# api: env PORT=$PORT ruby lib/workers/bin/run_single_worker.rb MiqWebServiceWorker
# remote_console: env PORT=$PORT ruby lib/workers/bin/run_single_worker.rb MiqRemoteConsoleWorker

# schedule: ruby lib/workers/bin/run_single_worker.rb MiqScheduleWorker

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
class MiqWebsocketWorker < MiqWorker
class MiqRemoteConsoleWorker < MiqWorker
require_nested :Runner

self.required_roles = ['websocket']
self.required_roles = ['remote_console']

RACK_APPLICATION = WebsocketServer
STARTING_PORT = 5000

def friendly_name
@friendly_name ||= "Websocket Worker"
@friendly_name ||= "Remote Console Worker"
end

include MiqWebServerWorkerMixin
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class MiqWebsocketWorker::Runner < MiqWorker::Runner
class MiqRemoteConsoleWorker::Runner < MiqWorker::Runner
include MiqWebServerRunnerMixin

def heartbeat(*args)
Expand All @@ -9,7 +9,7 @@ def heartbeat(*args)

def check_internal_thread
unless worker.rails_application.healthy?
do_exit("MiqWebsocketWorker internal thread crashed, exiting!", 1)
do_exit("MiqRemoteConsoleWorker internal thread crashed, exiting!", 1)
end
end
end
10 changes: 5 additions & 5 deletions app/models/miq_server/role_management.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module MiqServer::RoleManagement
extend ActiveSupport::Concern

ROLES_NEEDING_APACHE = %w(user_interface web_services websocket embedded_ansible cockpit_ws).freeze
ROLES_NEEDING_APACHE = %w(user_interface web_services remote_console embedded_ansible cockpit_ws).freeze

included do
has_many :assigned_server_roles, :dependent => :destroy
Expand Down Expand Up @@ -49,10 +49,10 @@ def apache_needed?
end

def set_active_role_flags
self.has_active_userinterface = self.has_active_role?("user_interface")
self.has_active_websocket = self.has_active_role?("websocket")
self.has_active_webservices = self.has_active_role?("web_services")
self.has_active_cockpit_ws = self.has_active_role?("cockpit_ws")
self.has_active_userinterface = self.has_active_role?("user_interface")
self.has_active_remote_console = self.has_active_role?("remote_console")
self.has_active_webservices = self.has_active_role?("web_services")
self.has_active_cockpit_ws = self.has_active_role?("cockpit_ws")
save
end

Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Vmdb::Application.routes.draw do
if Rails.env.development? && defined?(Rails::Server)
logger = Logger.new(STDOUT)
logger.level = Logger.const_get(::Settings.log.level_websocket.upcase)
logger.level = Logger.const_get(::Settings.log.level_remote_console.upcase)
mount WebsocketServer.new(:logger => logger) => '/ws/console'
end
end
6 changes: 3 additions & 3 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@
:level_scvmm: info
:level_vcloud: info
:level_vim: warn
:level_websocket: info
:level_remote_console: info
:notifications:
:history:
:purge_window_size: 1000
Expand Down Expand Up @@ -1026,7 +1026,7 @@
:prefetch_stale_threshold: 30.seconds
:rails_server: puma
:remote_console_type: VMRC
:role: database_operations,event,reporting,scheduler,smartstate,ems_operations,ems_inventory,user_interface,websocket,web_services,automate
:role: database_operations,event,reporting,scheduler,smartstate,ems_operations,ems_inventory,user_interface,remote_console,web_services,automate
:server_dequeue_frequency: 5.seconds
:server_log_frequency: 5.minutes
:server_log_timings_threshold: 1.second
Expand Down Expand Up @@ -1288,7 +1288,7 @@
:connection_pool_size: 8
:memory_threshold: 1.gigabytes
:nice_delta: 1
:websocket_worker:
:remote_console_worker:
:connection_pool_size: 14
:memory_threshold: 1.gigabytes
:nice_delta: 1
Expand Down
2 changes: 1 addition & 1 deletion db/fixtures/server_roles.csv
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ scheduler,Scheduler,1,false,region
smartproxy,SmartProxy,0,false,zone
smartstate,SmartState Analysis,0,false,zone
user_interface,User Interface,0,false,region
websocket,Websocket,0,false,region
remote_console,Remote Consoles,0,false,region
web_services,Web Services,0,false,region
84 changes: 42 additions & 42 deletions lib/vmdb/loggers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,53 +18,53 @@ def self.init
end

def self.apply_config(config)
apply_config_value(config, $log, :level)
apply_config_value(config, $rails_log, :level_rails)
apply_config_value(config, $ansible_tower_log, :level_ansible_tower)
apply_config_value(config, $api_log, :level_api)
apply_config_value(config, $miq_ae_logger, :level_automation)
apply_config_value(config, $aws_log, :level_aws)
apply_config_value(config, $azure_log, :level_azure)
apply_config_value(config, $cn_monitoring_log, :level_cn_monitoring)
apply_config_value(config, $datawarehouse_log, :level_datawarehouse)
apply_config_value(config, $fog_log, :level_fog)
apply_config_value(config, $kube_log, :level_kube)
apply_config_value(config, $lenovo_log, :level_lenovo)
apply_config_value(config, $nuage_log, :level_nuage)
apply_config_value(config, $policy_log, :level_policy)
apply_config_value(config, $redfish_log, :level_redfish)
apply_config_value(config, $rhevm_log, :level_rhevm)
apply_config_value(config, $scvmm_log, :level_scvmm)
apply_config_value(config, $vcloud_log, :level_vcloud)
apply_config_value(config, $vim_log, :level_vim)
apply_config_value(config, $websocket_log, :level_websocket)
apply_config_value(config, $log, :level)
apply_config_value(config, $rails_log, :level_rails)
apply_config_value(config, $ansible_tower_log, :level_ansible_tower)
apply_config_value(config, $api_log, :level_api)
apply_config_value(config, $miq_ae_logger, :level_automation)
apply_config_value(config, $aws_log, :level_aws)
apply_config_value(config, $azure_log, :level_azure)
apply_config_value(config, $cn_monitoring_log, :level_cn_monitoring)
apply_config_value(config, $datawarehouse_log, :level_datawarehouse)
apply_config_value(config, $fog_log, :level_fog)
apply_config_value(config, $kube_log, :level_kube)
apply_config_value(config, $lenovo_log, :level_lenovo)
apply_config_value(config, $nuage_log, :level_nuage)
apply_config_value(config, $policy_log, :level_policy)
apply_config_value(config, $redfish_log, :level_redfish)
apply_config_value(config, $rhevm_log, :level_rhevm)
apply_config_value(config, $scvmm_log, :level_scvmm)
apply_config_value(config, $vcloud_log, :level_vcloud)
apply_config_value(config, $vim_log, :level_vim)
apply_config_value(config, $remote_console_log, :level_remote_console)
end

def self.create_loggers
path_dir = ManageIQ.root.join("log")

$audit_log = AuditLogger.new(path_dir.join("audit.log"))
$container_log = ContainerLogger.new
$log = create_multicast_logger(path_dir.join("evm.log"))
$rails_log = create_multicast_logger(path_dir.join("#{Rails.env}.log"))
$api_log = create_multicast_logger(path_dir.join("api.log"))
$ansible_tower_log = create_multicast_logger(path_dir.join("ansible_tower.log"))
$miq_ae_logger = create_multicast_logger(path_dir.join("automation.log"))
$aws_log = create_multicast_logger(path_dir.join("aws.log"))
$azure_log = create_multicast_logger(path_dir.join("azure.log"), AzureLogger)
$cn_monitoring_log = create_multicast_logger(path_dir.join("container_monitoring.log"))
$datawarehouse_log = create_multicast_logger(path_dir.join("datawarehouse.log"))
$fog_log = create_multicast_logger(path_dir.join("fog.log"), FogLogger)
$kube_log = create_multicast_logger(path_dir.join("kubernetes.log"))
$lenovo_log = create_multicast_logger(path_dir.join("lenovo.log"))
$nuage_log = create_multicast_logger(path_dir.join("nuage.log"))
$policy_log = create_multicast_logger(path_dir.join("policy.log"))
$redfish_log = create_multicast_logger(path_dir.join("redfish.log"))
$rhevm_log = create_multicast_logger(path_dir.join("rhevm.log"))
$scvmm_log = create_multicast_logger(path_dir.join("scvmm.log"))
$vcloud_log = create_multicast_logger(path_dir.join("vcloud.log"))
$vim_log = create_multicast_logger(path_dir.join("vim.log"))
$websocket_log = create_multicast_logger(path_dir.join("websocket.log"))
$audit_log = AuditLogger.new(path_dir.join("audit.log"))
$container_log = ContainerLogger.new
$log = create_multicast_logger(path_dir.join("evm.log"))
$rails_log = create_multicast_logger(path_dir.join("#{Rails.env}.log"))
$api_log = create_multicast_logger(path_dir.join("api.log"))
$ansible_tower_log = create_multicast_logger(path_dir.join("ansible_tower.log"))
$miq_ae_logger = create_multicast_logger(path_dir.join("automation.log"))
$aws_log = create_multicast_logger(path_dir.join("aws.log"))
$azure_log = create_multicast_logger(path_dir.join("azure.log"), AzureLogger)
$cn_monitoring_log = create_multicast_logger(path_dir.join("container_monitoring.log"))
$datawarehouse_log = create_multicast_logger(path_dir.join("datawarehouse.log"))
$fog_log = create_multicast_logger(path_dir.join("fog.log"), FogLogger)
$kube_log = create_multicast_logger(path_dir.join("kubernetes.log"))
$lenovo_log = create_multicast_logger(path_dir.join("lenovo.log"))
$nuage_log = create_multicast_logger(path_dir.join("nuage.log"))
$policy_log = create_multicast_logger(path_dir.join("policy.log"))
$redfish_log = create_multicast_logger(path_dir.join("redfish.log"))
$rhevm_log = create_multicast_logger(path_dir.join("rhevm.log"))
$scvmm_log = create_multicast_logger(path_dir.join("scvmm.log"))
$vcloud_log = create_multicast_logger(path_dir.join("vcloud.log"))
$vim_log = create_multicast_logger(path_dir.join("vim.log"))
$remote_console_log = create_multicast_logger(path_dir.join("remote_console.log"))

configure_external_loggers
end
Expand Down
2 changes: 1 addition & 1 deletion lib/websocket_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class WebsocketServer
RACK_YAY = [-1, {}, []].freeze

def initialize(options = {})
@logger = options.fetch(:logger, $websocket_log)
@logger = options.fetch(:logger, $remote_console_log)
@logger.info('Initializing websocket server!')
@proxy = SurroGate.new(logger)
@adapters = {}
Expand Down
4 changes: 2 additions & 2 deletions lib/workers/miq_worker_types.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"MiqUiWorker" => %i(manageiq_default ui_dependencies),
"MiqVimBrokerWorker" => %i(manageiq_default),
"MiqWebServiceWorker" => %i(manageiq_default),
"MiqWebsocketWorker" => %i(manageiq_default),
"MiqRemoteConsoleWorker" => %i(manageiq_default),
}.freeze

MIQ_WORKER_TYPES_IN_KILL_ORDER = %w(
Expand Down Expand Up @@ -151,6 +151,6 @@
ManageIQ::Providers::Openshift::MonitoringManager::EventCatcher
ManageIQ::Providers::Lenovo::PhysicalInfraManager::EventCatcher
MiqUiWorker
MiqWebsocketWorker
MiqRemoteConsoleWorker
MiqCockpitWsWorker
).freeze
2 changes: 1 addition & 1 deletion spec/factories/miq_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
factory :miq_generic_worker, :class => "MiqGenericWorker", :parent => :miq_worker
factory :miq_ui_worker, :class => "MiqUiWorker", :parent => :miq_worker
factory :miq_schedule_worker, :parent => :miq_worker, :class => "MiqScheduleWorker"
factory :miq_websocket_worker, :class => "MiqWebsocketWorker", :parent => :miq_worker
factory :miq_remote_console_worker, :class => "MiqRemoteConsoleWorker", :parent => :miq_worker

factory :miq_ems_metrics_processor_worker, :class => "MiqEmsMetricsProcessorWorker", :parent => :miq_worker

Expand Down
2 changes: 1 addition & 1 deletion spec/lib/vmdb/loggers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def in_container_env(example)
$log, $rails_log, $api_log, $miq_ae_logger, $aws_log, $azure_log,
$cn_monitoring_log, $datawarehouse_log, $fog_log, $kube_log, $lenovo_log,
$nuage_log, $policy_log, $rhevm_log, $scvmm_log, $vcloud_log, $vim_log,
$websocket_log
$remote_console_log
].each do |logger|
context "for the #{File.basename(logger.filename)}" do
include_examples "has basic logging functionality", logger.dup
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
describe MiqWebsocketWorker::Runner do
describe MiqRemoteConsoleWorker::Runner do
describe '#check_internal_thread' do
subject do
w = described_class.allocate
allow(w).to receive(:worker_initialization)
w.send(:initialize, :guid => MiqWebsocketWorker.create_worker_record.guid)
w.send(:initialize, :guid => MiqRemoteConsoleWorker.create_worker_record.guid)
w
end

Expand Down
2 changes: 1 addition & 1 deletion spec/models/miq_server/role_management_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
smartproxy,SmartProxy,0,false,zone
smartstate,SmartState Analysis,0,false,zone
user_interface,User Interface,0,false,region
websocket,Websocket,0,false,region
remote_console,Remote Consoles,0,false,region
web_services,Web Services,0,false,region
cockpit_ws,Cockpit,1,false,region
CSV
Expand Down
2 changes: 1 addition & 1 deletion spec/models/miq_server/server_monitor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
smartproxy,SmartProxy,0,false,zone
smartstate,SmartState Analysis,0,false,zone
user_interface,User Interface,0,false,region
websocket,Websocket,0,false,region
remote_console,Remote Consoles,0,false,region
web_services,Web Services,0,false,region
CSV
allow(ServerRole).to receive(:seed_data).and_return(@csv)
Expand Down
4 changes: 2 additions & 2 deletions spec/models/mixins/miq_web_server_worker_mixin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ def self.binding_address
end

describe '#rails_application' do
let(:websocket_worker) { FactoryBot.create(:miq_websocket_worker, :uri => 'http://127.0.0.1:3000') }
let(:remote_console_worker) { FactoryBot.create(:miq_remote_console_worker, :uri => 'http://127.0.0.1:3000') }
let(:ui_worker) { FactoryBot.create(:miq_ui_worker, :uri => 'http://127.0.0.1:3000') }

it 'provides access to the Rack/Rails application' do
expect(websocket_worker.rails_application).to be_a_kind_of(WebsocketServer)
expect(remote_console_worker.rails_application).to be_a_kind_of(WebsocketServer)
expect(ui_worker.rails_application).to be_a_kind_of(Vmdb::Application)
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/models/server_role_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
smartproxy,SmartProxy,0,false,zone
smartstate,SmartState Analysis,0,false,zone
user_interface,User Interface,0,false,region
websocket,Websocket,0,false,region
remote_console,Remote Consoles,0,false,region
web_services,Web Services,0,false,region
CSV

Expand Down

0 comments on commit e518b13

Please sign in to comment.