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

Container update #594

Closed
wants to merge 68 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
9abbe36
Incrementing version number for next set of minor updates.
downiec Sep 23, 2022
3f659f4
Pin dependencies (#461)
renovate[bot] Sep 23, 2022
df1fe81
Update dependency @types/jest to v28.1.8 (#462)
renovate[bot] Sep 23, 2022
9d4fc4a
Support backend settings in config (#482)
sashakames Oct 13, 2022
6c029e3
Update react monorepo to v18 (#478)
renovate[bot] Oct 14, 2022
7b35d06
Pin dependencies (#477)
renovate[bot] Oct 19, 2022
9bad38b
Fixed tiny flake8 complaint
downiec Oct 25, 2022
31f34d7
hotfix to the last update so that local containers have the required …
downiec Oct 27, 2022
9f95688
Update .django
sashakames Nov 2, 2022
7d50069
Updating a few dependencies in the backend
downiec Mar 17, 2023
f0fee9a
Updating the Flake8 pre-commit config file to see if that resolves pr…
downiec Mar 17, 2023
c01f64d
Fixed typo in .coveragerc which caused migrations to be included in t…
downiec Mar 17, 2023
086dc61
Upgraded to Django 4.1.7, along with some other python packages.
downiec Mar 17, 2023
a071e6a
Upgraded more python packages while testing to make sure nothing breaks.
downiec Mar 17, 2023
5d43c9c
Reverted dj-rest-auth as it caused issues with tests failing (althoug…
downiec Mar 17, 2023
7510ad6
Updated dj-rest-auth to latest (before breaking changes)
downiec Mar 17, 2023
55158b0
Updating front-end to use the latest react-router-dom major version 6
downiec Mar 22, 2023
e44285f
Removed some comments and updated some tests. Tests still failing, ne…
downiec Mar 22, 2023
113c68a
Updated tests to use memory router to account for the useNavigate cha…
downiec Mar 29, 2023
5e59985
Updated some more frontend packages, however a few updates are breaki…
downiec Mar 29, 2023
119d5a9
Updated yarn.lock file to see if tests pass.
downiec Mar 29, 2023
5e49c80
Feature/500 info notifications (#520)
downiec May 5, 2023
ff49790
Feature/500 info notifications (#523)
downiec May 5, 2023
c91161b
Merged the globus_dev_demo branch with the latest v1.0.8 branch. Perf…
downiec May 12, 2023
55830d8
Added mip_era and data_node facets to the input4mips project.
downiec May 12, 2023
cf20f53
Updated the general facet order for input 4 mips
downiec May 16, 2023
b08d9bf
Merge branch 'v1.0.8' into globus_dev_demo
downiec May 18, 2023
cdcf4c7
Fixed the issue with incorrect search URL and updated files so config…
downiec May 19, 2023
6ff8b6a
Updated yarn.lock file
downiec May 19, 2023
ac11369
Removed some commented code, updated the table so that undefined and …
downiec May 24, 2023
50ddc18
Updated the link to correctly use solr URL
downiec May 25, 2023
af154d9
Removed unneccessary print statements in backend, removed commented c…
downiec May 26, 2023
4483eb8
Added some new message content for the new v1.0.9 Globus update. Stil…
downiec May 26, 2023
7b5f687
Added config option for setting globus enabled nodes which specifies …
downiec May 27, 2023
79f742b
Initial v1.0.9 branch update. Includes updating the version number in…
downiec Jun 10, 2023
e0eef98
Correct the Search URL setting (#525)
sashakames Jun 21, 2023
e0682d6
Added feature to filter search results by globus download availabilit…
downiec Jun 21, 2023
6817230
Updated UI so that Globus Download indicators don't show unless globu…
downiec Jun 21, 2023
9d338fb
Added logic that will determine whether there are selected items that…
downiec Jun 22, 2023
48375ab
Updated the globus ready download with some refactoring to improve se…
downiec Jun 22, 2023
3ea023d
Merged in the latest v1.0.9 branch
downiec Jun 22, 2023
bd03119
Removed obsolete/unused code to help reduce coverage requirements and…
downiec Jun 23, 2023
4b7051f
Changed the language of some messages and text to refer to functional…
downiec Jun 23, 2023
f996a1a
Created a task submitted list, which will allow user to view Globus T…
downiec Jun 24, 2023
e0617f2
Found and fixed the issue with message update closing too quickly. Fi…
downiec Jun 28, 2023
56ac6c6
Updated the joyride tutorial to include the globus ready icon and the…
downiec Jun 28, 2023
c119872
Added logic to ensure transfers aren't done too quickly (which may ca…
downiec Jun 29, 2023
9c7f3b9
Resolved issue with blank message popup when clicking remove all item…
downiec Jun 29, 2023
0bf9307
Messages to accompany Globus Transfer beta release (#534)
sashakames Jun 29, 2023
bd9d00e
Created notification functions to simplify code a bit and to adjust l…
downiec Jun 30, 2023
d65fb2c
Fixed the issues encountered with the manage_metagrid.sh functions on…
downiec Jul 14, 2023
2eae86b
Nodes link and Django, packages upgrade (#540)
sashakames Jul 22, 2023
db810a6
Removed unused functions from backend, cleaned up some styling in the…
downiec Jul 22, 2023
6bc19e8
Fixes cache yarn cache
jasonb5 Sep 9, 2023
5c3b12c
Fixes cache busting from docker directory
jasonb5 Sep 9, 2023
09ed0fb
Fixes search url variable name in environment
jasonb5 Sep 13, 2023
7bd6060
Fixes formatting
jasonb5 Sep 13, 2023
5dd6946
Adds makefile for building/runing container without docker-compose
jasonb5 Sep 13, 2023
9c19305
Adds runtime frontend configuration
jasonb5 Sep 13, 2023
eba2321
Adds dynamic entrypoint env file
jasonb5 Sep 13, 2023
4efb770
Adds missing environment variable
jasonb5 Sep 13, 2023
44206ac
Adds release workflow
jasonb5 Sep 13, 2023
3a0d9df
Fixes providing the default env
jasonb5 Sep 14, 2023
9ec492b
Merge branch 'automate-containers' into container_update
jasonb5 Sep 26, 2023
ac73d55
Allows container workflow to run against PR
jasonb5 Sep 26, 2023
a3eaf7a
Allows container workflow to run against PR
jasonb5 Sep 26, 2023
36b779c
Temporarily push as latest
jasonb5 Sep 26, 2023
9762034
Entrypoint handles updating index.html with runtime configuration aft…
jasonb5 Sep 27, 2023
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
10 changes: 5 additions & 5 deletions .github/workflows/backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ env:
KEYCLOAK_REALM: metagrid
KEYCLOAK_CLIENT_ID: backend
DATABASE_URL: pgsql://postgres:postgres@localhost:5432/postgres
REACT_APP_ESGF_NODE_URL: https://esgf-node.llnl.gov/esg-search/search
REACT_APP_WGET_API_URL: https://greyworm1-rh7.llnl.gov/wget
REACT_APP_ESGF_NODE_STATUS_URL: https://aims4.llnl.gov/prometheus/api/v1/query?query=probe_success%7Bjob%3D%22http_2xx%22%2C+target%3D~%22.%2Athredds.%2A%22%7D

REACT_APP_SEARCH_URL: https://esgf-node.llnl.gov/esg-search/search
REACT_APP_WGET_API_URL: https://esgf-node.llnl.gov/esg-search/wget
REACT_APP_ESGF_NODE_STATUS_URL: https://aims2.llnl.gov/metagrid-backend/proxy/status
REACT_APP_ESGF_SOLR_URL: https://esgf-fedtest.llnl.gov/solr

jobs:
build:
runs-on: ubuntu-latest

services:
postgres:
image: postgres:11.6
image: postgres:12.6
env:
POSTGRES_PASSWORD: postgres
ports:
Expand Down
48 changes: 48 additions & 0 deletions .github/workflows/containers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Container release

on:
push:
tags:
- v.*
pull_request:
branches:

jobs:
frontend:
name: Build/release frontend container
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: docker/setup-buildx-action@v2
- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v4
with:
cache-from: type=gha
cache-to: type=gha,mode=max
context: frontend/
file: frontend/docker/production/react/Dockerfile
push: true
tags: ghcr.io/aims-group/metagrid-frontend:latest
backend:
name: Build/release backend container
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: docker/setup-buildx-action@v2
- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v4
with:
cache-from: type=gha
cache-to: type=gha,mode=max
context: backend/
file: backend/docker/production/django/Dockerfile
push: true
tags: ghcr.io/aims-group/metagrid-backend:latest
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
.pytest_cache/

# Config backups
metagrid_configs/metagrid_config
metagrid_configs/backups

### Linux template
Expand Down
7 changes: 5 additions & 2 deletions backend/.envs/.django
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@ KEYCLOAK_CLIENT_ID=backend

# ESGF wget API
# https://github.com/ESGF/esgf-wget
REACT_APP_WGET_API_URL=https://nimbus3.llnl.gov/wget
REACT_APP_WGET_API_URL=https://esgf-node.llnl.gov/esg-search/wget

# ESGF Search API
# https://esgf.github.io/esg-search/ESGF_Search_RESTful_API.html
REACT_APP_ESGF_NODE_URL=https://esgf-node.llnl.gov/esg-search/search
REACT_APP_SEARCH_URL=https://esgf-node.llnl.gov/esg-search/search

# ESGF Node Status API
# https://github.com/ESGF/esgf-utils/blob/master/node_status/query_prom.py
REACT_APP_ESGF_NODE_STATUS_URL=https://aims2.llnl.gov/metagrid-backend/proxy/status

# ESGF Solr URL
REACT_APP_ESGF_SOLR_URL=https://esgf-fedtest.llnl.gov/solr
45 changes: 45 additions & 0 deletions backend/UpdateProjectData_README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
STEPS TO UPDATE PROJECTS, FACETS OR CATEGORIES

1. Edit the initial data file with the desired changes: metagrid/backend/metagrid/initial_projects_data.py
2. Change to the backend directory:
cd metagrid/backend/
3. Make sure the docker traefik and backend containers are up and running.
If not running, you can run the containers by going to the traefik directory first and running this command:
sudo docker compose -f docker-compose.prod.yml up --build -d
Then do the same in the backend directory (production backend depends on traefik)

RUN UPDATE AND CLEAR TABLES
If you need to clear tables to remove existing facets/projects or change their order then do the steps below:

Option 1:
4. Use the updateProjects.sh script. Just run the script using clear option:
sudo ./updateProject.sh --clear

DONE!

Option 2: Manually update without the script and clear tables:
4. sudo docker compose -f docker-compose.prod.yml build django # Build the container
5. sudo docker compose -f docker-compose.prod.yml run --rm django python manage.py migrate projects zero
6. sudo docker compose -f docker-compose.prod.yml run --rm django python manage.py migrate projects

DONE!

RUN UPDATE WITHOUT CLEARING TABLES
If your update is small and only involves minor modifications or additions to existing projects then you don't need to clear the tables.
If there are deletions or more significant changes, run steps above which include clearing tables otherwise do steps below:

Option 1:
4. Use the updateProjects.sh script. Just run the default script:
sudo ./updateProject.sh

DONE!

Option 2: Manually update without the script and don't clear tables:
4. sudo docker compose -f docker-compose.prod.yml build django # Build the container
5. sudo docker compose -f docker-compose.prod.yml run --rm django python manage.py migrate --fake projects 0001_initial
6. sudo docker compose -f docker-compose.prod.yml run --rm django python manage.py migrate projects

DONE!

MIGRATION FILE ISSUES:
If there are issues when attempting the steps above, make sure you don't have obsolete or modified migration files that don't match what's in the latest repository.
9 changes: 6 additions & 3 deletions backend/config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@
"django.middleware.clickjacking.XFrameOptionsMiddleware",
)

SESSION_SAVE_EVERY_REQUEST = True

# https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts
ALLOWED_HOSTS = ["localhost", "0.0.0.0", "127.0.0.1"]
ROOT_URLCONF = "config.urls"
Expand Down Expand Up @@ -272,7 +274,7 @@
"KEYCLOAK_REALM": env(
"KEYCLOAK_REALM",
),
}
},
}
# Used in data migration to register Keycloak social app
KEYCLOAK_CLIENT_ID = env("KEYCLOAK_CLIENT_ID")
Expand All @@ -295,9 +297,10 @@
# -------------------------------------------------------------------------------
# https://github.com/adamchainz/django-cors-headers#setup
CORS_ORIGIN_ALLOW_ALL = False
CORS_ALLOW_CREDENTIALS = True
CORS_ORIGIN_WHITELIST = env.list("CORS_ORIGIN_WHITELIST")


SEARCH_URL = env("REACT_APP_ESGF_NODE_URL")
SEARCH_URL = env("REACT_APP_SEARCH_URL")
WGET_URL = env("REACT_APP_WGET_API_URL")
STATUS_URL = env("REACT_APP_ESGF_NODE_STATUS_URL")
SOLR_URL = env("REACT_APP_ESGF_SOLR_URL")
14 changes: 13 additions & 1 deletion backend/config/urls.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,15 @@
from rest_framework import permissions
from rest_framework.routers import DefaultRouter

from metagrid.api_proxy.views import do_citation, do_search, do_status, do_wget
from metagrid.api_globus.views import do_globus_transfer, get_access_token
from metagrid.api_proxy.views import (
do_citation,
do_search,
do_status,
do_wget,
get_temp_storage,
set_temp_storage,
)
from metagrid.cart.views import CartViewSet, SearchViewSet
from metagrid.projects.views import ProjectsViewSet
from metagrid.users.views import UserCreateViewSet, UserViewSet
Expand Down Expand Up @@ -53,6 +61,10 @@ class KeycloakLogin(SocialLoginView):
path(
"dj-rest-auth/keycloak", KeycloakLogin.as_view(), name="keycloak_login"
),
path("tempStorage/get", get_temp_storage, name="temp_storage_get"),
path("tempStorage/set", set_temp_storage, name="temp_storage_set"),
path("globus/auth", get_access_token, name="globus_auth"),
path("globus/transfer", do_globus_transfer, name="globus_transfer"),
re_path(
r"^account-confirm-email/",
VerifyEmailView.as_view(),
Expand Down
2 changes: 1 addition & 1 deletion backend/docker/local/django/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ RUN apt-get update \

# Requirements are installed here to ensure they will be cached.
COPY ./requirements /requirements
RUN pip install -r /requirements/local.txt
RUN pip3 install -r /requirements/local.txt

COPY ./docker/production/django/entrypoint /entrypoint
RUN sed -i 's/\r$//g' /entrypoint
Expand Down
2 changes: 1 addition & 1 deletion backend/docker/production/django/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ RUN addgroup --system django \

# Requirements are installed here to ensure they will be cached.
COPY ./requirements /requirements
RUN pip install --no-cache-dir -r /requirements/production.txt \
RUN pip3 install --no-cache-dir -r /requirements/production.txt \
&& rm -rf /requirements

COPY ./docker/production/django/entrypoint /entrypoint
Expand Down
2 changes: 1 addition & 1 deletion backend/docker/production/postgres/maintenance/backup
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
### Create a database backup.
###
### Usage:
### $ docker-compose -f <environment>.yml (exec |run --rm) postgres backup
### $ docker compose -f <environment>.yml (exec |run --rm) postgres backup


set -o errexit
Expand Down
2 changes: 1 addition & 1 deletion backend/docker/production/postgres/maintenance/restore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
### <1> filename of an existing backup.
###
### Usage:
### $ docker-compose -f <environment>.yml (exec |run --rm) postgres restore <1>
### $ docker compose -f <environment>.yml (exec |run --rm) postgres restore <1>


set -o errexit
Expand Down
Empty file.
Empty file.
56 changes: 56 additions & 0 deletions backend/metagrid/api_globus/tests/test_views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
from django.urls import reverse
from rest_framework import status
from rest_framework.test import APITestCase

from metagrid.api_globus.views import split_value, truncate_urls


class TestGlobusViewSet(APITestCase):
def test_truncate(self):
lst = [{"url": ["test_url:globus_value|Globus"]}]
results = []
for value in truncate_urls(lst):
results.append(value)
assert results == ["globus_value"]

def test_split_value(self):
result = split_value(1)
result2 = split_value(1.0)
result3 = split_value("noSplitting")
result4 = split_value("splitValues,values")
result5 = split_value("splitValues,values,CESM1(CAM5.1,FV2)")
result6 = split_value(
"{splitValues,test},[test,test2],CESM1(CAM5.1,FV2)"
)

assert result == 1
assert result2 == 1.0
assert result3 == ["noSplitting"]
assert result4 == ["splitValues", "values"]
assert result5 == ["splitValues", "values", "CESM1(CAM5.1,FV2)"]
assert result6 == [
"{splitValues,test}",
"[test,test2]",
"CESM1(CAM5.1,FV2)",
]

def test_get_access_token(self):
url = reverse("globus_auth")
getdata = {}
response = self.client.post(url, getdata)
assert response.status_code == status.HTTP_404_NOT_FOUND

def test_globus_transfer(self):
url = reverse("globus_transfer")
getdata = {}
response = self.client.get(url, getdata)
assert response.status_code == status.HTTP_400_BAD_REQUEST

postdata = {
"access_token": "",
"refresh_token": "",
"endpointId": "test",
"path": "bad/path",
}
response = self.client.post(url, postdata)
assert response.status_code == status.HTTP_400_BAD_REQUEST
Loading
Loading