prima-twig 0.56.10 → 0.56.80

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/twig-feature +93 -207
  3. data/lib/prima_aws_client.rb +93 -0
  4. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0e794193674d8167c328100e9471ab4ef5c0a00d35c190a13a3c4ad82669d509
4
- data.tar.gz: fe8f1f232404a314505c2701eb61c05db2dacc079555d0d10499885ab387c4a7
3
+ metadata.gz: 93f30a720eb91bcbf9d8961d3234503ff4f631f33bb2b0b53e2b59f39ebb7816
4
+ data.tar.gz: 5314aa9871981c492e798e20cfad7f7806f01b6e6b42a86fdeb065659b00f144
5
5
  SHA512:
6
- metadata.gz: 05d2e3c429afdcdb0061fb5c5b861015262d1b10d1952e68777067d698e03967f189e2b8954b416644cc7ac0f5653c37a399844c6b25fc6a49b6064017702103
7
- data.tar.gz: 87c6d901842c212329e5af8e3d1173661ed914a24b3051ea9e4c6604c5f8a15edc8a179e66aabb6072721eb1bd80992336dcc7273d70be4fd5d3ece97da81f13
6
+ metadata.gz: e682f4802bd18af7b17698d405357f4976999344a72d7a49f1143d1ac0969075c5215ba4573e537aefe8341cc2c12fcb50750897f5605a7b34f7ac2c15d31963
7
+ data.tar.gz: 296ceb2a085908359d7b148e3f432103f91307443e2dcbc4489ccfd01b0207a18ec8aea596368ea5b70222be582e48f87cd67f369c8b7df8c348356da7c50a08
data/bin/twig-feature CHANGED
@@ -22,12 +22,7 @@ class Release
22
22
  exec "twig feature #{ARGV.join ' '}"
23
23
  end
24
24
  end
25
- @cf = Aws::CloudFormation::Client.new
26
- @alb = Aws::ElasticLoadBalancingV2::Client.new
27
- @ec2 = Aws::EC2::Client.new
28
- @ecs = Aws::ECS::Client.new
29
25
  @batch = Aws::Batch::Client.new
30
- @asg = Aws::AutoScaling::Client.new
31
26
  @s3 = Aws::S3::Client.new
32
27
  @s3_bucket = 'prima-artifacts'
33
28
  @artifact_path = '/tmp/prima-artifact.zip'
@@ -58,8 +53,7 @@ class Release
58
53
  'leftorium' => {},
59
54
  'pyxis-npm' => {},
60
55
  'starsky' => {},
61
- 'hutch' => {},
62
- 'maia' => {}
56
+ 'hutch' => {}
63
57
  }
64
58
  @base_stack_name_alb = 'ecs-alb-http-public-qa-'
65
59
  @base_stack_name_alb_ws = 'ecs-alb-ws-public-qa-'
@@ -518,7 +512,7 @@ class Release
518
512
  end
519
513
 
520
514
  # così recupero le informazioni sul branch, poi vado a scrivere il file branch_names con una sola riga
521
- branch = {'project' => { 'name' => project_definition[:name], 'revision' => project_definition['revision'], 'default_branch' => project_definition[:default_branch]}}
515
+ branch = {'project' => { 'name' => project_definition[:name], 'revision' => project_definition[:revision], 'default_branch' => project_definition[:default_branch]}}
522
516
 
523
517
  File.open('branch_names', 'w') { |file| file.write(JSON.generate(branch)) }
524
518
 
@@ -756,7 +750,7 @@ class Release
756
750
  create_alb_stack(stack_name_alb, "http", deploy_id, 'qa-minimal') unless stack_exists?(stack_name_alb)
757
751
  create_alb_stack(stack_name_alb_ws, "websocket", deploy_id, 'qa-minimal') unless stack_exists?(stack_name_alb_ws)
758
752
 
759
- resp = @cf.describe_stack_resource({stack_name: cluster_stack_name, logical_resource_id: 'ECSCluster'})
753
+ resp = describe_stack_resource(cluster_stack_name, 'ECSCluster')
760
754
  @ecs_cluster_name = resp.stack_resource_detail.physical_resource_id
761
755
 
762
756
  asg_stack_name = "ecs-asg-allinone-qa-#{deploy_id}"
@@ -905,8 +899,8 @@ class Release
905
899
  case key.to_s
906
900
  when 'crash'
907
901
  tags << { key: 'crash', value: @projects['crash']['name'] } if deploy_crash?
908
- when 'starsky', 'hutch', 'maia'
909
- tags << { key: key.to_s, value: @projects[key.to_s]['name'] } if deploy_starsky_hutch_maia?
902
+ when 'starsky', 'hutch'
903
+ tags << { key: key.to_s, value: @projects[key.to_s]['name'] } if deploy_starsky_hutch?
910
904
  else
911
905
  tags << { key: key, value: value['name'] }
912
906
  end
@@ -927,7 +921,7 @@ class Release
927
921
  create_alb_stack(stack_name_alb, "http", deploy_id) unless stack_exists?(stack_name_alb)
928
922
  create_alb_stack(stack_name_alb_ws, "websocket", deploy_id) unless stack_exists?(stack_name_alb_ws)
929
923
 
930
- resp = @cf.describe_stack_resource({stack_name: cluster_stack_name, logical_resource_id: 'ECSCluster'})
924
+ resp = describe_stack_resource(cluster_stack_name, 'ECSCluster')
931
925
  @ecs_cluster_name = resp.stack_resource_detail.physical_resource_id
932
926
 
933
927
  asg_stack_name = "ecs-asg-allinone-qa-#{deploy_id}"
@@ -971,9 +965,8 @@ class Release
971
965
  create_activia_artifact(@projects["activia"]['revision']) unless artifact_exists?('prima-artifacts-encrypted', "microservices/activia/#{@projects["activia"]['revision']}-qa.tar.gz")
972
966
  create_leftorium_artifact(@projects["leftorium"]['revision']) unless artifact_exists?('prima-artifacts-encrypted', "microservices/leftorium/#{@projects["leftorium"]['revision']}-qa.tar.gz")
973
967
  create_skynet_artifact(@projects["skynet"]['revision']) unless artifact_exists?('prima-artifacts-encrypted', "microservices/skynet/#{@projects["skynet"]['revision']}-qa.tar.gz")
974
- create_starsky_artifact(@projects["starsky"]['revision']) unless !deploy_starsky_hutch_maia? || artifact_exists?('prima-artifacts-encrypted', "microservices/starsky/#{@projects["starsky"]['revision']}-qa.tar.gz")
975
- create_hutch_artifact(@projects["hutch"]['revision']) unless !deploy_starsky_hutch_maia? || artifact_exists?('prima-artifacts-encrypted', "microservices/hutch/#{@projects["hutch"]['revision']}-qa.tar.gz")
976
- create_maia_artifact(@projects["maia"]['revision']) unless !deploy_starsky_hutch_maia? || artifact_exists?('prima-artifacts-encrypted', "microservices/maia/#{@projects["maia"]['revision']}-qa.tar.gz")
968
+ create_starsky_artifact(@projects["starsky"]['revision']) unless !deploy_starsky_hutch? || artifact_exists?('prima-artifacts-encrypted', "microservices/starsky/#{@projects["starsky"]['revision']}-qa.tar.gz")
969
+ create_hutch_artifact(@projects["hutch"]['revision']) unless !deploy_starsky_hutch? || artifact_exists?('prima-artifacts-encrypted', "microservices/hutch/#{@projects["hutch"]['revision']}-qa.tar.gz")
977
970
 
978
971
  wait_for_db_import(db_task) unless stack_exists?("ecs-route53-qa-#{deploy_id}") # dovrebbe essere istantaneo
979
972
 
@@ -1060,10 +1053,6 @@ class Release
1060
1053
  {
1061
1054
  parameter_key: 'HutchElbHostname',
1062
1055
  parameter_value: get_alb_host(stack_name_alb)
1063
- },
1064
- {
1065
- parameter_key: 'MaiaElbHostname',
1066
- parameter_value: get_alb_host(stack_name_alb)
1067
1056
  }
1068
1057
  ]
1069
1058
 
@@ -1616,7 +1605,7 @@ class Release
1616
1605
  end
1617
1606
  end
1618
1607
 
1619
- if deploy_starsky_hutch_maia?
1608
+ if deploy_starsky_hutch?
1620
1609
  stack_name_starsky = "ecs-task-starsky-qa-#{deploy_id}"
1621
1610
  git_checkout_version('starsky', @projects["starsky"]['revision'])
1622
1611
  stack_body = IO.read('projects/starsky/deploy/task.yml')
@@ -1873,8 +1862,8 @@ class Release
1873
1862
  end
1874
1863
 
1875
1864
 
1876
- if deploy_starsky_hutch_maia?
1877
- wait_for_stack_ready(stack_name_starsky) unless stack_ready?(stack_name_starsky) unless !deploy_starsky_hutch_maia?
1865
+ if deploy_starsky_hutch?
1866
+ wait_for_stack_ready(stack_name_starsky) unless stack_ready?(stack_name_starsky) unless !deploy_starsky_hutch?
1878
1867
 
1879
1868
  stack_name_hutch = "ecs-task-hutch-qa-#{deploy_id}"
1880
1869
  git_checkout_version('hutch', @projects["hutch"]['revision'])
@@ -1909,8 +1898,8 @@ class Release
1909
1898
  parameter_value: (hostname_pattern_priority.to_i + 254).to_s
1910
1899
  },
1911
1900
  {
1912
- parameter_key: "ApiUrl",
1913
- parameter_value: "https://#{get_route53_hostname('maia-intermediari')}"
1901
+ parameter_key: "StarskyUrl",
1902
+ parameter_value: "https://#{get_route53_hostname('ecs-task-starsky-qa-notneeded')}"
1914
1903
  }
1915
1904
  ]
1916
1905
  if stack_exists?(stack_name_hutch)
@@ -1921,54 +1910,6 @@ class Release
1921
1910
  end
1922
1911
  end
1923
1912
 
1924
- stack_name_maia = "ecs-task-maia-qa-#{deploy_id}"
1925
- git_checkout_version('maia', @projects["maia"]['revision'])
1926
- stack_body = File.read('projects/maia/deploy/task.yml')
1927
- parameters = [
1928
- {
1929
- parameter_key: "Environment",
1930
- parameter_value: "qa"
1931
- },
1932
- {
1933
- parameter_key: "ReleaseVersion",
1934
- parameter_value: "#{@projects["maia"]['revision']}"
1935
- },
1936
- {
1937
- parameter_key: "ALBShortName",
1938
- parameter_value: "maia-qa-#{deploy_id}"[0..15]
1939
- },
1940
- {
1941
- parameter_key: "ECSClusterName",
1942
- parameter_value: @ecs_cluster_name
1943
- },
1944
- {
1945
- parameter_key: "EnvHash",
1946
- parameter_value: deploy_id
1947
- },
1948
- {
1949
- parameter_key: "HostnamePatternPublic",
1950
- parameter_value: "api*-#{@dns_record_identifier}.qa.colaster.com"
1951
- },
1952
- {
1953
- parameter_key: "HostnamePatternPriority",
1954
- parameter_value: (hostname_pattern_priority.to_i + 128).to_s
1955
- },
1956
- {
1957
- parameter_key: "ProxyHostnameIntermediari",
1958
- parameter_value: "api-intermediari-#{@dns_record_identifier}.qa.colaster.com"
1959
- },
1960
- {
1961
- parameter_key: "ProxyHostnameApp",
1962
- parameter_value: "api-#{@dns_record_identifier}.qa.colaster.com"
1963
- }
1964
- ]
1965
- if stack_exists?(stack_name_maia)
1966
- cur_version = get_currently_deployed_version(stack_name_maia)
1967
- update_stack(stack_name_maia, stack_body, parameters, tags, @cf_role) unless cur_version.include?(@projects["maia"]['revision'])
1968
- else
1969
- create_stack(stack_name_maia, stack_body, parameters, tags, @cf_role)
1970
- end
1971
-
1972
1913
  wait_for_stack_ready(stack_name_web) unless stack_ready?(stack_name_web)
1973
1914
  wait_for_stack_ready(stack_name_consumer) unless stack_ready?(stack_name_consumer)
1974
1915
  wait_for_stack_ready(stack_name_ermes) unless stack_ready?(stack_name_ermes)
@@ -1978,8 +1919,7 @@ class Release
1978
1919
  wait_for_stack_ready(stack_name_borat) unless stack_ready?(stack_name_borat)
1979
1920
  wait_for_stack_ready(stack_name_activia) unless stack_ready?(stack_name_activia)
1980
1921
  wait_for_stack_ready(stack_name_crash) unless stack_ready?(stack_name_crash) unless !deploy_crash?
1981
- wait_for_stack_ready(stack_name_hutch) unless stack_ready?(stack_name_hutch) unless !deploy_starsky_hutch_maia?
1982
- wait_for_stack_ready(stack_name_maia) unless stack_ready?(stack_name_maia) unless !deploy_starsky_hutch_maia?
1922
+ wait_for_stack_ready(stack_name_hutch) unless stack_ready?(stack_name_hutch) unless !deploy_starsky_hutch?
1983
1923
 
1984
1924
  update_service_defaults(stack_name_web)
1985
1925
  update_service_defaults(stack_name_consumer)
@@ -1996,30 +1936,27 @@ class Release
1996
1936
  update_service_defaults(stack_name_skynet)
1997
1937
  update_service_defaults(stack_name_leftorium)
1998
1938
  update_service_defaults(stack_name_rachele)
1999
- update_service_defaults(stack_name_starsky) unless !deploy_starsky_hutch_maia?
2000
- update_service_defaults(stack_name_hutch) unless !deploy_starsky_hutch_maia?
2001
- update_service_defaults(stack_name_maia) unless !deploy_starsky_hutch_maia?
1939
+ update_service_defaults(stack_name_starsky) unless !deploy_starsky_hutch?
1940
+ update_service_defaults(stack_name_hutch) unless !deploy_starsky_hutch?
2002
1941
  update_service_defaults(stack_name_crash) unless !deploy_crash?
2003
1942
 
2004
- activia_hostname = get_route53_hostname("activia")
2005
- assange_hostname = get_route53_hostname("assange")
2006
- bburago_hostname = get_route53_hostname("bburago")
2007
- borat_hostname = get_route53_hostname("borat")
2008
- ermes_hostname = get_route53_hostname("ermes")
2009
- fidaty_hostname = get_route53_hostname("fidaty")
2010
- hal9000_hostname = get_route53_hostname("hal9000")
2011
- prima_hostname = get_route53_hostname("web")
2012
- peano_hostname = get_route53_hostname("peano")
2013
- skynet_hostname = get_route53_hostname("skynet")
2014
- urania_hostname = get_route53_hostname("urania")
2015
- roger_hostname = get_route53_hostname("roger")
2016
- leftorium_hostname = get_route53_hostname("leftorium")
2017
- rachele_hostname = get_route53_hostname("rachele")
2018
- crash_hostname = get_route53_hostname("crash") unless !deploy_crash?
2019
- starsky_hostname = get_route53_hostname("starsky") unless !deploy_starsky_hutch_maia?
2020
- hutch_hostname = get_route53_hostname("hutch") unless !deploy_starsky_hutch_maia?
2021
- maia_app_hostname = get_route53_hostname("maia-app") unless !deploy_starsky_hutch_maia?
2022
- maia_intermediari_hostname = get_route53_hostname("maia-intermediari") unless !deploy_starsky_hutch_maia?
1943
+ activia_hostname = get_route53_hostname(stack_name_activia)
1944
+ assange_hostname = get_route53_hostname(stack_name_assange)
1945
+ bburago_hostname = get_route53_hostname(stack_name_bburago)
1946
+ borat_hostname = get_route53_hostname(stack_name_borat)
1947
+ ermes_hostname = get_route53_hostname(stack_name_ermes)
1948
+ fidaty_hostname = get_route53_hostname(stack_name_fidaty)
1949
+ hal9000_hostname = get_route53_hostname(stack_name_hal9000)
1950
+ prima_hostname = get_route53_hostname(stack_name_web)
1951
+ peano_hostname = get_route53_hostname(stack_name_peano)
1952
+ skynet_hostname = get_route53_hostname(stack_name_skynet)
1953
+ urania_hostname = get_route53_hostname(stack_name_urania)
1954
+ roger_hostname = get_route53_hostname(stack_name_roger)
1955
+ leftorium_hostname = get_route53_hostname(stack_name_leftorium)
1956
+ rachele_hostname = get_route53_hostname(stack_name_rachele)
1957
+ crash_hostname = get_route53_hostname(stack_name_crash) unless !deploy_crash?
1958
+ starsky_hostname = get_route53_hostname(stack_name_starsky) unless !deploy_starsky_hutch?
1959
+ hutch_hostname = get_route53_hostname(stack_name_hutch) unless !deploy_starsky_hutch?
2023
1960
 
2024
1961
  # launch_marley ec2_ip_address(asg_stack_name), prima_hostname, borat_hostname
2025
1962
 
@@ -2042,9 +1979,7 @@ class Release
2042
1979
  > Crash url: https://#{crash_hostname}" if deploy_crash?
2043
1980
  projects_text.concat "
2044
1981
  > Starsky url: https://#{starsky_hostname}
2045
- > Hutch url: https://#{hutch_hostname}
2046
- > Maia App url: https://#{maia_app_hostname}
2047
- > Maia Intermediari url: https://#{maia_intermediari_hostname}" if deploy_starsky_hutch_maia?
1982
+ > Hutch url: https://#{hutch_hostname}" if deploy_starsky_hutch?
2048
1983
  projects_text.concat "
2049
1984
  > RabbitMQ url: http://#{ec2_ip_address(asg_stack_name)}:15672
2050
1985
  > Supervisor url: http://#{ec2_ip_address(asg_stack_name)}:9001
@@ -2056,61 +1991,51 @@ class Release
2056
1991
  qainit_write_output(projects_text, 'Indirizzi scritti su ')
2057
1992
  end
2058
1993
 
2059
- def get_route53_hostname(project)
1994
+ def get_route53_hostname(stack_name)
2060
1995
  case
2061
- when project.include?('web')
1996
+ when stack_name.include?('web')
2062
1997
  host = "www-#{@dns_record_identifier}.qa.colaster.com"
2063
- when project.include?('urania')
1998
+ when stack_name.include?('urania')
2064
1999
  host = "urania-#{@dns_record_identifier}.qa.colaster.com"
2065
- when project.include?('bburago')
2000
+ when stack_name.include?('bburago')
2066
2001
  host = "bburago-#{@dns_record_identifier}.qa.colaster.com"
2067
- when project.include?('hal9000')
2002
+ when stack_name.include?('hal9000')
2068
2003
  host = "hal9000-#{@dns_record_identifier}.qa.colaster.com"
2069
- when project.include?('fidaty')
2004
+ when stack_name.include?('fidaty')
2070
2005
  host = "fidaty-#{@dns_record_identifier}.qa.colaster.com"
2071
- when project.include?('peano')
2006
+ when stack_name.include?('peano')
2072
2007
  host = "peano-#{@dns_record_identifier}.qa.colaster.com"
2073
- when project.include?('assange')
2008
+ when stack_name.include?('assange')
2074
2009
  host = "assange-#{@dns_record_identifier}.qa.colaster.com"
2075
- when project.include?('borat')
2010
+ when stack_name.include?('borat')
2076
2011
  host = "backoffice-#{@dns_record_identifier}.qa.colaster.com"
2077
- when project.include?('crash')
2012
+ when stack_name.include?('crash')
2078
2013
  host = "crash-#{@dns_record_identifier}.qa.colaster.com"
2079
- when project.include?('ermes')
2014
+ when stack_name.include?('ermes')
2080
2015
  host = "ermes-#{@dns_record_identifier}.qa.colaster.com"
2081
- when project.include?('activia')
2016
+ when stack_name.include?('activia')
2082
2017
  host = "activia-#{@dns_record_identifier}.qa.colaster.com"
2083
- when project.include?('skynet')
2018
+ when stack_name.include?('skynet')
2084
2019
  host = "skynet-#{@dns_record_identifier}.qa.colaster.com"
2085
- when project.include?('roger')
2020
+ when stack_name.include?('roger')
2086
2021
  host = "roger-#{@dns_record_identifier}.qa.colaster.com"
2087
- when project.include?('leftorium')
2022
+ when stack_name.include?('leftorium')
2088
2023
  host = "leftorium-#{@dns_record_identifier}.qa.colaster.com"
2089
- when project.include?('rachele')
2024
+ when stack_name.include?('rachele')
2090
2025
  host = "rachele-#{@dns_record_identifier}.qa.colaster.com"
2091
- when project.include?('starsky')
2026
+ when stack_name.include?('starsky')
2092
2027
  host = "starsky-#{@dns_record_identifier}.qa.colaster.com"
2093
- when project.include?('hutch')
2028
+ when stack_name.include?('hutch')
2094
2029
  host = "hutch-#{@dns_record_identifier}.qa.colaster.com"
2095
- when project.include?('maia-app')
2096
- host = "api-#{@dns_record_identifier}.qa.colaster.com"
2097
- when project.include?('maia-intermediari')
2098
- host = "api-intermediari-#{@dns_record_identifier}.qa.colaster.com"
2099
2030
  end
2100
2031
  host
2101
2032
  end
2102
2033
 
2103
2034
  def ec2_ip_address(asg_stack_name)
2104
- resp = @cf.describe_stack_resource({
2105
- stack_name: asg_stack_name,
2106
- logical_resource_id: 'ECSAutoScalingGroup'
2107
- })
2108
- resp = @asg.describe_auto_scaling_groups({
2109
- auto_scaling_group_names: [resp.stack_resource_detail.physical_resource_id],
2110
- max_records: 1
2111
- })
2035
+ resp = describe_stack_resource(asg_stack_name, 'ECSAutoScalingGroup')
2036
+ resp = describe_auto_scaling_groups([resp.stack_resource_detail.physical_resource_id], 1)
2112
2037
  instance_id = resp.auto_scaling_groups[0].instances[0].instance_id
2113
- resp = @ec2.describe_instances({instance_ids: [instance_id]})
2038
+ resp = describe_instances([instance_id])
2114
2039
  resp.reservations[0].instances[0].private_ip_address
2115
2040
  end
2116
2041
 
@@ -2154,16 +2079,9 @@ class Release
2154
2079
  logical_resource_id = 'EcsApplicationLoadBalancerPublic'
2155
2080
  when stack_name.include?('hutch')
2156
2081
  logical_resource_id = 'EcsApplicationLoadBalancerPublic'
2157
- when stack_name.include?('maia')
2158
- logical_resource_id = 'EcsApplicationLoadBalancerPublic'
2159
2082
  end
2160
- resp = @cf.describe_stack_resource({
2161
- stack_name: stack_name,
2162
- logical_resource_id: logical_resource_id
2163
- })
2164
- resp = @alb.describe_load_balancers({
2165
- load_balancer_arns: [resp.stack_resource_detail.physical_resource_id]
2166
- })
2083
+ resp = describe_stack_resource(stack_name, logical_resource_id)
2084
+ resp = describe_load_balancers([resp.stack_resource_detail.physical_resource_id])
2167
2085
  resp.load_balancers[0].dns_name
2168
2086
  end
2169
2087
 
@@ -2209,23 +2127,11 @@ class Release
2209
2127
  logical_resource_id = 'ECSServiceStarskyQA'
2210
2128
  when stack_name.include?('hutch')
2211
2129
  logical_resource_id = 'ECSServiceHutch'
2212
- when stack_name.include?('maia')
2213
- logical_resource_id = 'ECSServiceMaia'
2214
2130
  else
2215
2131
  raise "Service name non gestito per lo stack #{stack_name}"
2216
2132
  end
2217
- resp = @cf.describe_stack_resource(
2218
- stack_name: stack_name,
2219
- logical_resource_id: logical_resource_id
2220
- )
2221
- @ecs.update_service(
2222
- cluster: @ecs_cluster_name,
2223
- service: resp.stack_resource_detail.physical_resource_id,
2224
- deployment_configuration: {
2225
- minimum_healthy_percent: 0,
2226
- maximum_percent: 100
2227
- }
2228
- )
2133
+ resp = describe_stack_resource(stack_name, logical_resource_id)
2134
+ update_ecs_service(@ecs_cluster_name, resp.stack_resource_detail.physical_resource_id, {minimum_healthy_percent: 0, maximum_percent: 100})
2229
2135
  end
2230
2136
 
2231
2137
  def create_activia_artifact(revision)
@@ -2506,16 +2412,29 @@ class Release
2506
2412
 
2507
2413
  Dir.chdir 'projects/hutch'
2508
2414
 
2415
+ version = `git rev-parse HEAD`
2416
+
2509
2417
  decrypt_secrets() unless File.exist?('config/secrets.yml')
2510
2418
 
2419
+ exec_step 'git submodule update'
2511
2420
  exec_step 'cp docker-compose-ci.yml docker-compose.yml'
2512
2421
  exec_step 'prepare-docker-compose --directory hutch && cp docker-compose-qainit.yml docker-compose.yml'
2422
+ exec_step "sed s/qa_deploy_id/#{get_deploy_id}/ .env.dist.qa"
2423
+ exec_step "cp .env.dist.qa .env"
2424
+ exec_step "rm -fr peano"
2513
2425
 
2514
- execute_command "deploy/build_qa_artifact #{get_route53_hostname("maia-intermediari")}"
2426
+ [
2427
+ "sed -i 's/USER app/USER root/g' Dockerfile",
2428
+ "docker-compose build web",
2429
+ "docker-compose run -w $PWD -u root -e ELM_APP_STARSKY_URL=https://#{get_route53_hostname("starsky")} --entrypoint /bin/sh web \
2430
+ '-c' 'yarn && yarn run build \
2431
+ && tar cfz #{revision}-qa.tar.gz *'"
2432
+ ].each do |cmd|
2433
+ execute_command cmd
2434
+ end
2515
2435
 
2516
- cleanup_containers
2436
+ artifact_path = "./#{revision}-qa.tar.gz"
2517
2437
 
2518
- artifact_path = "./hutch.tar.gz"
2519
2438
  upload_artifact(artifact_path, "microservices/hutch/#{revision}-qa.tar.gz", "#{@s3_bucket}-encrypted")
2520
2439
 
2521
2440
  Dir.chdir '../../'
@@ -2551,28 +2470,6 @@ class Release
2551
2470
  Dir.chdir '../../'
2552
2471
  end
2553
2472
 
2554
- def create_maia_artifact(revision)
2555
- output "Preparo l'artifact maia .zip\n".yellow
2556
-
2557
- git_checkout_version('maia', revision)
2558
-
2559
- Dir.chdir 'projects/maia'
2560
-
2561
- decrypt_secrets()
2562
-
2563
- exec_step 'cp docker-compose.yml docker-compose-ci.yml'
2564
- exec_step 'prepare-docker-compose --directory maia && cp docker-compose-qainit.yml docker-compose.yml'
2565
-
2566
- execute_command 'deploy/build_qa_artifact'
2567
-
2568
- cleanup_containers
2569
-
2570
- artifact_path = Dir.glob('_build/qa/rel/maia/releases/*/maia.tar.gz').first
2571
- upload_artifact(artifact_path, "microservices/maia/#{revision}-qa.tar.gz", "#{@s3_bucket}-encrypted")
2572
-
2573
- Dir.chdir '../../'
2574
- end
2575
-
2576
2473
  def create_peano_artifact(revision)
2577
2474
  output "Preparo l'artifact peano .zip\n".yellow
2578
2475
 
@@ -2878,11 +2775,10 @@ class Release
2878
2775
  crash_present || leftorium_present
2879
2776
  end
2880
2777
 
2881
- def deploy_starsky_hutch_maia?
2778
+ def deploy_starsky_hutch?
2882
2779
  starsky_present = !@projects['starsky'].nil? && !@projects['starsky'].empty? && @projects['starsky']['name'] != 'master' && !@projects['starsky']['default_branch']
2883
2780
  hutch_present = !@projects['hutch'].nil? && !@projects['hutch'].empty? && @projects['hutch']['name'] != 'master' && !@projects['hutch']['default_branch']
2884
- maia_present = !@projects['maia'].nil? && !@projects['maia'].empty? && @projects['maia']['name'] != 'master' && !@projects['maia']['default_branch']
2885
- starsky_present || hutch_present || maia_present
2781
+ starsky_present || hutch_present
2886
2782
  end
2887
2783
 
2888
2784
  def get_pyxis_version(deploy_id)
@@ -2970,24 +2866,20 @@ class Release
2970
2866
  end
2971
2867
 
2972
2868
  def import_dbs(ip_address)
2973
- resp = @ecs.run_task({
2974
- cluster: @ecs_cluster_name,
2975
- task_definition: @import_db_task,
2976
- overrides: {
2977
- container_overrides: [
2978
- {
2979
- name: 'dbrestore',
2980
- environment: [
2981
- {
2982
- name: 'EC2_IP_ADDRESS',
2983
- value: ip_address
2984
- }
2985
- ]
2986
- }
2987
- ]
2988
- },
2989
- count: 1
2990
- })
2869
+ overrides = {
2870
+ container_overrides: [
2871
+ {
2872
+ name: 'dbrestore',
2873
+ environment: [
2874
+ {
2875
+ name: 'EC2_IP_ADDRESS',
2876
+ value: ip_address
2877
+ }
2878
+ ]
2879
+ }
2880
+ ]
2881
+ }
2882
+ resp = run_ecs_task(@ecs_cluster_name, @import_db_task, overrides, 1)
2991
2883
  return resp
2992
2884
  end
2993
2885
 
@@ -3001,10 +2893,7 @@ class Release
3001
2893
  pp task
3002
2894
  stop_if true, "Task di import DB lanciato, ma risposta vuota!".red
3003
2895
  end
3004
- task = @ecs.describe_tasks({
3005
- cluster: task.tasks[0].cluster_arn,
3006
- tasks: [task.tasks[0].task_arn]
3007
- })
2896
+ task = describe_ecs_tasks(task.tasks[0].cluster_arn, [task.tasks[0].task_arn])
3008
2897
  stopped_at = task.tasks[0].stopped_at unless task.tasks[0].nil?
3009
2898
  sleep_seconds = 10
3010
2899
  seconds_elapsed = 0
@@ -3108,10 +2997,7 @@ class Release
3108
2997
  end
3109
2998
 
3110
2999
  def launch_marley(ip_address, prima_hostname, borat_hostname)
3111
- resp = @cf.describe_stack_resource({
3112
- stack_name: 'batch-job-marley',
3113
- logical_resource_id: 'JobDefinition'
3114
- })
3000
+ resp = describe_stack_resource('batch-job-marley', 'JobDefinition')
3115
3001
 
3116
3002
  @batch.submit_job({
3117
3003
  job_name: "marley-#{@dns_record_identifier}", # required
@@ -18,6 +18,14 @@ module PrimaAwsClient
18
18
  @ec2 ||= Aws::EC2::Client.new
19
19
  end
20
20
 
21
+ def alb_client
22
+ @alb ||= Aws::ElasticLoadBalancingV2::Client.new
23
+ end
24
+
25
+ def ecs_client
26
+ @ecs ||= Aws::ECS::Client.new
27
+ end
28
+
21
29
  def stack_list
22
30
  stacks = []
23
31
  next_token = ''
@@ -307,6 +315,91 @@ module PrimaAwsClient
307
315
  stacks
308
316
  end
309
317
 
318
+ def describe_stack_resource(cluster_stack_name, logical_resource_id)
319
+ begin
320
+ resp = cf_client.describe_stack_resource({stack_name: stack_name, logical_resource_id: logical_resource_id})
321
+ rescue Aws::CloudFormation::Errors::Throttling => e
322
+ output 'Throttling, retrying in 15 seconds'.red
323
+ sleep 15
324
+ resp = describe_stack_resource(cluster_stack_name, logical_resource_id)
325
+ end
326
+ end
327
+
328
+ def describe_instances(instance_ids)
329
+ begin
330
+ resp = ec2_client.describe_instances(instance_ids)
331
+ rescue Aws::CloudFormation::Errors::Throttling => e
332
+ output 'Throttling, retrying in 15 seconds'.red
333
+ sleep 15
334
+ resp = describe_instances(instance_ids)
335
+ end
336
+ end
337
+
338
+ def describe_auto_scaling_groups(auto_scaling_group_names, max_records)
339
+ begin
340
+ resp = asg_client.describe_auto_scaling_groups({
341
+ auto_scaling_group_names: auto_scaling_group_names,
342
+ max_records: max_records
343
+ })
344
+ rescue Aws::CloudFormation::Errors::Throttling => e
345
+ output 'Throttling, retrying in 15 seconds'.red
346
+ sleep 15
347
+ resp = describe_auto_scaling_groups(auto_scaling_group_names, max_records)
348
+ end
349
+ end
350
+
351
+ def describe_load_balancers(load_balancer_arns)
352
+ begin
353
+ resp = alb_client.describe_load_balancers({load_balancer_arns: load_balancer_arns})
354
+ rescue Aws::CloudFormation::Errors::Throttling => e
355
+ output 'Throttling, retrying in 15 seconds'.red
356
+ sleep 15
357
+ resp = describe_load_balancers(load_balancer_arns)
358
+ end
359
+ end
360
+
361
+ def update_ecs_service(cluster, service, deployment_configuration)
362
+ begin
363
+ resp = ecs_client.update_service(
364
+ cluster: cluster,
365
+ service: service,
366
+ deployment_configuration: deployment_configuration
367
+ )
368
+ rescue Aws::CloudFormation::Errors::Throttling => e
369
+ output 'Throttling, retrying in 15 seconds'.red
370
+ sleep 15
371
+ resp = update_ecs_service(cluster, service, deployment_configuration)
372
+ end
373
+ end
374
+
375
+ def describe_ecs_tasks(cluster, tasks)
376
+ begin
377
+ resp = ecs_client.describe_tasks({
378
+ cluster: cluster,
379
+ tasks: tasks
380
+ })
381
+ rescue Aws::CloudFormation::Errors::Throttling => e
382
+ output 'Throttling, retrying in 15 seconds'.red
383
+ sleep 15
384
+ resp = describe_ecs_tasks(cluster, tasks)
385
+ end
386
+ end
387
+
388
+ def run_ecs_task(cluster, task_definition, overrides, count)
389
+ begin
390
+ resp = ecs_client.run_task({
391
+ cluster: cluster,
392
+ task_definition: task_definition,
393
+ overrides: overrides,
394
+ count: count
395
+ })
396
+ rescue Aws::CloudFormation::Errors::Throttling => e
397
+ output 'Throttling, retrying in 15 seconds'.red
398
+ sleep 15
399
+ resp = run_ecs_task(cluster, task_definition, overrides, count)
400
+ end
401
+ end
402
+
310
403
  def get_autoscaling_capacity(asg_name)
311
404
  resp = asg_client.describe_auto_scaling_groups(auto_scaling_group_names: [asg_name])
312
405
  resp.auto_scaling_groups[0].desired_capacity
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prima-twig
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.56.10
4
+ version: 0.56.80
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matteo Giachino
@@ -14,7 +14,7 @@ authors:
14
14
  autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
- date: 2019-11-22 00:00:00.000000000 Z
17
+ date: 2019-11-25 00:00:00.000000000 Z
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
20
20
  name: aws-sdk
@@ -214,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
214
214
  - !ruby/object:Gem::Version
215
215
  version: '0'
216
216
  requirements: []
217
- rubygems_version: 3.0.3
217
+ rubygems_version: 3.0.1
218
218
  signing_key:
219
219
  specification_version: 4
220
220
  summary: The Prima twig toolbelt