Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
akinaka
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
12
Issues
12
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
olindata
akinaka
Commits
3c5cae99
Verified
Commit
3c5cae99
authored
Sep 19, 2019
by
Afraz Ahmadzadeh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ASG updates now respect current scale
parent
4e898190
Pipeline
#2185
failed with stages
in 53 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
7 deletions
+16
-7
akinaka_update/asg/update_asg.py
akinaka_update/asg/update_asg.py
+15
-6
setup.py
setup.py
+1
-1
No files found.
akinaka_update/asg/update_asg.py
View file @
3c5cae99
...
...
@@ -20,12 +20,7 @@ class ASG():
self
.
role_arn
=
role_arn
self
.
asg
=
asg
self
.
target_group
=
target_group
if
not
scale_to
:
asg_client
=
aws_client
.
create_client
(
'autoscaling'
,
self
.
region
,
self
.
role_arn
)
asg
=
asg_client
.
describe_auto_scaling_groups
(
AutoScalingGroupNames
=
[
self
.
asg
])[
'AutoScalingGroups'
][
0
]
self
.
scale_to
=
scale_to
if
scale_to
else
asg
[
'DesiredCapacity'
]
self
.
scale_to
=
scale_to
if
scale_to
else
None
def
get_application_name
(
self
):
"""
...
...
@@ -60,6 +55,8 @@ class ASG():
logging
.
info
(
"New ASG was worked out as {}. Now updating it's Launch Template"
.
format
(
new_asg
))
self
.
update_launch_template
(
new_asg
,
new_ami
,
self
.
get_lt_name
(
new_asg
))
self
.
scale_to
=
self
.
get_current_scale
(
new_asg
)
logging
.
info
(
"Scaling ASG down"
)
self
.
scale
(
new_asg
,
0
,
0
,
0
)
while
not
self
.
asg_is_empty
(
new_asg
):
...
...
@@ -276,6 +273,18 @@ class ASG():
return
response
def
get_current_scale
(
self
,
asg
):
"""
Gets the current scale of the given ASG, presuming that min, max, and desired
are all the same
"""
if
not
self
.
scale_to
:
asg_client
=
aws_client
.
create_client
(
'autoscaling'
,
self
.
region
,
self
.
role_arn
)
asg
=
asg_client
.
describe_auto_scaling_groups
(
AutoScalingGroupNames
=
[
asg
])[
'AutoScalingGroups'
][
0
]
return
asg
[
'DesiredCapacity'
]
def
get_auto_scaling_group_instances
(
self
,
auto_scaling_group_id
,
instance_ids
=
None
):
asg_client
=
aws_client
.
create_client
(
'autoscaling'
,
self
.
region
,
self
.
role_arn
)
instance_ids
=
instance_ids
if
instance_ids
else
[]
...
...
setup.py
View file @
3c5cae99
...
...
@@ -6,7 +6,7 @@ with open("README.md", "r") as fh:
setuptools
.
setup
(
name
=
"akinaka"
,
python_requires
=
'>=3.3.0'
,
version
=
"0.2.2
8
"
,
version
=
"0.2.2
9
"
,
author
=
"Afraz"
,
author_email
=
"afraz@olindata.com"
,
description
=
"OlinData's aws cli Extras"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment