cloud-mu 3.3.2 → 3.4.0
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 +4 -4
- data/cloud-mu.gemspec +3 -3
- data/cookbooks/mu-tools/attributes/default.rb +7 -0
- data/cookbooks/mu-tools/libraries/helper.rb +86 -2
- data/cookbooks/mu-tools/recipes/apply_security.rb +25 -9
- data/cookbooks/mu-tools/recipes/aws_api.rb +4 -0
- data/cookbooks/mu-tools/recipes/google_api.rb +4 -0
- data/cookbooks/mu-tools/recipes/rsyslog.rb +8 -1
- data/cookbooks/mu-tools/resources/disk.rb +33 -12
- data/cookbooks/mu-tools/resources/mommacat_request.rb +1 -2
- data/cookbooks/mu-tools/templates/centos-8/sshd_config.erb +215 -0
- data/extras/clean-stock-amis +10 -2
- data/extras/generate-stock-images +6 -3
- data/extras/image-generators/AWS/centos7.yaml +19 -16
- data/extras/image-generators/AWS/{rhel7.yaml → rhel71.yaml} +0 -0
- data/extras/image-generators/AWS/{win2k12.yaml → win2k12r2.yaml} +0 -0
- data/modules/mommacat.ru +2 -2
- data/modules/mu/cloud/wrappers.rb +16 -7
- data/modules/mu/config/ref.rb +1 -1
- data/modules/mu/defaults/AWS.yaml +96 -96
- data/modules/mu/mommacat.rb +10 -2
- data/modules/mu/mommacat/search.rb +11 -2
- data/modules/mu/mommacat/storage.rb +30 -15
- data/modules/mu/providers/aws.rb +43 -23
- data/modules/mu/providers/aws/database.rb +9 -6
- data/modules/mu/providers/aws/function.rb +8 -5
- data/modules/mu/providers/aws/job.rb +29 -26
- data/modules/mu/providers/aws/role.rb +38 -32
- data/modules/mu/providers/aws/server.rb +58 -51
- data/modules/mu/providers/aws/vpc.rb +3 -0
- data/modules/mu/providers/google.rb +1 -1
- data/modules/mu/providers/google/role.rb +1 -0
- metadata +10 -9
data/extras/clean-stock-amis
CHANGED
@@ -23,7 +23,7 @@ $opts = Optimist::options do
|
|
23
23
|
#{$0} [-c credentials] [-i imagename]
|
24
24
|
EOS
|
25
25
|
opt :credentials, "Use these AWS credentials from mu.yaml instead of the default set", :required => false, :type => :string
|
26
|
-
opt :image, "Purge a specific image, instead of just
|
26
|
+
opt :image, "Purge a specific image, instead of just scrubbing old ones", :required => false, :type => :string
|
27
27
|
end
|
28
28
|
|
29
29
|
filters = [
|
@@ -33,12 +33,14 @@ filters = [
|
|
33
33
|
}
|
34
34
|
]
|
35
35
|
|
36
|
+
in_use = MU::Cloud.getStockImage("AWS").values.flatten.map { |h| h.values }.flatten
|
36
37
|
|
37
38
|
MU::Cloud::AWS.listRegions.each { | r|
|
38
39
|
images = MU::Cloud::AWS.ec2(region: r, credentials: $opts[:credentials]).describe_images(
|
39
40
|
filters: filters + [{ "name" => "state", "values" => ["available"]}]
|
40
41
|
).images
|
41
42
|
images.each { |ami|
|
43
|
+
next if in_use.include?(ami)
|
42
44
|
if ($opts[:image] and ami.name == $opts[:image]) or
|
43
45
|
((DateTime.now.to_time - DateTime.parse(ami.creation_date).to_time) > 15552000 and ami.name.match(/^MU-(PROD|DEV)/))
|
44
46
|
snaps = []
|
@@ -53,7 +55,13 @@ MU::Cloud::AWS.listRegions.each { | r|
|
|
53
55
|
rescue Aws::EC2::Errors::InvalidAMIIDUnavailable
|
54
56
|
end
|
55
57
|
snaps.each { |snap_id|
|
56
|
-
|
58
|
+
begin
|
59
|
+
MU::Cloud::AWS.ec2(region: r, credentials: $opts[:credentials]).delete_snapshot(snapshot_id: snap_id)
|
60
|
+
rescue Aws::EC2::Errors::InvalidSnapshotInUse
|
61
|
+
sleep 5
|
62
|
+
retry
|
63
|
+
rescue Aws::EC2::Errors::InvalidSnapshotNotFound
|
64
|
+
end
|
57
65
|
}
|
58
66
|
end
|
59
67
|
}
|
@@ -63,6 +63,7 @@ end
|
|
63
63
|
now = DateTime.now
|
64
64
|
|
65
65
|
exitcode = 0
|
66
|
+
succeeded = 0
|
66
67
|
$opts[:clouds].each { |cloud|
|
67
68
|
current_images = MU::Cloud.getStockImage(cloud, fail_hard: true)
|
68
69
|
$opts[:platforms].each { |platform|
|
@@ -114,6 +115,7 @@ $opts[:clouds].each { |cloud|
|
|
114
115
|
# Scrub any loose metadata left over from our image deployment. It's
|
115
116
|
# ok, this won't touch the images we just made.
|
116
117
|
MU::Cleanup.run(deployer.mommacat.deploy_id, skipsnapshots: true, verbosity: MU::Logger::QUIET)
|
118
|
+
succeeded += 1
|
117
119
|
rescue Exception => e
|
118
120
|
MU.log e.message, MU::ERR
|
119
121
|
exitcode = 1
|
@@ -122,10 +124,11 @@ $opts[:clouds].each { |cloud|
|
|
122
124
|
end
|
123
125
|
}
|
124
126
|
|
125
|
-
if
|
127
|
+
if !$opts[:dryrun] and succeeded > 0
|
126
128
|
puts current_images.to_yaml
|
127
|
-
|
128
|
-
|
129
|
+
if available_clouds.keys.include?("AWS")
|
130
|
+
MU::Cloud::AWS::Bucket.upload($opts[:upload_to]+"/"+cloud+".yaml", data: current_images.to_yaml, credentials: $opts[:aws_creds], acl: "public-read")
|
131
|
+
end
|
129
132
|
end
|
130
133
|
}
|
131
134
|
|
@@ -1,17 +1,20 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
2
|
+
appname: mu
|
3
|
+
servers:
|
4
|
+
- name: centos7
|
5
|
+
platform: centos7
|
6
|
+
size: m4.large
|
7
|
+
vpc:
|
8
|
+
name: c7vpc
|
9
|
+
scrub_groomer: true
|
10
|
+
run_list:
|
11
|
+
- recipe[mu-tools::apply_security]
|
12
|
+
- recipe[mu-tools::updates]
|
13
|
+
- recipe[mu-tools::split_var_partitions]
|
14
|
+
create_image:
|
15
|
+
image_then_destroy: true
|
16
|
+
public: true
|
17
|
+
copy_to_regions:
|
18
|
+
- "#ALL"
|
19
|
+
vpcs:
|
20
|
+
- name: c7vpc
|
File without changes
|
File without changes
|
data/modules/mommacat.ru
CHANGED
@@ -387,7 +387,7 @@ app = proc do |env|
|
|
387
387
|
|
388
388
|
# XXX We can't assume AWS anymore. What does this look like otherwise?
|
389
389
|
# If this is an already-groomed instance, try to get a real object for it
|
390
|
-
instance = MU::MommaCat.findStray("AWS", "server", cloud_id: req["mu_instance_id"], region: server_cfg["region"], deploy_id: req["mu_id"], name: req["mu_resource_name"], dummy_ok:
|
390
|
+
instance = MU::MommaCat.findStray("AWS", "server", cloud_id: req["mu_instance_id"], region: server_cfg["region"], deploy_id: req["mu_id"], name: req["mu_resource_name"], dummy_ok: true, calling_deploy: kittenpile).first
|
391
391
|
mu_name = nil
|
392
392
|
if instance.nil?
|
393
393
|
# Now we're just checking for existence in the cloud provider, really
|
@@ -416,7 +416,7 @@ app = proc do |env|
|
|
416
416
|
if instance.respond_to?(:addVolume)
|
417
417
|
# XXX make sure we handle mangled input safely
|
418
418
|
params = JSON.parse(Base64.decode64(req["add_volume"]))
|
419
|
-
MU.log "
|
419
|
+
MU.log "add_volume request", MU::NOTICE, details: params
|
420
420
|
instance.addVolume(params["dev"], params["size"], delete_on_termination: params["delete_on_termination"])
|
421
421
|
else
|
422
422
|
returnval = throw500 "I don't know how to add a volume for #{instance}"
|
@@ -103,14 +103,23 @@ module MU
|
|
103
103
|
next
|
104
104
|
end
|
105
105
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
else
|
111
|
-
raise MuError, "#{cloudclass}.find returned a non-Hash result"
|
112
|
-
end
|
106
|
+
credsets = if args[:credentials]
|
107
|
+
[args[:credentials]]
|
108
|
+
else
|
109
|
+
cloudbase.listCredentials
|
113
110
|
end
|
111
|
+
|
112
|
+
credsets.each { |creds|
|
113
|
+
args[:credentials] = creds
|
114
|
+
found = cloudclass.find(args)
|
115
|
+
if !found.nil?
|
116
|
+
if found.is_a?(Hash)
|
117
|
+
allfound.merge!(found)
|
118
|
+
else
|
119
|
+
raise MuError, "#{cloudclass}.find returned a non-Hash result"
|
120
|
+
end
|
121
|
+
end
|
122
|
+
}
|
114
123
|
rescue MuCloudResourceNotImplemented
|
115
124
|
end
|
116
125
|
}
|
data/modules/mu/config/ref.rb
CHANGED
@@ -310,7 +310,7 @@ module MU
|
|
310
310
|
return @obj
|
311
311
|
end
|
312
312
|
|
313
|
-
if mommacat and
|
313
|
+
if mommacat and caller.grep(/`findLitterMate'/).empty? # XXX the dumbest
|
314
314
|
MU.log "Looking for #{@type} #{@name} #{@id} in deploy #{mommacat.deploy_id}", loglevel
|
315
315
|
begin
|
316
316
|
@obj = mommacat.findLitterMate(type: @type, name: @name, cloud_id: @id, credentials: @credentials, debug: debug)
|
@@ -1,55 +1,55 @@
|
|
1
1
|
---
|
2
2
|
rhel71: &5
|
3
|
-
us-east-1: ami-
|
4
|
-
ap-northeast-1: ami-
|
5
|
-
ap-northeast-2: ami-
|
6
|
-
ap-south-1: ami-
|
7
|
-
ap-southeast-1: ami-
|
8
|
-
ap-southeast-2: ami-
|
9
|
-
ca-central-1: ami-
|
10
|
-
eu-central-1: ami-
|
11
|
-
eu-north-1: ami-
|
12
|
-
eu-west-1: ami-
|
13
|
-
eu-west-2: ami-
|
14
|
-
eu-west-3: ami-
|
15
|
-
sa-east-1: ami-
|
16
|
-
us-east-2: ami-
|
17
|
-
us-west-1: ami-
|
18
|
-
us-west-2: ami-
|
3
|
+
us-east-1: ami-0c834836b3bd45e2f
|
4
|
+
ap-northeast-1: ami-036bb589253fe929e
|
5
|
+
ap-northeast-2: ami-0e39b4957dbc7e14d
|
6
|
+
ap-south-1: ami-0cd0554d9a05dddc9
|
7
|
+
ap-southeast-1: ami-0bae2684e9ed09b8b
|
8
|
+
ap-southeast-2: ami-0711ccf93abe3989b
|
9
|
+
ca-central-1: ami-0d75d90f73e417c25
|
10
|
+
eu-central-1: ami-0cae3cb53b9bbd783
|
11
|
+
eu-north-1: ami-0cd30fe8547a809f7
|
12
|
+
eu-west-1: ami-01441cca97c35eb0e
|
13
|
+
eu-west-2: ami-051aaf1b532b3e6bc
|
14
|
+
eu-west-3: ami-09a7af6793a3e8d09
|
15
|
+
sa-east-1: ami-0c4064cfe711311d5
|
16
|
+
us-east-2: ami-0124fd8917f59f8ce
|
17
|
+
us-west-1: ami-00457c55541605cb4
|
18
|
+
us-west-2: ami-02211d4e254a9e10f
|
19
19
|
centos6: &4
|
20
|
-
us-east-1: ami-
|
21
|
-
us-east-2: ami-
|
22
|
-
ap-northeast-1: ami-
|
23
|
-
ap-northeast-2: ami-
|
24
|
-
ap-south-1: ami-
|
25
|
-
ap-southeast-1: ami-
|
26
|
-
ap-southeast-2: ami-
|
27
|
-
ca-central-1: ami-
|
28
|
-
eu-central-1: ami-
|
29
|
-
eu-north-1: ami-
|
30
|
-
eu-west-1: ami-
|
31
|
-
eu-west-2: ami-
|
32
|
-
eu-west-3: ami-
|
33
|
-
sa-east-1: ami-
|
34
|
-
us-west-1: ami-
|
35
|
-
us-west-2: ami-
|
20
|
+
us-east-1: ami-0ccdc671f12147a1d
|
21
|
+
us-east-2: ami-00d0e8bc2f05ab949
|
22
|
+
ap-northeast-1: ami-0726801ceef87f5f8
|
23
|
+
ap-northeast-2: ami-05fa4afc4a0493b0a
|
24
|
+
ap-south-1: ami-0d6e4f3b6592b3139
|
25
|
+
ap-southeast-1: ami-0c988e3dc80b14653
|
26
|
+
ap-southeast-2: ami-02ac856fd094675ef
|
27
|
+
ca-central-1: ami-0ce7e343953af2292
|
28
|
+
eu-central-1: ami-0ce8317423cea27b8
|
29
|
+
eu-north-1: ami-0a923b493d5fc9743
|
30
|
+
eu-west-1: ami-06e0f02328921c865
|
31
|
+
eu-west-2: ami-07ae118c8814df140
|
32
|
+
eu-west-3: ami-03c1017cd1ccc6e9d
|
33
|
+
sa-east-1: ami-05212ae133b9c3ba1
|
34
|
+
us-west-1: ami-0b05ec54412b9f8b0
|
35
|
+
us-west-2: ami-0447e036b102b2ca0
|
36
36
|
centos7:
|
37
|
-
us-east-1: ami-
|
38
|
-
ap-northeast-1: ami-
|
39
|
-
ap-northeast-2: ami-
|
40
|
-
ap-south-1: ami-
|
41
|
-
ap-southeast-1: ami-
|
42
|
-
ap-southeast-2: ami-
|
43
|
-
ca-central-1: ami-
|
44
|
-
eu-central-1: ami-
|
45
|
-
eu-north-1: ami-
|
46
|
-
eu-west-1: ami-
|
47
|
-
eu-west-2: ami-
|
48
|
-
eu-west-3: ami-
|
49
|
-
sa-east-1: ami-
|
50
|
-
us-east-2: ami-
|
51
|
-
us-west-1: ami-
|
52
|
-
us-west-2: ami-
|
37
|
+
us-east-1: ami-0be9d646b29a9f51d
|
38
|
+
ap-northeast-1: ami-0ea500fc488406ad8
|
39
|
+
ap-northeast-2: ami-062d5536e5ebf04e9
|
40
|
+
ap-south-1: ami-0c2bf51384a5dcd92
|
41
|
+
ap-southeast-1: ami-0a8022e9bb353022f
|
42
|
+
ap-southeast-2: ami-03d47c88f2e01203b
|
43
|
+
ca-central-1: ami-0f0dc8a3e18a28544
|
44
|
+
eu-central-1: ami-0ea618bc5a1f372a2
|
45
|
+
eu-north-1: ami-02b062056e7dd4741
|
46
|
+
eu-west-1: ami-03851110db1a143e7
|
47
|
+
eu-west-2: ami-03800a8fe524171d2
|
48
|
+
eu-west-3: ami-074acd461ca002f0a
|
49
|
+
sa-east-1: ami-00c88550221a205f9
|
50
|
+
us-east-2: ami-098da5da2eef484e5
|
51
|
+
us-west-1: ami-0eea632474ef51860
|
52
|
+
us-west-2: ami-075aad0e6e9fc5654
|
53
53
|
ubuntu16: &3
|
54
54
|
us-east-1: ami-bcdc16c6
|
55
55
|
us-west-1: ami-1b17257b
|
@@ -73,56 +73,56 @@ ubuntu14:
|
|
73
73
|
ap-southeast-1: ami-2855964b
|
74
74
|
ap-southeast-2: ami-d19fc4b2
|
75
75
|
win2k12r2: &1
|
76
|
-
us-east-1: ami-
|
77
|
-
us-east-2: ami-
|
78
|
-
ca-central-1: ami-
|
79
|
-
us-west-2: ami-
|
80
|
-
us-west-1: ami-
|
81
|
-
eu-west-1: ami-
|
82
|
-
eu-west-2: ami-
|
83
|
-
eu-west-3: ami-
|
84
|
-
eu-north-1: ami-
|
85
|
-
sa-east-1: ami-
|
86
|
-
eu-central-1: ami-
|
87
|
-
ap-northeast-1: ami-
|
88
|
-
ap-south-1: ami-
|
89
|
-
ap-northeast-2: ami-
|
90
|
-
ap-southeast-1: ami-
|
91
|
-
ap-southeast-2: ami-
|
76
|
+
us-east-1: ami-0d28b9a40ed446e35
|
77
|
+
us-east-2: ami-010d247b7ee850d55
|
78
|
+
ca-central-1: ami-0c223858875f62d11
|
79
|
+
us-west-2: ami-01d188c5c06078fee
|
80
|
+
us-west-1: ami-0dbcc051c49ec24ec
|
81
|
+
eu-west-1: ami-080c7b4d6e32bf9f3
|
82
|
+
eu-west-2: ami-01b1edb5894a54bcc
|
83
|
+
eu-west-3: ami-09445cdc7a2acb1c0
|
84
|
+
eu-north-1: ami-0093cc63496e435df
|
85
|
+
sa-east-1: ami-04d015c8b371ba7b3
|
86
|
+
eu-central-1: ami-04d6144bcbb029141
|
87
|
+
ap-northeast-1: ami-07fad72f121aa157c
|
88
|
+
ap-south-1: ami-0b3241fd09b1ce87f
|
89
|
+
ap-northeast-2: ami-0ba7cd822e36dc0df
|
90
|
+
ap-southeast-1: ami-0648522a4cb50953c
|
91
|
+
ap-southeast-2: ami-0fc0bd73cd61a970f
|
92
92
|
win2k16: &2
|
93
|
-
us-east-1: ami-
|
94
|
-
us-east-2: ami-
|
95
|
-
ca-central-1: ami-
|
96
|
-
us-west-2: ami-
|
97
|
-
eu-west-1: ami-
|
98
|
-
us-west-1: ami-
|
99
|
-
eu-west-2: ami-
|
100
|
-
eu-west-3: ami-
|
101
|
-
eu-central-1: ami-
|
102
|
-
sa-east-1: ami-
|
103
|
-
ap-northeast-1: ami-
|
104
|
-
ap-south-1: ami-
|
105
|
-
ap-northeast-2: ami-
|
106
|
-
ap-southeast-2: ami-
|
107
|
-
ap-southeast-1: ami-
|
108
|
-
eu-north-1: ami-
|
93
|
+
us-east-1: ami-018151f8c8339a093
|
94
|
+
us-east-2: ami-09e045936c7d9ecd5
|
95
|
+
ca-central-1: ami-0a16abf0f1c35667a
|
96
|
+
us-west-2: ami-00d4216f80a82894d
|
97
|
+
eu-west-1: ami-07afc1525928ccad7
|
98
|
+
us-west-1: ami-0d2f7d4198b79a625
|
99
|
+
eu-west-2: ami-04eb62f17efc84a37
|
100
|
+
eu-west-3: ami-0b4affcd5848cf50c
|
101
|
+
eu-central-1: ami-0a92ae047ebc7a3da
|
102
|
+
sa-east-1: ami-0cc9a87c95fb37832
|
103
|
+
ap-northeast-1: ami-014c730050acef11d
|
104
|
+
ap-south-1: ami-0c3c8739263aa4844
|
105
|
+
ap-northeast-2: ami-0018a05eb15503b5e
|
106
|
+
ap-southeast-2: ami-0b50bfbb507285a89
|
107
|
+
ap-southeast-1: ami-073c677bcf225774a
|
108
|
+
eu-north-1: ami-09bb6d618593f2e7f
|
109
109
|
win2k19:
|
110
|
-
us-east-1: ami-
|
111
|
-
us-east-2: ami-
|
112
|
-
ca-central-1: ami-
|
113
|
-
us-west-2: ami-
|
114
|
-
eu-west-2: ami-
|
115
|
-
us-west-1: ami-
|
116
|
-
eu-west-1: ami-
|
117
|
-
eu-central-1: ami-
|
118
|
-
eu-west-3: ami-
|
119
|
-
eu-north-1: ami-
|
120
|
-
sa-east-1: ami-
|
121
|
-
ap-northeast-2: ami-
|
122
|
-
ap-northeast-1: ami-
|
123
|
-
ap-southeast-1: ami-
|
124
|
-
ap-southeast-2: ami-
|
125
|
-
ap-south-1: ami-
|
110
|
+
us-east-1: ami-09c18c34c341f2b6a
|
111
|
+
us-east-2: ami-030371d5ee8881350
|
112
|
+
ca-central-1: ami-018e5bf45c30fa58f
|
113
|
+
us-west-2: ami-07d1e5c4f906877e1
|
114
|
+
eu-west-2: ami-0b9d95fef44aa7c11
|
115
|
+
us-west-1: ami-0e7e082d6fa1769f3
|
116
|
+
eu-west-1: ami-05573fafa080144b6
|
117
|
+
eu-central-1: ami-0122b027c265988ea
|
118
|
+
eu-west-3: ami-0ba7c0a3dc4148b6a
|
119
|
+
eu-north-1: ami-03d8c3307f72f9847
|
120
|
+
sa-east-1: ami-0d0f66c3e0dfc09ee
|
121
|
+
ap-northeast-2: ami-07eff56de9293ab16
|
122
|
+
ap-northeast-1: ami-020fb790a3bed4cda
|
123
|
+
ap-southeast-1: ami-0b5d036d6d711a4c8
|
124
|
+
ap-southeast-2: ami-0fff96935fef7bf60
|
125
|
+
ap-south-1: ami-030ec249497f66a33
|
126
126
|
amazon:
|
127
127
|
us-east-1: ami-b73b63a0
|
128
128
|
us-east-2: ami-58277d3d
|
data/modules/mu/mommacat.rb
CHANGED
@@ -547,7 +547,7 @@ module MU
|
|
547
547
|
# @param remove [Boolean]: Remove this resource from the deploy structure, instead of adding it.
|
548
548
|
# @return [void]
|
549
549
|
def notify(type, key, data, mu_name: nil, remove: false, triggering_node: nil, delayed_save: false)
|
550
|
-
no_write = (@no_artifacts or caller.grep(/\/mommacat\.rb:\d+:in `notify'/))
|
550
|
+
no_write = (@no_artifacts or !caller.grep(/\/mommacat\.rb:\d+:in `notify'/).empty?)
|
551
551
|
|
552
552
|
begin
|
553
553
|
if !no_write
|
@@ -560,7 +560,13 @@ module MU
|
|
560
560
|
loadDeploy(true) # make sure we're saving the latest and greatest
|
561
561
|
end
|
562
562
|
|
563
|
-
|
563
|
+
@timestamp ||= @deployment['timestamp']
|
564
|
+
@seed ||= @deployment['seed']
|
565
|
+
@appname ||= @deployment['appname']
|
566
|
+
@handle ||= @deployment['handle']
|
567
|
+
|
568
|
+
_shortclass, _cfg_name, mu_type, _classname, attrs = MU::Cloud.getResourceNames(type, false)
|
569
|
+
type = mu_type if mu_type
|
564
570
|
has_multiples = attrs[:has_multiples] ? true : false
|
565
571
|
|
566
572
|
mu_name ||= if !data.nil? and !data["mu_name"].nil?
|
@@ -574,6 +580,7 @@ module MU
|
|
574
580
|
end
|
575
581
|
|
576
582
|
@need_deploy_flush = true
|
583
|
+
@last_modified = Time.now
|
577
584
|
|
578
585
|
if !remove
|
579
586
|
if data.nil?
|
@@ -903,6 +910,7 @@ MAIL_HEAD_END
|
|
903
910
|
###########################################################################
|
904
911
|
###########################################################################
|
905
912
|
def setThreadContextToMe
|
913
|
+
|
906
914
|
["appname", "environment", "timestamp", "seed", "handle"].each { |var|
|
907
915
|
@deployment[var] ||= instance_variable_get("@#{var}".to_sym)
|
908
916
|
if @deployment[var]
|
@@ -107,8 +107,17 @@ module MU
|
|
107
107
|
matches = []
|
108
108
|
|
109
109
|
credlist.each { |creds|
|
110
|
-
|
111
|
-
|
110
|
+
cur_habitats = []
|
111
|
+
|
112
|
+
if habitats and !habitats.empty? and habitats != [nil]
|
113
|
+
valid_habitats = cloudclass.listHabitats(creds)
|
114
|
+
cur_habitats = (habitats & valid_habitats)
|
115
|
+
next if cur_habitats.empty?
|
116
|
+
else
|
117
|
+
cur_habitats = cloudclass.listHabitats(creds)
|
118
|
+
end
|
119
|
+
|
120
|
+
cloud_descs = search_cloud_provider(type, cloud, cur_habitats, region, cloud_id: cloud_id, tag_key: tag_key, tag_value: tag_value, credentials: creds, flags: flags)
|
112
121
|
|
113
122
|
cloud_descs.each_pair.each { |p, regions|
|
114
123
|
regions.each_pair.each { |r, results|
|
@@ -202,14 +202,16 @@ module MU
|
|
202
202
|
|
203
203
|
MU.log "Getting a lock on #{lockdir}/#{id}.lock (thread #{Thread.current.object_id})...", MU::DEBUG, details: caller
|
204
204
|
show_relevant = Proc.new {
|
205
|
-
@
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
205
|
+
@lock_semaphore.synchronize {
|
206
|
+
@locks.each_pair { |thread_id, lock|
|
207
|
+
lock.each_pair { |lockid, lockpath|
|
208
|
+
if lockid == id
|
209
|
+
thread = Thread.list.select { |t| t.object_id == thread_id }.first
|
210
|
+
if thread.object_id != Thread.current.object_id
|
211
|
+
MU.log "#{thread_id} sitting on #{id}", MU::WARN, thread.backtrace
|
212
|
+
end
|
211
213
|
end
|
212
|
-
|
214
|
+
}
|
213
215
|
}
|
214
216
|
}
|
215
217
|
}
|
@@ -218,11 +220,13 @@ module MU
|
|
218
220
|
if !@locks[Thread.current.object_id][id].flock(File::LOCK_EX|File::LOCK_NB)
|
219
221
|
if retries > 0
|
220
222
|
success = false
|
221
|
-
MU.retrier([], loop_if: Proc.new { !success }, loop_msg: "Waiting for lock on #{lockdir}/#{id}.lock...", max: retries) {
|
223
|
+
MU.retrier([], loop_if: Proc.new { !success }, loop_msg: "Waiting for lock on #{lockdir}/#{id}.lock...", max: retries) { |cur_retries, _wait|
|
222
224
|
success = @locks[Thread.current.object_id][id].flock(File::LOCK_EX|File::LOCK_NB)
|
223
|
-
|
225
|
+
if !success and cur_retries > 0 and (cur_retries % 3) == 0
|
226
|
+
show_relevant.call(cur_retries)
|
227
|
+
end
|
224
228
|
}
|
225
|
-
show_relevant.call() if !success
|
229
|
+
show_relevant.call(cur_retries) if !success
|
226
230
|
return success
|
227
231
|
else
|
228
232
|
return false
|
@@ -415,6 +419,7 @@ module MU
|
|
415
419
|
deploy.flock(File::LOCK_UN)
|
416
420
|
deploy.close
|
417
421
|
@need_deploy_flush = false
|
422
|
+
@last_modified = nil
|
418
423
|
MU::MommaCat.updateLitter(@deploy_id, self)
|
419
424
|
end
|
420
425
|
|
@@ -643,6 +648,14 @@ module MU
|
|
643
648
|
def loadDeployFromCache(set_context_to_me = true)
|
644
649
|
return false if !File.size?(deploy_dir+"/deployment.json")
|
645
650
|
|
651
|
+
lastmod = File.mtime("#{deploy_dir}/deployment.json")
|
652
|
+
if @last_modified and lastmod < @last_modified
|
653
|
+
MU.log "#{deploy_dir}/deployment.json last written at #{lastmod}, live meta at #{@last_modified}, not loading", MU::WARN if @last_modified
|
654
|
+
# this is a weird place for this
|
655
|
+
setThreadContextToMe if set_context_to_me
|
656
|
+
return true
|
657
|
+
end
|
658
|
+
|
646
659
|
deploy = File.open("#{deploy_dir}/deployment.json", File::RDONLY)
|
647
660
|
MU.log "Getting lock to read #{deploy_dir}/deployment.json", MU::DEBUG
|
648
661
|
# deploy.flock(File::LOCK_EX)
|
@@ -654,6 +667,7 @@ module MU
|
|
654
667
|
|
655
668
|
begin
|
656
669
|
@deployment = JSON.parse(File.read("#{deploy_dir}/deployment.json"))
|
670
|
+
# XXX is it worthwhile to merge fuckery?
|
657
671
|
rescue JSON::ParserError => e
|
658
672
|
MU.log "JSON parse failed on #{deploy_dir}/deployment.json", MU::ERR, details: e.message
|
659
673
|
end
|
@@ -663,20 +677,21 @@ module MU
|
|
663
677
|
|
664
678
|
setThreadContextToMe if set_context_to_me
|
665
679
|
|
666
|
-
@timestamp = @deployment['timestamp']
|
667
|
-
@seed = @deployment['seed']
|
668
|
-
@appname = @deployment['appname']
|
669
|
-
@handle = @deployment['handle']
|
670
|
-
|
671
680
|
true
|
672
681
|
end
|
673
682
|
|
683
|
+
|
674
684
|
###########################################################################
|
675
685
|
###########################################################################
|
676
686
|
def loadDeploy(deployment_json_only = false, set_context_to_me: true)
|
677
687
|
MU::MommaCat.deploy_struct_semaphore.synchronize {
|
678
688
|
success = loadDeployFromCache(set_context_to_me)
|
679
689
|
|
690
|
+
@timestamp ||= @deployment['timestamp']
|
691
|
+
@seed ||= @deployment['seed']
|
692
|
+
@appname ||= @deployment['appname']
|
693
|
+
@handle ||= @deployment['handle']
|
694
|
+
|
680
695
|
return if deployment_json_only and success
|
681
696
|
|
682
697
|
if File.exist?(deploy_dir+"/private_key")
|