shards 3.1 → 3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/settings/workflows/delete_by_api.yaml +1 -7
- data/lib/settings/workflows/reload_by_api.yaml +8 -1
- data/lib/shards/stage.rb +11 -2
- data/lib/shards/version.rb +1 -1
- data/lib/shards/workflow/base.rb +8 -1
- data/lib/shards/workflow/delete_by_api.rb +0 -28
- data/lib/shards/workflow/reload_by_api.rb +28 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6f3e5c3b27a1260b50f1a00cf86ae62e8b7c1593fc2feb1e68bd7cd7194d438
|
4
|
+
data.tar.gz: 6ba8aaf2b3d0025d8750d552ea50d9061f2bae402f951770813f0dbaef8285ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8064c86c8daab178f602e47052b2d56977c744214b169524e3b8cf5d16c704456dd1e1657030b6dc040ff72b1f646877155d8ceabfedf7182c7fcef64e0abd66
|
7
|
+
data.tar.gz: d4a076e06a2af9e83d8efc2bc01c2234d46062fca82e41c97420cdbd4c354d67aa305109498e09b2bdb77415162038f8270aaf570258e8b8dbae34b2cde1a31f
|
data/Gemfile.lock
CHANGED
@@ -27,16 +27,11 @@ delete_by_api:
|
|
27
27
|
commit_changes:
|
28
28
|
message: The changes has been committed and pushed to the remote repository.
|
29
29
|
wrong_message: We had an issue to commit and push the changes.
|
30
|
-
correct:
|
30
|
+
correct: finish_successfully
|
31
31
|
wrong: finish
|
32
32
|
|
33
33
|
#TODO restart sidekiq before the database deletion.
|
34
34
|
|
35
|
-
delete_database:
|
36
|
-
wrong_message: The database %s could not be deleted.
|
37
|
-
message: Database %s has been deleted.
|
38
|
-
correct: finish_successfully
|
39
|
-
wrong: finish
|
40
35
|
|
41
36
|
start: validate_location
|
42
37
|
|
@@ -48,6 +43,5 @@ correct_steps_summary:
|
|
48
43
|
- delete_site_and_shard
|
49
44
|
- write_yaml_files
|
50
45
|
- commit_changes
|
51
|
-
- delete_database
|
52
46
|
|
53
47
|
start: validate_location
|
@@ -19,7 +19,7 @@ reload_by_api:
|
|
19
19
|
application_reload_shards_task:
|
20
20
|
message: Reload task have been executed successfully.
|
21
21
|
wrong_message: Errors found in the reload task %s.
|
22
|
-
correct:
|
22
|
+
correct: delete_database
|
23
23
|
wrong: finish
|
24
24
|
|
25
25
|
puppet_agent_update:
|
@@ -34,6 +34,12 @@ reload_by_api:
|
|
34
34
|
correct: application_reload_shards_task
|
35
35
|
wrong: finish
|
36
36
|
|
37
|
+
delete_database:
|
38
|
+
wrong_message: The database %s could not be deleted.
|
39
|
+
message: Database %s has been deleted.
|
40
|
+
correct: finish_successfully
|
41
|
+
wrong: finish
|
42
|
+
|
37
43
|
correct_steps_summary:
|
38
44
|
- validate_client
|
39
45
|
- validate_domain
|
@@ -43,5 +49,6 @@ correct_steps_summary:
|
|
43
49
|
- puppet_agent_update
|
44
50
|
- check_fingerprints2
|
45
51
|
- application_reload_shards_task
|
52
|
+
- delete_database
|
46
53
|
|
47
54
|
start: validate_client
|
data/lib/shards/stage.rb
CHANGED
@@ -14,6 +14,7 @@ module Shards
|
|
14
14
|
end
|
15
15
|
|
16
16
|
attr_accessor :name, :location_name, :shard, :chosen_blank_db
|
17
|
+
attr_writer :host_list
|
17
18
|
|
18
19
|
def initialize name, data, location_name
|
19
20
|
|
@@ -78,7 +79,7 @@ module Shards
|
|
78
79
|
end
|
79
80
|
|
80
81
|
def web_server_hosts
|
81
|
-
name=='prod' ?
|
82
|
+
name=='prod' ? get_production_hosts : [ internal_host ]
|
82
83
|
end
|
83
84
|
|
84
85
|
def hosts_to_check
|
@@ -93,6 +94,10 @@ module Shards
|
|
93
94
|
[]
|
94
95
|
end
|
95
96
|
|
97
|
+
def get_production_hosts
|
98
|
+
@host_list || @ips || get_production_ips
|
99
|
+
end
|
100
|
+
|
96
101
|
def get_production_ips
|
97
102
|
ip_search=Shards::IpSearch.new self
|
98
103
|
@ips||=ip_search.ips
|
@@ -106,8 +111,12 @@ module Shards
|
|
106
111
|
get('route53').split('.').first
|
107
112
|
end
|
108
113
|
|
114
|
+
def host_list
|
115
|
+
@host_list || hosts_to_check
|
116
|
+
end
|
117
|
+
|
109
118
|
def check_remote_process remote_check: :internal_host
|
110
|
-
|
119
|
+
host_list.map do |h|
|
111
120
|
@internal_host=h
|
112
121
|
[ h , send(remote_check) ]
|
113
122
|
end.to_h
|
data/lib/shards/version.rb
CHANGED
data/lib/shards/workflow/base.rb
CHANGED
@@ -278,7 +278,9 @@ module Shards
|
|
278
278
|
|
279
279
|
def check_fingerprints
|
280
280
|
resp=stage.check_remote_process remote_check: :fingerprints
|
281
|
-
|
281
|
+
|
282
|
+
errors=filter_errors multitenant(resp)
|
283
|
+
stage.host_list = multitenant(resp).keys
|
282
284
|
raise_wrong_text errors if errors.count>0
|
283
285
|
output_message step['message']
|
284
286
|
end
|
@@ -326,6 +328,11 @@ module Shards
|
|
326
328
|
def filter_status_errors resp
|
327
329
|
resp.select { |k,x| x[:status]==1 }
|
328
330
|
end
|
331
|
+
|
332
|
+
def multitenant resp
|
333
|
+
resp.select { |k,x| x.values.count { |v| v[:remote]=='md5sum:' } < 1 }
|
334
|
+
end
|
335
|
+
|
329
336
|
end
|
330
337
|
|
331
338
|
end
|
@@ -53,34 +53,6 @@ module Shards
|
|
53
53
|
output_message config.repo.message
|
54
54
|
end
|
55
55
|
|
56
|
-
def delete_database
|
57
|
-
|
58
|
-
if database_to_drop
|
59
|
-
|
60
|
-
@db=Shards::Db.new stage: stage
|
61
|
-
|
62
|
-
db.database_to_drop=database_to_drop
|
63
|
-
|
64
|
-
raise "Database %s does is not in present db servers" % database_to_drop unless db.exist?(database_to_drop)
|
65
|
-
|
66
|
-
db.servers_to_drop.each do |host|
|
67
|
-
|
68
|
-
output_message "Database:\t #{database_to_drop}"
|
69
|
-
output_message "Host: \t #{host}"
|
70
|
-
output_message "DELETING database #{database_to_drop} in #{host}"
|
71
|
-
db.server=host
|
72
|
-
db.drop
|
73
|
-
|
74
|
-
end
|
75
|
-
|
76
|
-
raise_wrong_text database_to_drop if db.exist? database_to_drop
|
77
|
-
output_message step['message'] % database_to_drop
|
78
|
-
|
79
|
-
else
|
80
|
-
output_message "The shard is in use by other site, will not be deleted"
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
56
|
private
|
85
57
|
|
86
58
|
def target_message_error
|
@@ -1,6 +1,34 @@
|
|
1
1
|
module Shards
|
2
2
|
module Workflow
|
3
3
|
class ReloadByApi < Shards::Workflow::FingerprintsByApi
|
4
|
+
def delete_database
|
5
|
+
|
6
|
+
if database_to_drop
|
7
|
+
|
8
|
+
@db=Shards::Db.new stage: stage
|
9
|
+
|
10
|
+
db.database_to_drop=database_to_drop
|
11
|
+
|
12
|
+
raise "Database %s does is not in present db servers" % database_to_drop unless db.exist?(database_to_drop)
|
13
|
+
|
14
|
+
db.servers_to_drop.each do |host|
|
15
|
+
|
16
|
+
output_message "Database:\t #{database_to_drop}"
|
17
|
+
output_message "Host: \t #{host}"
|
18
|
+
output_message "DELETING database #{database_to_drop} in #{host}"
|
19
|
+
db.server=host
|
20
|
+
db.drop
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
raise_wrong_text database_to_drop if db.exist? database_to_drop
|
25
|
+
output_message step['message'] % database_to_drop
|
26
|
+
|
27
|
+
else
|
28
|
+
output_message "The shard is in use by other site, will not be deleted"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
4
32
|
end
|
5
33
|
end
|
6
34
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shards
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '3.
|
4
|
+
version: '3.2'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Diego PL
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-03-
|
11
|
+
date: 2019-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|