Skip to content

Commit

Permalink
Added native driver and redesigned the image management logic (#46)
Browse files Browse the repository at this point in the history
Besides adding the new Native driver for MacOS this change also changes the image definition process of the VMX and Docker drivers.

* Native driver was added! It's as usual supports only macos for now, but adding to the other systems should not be so hard. It uses the node description to get the identifiers (configurable) which should be used by the Labels to find the appropriate fish node to execute on.
* **BREAKING**: VMX and Docker now uses a bit different way to specify the Label definition images, so the Labels need to be updated. But as an advantage now it supports checksum to verify the image!
* Added node filter and node identifiers for easy selecting where to execute the workload. It's common for all the drivers so can be used for VMX to run macos on macos or to run arm64 on arm64.
* Switched examples to YAML representation - now it's readability is better
* A number of fixes:
   * Fixed AWS startup issue - messed up gt with lt as usual
   * Replaced ioutil usage since deprecated as of go v1.16
   * Replaced all `interface{}` to `any`
   * Fixed YAML user interface introduced in #48 - now it properly handled
   * Added UID references validation, previously they was handled automatically but after migration from dqlite that was lost
  • Loading branch information
sparshev authored Apr 16, 2023
1 parent b9cf5c9 commit 169c4ac
Show file tree
Hide file tree
Showing 69 changed files with 2,630 additions and 581 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ jobs:
fetch-depth: 0 # To get all the tags for versioning

- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: 1.18
go-version-file: go.mod

- name: Build
run: RELEASE=1 ./build.sh
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ jobs:
fetch-depth: 0 # To get all the tags for versioning

- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: 1.18
go-version-file: go.mod

- name: Build
run: RELEASE=1 ./build.sh
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ clouds, etc.) to one entry point of allocating devices which can be used across

## Requirements

In general it can be built for any OS/architecture but for now the primary ones are:
In general it can be built and used on any OS/architecture but for now the primary ones are:
* MacOS
* Linux

Expand Down
25 changes: 25 additions & 0 deletions docs/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,8 @@ components:
# TODO: in OAPI v3.1.0 siblings: $ref: '#/components/schemas/LabelUID'
type: string
format: uuid
x-oapi-codegen-extra-tags:
yaml: label_UID
metadata:
x-go-type: util.UnparsedJson
description: Additional metadata in JSON format (can't override Label metadata)
Expand Down Expand Up @@ -1038,6 +1040,8 @@ components:
# TODO: in OAPI v3.1.0 siblings: $ref: '#/components/schemas/ApplicationUID'
type: string
format: uuid
x-oapi-codegen-extra-tags:
yaml: application_UID
status:
$ref: '#/components/schemas/ApplicationStatus'
description:
Expand Down Expand Up @@ -1082,6 +1086,8 @@ components:
# TODO: in OAPI v3.1.0 siblings: $ref: '#/components/schemas/ApplicationUID'
type: string
format: uuid
x-oapi-codegen-extra-tags:
yaml: application_UID
task:
type: string
description: Identifier of the task
Expand Down Expand Up @@ -1284,6 +1290,7 @@ components:
- ram
- disks
- network
- node_filter
- multitenancy
- cpu_overbook
- ram_overbook
Expand All @@ -1306,6 +1313,15 @@ components:
network:
type: string
description: Which network configuration to use for the environment
node_filter:
type: array
items:
type: string
description: The list of the Node identifiers to run resource on, supports path wildcards
example:
- OS:darwin
- OSVersion:12.*
- Arch:x86_64
multitenancy:
type: boolean
description: Tolerate to run along with the other envs on the same node
Expand Down Expand Up @@ -1465,14 +1481,20 @@ components:
# TODO: in OAPI v3.1.0 siblings: $ref: '#/components/schemas/ApplicationUID'
type: string
format: uuid
x-oapi-codegen-extra-tags:
yaml: application_UID
node_UID:
# TODO: in OAPI v3.1.0 siblings: $ref: '#/components/schemas/NodeUID'
type: string
format: uuid
x-oapi-codegen-extra-tags:
yaml: node_UID
label_UID:
# TODO: in OAPI v3.1.0 siblings: $ref: '#/components/schemas/LabelUID'
type: string
format: uuid
x-oapi-codegen-extra-tags:
yaml: label_UID
definition_index:
type: integer
identifier:
Expand Down Expand Up @@ -1531,12 +1553,14 @@ components:
type: string
format: uuid
x-oapi-codegen-extra-tags:
yaml: application_UID
gorm: uniqueIndex:idx_node_app_round_uniq
node_UID:
# TODO: in OAPI v3.1.0 siblings: $ref: '#/components/schemas/NodeUID'
type: string
format: uuid
x-oapi-codegen-extra-tags:
yaml: node_UID
gorm: uniqueIndex:idx_node_app_round_uniq
round:
x-go-type: uint16
Expand Down Expand Up @@ -1625,6 +1649,7 @@ components:
format: uuid
description: Optional, if need to override the cluster-wide redirects
x-oapi-codegen-extra-tags:
yaml: application_UID
gorm: uniqueIndex:idx_location_service_app_uniq

securitySchemes:
Expand Down
46 changes: 21 additions & 25 deletions examples/create_label-aws-ubuntu2004.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,30 +34,26 @@ echo "Create the new version of Label '$label:$new_version' ?"
echo "Press any key to create or Ctrl-C to abort"
read w1

label_id=$(curl -s -u "admin:$token" -k -X POST -H 'Content-Type: application/json' -d '{"name":"'$label'", "version":'$new_version',
"definitions": [{
"driver":"aws",
"options": {
"image": "ami-0aab355e1bfa1e72e",
"instance_type": "c6a.4xlarge",
"security_group": "test-sec-group",
"userdata_format": "env"
},
"resources": {
"cpu": 16,
"ram": 32,
"disks": {
"/dev/sdc": {
"label": "Name:workspace_lin",
"size": 100
}
},
"network": "Name:test-vpc"
}
}],
"metadata": {
"JENKINS_AGENT_WORKSPACE": "/mnt/workspace"
}
}' "https://$hostport/api/v1/label/" | grep -o '"UID": *"[^"]\+"' | cut -d':' -f 2 | tr -d ' "')
label_id=$(curl -s -u "admin:$token" -k -X POST -H 'Content-Type: application/yaml' -d '---
name: "'$label'"
version: '$new_version'
definitions:
- driver: aws
options:
image: ami-0aab355e1bfa1e72e
instance_type: c6a.4xlarge
security_group: test-sec-group
userdata_format: env
resources:
cpu: 16
ram: 32
disks:
/dev/sdc:
label: Name:workspace_lin
size: 10
network: Name:test-vpc
metadata:
JENKINS_AGENT_WORKSPACE: /mnt/workspace
' "https://$hostport/api/v1/label/" | grep -o '"UID": *"[^"]\+"' | cut -d':' -f 2 | tr -d ' "')

echo "Created Label ID: ${label_id}"
48 changes: 21 additions & 27 deletions examples/create_label-docker-ubuntu2004-python3-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,32 +34,26 @@ echo "Create the new version of Label '$label:$new_version' ?"
echo "Press any key to create or Ctrl-C to abort"
read w1

label_id=$(curl -s -u "admin:$token" -k -X POST -H 'Content-Type: application/json' -d '{"name":"'$label'", "version":'$new_version',
"definitions": [{
"driver":"docker",
"options": {
"image": "ubuntu2004-python3-ci",
"images": {
"ubuntu2004": "https://artifact-storage/aquarium/image/docker/ubuntu2004/ubuntu2004-VERSION.tar.xz",
"ubuntu2004-python3": "https://artifact-storage/aquarium/image/docker/ubuntu2004-python3/ubuntu2004-python3-VERSION.tar.xz",
"ubuntu2004-python3-ci": "https://artifact-storage/aquarium/image/docker/ubuntu2004-python3-ci/ubuntu2004-python3-ci-VERSION.tar.xz"
}
},
"resources": {
"cpu": 4,
"ram": 4,
"disks": {
"python3": {
"type": "hfs+",
"size": 10
}
},
"network": "nat"
}
}],
"metadata": {
"JENKINS_AGENT_WORKSPACE": "/mnt/python3"
}
}' "https://$hostport/api/v1/label/" | grep -o '"UID": *"[^"]\+"' | cut -d':' -f 2 | tr -d ' "')
label_id=$(curl -s -u "admin:$token" -k -X POST -H 'Content-Type: application/yaml' -d '---
name: "'$label'"
version: '$new_version'
definitions:
- driver: docker
options:
images: # For test purposes images are used as symlink to aquarium-bait/out so does not need checksum
- url: https://artifact-storage/aquarium/image/docker/ubuntu2004/ubuntu2004-VERSION.tar.xz
- url: https://artifact-storage/aquarium/image/docker/ubuntu2004-python3/ubuntu2004-python3-VERSION.tar.xz
- url: https://artifact-storage/aquarium/image/docker/ubuntu2004-python3-ci/ubuntu2004-python3-ci-VERSION.tar.xz
resources:
cpu: 4
ram: 4
disks:
python3:
type: hfs+
size: 10
network: nat
metadata:
JENKINS_AGENT_WORKSPACE: "/mnt/python3"
' "https://$hostport/api/v1/label/" | grep -o '"UID": *"[^"]\+"' | cut -d':' -f 2 | tr -d ' "')

echo "Created Label ID: ${label_id}"
81 changes: 35 additions & 46 deletions examples/create_label-multi-ubuntu2004.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,51 +34,40 @@ echo "Create the new version of Label '$label:$new_version' ?"
echo "Press any key to create or Ctrl-C to abort"
read w1

label_id=$(curl -s -u "admin:$token" -k -X POST -H 'Content-Type: application/json' -d '{"name":"'$label'", "version":'$new_version',
"definitions": [{
"driver":"docker",
"options": {
"image": "ubuntu2004-python3-ci",
"images": {
"ubuntu2004": "https://artifact-storage/aquarium/image/docker/ubuntu2004/ubuntu2004-VERSION.tar.xz",
"ubuntu2004-python3": "https://artifact-storage/aquarium/image/docker/ubuntu2004-python3/ubuntu2004-python3-VERSION.tar.xz",
"ubuntu2004-python3-ci": "https://artifact-storage/aquarium/image/docker/ubuntu2004-python3-ci/ubuntu2004-python3-ci-VERSION.tar.xz"
}
},
"resources": {
"cpu": 4,
"ram": 8,
"disks": {
"python3": {
"type": "hfs+",
"size": 10
}
},
"network": "nat"
}
}, {
"driver":"aws",
"options": {
"image": "ami-0aab355e1bfa1e72e",
"instance_type": "c6a.xlarge",
"security_group": "test-sec-group",
"userdata_format": "env"
},
"resources": {
"cpu": 4,
"ram": 8,
"disks": {
"/dev/sdc": {
"label": "Name:workspace_lin",
"size": 100
}
},
"network": "Name:test-vpc"
}
}],
"metadata": {
"JENKINS_AGENT_WORKSPACE": "/mnt/workspace"
}
}' "https://$hostport/api/v1/label/" | grep -o '"UID": *"[^"]\+"' | cut -d':' -f 2 | tr -d ' "')
label_id=$(curl -s -u "admin:$token" -k -X POST -H 'Content-Type: application/yaml' -d '---
name: "'$label'"
version: '$new_version'
definitions:
- driver: docker
options:
images: # For test purposes images are used as symlink to aquarium-bait/out so does not need checksum
- url: https://artifact-storage/aquarium/image/docker/ubuntu2004/ubuntu2004-VERSION.tar.xz
- url: https://artifact-storage/aquarium/image/docker/ubuntu2004-python3/ubuntu2004-python3-VERSION.tar.xz
- url: https://artifact-storage/aquarium/image/docker/ubuntu2004-python3-ci/ubuntu2004-python3-ci-VERSION.tar.xz
resources:
cpu: 4
ram: 8
disks:
python3:
type: hfs+
size: 10
network: nat
- driver: aws
options:
image: ami-0aab355e1bfa1e72e
instance_type: c6a.xlarge
security_group: test-sec-group
userdata_format: env
resources:
cpu: 4
ram: 8
disks:
"/dev/sdc":
label: Name:workspace_lin
size: 10
network: Name:test-vpc
metadata:
JENKINS_AGENT_WORKSPACE: "/mnt/workspace"
' "https://$hostport/api/v1/label/" | grep -o '"UID": *"[^"]\+"' | cut -d':' -f 2 | tr -d ' "')

echo "Created Label ID: ${label_id}"
66 changes: 66 additions & 0 deletions examples/create_label-native-mac12-ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/bin/sh -e
# Copyright 2023 Adobe. All rights reserved.
# This file is licensed to you under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. You may obtain a copy
# of the License at http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software distributed under
# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
# OF ANY KIND, either express or implied. See the License for the specific language
# governing permissions and limitations under the License.

#
# This example script allows to see the existing Label and create a new version of it
# Please check the images URLs in Label definitions below
#

token=$1
[ "$token" ] || exit 1
hostport=$2
[ "$hostport" ] || hostport=localhost:8001

label=mac12_native

# It's a bit dirty, but works for now - probably better to create API call to find the latest label
curr_label=$(curl -s -u "admin:$token" -k "https://$hostport/api/v1/label/?filter=name=\"$label\"" | sed 's/},{/},\n{/g' | tail -1)
curr_version="$(echo "$curr_label" | grep -o '"version": *[0-9]\+' | tr -dc '0-9')"
echo "Current label '$label:$curr_version': $curr_label"

[ "x$curr_version" != "x" ] || curr_version=0
new_version=$(($curr_version+1))

echo
echo "Create the new version of Label '$label:$new_version' ?"
echo "Press any key to create or Ctrl-C to abort"
read w1

label_id=$(curl -s -u "admin:$token" -k -X POST -H 'Content-Type: application/yaml' -d '---
name: "'$label'"
version: '$new_version'
definitions:
- driver: native
options:
images: # For test purposes images are used as symlink to aquarium-bait/out so does not need checksum
- url: https://artifact-storage/aquarium/image/native/mac/mac-VERSION.tar.xz
tag: ws
- url: https://artifact-storage/aquarium/image/native/mac-ci/mac-ci-VERSION.tar.xz
tag: ws
groups:
- staff
entry: "{{ .Disks.ws }}/init.sh"
resources:
node_filter:
- OS:darwin
- OSVersion:12.*
- Arch:x86_64
cpu: 4
ram: 8
disks:
ws:
size: 10
network: Name:test-vpc
metadata:
JENKINS_AGENT_WORKSPACE: "{{ .Disks.ws }}"
' "https://$hostport/api/v1/label/" | grep -o '"UID": *"[^"]\+"' | cut -d':' -f 2 | tr -d ' "')

echo "Created Label ID: ${label_id}"
Loading

0 comments on commit 169c4ac

Please sign in to comment.