Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
Openstack Gitlab Executor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pi-Lab
Infrastructure
Openstack Gitlab Executor
Commits
b0df83e4
Commit
b0df83e4
authored
2 years ago
by
istmxrein
Browse files
Options
Downloads
Patches
Plain Diff
fix preparation state
parent
b965df5d
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cleanup.py
+0
-16
0 additions, 16 deletions
cleanup.py
prepare.py
+12
-16
12 additions, 16 deletions
prepare.py
with
12 additions
and
32 deletions
cleanup.py
+
0
−
16
View file @
b0df83e4
...
@@ -10,9 +10,7 @@ def main() -> None:
...
@@ -10,9 +10,7 @@ def main() -> None:
print
(
"
Delete openstack instances
"
,
flush
=
True
)
print
(
"
Delete openstack instances
"
,
flush
=
True
)
try
:
try
:
conn
=
openstack
.
connect
()
conn
=
openstack
.
connect
()
for
server
in
conn
.
compute
.
servers
(
name
=
env
.
VM_NAME
):
for
server
in
conn
.
compute
.
servers
(
name
=
env
.
VM_NAME
):
volumes
=
server
.
attached_volumes
for
i
in
range
(
5
):
for
i
in
range
(
5
):
conn
.
delete_server
(
server
.
id
,
delete_ips
=
True
)
conn
.
delete_server
(
server
.
id
,
delete_ips
=
True
)
time
.
sleep
(
5
)
time
.
sleep
(
5
)
...
@@ -20,24 +18,10 @@ def main() -> None:
...
@@ -20,24 +18,10 @@ def main() -> None:
if
state
is
None
:
if
state
is
None
:
print
(
f
'
Delete server
{
server
.
id
}
successful
'
,
flush
=
True
)
print
(
f
'
Delete server
{
server
.
id
}
successful
'
,
flush
=
True
)
break
break
for
volume
in
volumes
:
start_time
=
time
.
time
()
while
time
.
time
()
-
start_time
<
300
:
# Keep trying for up to 5 minutes
try
:
if
conn
.
block_storage
.
find_volume
(
volume
.
id
):
conn
.
block_storage
.
delete_volume
(
volume
.
id
)
print
(
f
"
Successfully deleted volume with ID
{
volume
.
id
}
"
,
flush
=
True
)
break
except
openstack
.
exceptions
.
SDKException
as
e
:
print
(
f
"
Error deleting volume with ID
{
volume
.
id
}
:
{
e
}
"
,
flush
=
True
)
print
(
"
Retrying in 10 seconds...
"
,
flush
=
True
)
time
.
sleep
(
10
)
if
os
.
path
.
exists
(
env
.
PRIVATE_KEY_PATH
):
if
os
.
path
.
exists
(
env
.
PRIVATE_KEY_PATH
):
os
.
remove
(
env
.
PRIVATE_KEY_PATH
)
os
.
remove
(
env
.
PRIVATE_KEY_PATH
)
conn
.
delete_keypair
(
env
.
KEY_PAIR_NAME
)
conn
.
delete_keypair
(
env
.
KEY_PAIR_NAME
)
conn
.
close
()
conn
.
close
()
except
Exception
as
e
:
except
Exception
as
e
:
traceback
.
print_exc
()
traceback
.
print_exc
()
...
...
This diff is collapsed.
Click to expand it.
prepare.py
+
12
−
16
View file @
b0df83e4
...
@@ -23,25 +23,21 @@ def provision_server(
...
@@ -23,25 +23,21 @@ def provision_server(
image
=
conn
.
compute
.
find_image
(
env
.
BUILDER_IMAGE
)
image
=
conn
.
compute
.
find_image
(
env
.
BUILDER_IMAGE
)
flavor
=
conn
.
compute
.
find_flavor
(
env
.
FLAVOR
)
flavor
=
conn
.
compute
.
find_flavor
(
env
.
FLAVOR
)
network
=
conn
.
network
.
find_network
(
env
.
NETWORK
)
network
=
conn
.
network
.
find_network
(
env
.
NETWORK
)
try
:
server
=
conn
.
create_server
(
server
=
conn
.
create_server
(
name
=
env
.
VM_NAME
,
name
=
env
.
VM_NAME
,
flavor
=
flavor
.
id
,
flavor
=
flavor
.
id
,
image
=
image
.
id
,
image
=
image
.
id
,
boot_from_volume
=
True
,
boot_from_volume
=
True
,
terminate_volume
=
True
,
terminate_volume
=
True
,
volume_size
=
env
.
VOLUME_SIZE
,
volume_size
=
env
.
VOLUME_SIZE
,
key_name
=
env
.
KEY_PAIR_NAME
,
key_name
=
env
.
KEY_PAIR_NAME
,
security_groups
=
[
group
for
group
in
env
.
SECURITY_GROUPS
.
split
()],
security_groups
=
[
group
for
group
in
env
.
SECURITY_GROUPS
.
split
()],
network
=
network
.
id
network
=
network
.
id
)
)
except
openstack
.
exceptions
.
SDKException
as
e
:
print
(
e
,
flush
=
True
)
except
Exception
as
e
:
print
(
e
,
flush
=
True
)
print
(
f
'
Waiting for server to come up...
'
)
print
(
f
'
Waiting for server to come up...
'
)
server
=
conn
.
wait_for_server
(
server
,
timeout
=
int
(
env
.
SERVER_CREATION_TIMEOUT
))
server
=
conn
.
wait_for_server
(
server
,
timeout
=
int
(
env
.
SERVER_CREATION_TIMEOUT
))
return
server
return
server
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment