diff --git a/logstash-core/lib/logstash/agent.rb b/logstash-core/lib/logstash/agent.rb index 5a20c90ce..09f2d21cb 100644 --- a/logstash-core/lib/logstash/agent.rb +++ b/logstash-core/lib/logstash/agent.rb @@ -165,12 +165,15 @@ class LogStash::Agent @collect_metric end - def create_pipeline(settings) - begin - config = fetch_config(settings) - rescue => e - @logger.error("failed to fetch pipeline configuration", :message => e.message) - return + def create_pipeline(settings, config=nil) + + if config.nil? + begin + config = fetch_config(settings) + rescue => e + @logger.error("failed to fetch pipeline configuration", :message => e.message) + return + end end begin @@ -189,13 +192,14 @@ class LogStash::Agent # wrapped in @upgrade_mutex in the parent call `reload_state!` def reload_pipeline!(id) old_pipeline = @pipelines[id] - if old_pipeline.config_str == fetch_config(old_pipeline.original_settings) + new_config = fetch_config(old_pipeline.original_settings) + if old_pipeline.config_str == new_config @logger.debug("no configuration change for pipeline", - :pipeline => id, :config => old_pipeline.config_str) + :pipeline => id, :config => new_config) return end - new_pipeline = create_pipeline(old_pipeline.original_settings) + new_pipeline = create_pipeline(old_pipeline.original_settings, new_config) return if new_pipeline.nil? if new_pipeline.non_reloadable_plugins.any? diff --git a/logstash-core/spec/logstash/agent_spec.rb b/logstash-core/spec/logstash/agent_spec.rb index f921c2724..60d28987f 100644 --- a/logstash-core/spec/logstash/agent_spec.rb +++ b/logstash-core/spec/logstash/agent_spec.rb @@ -179,7 +179,7 @@ describe LogStash::Agent do context "when fetching a new state" do it "upgrades the state" do - expect(subject).to receive(:fetch_config).twice.and_return(second_pipeline_config) + expect(subject).to receive(:fetch_config).and_return(second_pipeline_config) expect(subject).to receive(:upgrade_pipeline).with(pipeline_id, kind_of(LogStash::Pipeline)) subject.send(:reload_state!) end