clc-promote 0.7.9 → 0.7.10

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: 56b10c9acfc5f5b2f181a84eb1b7415369965e8f
4
- data.tar.gz: bc443577ed51404ceb92d84f781a818a2451c49b
3
+ metadata.gz: f5633c6eb35655f0e48f3ca0c541518a2f77ca04
4
+ data.tar.gz: 5175538852c4345a2b3d79c7fe91be9b89b57ab3
5
5
  SHA512:
6
- metadata.gz: fe5616c464c398a0723b6dfa1381045168867e815def32f470579a34bbc9f90f49da186819c3664e1017c653c6c196741de62d50b4da7423908540c6ca287dbc
7
- data.tar.gz: 6410adce8ec11b13160d041d2af80c77c925c08aaa934bd956d63342c09b463fac416ef25abeb048d2202fe563420a8dbee0f339f7048f286dafa52d64b31dc5
6
+ metadata.gz: 0270705d80833cda8010dbac523b1265a3e853a3fc8e4b59207362f9834a2471f74496df0d948ebbb8dd6497c3c9f39bde5b0786b9243674c1a0fe1d75707a40
7
+ data.tar.gz: 6e2a1384d06f75ef43b050ffa5540487e664bc4f68126b09345ace9017175cc4de06276a0416d35c51c9d58dc693daeef36c2900bd0298b67dacf672aa557a69
@@ -20,9 +20,34 @@ module Promote
20
20
  dest.write_cookbook_versions(source.cookbook_versions)
21
21
  end
22
22
 
23
- def monitor_promotion(source_environment, destination_environments, probe_interval, ui = nil)
23
+ def monitor_promotion(source_environment, destination_environments, probe_interval, max_wait = 3600, ui = nil)
24
24
  destination_environments.each do |env|
25
- promote_to(source_environment, env, ui)
25
+ promote_to(source_environment, env, ui)
26
+ start = Time.now.to_i
27
+ finder = NodeFinder.new("chef_environment:#{env}", config)
28
+ unconverged = nil
29
+ converged = []
30
+ until Time.now.to_i - start > max_wait
31
+ result = finder.search
32
+ unconverged = []
33
+ result.each do |node|
34
+ if node['ohai_time'].to_i < start
35
+ unconverged << node
36
+ elsif converged.grep(/#{node.name}/).empty?
37
+ converged << node.name
38
+ ui.info "#{node.name} has converged" if ui
39
+ end
40
+ end
41
+ break if unconverged.count == 0
42
+
43
+ ui.stdout.print "." if ui
44
+
45
+ sleep probe_interval
46
+ end
47
+
48
+ if unconverged.count > 0
49
+ raise "Stopping promotion! Nodes (#{unconverged}) are not converging in #{env}"
50
+ end
26
51
  end
27
52
  end
28
53
 
@@ -99,9 +99,9 @@ module Promote
99
99
  def define_promote_environment
100
100
  namespace "Promote" do
101
101
  desc "Promote one environment from another"
102
- task "promote_environment", :source_environment, :destination_environments do |task, args|
103
- puts "Promoting constraints in #{args.source_environment} to #{args.destination_environments}"
104
- @promoter.monitor_promotion(args.source_environment, args.destination_environments, 60 * 5)
102
+ task "promote_environment", :source_environment, :destination_environment do |task, args|
103
+ puts "Promoting constraints in #{args.source_environment} to #{args.destination_environment}"
104
+ deps = @promoter.promote_to(args.source_environment, args.destination_environment)
105
105
  end
106
106
  end
107
107
  end
@@ -110,8 +110,8 @@ module Promote
110
110
  namespace "Promote" do
111
111
  desc "Promote a list of environments from another"
112
112
  task "promote_environments", :source_environment, :destination_environments do |task, args|
113
- puts "Promoting constraints in #{args.source_environment} to #{args.destination_environment}"
114
- deps = @promoter.promote_to(args.source_environment, args.destination_environment)
113
+ puts "Promoting constraints in #{args.source_environment} to #{args.destination_environments}"
114
+ @promoter.monitor_promotion(args.source_environment, args.destination_environments, 60 * 5)
115
115
  end
116
116
  end
117
117
  end
@@ -1,3 +1,3 @@
1
1
  module Promote
2
- VERSION = '0.7.9'
2
+ VERSION = '0.7.10'
3
3
  end
@@ -7,6 +7,8 @@ describe Promote::Promoter do
7
7
  :client_key => 'key',
8
8
  :chef_server_url => 'https://some.chef.server'}) }
9
9
 
10
+ let(:ui) { Chef::Knife::UI.new(STDOUT, STDERR, STDIN, {}) }
11
+
10
12
  subject { Promote::Promoter.new(config) }
11
13
 
12
14
  context "promote_to" do
@@ -63,14 +65,17 @@ describe Promote::Promoter do
63
65
  let(:finder_bad){ double('node_finder', :search => [bad_node]) }
64
66
  let (:good_node) {
65
67
  node = Chef::Node.new
68
+ node.name "good_node"
66
69
  node.default["ohai_time"] = Time.now.to_i + 3600
67
70
  node
68
71
  }
69
72
  let (:bad_node) {
70
73
  node = Chef::Node.new
74
+ node.name "bad_node"
71
75
  node.default["ohai_time"] = Time.now.to_i - 3600
72
76
  node
73
77
  }
78
+ let(:ui) { nil }
74
79
 
75
80
  before {
76
81
  allow(Promote::NodeFinder).to receive(:new).and_return(finder_good)
@@ -78,10 +83,10 @@ describe Promote::Promoter do
78
83
 
79
84
  context "all environments succeed" do
80
85
  it "promotes all nodes" do
81
- expect(subject).to receive(:promote_to).with("env1", "env2", nil)
82
- expect(subject).to receive(:promote_to).with("env1", "env3", nil)
83
- expect(subject).to receive(:promote_to).with("env1", "env4", nil)
84
- subject.monitor_promotion("env1", ["env2", "env3", "env4"], 1)
86
+ expect(subject).to receive(:promote_to).with("env1", "env2", ui)
87
+ expect(subject).to receive(:promote_to).with("env1", "env3", ui)
88
+ expect(subject).to receive(:promote_to).with("env1", "env4", ui)
89
+ subject.monitor_promotion("env1", ["env2", "env3", "env4"], 0.25, 1, ui)
85
90
  end
86
91
  end
87
92
 
@@ -91,11 +96,10 @@ describe Promote::Promoter do
91
96
  }
92
97
 
93
98
  it "stops on failure" do
94
-
95
- expect(subject).to receive(:promote_to).with("env1", "env2", nil)
96
- expect(subject).not_to receive(:promote_to).with("env1", "env3", nil)
97
- expect(subject).not_to receive(:promote_to).with("env1", "env4", nil)
98
- subject.monitor_promotion("env1", ["env2", "env3", "env4"], 1)
99
+ expect(subject).to receive(:promote_to).with("env1", "env2", ui)
100
+ expect(subject).to receive(:promote_to).with("env1", "env3", ui)
101
+ expect(subject).not_to receive(:promote_to).with("env1", "env4", ui)
102
+ expect{ subject.monitor_promotion("env1", ["env2", "env3", "env4"], 0.25, 1, ui) }.to raise_error(/env3$/)
99
103
  end
100
104
  end
101
105
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clc-promote
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.9
4
+ version: 0.7.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - CenturyLink Cloud
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-18 00:00:00.000000000 Z
11
+ date: 2015-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clc-git