Skip to content
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

Remove more kurono #328

Merged
merged 4 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 1 addition & 50 deletions .github/actions/deploy_gcloud/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Deploy to Google Cloud
description: Deploys portal, rapid-router and aimmo to Google Cloud
description: Deploys portal and rapid-router to Google Cloud
inputs:
app-id:
description: App ID
Expand Down Expand Up @@ -76,10 +76,6 @@ inputs:
react-app-kurono-badges-url:
description: URL for Kurono badges service
required: true
aimmo-branch:
description: Optional rapid-router branch to deploy
default: ""
required: false
portal-branch:
description: Optional portal branch to deploy
default: ""
Expand Down Expand Up @@ -125,34 +121,6 @@ runs:
pip install -t lib django-anymail[amazon_ses]
pip install -t lib google-auth==1.*
# Install aimmo
if [[ $MODULE_NAME = "default" ]]; then
pip install -t lib --upgrade --no-deps aimmo
else
if [[ -z $AIMMO_BRANCH ]]; then
pip install -t lib --pre --upgrade --no-deps aimmo
else
REQUIREMENTS_ARGS+="--aimmo-branch ${AIMMO_BRANCH} "
git clone --depth 1 --branch ${AIMMO_BRANCH} https://github.com/ocadotechnology/aimmo.git
pushd aimmo
pip install wheel
./aimmo_runner/build_worker_wheel.sh
popd
pushd aimmo/game_frontend
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
nvm install 12.20.2
nvm use 12.20.2
yarn --frozen-lockfile
NODE_ENV=production node djangoBundler.js
popd
pip install -t lib --pre --upgrade --no-deps ./aimmo
fi
fi
# Install custom common package after everything else if deploying a specific portal branch to ensure the
# changes from common come through
Expand All @@ -166,26 +134,10 @@ runs:
./manage.py collectstatic --noinput --settings django_site.pipeline_settings
env:
MODULE_NAME: ${{ inputs.module-name }}
AIMMO_BRANCH: ${{ inputs.aimmo-branch }}
PORTAL_BRANCH: ${{ inputs.portal-branch }}
RAPID_ROUTER_BRANCH: ${{ inputs.rapid-router-branch }}
shell: bash

- name: "Get cluster credentials"
run: |
gcloud components install gke-gcloud-auth-plugin
gcloud container clusters get-credentials "aimmo-$MODULE_NAME" --zone "$GKE_ZONE"
env:
MODULE_NAME: ${{ inputs.module-name }}
GKE_ZONE: ${{ inputs.gke-zone }}
shell: bash

- name: "Deploy k8s"
run: python clusters_setup/deploy.py $MODULE_NAME
env:
MODULE_NAME: ${{ inputs.module-name }}
shell: bash

- name: "Deploy"
run: |
# Install Cloud SQL Proxy - Fixing to version 1.32.0 for now as upgrading to 1.33.0 causes an error when pinging the server later
Expand Down Expand Up @@ -214,7 +166,6 @@ runs:
exit 1
fi
envsubst <django_site/kubeconfig.yaml.tmpl >django_site/kubeconfig.yaml
envsubst <app.yaml.tmpl >app.yaml
./manage.py migrate --no-input
Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/deploy_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ name: Deploy to Dev
on:
workflow_dispatch:
inputs:
aimmo-branch:
description: "aimmo branch"
required: false
default: ""
portal-branch:
description: "portal branch"
required: false
Expand Down Expand Up @@ -83,7 +79,6 @@ jobs:
redis-ip: ${{ secrets.REDIS_IP }}
redis-port: ${{ secrets.REDIS_PORT }}
react-app-kurono-badges-url: ${{ secrets.REACT_APP_KURONO_BADGES_URL }}
aimmo-branch: ${{ github.event.inputs.aimmo-branch }}
portal-branch: ${{ github.event.inputs.portal-branch }}
rapid-router-branch: ${{ github.event.inputs.rapid-router-branch }}

Expand All @@ -92,7 +87,6 @@ jobs:
run: ./notify_deployment.py
env:
DEPLOY_NOTIFY_URL: ${{ secrets.DEPLOY_NOTIFY_URL }}
AIMMO_BRANCH: ${{ github.event.inputs.aimmo-branch }}
PORTAL_BRANCH: ${{ github.event.inputs.portal-branch }}
RAPID_ROUTER_BRANCH: ${{ github.event.inputs.rapid-router-branch }}

Expand Down
1 change: 0 additions & 1 deletion app.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,3 @@ env_variables:
AWS_ACCESS_KEY_ID: '${AWS_ACCESS_KEY_ID}'
AWS_SECRET_ACCESS_KEY: '${AWS_SECRET_ACCESS_KEY}'
REACT_APP_KURONO_BADGES_URL: '${REACT_APP_KURONO_BADGES_URL}'
KUBECONFIG: 'kubeconfig.yaml'
28 changes: 0 additions & 28 deletions django_site/apps.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,6 @@
import logging
import os
import time
from threading import Thread

import yaml
from kubernetes import config

CURR_DIR = os.path.abspath(os.path.dirname(__file__))

logging.basicConfig(level=logging.DEBUG)


def setup_gke():
filename = os.path.join(CURR_DIR, "kubeconfig.yaml")
config_dict = yaml.safe_load(open(filename, "r").read())
config_reload_interval = 15 * 60 # 15 minutes

def load_kube_config_periodically(interval):
while True:
try:
logging.info("Loading kube config")
config.load_kube_config_from_dict(config_dict)
except:
logging.exception("Exception when calling load_kube_config_from_dict")
time.sleep(interval)

# Start a thread that loads kube config periodically
thread = Thread(
target=load_kube_config_periodically,
args=(config_reload_interval,),
daemon=True,
)
thread.start()
32 changes: 0 additions & 32 deletions django_site/kubeconfig.yaml.tmpl

This file was deleted.

1 change: 0 additions & 1 deletion django_site/pipeline_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
INSTALLED_APPS = (
"anymail",
"deploy",
"aimmo",
"game",
"pipeline",
"portal",
Expand Down
14 changes: 0 additions & 14 deletions django_site/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
INSTALLED_APPS = (
"anymail",
"deploy",
"aimmo",
"game",
"pipeline",
"portal",
Expand Down Expand Up @@ -104,7 +103,6 @@
"preventconcurrentlogins.middleware.PreventConcurrentLoginsMiddleware",
"csp.middleware.CSPMiddleware",
"deploy.middleware.screentime_warning.ScreentimeWarningMiddleware",
"aimmo.middleware.game_limit_exceeded.GameLimitExceededMiddleware",
]

AUTHENTICATION_BACKENDS = [
Expand Down Expand Up @@ -219,16 +217,6 @@
CSRF_COOKIE_SECURE = True
CSRF_USE_SESSIONS = False

AIMMO_DJANGO_BASE_URL = f"https://{os.getenv('GAE_SERVICE')}-dot-decent-digit-629.appspot.com"

AIMMO_GAME_SERVER_URL_FUNCTION = lambda game: (
f"{os.getenv('GAE_SERVICE')}-aimmo.codeforlife.education",
f"/game-{game}/socket.io",
)

AIMMO_GAME_SERVER_PORT_FUNCTION = lambda game: 0
AIMMO_GAME_SERVER_SSL_FLAG = True

EMAIL_ADDRESS = "[email protected]"

LOCALE_PATHS = ("conf/locale",)
Expand Down Expand Up @@ -301,8 +289,6 @@ def domain():
"https://crowdin.com/",
"https://o2.mouseflow.com/",
"https://stats.g.doubleclick.net/",
f"wss://{MODULE_NAME}-aimmo.codeforlife.education/",
f"https://{MODULE_NAME}-aimmo.codeforlife.education/",
)
CSP_FONT_SRC = (
"'self'",
Expand Down
2 changes: 0 additions & 2 deletions django_site/views.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
from django.http import JsonResponse

import aimmo
import game
import portal


def versions(_request):
"""Return json containing the installed versions of the main packages."""
return JsonResponse({
'aimmo': aimmo.__version__,
'codeforlife-portal': portal.__version__,
'rapid-router': game.__version__
})
3 changes: 0 additions & 3 deletions django_site/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import logging
import google.cloud.logging
from google.auth.exceptions import DefaultCredentialsError
from .apps import setup_gke

logging.basicConfig(level=logging.DEBUG)

Expand All @@ -25,8 +24,6 @@

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "django_site.settings")

setup_gke()

from lib.django.core.wsgi import get_wsgi_application

application = get_wsgi_application()
10 changes: 1 addition & 9 deletions generate_requirements.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import argparse

# Versions will be fetched from the init of each package (portal, aimmo, game) after they are installed in lib - this happens in the "Build" step.
from lib.aimmo import __version__ as aimmo_version
# Versions will be fetched from the init of each package (portal, game) after they are installed in lib - this happens in the "Build" step.
from lib.game import __version__ as rapid_router_version
from lib.portal import __version__ as portal_version


parser = argparse.ArgumentParser()
parser.add_argument("--portal-branch")
parser.add_argument("--rapid-router-branch")
parser.add_argument("--aimmo-branch")
args = parser.parse_args()

if args.portal_branch:
Expand All @@ -24,17 +22,11 @@
else:
rapid_router_requirement = f"rapid-router=={rapid_router_version}"

if args.aimmo_branch:
aimmo_requirement = "./aimmo"
else:
aimmo_requirement = f"aimmo=={aimmo_version}"

requirements = "\n".join(
[
rapid_router_requirement,
portal_requirement,
common_requirement,
aimmo_requirement,
"requests-toolbelt==0.9.*",
"mysqlclient==2.1.*",
"redis==3.3.*",
Expand Down
6 changes: 0 additions & 6 deletions manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,4 @@

from django.core.management import execute_from_command_line

# Need to setup GKE if running migrations
if sys.argv[1] == "migrate":
import kubernetes

kubernetes.config.load_kube_config("/home/runner/.kube/config")

execute_from_command_line(sys.argv)
4 changes: 0 additions & 4 deletions notify_deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
logging.basicConfig()

MODULE_NAME = os.environ.get("MODULE_NAME")
AIMMO_BRANCH = os.environ.get("AIMMO_BRANCH")
PORTAL_BRANCH = os.environ.get("PORTAL_BRANCH")
RAPID_ROUTER_BRANCH = os.environ.get("RAPID_ROUTER_BRANCH")

Expand All @@ -33,8 +32,6 @@
except:
logging.exception("Error occurred while getting versions")

if AIMMO_BRANCH:
versions["aimmo"] = AIMMO_BRANCH
if PORTAL_BRANCH:
versions["codeforlife-portal"] = PORTAL_BRANCH
if RAPID_ROUTER_BRANCH:
Expand All @@ -43,7 +40,6 @@
message += (
f"completed successfully :tada:\n"
f"\n"
f"aimmo: `{versions['aimmo']}`\n"
f"codeforlife-portal: `{versions['codeforlife-portal']}`\n"
f"rapid-router: `{versions['rapid-router']}`"
)
Expand Down
Loading