From c155b4ba4506275f41d79cad00693b9b5ff210b2 Mon Sep 17 00:00:00 2001 From: r-dilip Date: Thu, 22 Aug 2019 15:34:11 -0700 Subject: [PATCH 1/2] Add require to all files referencing other classes --- source/code/plugin/health/agg_monitor_id_labels.rb | 1 + source/code/plugin/health/aggregate_monitor.rb | 2 +- source/code/plugin/health/aggregate_monitor_state_finalizer.rb | 1 + source/code/plugin/health/health_kube_api_down_handler.rb | 1 + source/code/plugin/health/health_missing_signal_generator.rb | 1 + source/code/plugin/health/health_model_builder.rb | 1 - source/code/plugin/health/health_monitor_helpers.rb | 1 + source/code/plugin/health/health_monitor_provider.rb | 1 + source/code/plugin/health/health_monitor_state.rb | 1 + source/code/plugin/health/health_monitor_utils.rb | 1 + source/code/plugin/health/health_signal_reducer.rb | 2 ++ source/code/plugin/health/monitor_factory.rb | 2 ++ source/code/plugin/health/node_monitor_hierarchy_reducer.rb | 1 + source/code/plugin/health/parent_monitor_provider.rb | 1 + source/code/plugin/health/unit_monitor.rb | 1 - 15 files changed, 15 insertions(+), 3 deletions(-) diff --git a/source/code/plugin/health/agg_monitor_id_labels.rb b/source/code/plugin/health/agg_monitor_id_labels.rb index 48ca46184..c40cf66c3 100644 --- a/source/code/plugin/health/agg_monitor_id_labels.rb +++ b/source/code/plugin/health/agg_monitor_id_labels.rb @@ -1,3 +1,4 @@ +Dir[File.join(__dir__, '*.rb')].each { |file| require file } module HealthModel class AggregateMonitorInstanceIdLabels @@id_labels_mapping = { diff --git a/source/code/plugin/health/aggregate_monitor.rb b/source/code/plugin/health/aggregate_monitor.rb index 794f716ce..5eb954ac4 100644 --- a/source/code/plugin/health/aggregate_monitor.rb +++ b/source/code/plugin/health/aggregate_monitor.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative 'health_model_constants' +Dir[File.join(__dir__, '*.rb')].each { |file| require file } require 'json' module HealthModel diff --git a/source/code/plugin/health/aggregate_monitor_state_finalizer.rb b/source/code/plugin/health/aggregate_monitor_state_finalizer.rb index 74e780924..83d453d9e 100644 --- a/source/code/plugin/health/aggregate_monitor_state_finalizer.rb +++ b/source/code/plugin/health/aggregate_monitor_state_finalizer.rb @@ -1,3 +1,4 @@ +Dir[File.join(__dir__, '*.rb')].each { |file| require file } module HealthModel class AggregateMonitorStateFinalizer diff --git a/source/code/plugin/health/health_kube_api_down_handler.rb b/source/code/plugin/health/health_kube_api_down_handler.rb index 7f7ba1bd3..d8669da7c 100644 --- a/source/code/plugin/health/health_kube_api_down_handler.rb +++ b/source/code/plugin/health/health_kube_api_down_handler.rb @@ -1,3 +1,4 @@ +Dir[File.join(__dir__, '*.rb')].each { |file| require file } module HealthModel class HealthKubeApiDownHandler def initialize diff --git a/source/code/plugin/health/health_missing_signal_generator.rb b/source/code/plugin/health/health_missing_signal_generator.rb index ff7f6a390..fa2c1ecb9 100644 --- a/source/code/plugin/health/health_missing_signal_generator.rb +++ b/source/code/plugin/health/health_missing_signal_generator.rb @@ -1,3 +1,4 @@ +Dir[File.join(__dir__, '*.rb')].each { |file| require file } module HealthModel class HealthMissingSignalGenerator attr_accessor :last_received_records, :current_received_records diff --git a/source/code/plugin/health/health_model_builder.rb b/source/code/plugin/health/health_model_builder.rb index 4cf802798..13813c8d9 100644 --- a/source/code/plugin/health/health_model_builder.rb +++ b/source/code/plugin/health/health_model_builder.rb @@ -1,4 +1,3 @@ -require_relative 'health_model_constants' require 'time' module HealthModel diff --git a/source/code/plugin/health/health_monitor_helpers.rb b/source/code/plugin/health/health_monitor_helpers.rb index 9e2977a0e..267bc2a43 100644 --- a/source/code/plugin/health/health_monitor_helpers.rb +++ b/source/code/plugin/health/health_monitor_helpers.rb @@ -1,5 +1,6 @@ require 'logger' require 'digest' +Dir[File.join(__dir__, '*.rb')].each { |file| require file } module HealthModel # static class that provides a bunch of utility methods diff --git a/source/code/plugin/health/health_monitor_provider.rb b/source/code/plugin/health/health_monitor_provider.rb index 0c1cbf7f2..d77e50168 100644 --- a/source/code/plugin/health/health_monitor_provider.rb +++ b/source/code/plugin/health/health_monitor_provider.rb @@ -1,3 +1,4 @@ +Dir[File.join(__dir__, '*.rb')].each { |file| require file } module HealthModel class HealthMonitorProvider diff --git a/source/code/plugin/health/health_monitor_state.rb b/source/code/plugin/health/health_monitor_state.rb index e6205b481..ec305a194 100644 --- a/source/code/plugin/health/health_monitor_state.rb +++ b/source/code/plugin/health/health_monitor_state.rb @@ -1,3 +1,4 @@ +Dir[File.join(__dir__, '*.rb')].each { |file| require file } module HealthModel HealthMonitorInstanceState = Struct.new(:prev_sent_record_time, :old_state, :new_state, :state_change_time, :prev_records, :is_state_change_consistent, :should_send) do diff --git a/source/code/plugin/health/health_monitor_utils.rb b/source/code/plugin/health/health_monitor_utils.rb index b1c77a4a1..d02719658 100644 --- a/source/code/plugin/health/health_monitor_utils.rb +++ b/source/code/plugin/health/health_monitor_utils.rb @@ -1,5 +1,6 @@ require 'logger' require 'digest' +Dir[File.join(__dir__, '*.rb')].each { |file| require file } module HealthModel # static class that provides a bunch of utility methods diff --git a/source/code/plugin/health/health_signal_reducer.rb b/source/code/plugin/health/health_signal_reducer.rb index 4cf53e82c..0bd80f353 100644 --- a/source/code/plugin/health/health_signal_reducer.rb +++ b/source/code/plugin/health/health_signal_reducer.rb @@ -1,3 +1,5 @@ +Dir[File.join(__dir__, '*.rb')].each { |file| require file } + module HealthModel # this class # 1. dedupes daemonset signals and takes only the latest diff --git a/source/code/plugin/health/monitor_factory.rb b/source/code/plugin/health/monitor_factory.rb index e6ec9d2c3..ddd42e284 100644 --- a/source/code/plugin/health/monitor_factory.rb +++ b/source/code/plugin/health/monitor_factory.rb @@ -1,3 +1,5 @@ +Dir[File.join(__dir__, '*.rb')].each { |file| require file } + module HealthModel class MonitorFactory diff --git a/source/code/plugin/health/node_monitor_hierarchy_reducer.rb b/source/code/plugin/health/node_monitor_hierarchy_reducer.rb index aafbd07a8..1c9c02194 100644 --- a/source/code/plugin/health/node_monitor_hierarchy_reducer.rb +++ b/source/code/plugin/health/node_monitor_hierarchy_reducer.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true +Dir[File.join(__dir__, '*.rb')].each { |file| require file } module HealthModel class NodeMonitorHierarchyReducer diff --git a/source/code/plugin/health/parent_monitor_provider.rb b/source/code/plugin/health/parent_monitor_provider.rb index 6a27f11d8..969d8de96 100644 --- a/source/code/plugin/health/parent_monitor_provider.rb +++ b/source/code/plugin/health/parent_monitor_provider.rb @@ -1,3 +1,4 @@ +Dir[File.join(__dir__, '*.rb')].each { |file| require file } module HealthModel class ParentMonitorProvider diff --git a/source/code/plugin/health/unit_monitor.rb b/source/code/plugin/health/unit_monitor.rb index 9af599321..64262aa2e 100644 --- a/source/code/plugin/health/unit_monitor.rb +++ b/source/code/plugin/health/unit_monitor.rb @@ -1,4 +1,3 @@ -require_relative 'health_model_constants' require 'json' module HealthModel From 502944135129429aa811bf0c3474c9a40ed89e8d Mon Sep 17 00:00:00 2001 From: r-dilip Date: Thu, 22 Aug 2019 15:55:22 -0700 Subject: [PATCH 2/2] Adding explicit require_relative --- source/code/plugin/health/agg_monitor_id_labels.rb | 3 ++- source/code/plugin/health/aggregate_monitor.rb | 2 +- .../code/plugin/health/aggregate_monitor_state_finalizer.rb | 1 - source/code/plugin/health/health_kube_api_down_handler.rb | 2 +- source/code/plugin/health/health_kubernetes_resources.rb | 1 + source/code/plugin/health/health_missing_signal_generator.rb | 4 +++- source/code/plugin/health/health_monitor_helpers.rb | 2 +- source/code/plugin/health/health_monitor_provider.rb | 3 ++- source/code/plugin/health/health_monitor_state.rb | 3 ++- source/code/plugin/health/health_monitor_utils.rb | 2 +- source/code/plugin/health/health_signal_reducer.rb | 2 +- source/code/plugin/health/monitor_factory.rb | 3 ++- source/code/plugin/health/node_monitor_hierarchy_reducer.rb | 2 +- source/code/plugin/health/parent_monitor_provider.rb | 2 +- 14 files changed, 19 insertions(+), 13 deletions(-) diff --git a/source/code/plugin/health/agg_monitor_id_labels.rb b/source/code/plugin/health/agg_monitor_id_labels.rb index c40cf66c3..86a3381cd 100644 --- a/source/code/plugin/health/agg_monitor_id_labels.rb +++ b/source/code/plugin/health/agg_monitor_id_labels.rb @@ -1,4 +1,5 @@ -Dir[File.join(__dir__, '*.rb')].each { |file| require file } +require_relative 'health_model_constants' + module HealthModel class AggregateMonitorInstanceIdLabels @@id_labels_mapping = { diff --git a/source/code/plugin/health/aggregate_monitor.rb b/source/code/plugin/health/aggregate_monitor.rb index 5eb954ac4..794f716ce 100644 --- a/source/code/plugin/health/aggregate_monitor.rb +++ b/source/code/plugin/health/aggregate_monitor.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -Dir[File.join(__dir__, '*.rb')].each { |file| require file } +require_relative 'health_model_constants' require 'json' module HealthModel diff --git a/source/code/plugin/health/aggregate_monitor_state_finalizer.rb b/source/code/plugin/health/aggregate_monitor_state_finalizer.rb index 83d453d9e..74e780924 100644 --- a/source/code/plugin/health/aggregate_monitor_state_finalizer.rb +++ b/source/code/plugin/health/aggregate_monitor_state_finalizer.rb @@ -1,4 +1,3 @@ -Dir[File.join(__dir__, '*.rb')].each { |file| require file } module HealthModel class AggregateMonitorStateFinalizer diff --git a/source/code/plugin/health/health_kube_api_down_handler.rb b/source/code/plugin/health/health_kube_api_down_handler.rb index d8669da7c..7f72360f8 100644 --- a/source/code/plugin/health/health_kube_api_down_handler.rb +++ b/source/code/plugin/health/health_kube_api_down_handler.rb @@ -1,4 +1,4 @@ -Dir[File.join(__dir__, '*.rb')].each { |file| require file } +require_relative 'health_model_constants' module HealthModel class HealthKubeApiDownHandler def initialize diff --git a/source/code/plugin/health/health_kubernetes_resources.rb b/source/code/plugin/health/health_kubernetes_resources.rb index 53f879bf5..2f591722b 100644 --- a/source/code/plugin/health/health_kubernetes_resources.rb +++ b/source/code/plugin/health/health_kubernetes_resources.rb @@ -1,4 +1,5 @@ require 'singleton' +require_relative 'health_model_constants' module HealthModel class HealthKubernetesResources diff --git a/source/code/plugin/health/health_missing_signal_generator.rb b/source/code/plugin/health/health_missing_signal_generator.rb index fa2c1ecb9..419680afa 100644 --- a/source/code/plugin/health/health_missing_signal_generator.rb +++ b/source/code/plugin/health/health_missing_signal_generator.rb @@ -1,4 +1,6 @@ -Dir[File.join(__dir__, '*.rb')].each { |file| require file } +require_relative 'health_model_constants' +require_relative 'health_monitor_record' + module HealthModel class HealthMissingSignalGenerator attr_accessor :last_received_records, :current_received_records diff --git a/source/code/plugin/health/health_monitor_helpers.rb b/source/code/plugin/health/health_monitor_helpers.rb index 267bc2a43..9f0315978 100644 --- a/source/code/plugin/health/health_monitor_helpers.rb +++ b/source/code/plugin/health/health_monitor_helpers.rb @@ -1,6 +1,6 @@ require 'logger' require 'digest' -Dir[File.join(__dir__, '*.rb')].each { |file| require file } +require_relative 'health_model_constants' module HealthModel # static class that provides a bunch of utility methods diff --git a/source/code/plugin/health/health_monitor_provider.rb b/source/code/plugin/health/health_monitor_provider.rb index d77e50168..60ad69d76 100644 --- a/source/code/plugin/health/health_monitor_provider.rb +++ b/source/code/plugin/health/health_monitor_provider.rb @@ -1,4 +1,5 @@ -Dir[File.join(__dir__, '*.rb')].each { |file| require file } +require_relative 'health_model_constants' + module HealthModel class HealthMonitorProvider diff --git a/source/code/plugin/health/health_monitor_state.rb b/source/code/plugin/health/health_monitor_state.rb index ec305a194..498c75ec7 100644 --- a/source/code/plugin/health/health_monitor_state.rb +++ b/source/code/plugin/health/health_monitor_state.rb @@ -1,4 +1,5 @@ -Dir[File.join(__dir__, '*.rb')].each { |file| require file } +require_relative 'health_model_constants' + module HealthModel HealthMonitorInstanceState = Struct.new(:prev_sent_record_time, :old_state, :new_state, :state_change_time, :prev_records, :is_state_change_consistent, :should_send) do diff --git a/source/code/plugin/health/health_monitor_utils.rb b/source/code/plugin/health/health_monitor_utils.rb index d02719658..e707651dc 100644 --- a/source/code/plugin/health/health_monitor_utils.rb +++ b/source/code/plugin/health/health_monitor_utils.rb @@ -1,6 +1,6 @@ require 'logger' require 'digest' -Dir[File.join(__dir__, '*.rb')].each { |file| require file } +require_relative 'health_model_constants' module HealthModel # static class that provides a bunch of utility methods diff --git a/source/code/plugin/health/health_signal_reducer.rb b/source/code/plugin/health/health_signal_reducer.rb index 0bd80f353..1d520da8d 100644 --- a/source/code/plugin/health/health_signal_reducer.rb +++ b/source/code/plugin/health/health_signal_reducer.rb @@ -1,4 +1,4 @@ -Dir[File.join(__dir__, '*.rb')].each { |file| require file } +require_relative 'health_model_constants' module HealthModel # this class diff --git a/source/code/plugin/health/monitor_factory.rb b/source/code/plugin/health/monitor_factory.rb index ddd42e284..5f2c3945c 100644 --- a/source/code/plugin/health/monitor_factory.rb +++ b/source/code/plugin/health/monitor_factory.rb @@ -1,4 +1,5 @@ -Dir[File.join(__dir__, '*.rb')].each { |file| require file } +require_relative 'aggregate_monitor' +require_relative 'unit_monitor' module HealthModel class MonitorFactory diff --git a/source/code/plugin/health/node_monitor_hierarchy_reducer.rb b/source/code/plugin/health/node_monitor_hierarchy_reducer.rb index 1c9c02194..0bad4517e 100644 --- a/source/code/plugin/health/node_monitor_hierarchy_reducer.rb +++ b/source/code/plugin/health/node_monitor_hierarchy_reducer.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -Dir[File.join(__dir__, '*.rb')].each { |file| require file } +require_relative 'health_model_constants' module HealthModel class NodeMonitorHierarchyReducer diff --git a/source/code/plugin/health/parent_monitor_provider.rb b/source/code/plugin/health/parent_monitor_provider.rb index 969d8de96..4577abb99 100644 --- a/source/code/plugin/health/parent_monitor_provider.rb +++ b/source/code/plugin/health/parent_monitor_provider.rb @@ -1,4 +1,4 @@ -Dir[File.join(__dir__, '*.rb')].each { |file| require file } +require_relative 'health_model_constants' module HealthModel class ParentMonitorProvider