vagrant-orchestrate 0.7.0.pre.4 → 0.7.0.pre.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fc39c0db6444e86098e5908f49c4c23596558de9
4
- data.tar.gz: 2e4419f8b8506c7fcae39ce4f4d0ae35a1faed98
3
+ metadata.gz: 59aea228f2a1e4823a9ee37bf871a5fbc145fc66
4
+ data.tar.gz: 0d6ec5e9e2cd48d03b5eff1ba2788057b2d903a0
5
5
  SHA512:
6
- metadata.gz: f295399ff5a18ffa724f919542e6958962f435618b43e4bf1b96d770869e7ec8b07e13bcb2bc7cb733b0128aead302935542768d350fa0d835e62dd1cd476ae8
7
- data.tar.gz: 72411db2885f12b14e8dca667d785b7fc361f5127bb088da64daa8abc000c6542cbcb54a5f2763d44a899e6f93602709c28672eccebb4e335b93142a96002b63
6
+ metadata.gz: 7c7d33a483e98f4a749defff7e7e3cf20c7531eceb7ca6686061a6b67a5a51f7d44b0cc9d823b62691e02adabf23cac3f9bddd7cea6c24863b89e785a4ad360f
7
+ data.tar.gz: a9e96fe08b81ae251a82695e9e2a4251070745c616e6e1c6f7f083516287ba13f925c93ea704c5414c52fce12d4d66d35f647470b487346edf0ffc1a44c5dc77
@@ -85,6 +85,14 @@ Add the following configuration option to your Vagrantfile
85
85
 
86
86
  config.orchestrate.tracker_host = "http://deploymenttracker.mydomain.com"
87
87
 
88
+ ## Logging
89
+
90
+ Each line sent to Vagrant's UI (your console) will be sent to deployment tracker and
91
+ forwarded on to an appropriate log collector. The current implementation is naive and
92
+ creates an HTTP POST request for each line printed to the console. If this is causing
93
+ performance issues with your deployment, you can disable it with:
94
+
95
+ config.orchestrate.tracker_logging_enabled = false
88
96
 
89
97
  ## Initialization
90
98
 
@@ -1,45 +1,28 @@
1
1
  require "log4r/outputter/outputter"
2
2
  require "time"
3
- require "thread"
4
3
 
5
4
  module Log4r
6
5
  class DeploymentTrackerOutputter < Outputter
7
- FLUSH_SIZE = 25 # Number of messages to queue before a flush happens
8
- MAX_QUEUE_SIZE = 255 # Maximum number of messages to store before messages are dropped
9
-
10
6
  def initialize(name, hash = {})
11
7
  super(name, hash)
12
8
  @logger = Log4r::Logger.new("vagrant_orchestrate::log4r::deployment_tracker_outputter")
13
- @queue = []
14
- @lock = Mutex.new
15
- end
16
-
17
- def flush
18
- @lock.synchronize do
19
- DeploymentTrackerClient::DefaultApi.post_logs(VagrantPlugins::Orchestrate::DEPLOYMENT_ID, @queue)
20
- @queue.clear
21
- end
22
- rescue
23
- @logger.warn "Unable to send log messages to deployment-tracker"
24
9
  end
25
10
 
26
11
  private
27
12
 
28
13
  def canonical_log(event)
29
- if @queue.size >= MAX_QUEUE_SIZE
30
- @logger.warn("Deployment Tracker Log Outputter queue size at maximum of #{MAX_QUEUE_SIZE}, dropping message")
31
- return
32
- end
33
-
34
14
  data = {}
35
15
  data["type"] = event.fullname
36
16
  data["timestamp"] = Time.now.getutc.iso8601
37
17
  data["level"] = LNAMES[event.level]
38
18
  data["message"] = event.data
39
19
 
40
- @queue << data
41
-
42
- flush if @queue.size >= FLUSH_SIZE
20
+ begin
21
+ id = VagrantPlugins::Orchestrate::DEPLOYMENT_ID
22
+ DeploymentTrackerClient::DefaultApi.post_logs(id, [data])
23
+ rescue
24
+ @logger.warn "Unable to send log messages to deployment-tracker"
25
+ end
43
26
  end
44
27
  end
45
28
  end
@@ -24,11 +24,14 @@ module VagrantPlugins
24
24
  SwaggerClient::Swagger.configure do |config|
25
25
  config.host = host
26
26
  end
27
- ui = env[:ui]
28
- unless ui.logger.outputters.collect(&:name).include?("deployment-tracker")
29
- # Make sure that we've hooked the global ui logger as well. We should
30
- # see if we can do this earlier in the process to capture more of the output
31
- ui.logger.add Log4r::DeploymentTrackerOutputter.new("deployment-tracker")
27
+
28
+ if env[:tracker_logging_enabled]
29
+ ui = env[:ui]
30
+ unless ui.logger.outputters.collect(&:name).include?("deployment-tracker")
31
+ # Make sure that we've hooked the global ui logger as well. We should
32
+ # see if we can do this earlier in the process to capture more of the output
33
+ ui.logger.add Log4r::DeploymentTrackerOutputter.new("deployment-tracker")
34
+ end
32
35
  end
33
36
  @app.call(env)
34
37
  end
@@ -14,8 +14,6 @@ module VagrantPlugins
14
14
  @app.call(env)
15
15
  end
16
16
 
17
- private
18
-
19
17
  def track_deployment_end(host, start, success, ui)
20
18
  return unless host
21
19
  @logger.debug("Tracking deployment end to #{host}.")
@@ -27,23 +25,11 @@ module VagrantPlugins
27
25
  assert_empty_server_result: true,
28
26
  elapsed_seconds: elapsed_seconds }
29
27
  DeploymentTrackerClient::DefaultApi.put_deployment(id, deployment)
30
-
31
- flush_logger ui
32
28
  rescue => ex
33
- ui.warn("There was an error notifying deployment tracker. Run with --debug for more details.")
29
+ ui.warn("There was an error notifying deployment tracker. See error log for details.")
34
30
  @logger.warn("Error tracking deployment end for deployment #{id}")
35
31
  @logger.warn(ex)
36
32
  end
37
-
38
- # Since log messages are being buffered, there could be some that
39
- # are buffered up to send, but have yet to be delivered. We'll clear
40
- # those out now. If there is a problem getting the logs to deployment
41
- # tracker, we'll just see the 1 warning message
42
- def flush_logger(ui)
43
- ui.logger.outputters.each do |outputter|
44
- outputter.flush if outputter.respond_to?("flush")
45
- end
46
- end
47
33
  end
48
34
  end
49
35
  end
@@ -33,7 +33,7 @@ module VagrantPlugins
33
33
  }
34
34
  DeploymentTrackerClient::DefaultApi.post_deployment(id, deployment)
35
35
  rescue => ex
36
- ui.warn("There was an error notifying deployment tracker. Run with --debug for more details.")
36
+ ui.warn("There was an error notifying deployment tracker. See error log for details.")
37
37
  @logger.warn("Error tracking deployment start for deployment #{id}")
38
38
  @logger.warn(ex)
39
39
  end
@@ -28,7 +28,7 @@ module VagrantPlugins
28
28
  }
29
29
  DeploymentTrackerClient::DefaultApi.put_server(id, server)
30
30
  rescue => ex
31
- ui.warn("There was an error notifying deployment tracker of server end. Run with --debug for more details.")
31
+ ui.warn("There was an error notifying deployment tracker of server end. See error log for details.")
32
32
  ui.warn(ex.message)
33
33
  pp ex
34
34
  @logger.warn("Error tracking deployment server end for deployment #{id}")
@@ -28,7 +28,7 @@ module VagrantPlugins
28
28
  }
29
29
  DeploymentTrackerClient::DefaultApi.post_server(id, server)
30
30
  rescue => ex
31
- ui.warn("There was an error notifying deployment tracker of server start. Run with --debug for more details.")
31
+ ui.warn("There was an error notifying deployment tracker of server start. See error log for details.")
32
32
  ui.warn(ex.message)
33
33
  @logger.warn("Error tracking deployment server start for deployment #{id}")
34
34
  @logger.warn(ex)
@@ -73,6 +73,7 @@ module VagrantPlugins
73
73
 
74
74
  @env.action_runner.run(VagrantPlugins::ManagedServers::Action::InitDeploymentTracker,
75
75
  tracker_host: @env.vagrantfile.config.orchestrate.tracker_host,
76
+ tracker_logging_enabled: @env.vagrantfile.config.orchestrate.tracker_logging_enabled,
76
77
  ui: @env.ui)
77
78
  @env.action_runner.run(VagrantPlugins::ManagedServers::Action::TrackDeploymentStart,
78
79
  tracker_host: @env.vagrantfile.config.orchestrate.tracker_host,
@@ -8,6 +8,7 @@ module VagrantPlugins
8
8
  attr_accessor :strategy
9
9
  attr_accessor :force_push
10
10
  attr_accessor :tracker_host
11
+ attr_accessor :tracker_logging_enabled
11
12
  attr_accessor :credentials
12
13
 
13
14
  def initialize
@@ -15,6 +16,7 @@ module VagrantPlugins
15
16
  @strategy = UNSET_VALUE
16
17
  @force_push = UNSET_VALUE
17
18
  @tracker_host = UNSET_VALUE
19
+ @tracker_logging_enabled = UNSET_VALUE
18
20
  @credentials = Credentials.new
19
21
  end
20
22
 
@@ -38,16 +40,17 @@ module VagrantPlugins
38
40
  end
39
41
  end
40
42
 
41
- # rubocop:disable Metrics/CyclomaticComplexity
43
+ # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
42
44
  def finalize!
43
45
  @filter_managed_commands = false if @filter_managed_commands == UNSET_VALUE
44
46
  @strategy = :serial if @strategy == UNSET_VALUE
45
47
  @force_push = false if @force_push == UNSET_VALUE
46
48
  @tracker_host = nil if @tracker_host == UNSET_VALUE
49
+ @tracker_logging_enabled = true if @tracker_logging_enabled == UNSET_VALUE
47
50
  @credentials = nil if @credentials.unset?
48
51
  @credentials.finalize! if @credentials
49
52
  end
50
- # rubocop:enable Metrics/CyclomaticComplexity
53
+ # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
51
54
 
52
55
  class Credentials
53
56
  # Same as Vagrant does to distinguish uninitialized variables and intentional assignments
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module Orchestrate
3
- VERSION = "0.7.0.pre.4"
3
+ VERSION = "0.7.0.pre.5"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-orchestrate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0.pre.4
4
+ version: 0.7.0.pre.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher Baldauf