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
8f639094
Commit
8f639094
authored
2 years ago
by
istmxrein
Browse files
Options
Downloads
Patches
Plain Diff
wip: test timeout for server creation
parent
d4aff0f5
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
cleanup.py
+19
-1
19 additions, 1 deletion
cleanup.py
env.py
+1
-0
1 addition, 0 deletions
env.py
prepare.py
+19
-15
19 additions, 15 deletions
prepare.py
with
39 additions
and
16 deletions
cleanup.py
+
19
−
1
View file @
8f639094
...
...
@@ -10,17 +10,35 @@ def main() -> None:
print
(
"
Delete openstack instances
"
,
flush
=
True
)
try
:
conn
=
openstack
.
connect
()
for
server
in
conn
.
compute
.
servers
(
name
=
env
.
VM_NAME
):
volumes
=
server
.
list_volumes
()
for
i
in
range
(
5
):
conn
.
delete_server
(
server
.
id
,
delete_ips
=
True
)
time
.
sleep
(
5
)
state
=
conn
.
compute
.
find_server
(
server
.
id
,
ignore_missing
=
True
)
if
state
is
None
:
print
(
f
'
Delete server
{
server
.
id
}
successful
'
)
print
(
f
'
Delete server
{
server
.
id
}
successful
'
,
flush
=
True
)
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
)
return
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
)
print
(
f
"
Unable to delete volume with ID
{
volume
.
id
}
after 5 minutes
"
,
flush
=
True
)
if
os
.
path
.
exists
(
env
.
PRIVATE_KEY_PATH
):
os
.
remove
(
env
.
PRIVATE_KEY_PATH
)
conn
.
delete_keypair
(
env
.
KEY_PAIR_NAME
)
conn
.
close
()
except
Exception
as
e
:
traceback
.
print_exc
()
...
...
This diff is collapsed.
Click to expand it.
env.py
+
1
−
0
View file @
8f639094
...
...
@@ -14,3 +14,4 @@ FLOATING_IP_NETWORK = os.getenv("FLOATING_IP_NETWORK") or "public"
SSH_IP_VERSION
=
os
.
getenv
(
"
SSH_IP_VERSION
"
)
or
"
4
"
BUILD_FAILURE_EXIT_CODE
=
os
.
getenv
(
"
BUILD_FAILURE_EXIT_CODE
"
)
SYSTEM_FAILURE_EXIT_CODE
=
os
.
getenv
(
"
SYSTEM_FAILURE_EXIT_CODE
"
)
SERVER_CREATION_TIMEOUT
=
os
.
getenv
(
"
SERVER_CREATION_TIMEOUT
"
)
or
"
180
"
This diff is collapsed.
Click to expand it.
prepare.py
+
19
−
15
View file @
8f639094
...
...
@@ -23,21 +23,25 @@ def provision_server(
image
=
conn
.
compute
.
find_image
(
env
.
BUILDER_IMAGE
)
flavor
=
conn
.
compute
.
find_flavor
(
env
.
FLAVOR
)
network
=
conn
.
network
.
find_network
(
env
.
NETWORK
)
server
=
conn
.
create_server
(
name
=
env
.
VM_NAME
,
flavor
=
flavor
.
id
,
image
=
image
.
id
,
boot_from_volume
=
True
,
terminate_volume
=
True
,
wait
=
True
,
timeout
=
300
,
volume_size
=
env
.
VOLUME_SIZE
,
key_name
=
env
.
KEY_PAIR_NAME
,
security_groups
=
[
group
for
group
in
env
.
SECURITY_GROUPS
.
split
()],
network
=
network
.
id
)
try
:
server
=
conn
.
create_server
(
name
=
env
.
VM_NAME
,
flavor
=
flavor
.
id
,
image
=
image
.
id
,
boot_from_volume
=
True
,
terminate_volume
=
True
,
volume_size
=
env
.
VOLUME_SIZE
,
key_name
=
env
.
KEY_PAIR_NAME
,
security_groups
=
[
group
for
group
in
env
.
SECURITY_GROUPS
.
split
()],
network
=
network
.
id
)
except
openstack
.
exceptions
.
SDKException
as
e
:
print
(
e
,
flush
=
True
)
except
Exception
as
e
:
print
(
e
,
flush
=
True
)
server
=
conn
.
wait_for_server
(
server
,
timeout
=
180
)
print
(
f
'
Waiting for server to come up...
'
)
server
=
conn
.
wait_for_server
(
server
,
timeout
=
int
(
env
.
SERVER_CREATION_TIMEOUT
))
return
server
...
...
@@ -104,7 +108,6 @@ def generate_rsa_keypair():
with
open
(
env
.
PRIVATE_KEY_PATH
,
'
w
'
)
as
content_file
:
content_file
.
write
(
pem
.
decode
(
'
utf-8
'
))
public_key_str
=
public_key
.
decode
(
'
utf-8
'
)
print
(
f
'
Public Key:
{
public_key_str
}
'
)
return
public_key_str
...
...
@@ -118,6 +121,7 @@ def main() -> None:
conn
=
openstack
.
connect
()
print
(
f
"
Provisioning an instance
{
env
.
VM_NAME
}
"
,
flush
=
True
)
public_key
=
generate_rsa_keypair
()
print
(
f
'
Public Key:
{
public_key
}
'
,
flush
=
True
)
server
=
provision_server
(
conn
,
public_key
)
ip
=
get_server_ip
(
conn
,
server
)
print
(
f
"
Instance
{
env
.
VM_NAME
}
is running on address
{
ip
}
"
,
flush
=
True
)
...
...
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