Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
float
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container registry
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ai3
float
Commits
279445c2
Commit
279445c2
authored
3 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
Pass vmine group ID between review app jobs
parent
4820320e
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitlab-ci.yml
+10
-4
10 additions, 4 deletions
.gitlab-ci.yml
scripts/floatup.py
+25
-0
25 additions, 0 deletions
scripts/floatup.py
with
35 additions
and
4 deletions
.gitlab-ci.yml
+
10
−
4
View file @
279445c2
...
@@ -60,14 +60,21 @@ full_test:
...
@@ -60,14 +60,21 @@ full_test:
full_test_review
:
full_test_review
:
<<
:
*base_test
<<
:
*base_test
after_script
:
[]
after_script
:
-
with-ssh-key ./test-driver cleanup --no-vagrant $BUILD_DIR
variables
:
variables
:
VM_IMAGE
:
"
bullseye"
VM_IMAGE
:
"
bullseye"
CREATE_ENV_VARS
:
"
-e
config.float_debian_dist=bullseye
-e
inventory.group_vars.vagrant.ansible_python_interpreter=/usr/bin/python3"
CREATE_ENV_VARS
:
"
-e
config.float_debian_dist=bullseye
-e
inventory.group_vars.vagrant.ansible_python_interpreter=/usr/bin/python3"
FLOATUP_ARGS
:
"
--
ttl
6h
"
FLOATUP_ARGS
:
"
--
state-file
.vmine_group_review_$CI_MERGE_REQUEST_ID
--ttl
6h
--env
deploy.env
--dashboard-url
https://vm.investici.org
"
TEST_DIR
:
"
test/full.ref"
TEST_DIR
:
"
test/full.ref"
allow_failure
:
true
artifacts
:
reports
:
dotenv
:
deploy.env
paths
:
[
'
.vmine_group_review*'
]
environment
:
environment
:
name
:
review/$CI_COMMIT_REF_SLUG
name
:
review/$CI_COMMIT_REF_SLUG
url
:
$VMINE_GROUP_URL
on_stop
:
stop_full_test_review
on_stop
:
stop_full_test_review
auto_stop_in
:
"
6
hours"
auto_stop_in
:
"
6
hours"
rules
:
rules
:
...
@@ -77,8 +84,7 @@ stop_full_test_review:
...
@@ -77,8 +84,7 @@ stop_full_test_review:
stage
:
test
stage
:
test
image
:
registry.git.autistici.org/ai3/docker/float-runner:master
image
:
registry.git.autistici.org/ai3/docker/float-runner:master
script
:
script
:
-
with-ssh-key ./test-driver cleanup --no-vagrant $BUILD_DIR
-
with-ssh-key ./scripts/floatup.py --state-file .vmine_group_review_$CI_MERGE_REQUEST_ID ${LIBVIRT:+--ssh $LIBVIRT} down
-
with-ssh-key ./scripts/floatup.py ${LIBVIRT:+--ssh $LIBVIRT} down
allow_failure
:
true
allow_failure
:
true
environment
:
environment
:
name
:
review/$CI_COMMIT_REF_SLUG
name
:
review/$CI_COMMIT_REF_SLUG
...
...
This diff is collapsed.
Click to expand it.
scripts/floatup.py
+
25
−
0
View file @
279445c2
...
@@ -5,12 +5,14 @@
...
@@ -5,12 +5,14 @@
#
#
import
argparse
import
argparse
import
base64
import
json
import
json
import
os
import
os
import
re
import
re
import
shlex
import
shlex
import
subprocess
import
subprocess
import
yaml
import
yaml
import
zlib
# The Vagrant "insecure" SSH key that is used to log onto the VMs.
# The Vagrant "insecure" SSH key that is used to log onto the VMs.
...
@@ -76,6 +78,15 @@ def do_request(url, ssh_gw, payload):
...
@@ -76,6 +78,15 @@ def do_request(url, ssh_gw, payload):
raise
raise
def
encode_dashboard_request
(
req
):
# JSON data, in a raw zlib stream, base64-encoded.
hosts
=
sorted
(
req
[
'
hosts
'
],
key
=
lambda
x
:
x
[
'
name
'
])
data
=
json
.
dumps
(
hosts
,
separators
=
(
'
,
'
,
'
:
'
)).
encode
(
'
utf-8
'
)
comp
=
zlib
.
compressobj
(
level
=
9
,
wbits
=-
9
)
comp
.
compress
(
data
)
return
base64
.
urlsafe_b64encode
(
comp
.
flush
()).
decode
(
'
ascii
'
)
def
install_ssh_key
():
def
install_ssh_key
():
# Install the SSH key as Vagrant would do, for compatibility.
# Install the SSH key as Vagrant would do, for compatibility.
key_path
=
os
.
path
.
join
(
key_path
=
os
.
path
.
join
(
...
@@ -116,6 +127,12 @@ def main():
...
@@ -116,6 +127,12 @@ def main():
parser
.
add_argument
(
parser
.
add_argument
(
'
--ttl
'
,
metavar
=
'
DURATION
'
,
default
=
'
1h
'
,
'
--ttl
'
,
metavar
=
'
DURATION
'
,
default
=
'
1h
'
,
help
=
'
TTL for the virtual machines
'
)
help
=
'
TTL for the virtual machines
'
)
parser
.
add_argument
(
'
--env
'
,
metavar
=
'
FILE
'
,
help
=
'
generate a dotenv file (for Gitlab CI)
'
)
parser
.
add_argument
(
'
--dashboard-url
'
,
metavar
=
'
URL
'
,
help
=
'
vmine dashboard base URL (for Gitlab CI)
'
)
parser
.
add_argument
(
parser
.
add_argument
(
'
cmd
'
,
'
cmd
'
,
choices
=
[
'
up
'
,
'
down
'
])
choices
=
[
'
up
'
,
'
down
'
])
...
@@ -142,6 +159,14 @@ def main():
...
@@ -142,6 +159,14 @@ def main():
install_ssh_key
()
install_ssh_key
()
if
args
.
env
:
with
open
(
args
.
env
,
'
w
'
)
as
fd
:
fd
.
write
(
f
'
VMINE_ID=
{
group_id
}
\n
'
)
if
args
.
dashboard_url
:
base_url
=
args
.
dashboard_url
.
rstrip
(
'
/
'
)
payload
=
encode_dashboard_request
(
req
)
fd
.
write
(
f
'
VMINE_GROUP_URL=
{
base_url
}
/dash/
{
payload
}
\n
'
)
elif
args
.
cmd
==
'
down
'
:
elif
args
.
cmd
==
'
down
'
:
try
:
try
:
with
open
(
args
.
state_file
)
as
fd
:
with
open
(
args
.
state_file
)
as
fd
:
...
...
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