-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OpenShift support #33
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,4 +23,4 @@ jobs: | |
|
||
- name: Run functional tests | ||
run: | | ||
./ci/run_functional_tests.sh | ||
./ci/run_functional_tests_openstack.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: test-py39-functional-microshift | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Set up Python 3.9 | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: 3.9 | ||
|
||
- name: Install Microshift | ||
run: | | ||
./ci/microshift.sh | ||
|
||
- name: Install ColdFront and plugin | ||
run: | | ||
./ci/setup.sh | ||
|
||
- name: Run functional tests | ||
run: | | ||
./ci/run_functional_tests_openshift.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,42 @@ | ||
Vagrant.configure("2") do |config| | ||
config.vm.box = "generic/ubuntu2004" | ||
config.vm.synced_folder ".", "/home/vagrant/coldfront-plugin-openstack/" | ||
|
||
config.vm.network :private_network | ||
|
||
config.vm.provider "vmware_fusion" do |vb| | ||
vb.gui = false | ||
vb.memory = "9000" | ||
vb.cpus = "4" | ||
config.vm.define "openstack" do |openstack| | ||
openstack.vm.box = "generic/ubuntu2004" | ||
|
||
openstack.vm.provider "vmware_fusion" do |vb| | ||
vb.gui = false | ||
vb.memory = "9000" | ||
vb.cpus = "4" | ||
end | ||
|
||
openstack.vm.provision "shell", privileged: false, inline: <<-SHELL | ||
set -xe | ||
|
||
cd ~/coldfront-plugin-openstack | ||
./ci/devstack.sh | ||
./ci/setup.sh | ||
./ci/run_functional_tests.sh | ||
SHELL | ||
end | ||
|
||
config.vm.provision "shell", privileged: false, inline: <<-SHELL | ||
set -xe | ||
config.vm.define "openshift" do |openshift| | ||
openshift.vm.box = "generic/ubuntu2004" | ||
|
||
cd ~/coldfront-plugin-openstack | ||
./ci/devstack.sh | ||
./ci/setup.sh | ||
./ci/run_functional_tests.sh | ||
SHELL | ||
openshift.vm.provider "vmware_fusion" do |vb| | ||
vb.gui = false | ||
vb.memory = "4096" | ||
vb.cpus = "4" | ||
end | ||
|
||
openshift.vm.provision "shell", privileged: false, inline: <<-SHELL | ||
set -xe | ||
|
||
cd ~/coldfront-plugin-openstack | ||
./ci/microshift.sh | ||
./ci/setup.sh | ||
./ci/run_functional_tests_openshift.sh | ||
SHELL | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# | ||
# Installs Microshift on Docker | ||
# | ||
set -xe | ||
|
||
export ACCT_MGT_VERSION="e955158dc9fbd2a7aa68a8818fb7018315141d2b" | ||
|
||
sudo apt-get update && sudo apt-get upgrade -y | ||
|
||
if [[ ! "${CI}" == "true" ]]; then | ||
sudo apt-get install docker.io docker-compose python3-virtualenv -y | ||
fi | ||
|
||
echo '127.0.0.1 onboarding-onboarding.cluster.local' | sudo tee -a /etc/hosts | ||
|
||
sudo docker run -d --rm --name microshift --privileged \ | ||
--network host \ | ||
-v microshift-data:/var/lib \ | ||
quay.io/microshift/microshift-aio:latest | ||
|
||
sudo docker run -d --name registry --network host registry:2 | ||
|
||
curl -O "https://mirror.openshift.com/pub/openshift-v4/$(uname -m)/clients/ocp/stable/openshift-client-linux.tar.gz" | ||
sudo tar -xf openshift-client-linux.tar.gz -C /usr/local/bin oc kubectl | ||
|
||
mkdir ~/.kube | ||
sudo docker cp microshift:/var/lib/microshift/resources/kubeadmin/kubeconfig ~/.kube/config | ||
|
||
while ! oc get all -h; do | ||
echo "Waiting on Microshift" | ||
sleep 5 | ||
done | ||
|
||
# Install OpenShift Account Management | ||
git clone https://github.com/cci-moc/openshift-acct-mgt.git ~/openshift-acct-mgt | ||
cd ~/openshift-acct-mgt | ||
git checkout "$ACCT_MGT_VERSION" | ||
sudo docker build . -t "localhost:5000/cci-moc/openshift-acct-mgt:latest" | ||
sudo docker push "localhost:5000/cci-moc/openshift-acct-mgt:latest" | ||
|
||
oc apply -k k8s/overlays/crc | ||
oc wait -n onboarding --for=condition=available --timeout=800s deployment/onboarding | ||
|
||
sleep 60 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Creates the appropriate credentials and runs tests | ||
# | ||
# Tests expect the resource to be name Devstack | ||
set -xe | ||
|
||
export OPENSHIFT_MICROSHIFT_USERNAME="admin" | ||
export OPENSHIFT_MICROSHIFT_PASSWORD="pass" | ||
|
||
if [[ ! "${CI}" == "true" ]]; then | ||
source /tmp/coldfront_venv/bin/activate | ||
fi | ||
|
||
export DJANGO_SETTINGS_MODULE="local_settings" | ||
export FUNCTIONAL_TESTS="True" | ||
export OS_AUTH_URL="https://onboarding-onboarding.cluster.local" | ||
|
||
coldfront test coldfront_plugin_openstack.tests.functional.openshift |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
set -xe | ||
|
||
virtualenv -p python3 /tmp/coldfront_venv | ||
source /tmp/coldfront_venv/bin/activate | ||
# If running on Github actions, don't create a virtualenv | ||
if [[ ! "${CI}" == "true" ]]; then | ||
virtualenv -p python3 /tmp/coldfront_venv | ||
source /tmp/coldfront_venv/bin/activate | ||
fi | ||
|
||
pip3 install -r test-requirements.txt | ||
pip3 install -e . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/coldfront_plugin_openstack/management/commands/add_openshift_resource.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from django.core.management.base import BaseCommand | ||
from django.core.management import call_command | ||
|
||
from coldfront.core.resource.models import (Resource, | ||
ResourceAttribute, | ||
ResourceAttributeType, | ||
ResourceType) | ||
|
||
from coldfront_plugin_openstack import attributes | ||
|
||
|
||
class Command(BaseCommand): | ||
help = 'Create OpenShift resource' | ||
|
||
def add_arguments(self, parser): | ||
parser.add_argument('--name', type=str, required=True, | ||
help='Name of OpenShift resource') | ||
parser.add_argument('--auth-url', type=str, required=True, | ||
help='URL of the openshift-acct-mgt endpoint') | ||
parser.add_argument('--role', type=str, default='edit', | ||
help='Role for user when added to project (default: edit)') | ||
|
||
def handle(self, *args, **options): | ||
openshift, _ = Resource.objects.get_or_create( | ||
resource_type=ResourceType.objects.get(name='OpenShift'), | ||
parent_resource=None, | ||
name=options['name'], | ||
description='OpenShift cloud environment', | ||
is_available=True, | ||
is_public=True, | ||
is_allocatable=True | ||
) | ||
|
||
ResourceAttribute.objects.get_or_create( | ||
resource_attribute_type=ResourceAttributeType.objects.get( | ||
name=attributes.RESOURCE_AUTH_URL), | ||
resource=openshift, | ||
value=options['auth_url'] | ||
) | ||
ResourceAttribute.objects.get_or_create( | ||
resource_attribute_type=ResourceAttributeType.objects.get( | ||
name=attributes.RESOURCE_ROLE), | ||
resource=openshift, | ||
value=options['role'] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be pinned to a particular version? Otherwise changes in
openshift-acct-mgr
could cause CI on this repository to break. Ideally we'd simply use a tagged image from a hosted repository (docker/quay/ghcr/etc), but even if we can't do that pinning to a particular commit or tag might be a good idea.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. I'd rather not, since the two systems are likely to be deployed separately, and this forces us to not break compatibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's my concern, in case I wasn't clear:
In the current state, because we're pulling straight from the main branch of
openshift-acct-mgt
, we could end up with failing CI here just becauseopenshift-acct-mgt
is broken. By pinning to a specific known-good version we avoid that problem.This way we're testing the code in this repository, rather than also testing the code in a dependent repository.
Does that change your mind at all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My mind was already changed, I was just being lazy. Ideally we would have a release process for
openshift-acct-mgt
and pin to a release that already has a published docker container rather than build. For now it should be enough to pin to a commit hash. I'll revise.