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

#1963 - Database Name prefixed #2152

Merged
merged 14 commits into from
Aug 3, 2023
Merged

Conversation

guru-aot
Copy link
Collaborator

@guru-aot guru-aot commented Aug 1, 2023

  1. Updated database name as a parameter for deployments, the sims_db_name is connected from every environment github secrets.
  2. The existing environment github secret database_name_key will be removed, as it is not used.
  3. The sims_db_name, is a new environment github secret, which needs to be defined in every environment, which is connected to sims-creds secret in openshift. In-turn used in the deployments in github actions as an application secret.

Note: Connecting the existing patroni locally and creating a database in the name '{sims_db_name}' is required as a prerequisite, so that the github actions can find the new database when run.

@guru-aot guru-aot marked this pull request as ready for review August 1, 2023 17:16
@@ -88,7 +88,7 @@ env:
QUEUE_PREFIX: ${{ secrets.QUEUE_PREFIX }}
API_PORT: ${{ secrets.API_PORT }}
WEB_PORT: ${{ secrets.WEB_PORT }}
DATABASE_NAME_KEY: ${{ secrets.DATABASE_NAME_KEY }}
DATABASE_NAME_PREFIX: ${{ secrets.DATABASE_NAME_PREFIX }}
Copy link
Collaborator

@dheepak-aot dheepak-aot Aug 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need the prefix? DATABASE_NAME could be something which is mapped from github env to deployment directly right?

like this DATABASE_NAME: ${{ vars.DATABASE_NAME }}

Also should database name be in secrets in github? we can use vars

Copy link
Collaborator Author

@guru-aot guru-aot Aug 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes we can have and we already discussed this i guess. The thing is even without the database_name or the database_name_prefix in the github secrets, the database name should be taken as SIMSDB and all the actions should work. This change is for an exception scenario where we have to create a new set of db for new environment. So introduced the prefix, rather going with the database_name and repeating with the same value everywhere.

This inturn does not need the change in the prod environment deployment, if the secret database_name_key is removed from the Prod github secrets

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can talk as a team and settle this. Maybe I am missing something but I was under the assumption that the DB name would go under the sims-env-creds maybe, but the current approach would also be acceptable.

@@ -103,6 +103,7 @@ jobs:
echo Git Red: ${{ inputs.gitRef }}
echo BUILD NAMESPACE: $BUILD_NAMESPACE
echo HOST_PREFIX: $HOST_PREFIX
echo DATABASE_NAME_PREFIX: $DATABASE_NAME_PREFIX
Copy link
Collaborator

@dheepak-aot dheepak-aot Aug 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just an echo but we need the same for deploy-sims-api, workers and queue-consumers right?

Copy link
Collaborator Author

@guru-aot guru-aot Aug 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, but i guess, we can remove all the echos in the deploy-sims-api, workers and queue-consumers too, as they depends on run-db-migrations. its okay to have at one place :). I will add it in other places too

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the DATABASE_NAME_PREFIX is in the secrets GitHub will not print its value at all, the same for $HOST_PREFIX.
image

Copy link
Collaborator Author

@guru-aot guru-aot Aug 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay then we can remove them in all the entires.

@dheepak-aot
Copy link
Collaborator

Great job on having the staging environment ready. Added 2 comments out of which only first one is something I am confused about.

@guru-aot guru-aot self-assigned this Aug 1, 2023
@guru-aot guru-aot added the Devops Devops label Aug 1, 2023
Copy link
Collaborator

@andrewsignori-aot andrewsignori-aot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, let's try to settle the comments quickly 😉
I do not see a major concern between the options.

@@ -103,6 +103,7 @@ jobs:
echo Git Red: ${{ inputs.gitRef }}
echo BUILD NAMESPACE: $BUILD_NAMESPACE
echo HOST_PREFIX: $HOST_PREFIX
echo DATABASE_NAME_PREFIX: $DATABASE_NAME_PREFIX
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the DATABASE_NAME_PREFIX is in the secrets GitHub will not print its value at all, the same for $HOST_PREFIX.
image

@@ -88,7 +88,7 @@ env:
QUEUE_PREFIX: ${{ secrets.QUEUE_PREFIX }}
API_PORT: ${{ secrets.API_PORT }}
WEB_PORT: ${{ secrets.WEB_PORT }}
DATABASE_NAME_KEY: ${{ secrets.DATABASE_NAME_KEY }}
DATABASE_NAME_PREFIX: ${{ secrets.DATABASE_NAME_PREFIX }}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can talk as a team and settle this. Maybe I am missing something but I was under the assumption that the DB name would go under the sims-env-creds maybe, but the current approach would also be acceptable.

@andrewsignori-aot andrewsignori-aot changed the title Database Name prefixed #1963 - Database Name prefixed Aug 1, 2023
@@ -101,8 +100,6 @@ jobs:
run: |
echo Git Environment: ${{ inputs.environment }}
echo Git Red: ${{ inputs.gitRef }}
echo BUILD NAMESPACE: $BUILD_NAMESPACE
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did we remove the echo of the build_namespace ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its also not printing so removed.

image

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct me if wrong. I see the echo happening just under that.
image

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad missed it in the printing below, reverted the change back :)

@@ -276,8 +276,10 @@ parameters:
value: superuser-username
- name: DB_PASSWORD_KEY
value: superuser-password
- name: DATABASE_NAME_KEY
required: true
- name: API_SECRET_NAME
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API_SECRET_NAME is not required to be added here. QUEUE_CONSUMERS_SECRET_NAME can be used.

key: ${DATABASE_NAME_KEY}
name: ${DB_SECRET_NAME}
key: ${SIMS_DB_NAME}
name: ${API_SECRET_NAME}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QUEUE_CONSUMERS_SECRET_NAME can be used.

@@ -124,8 +124,10 @@ parameters:
value: superuser-username
- name: DB_PASSWORD_KEY
value: superuser-password
- name: DATABASE_NAME_KEY
required: true
- name: API_SECRET_NAME
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API_SECRET_NAME is not required to be added here. WORKERS_SECRET_NAME can be re-used.

key: ${DATABASE_NAME_KEY}
name: ${DB_SECRET_NAME}
key: ${SIMS_DB_NAME}
name: ${API_SECRET_NAME}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WORKERS_SECRET_NAME can be used.

@@ -88,7 +88,6 @@ env:
QUEUE_PREFIX: ${{ secrets.QUEUE_PREFIX }}
API_PORT: ${{ secrets.API_PORT }}
WEB_PORT: ${{ secrets.WEB_PORT }}
DATABASE_NAME_KEY: ${{ secrets.DATABASE_NAME_KEY }}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not part of the PR. I see that the build namespace and keycloak realm are hard coded here. I believe we will be changing it to read from github secrets in future.

image

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have the BUILD_NAMESPACE already available and used, for instance, in .github\workflows\env-setup-build-forms-server.yml
We can do the same for the KEYCLOAK_REALM.
By the way, @dheepak-aot for these ones that were hard-code, we used the vars.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added a repository variable and changed it.

Copy link
Collaborator

@dheepak-aot dheepak-aot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing the additional refactors to replace the tools namespace and keycloak realm. 👍

@@ -137,6 +137,7 @@ parameters:
- name: BUILD_TAG
value: "0"
- name: WORKERS_SECRET_NAME
value: sims-api-creds
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not following this default value. Do we need it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just following the steps follwed in api-deploy.yml, also the name was not self understanding what it is, the value just gives an idea what this secret name is.

@@ -289,6 +289,7 @@ parameters:
- name: BUILD_TAG
value: "0"
- name: QUEUE_CONSUMERS_SECRET_NAME
value: sims-api-creds
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just following the steps follwed in api-deploy.yml, also the name was not self understanding what it is, the value just gives an idea what this secret name is.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, the standard is old and does not represent well the change that we did when we introduced the sims-ENV-creds.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

Copy link
Collaborator

@andrewsignori-aot andrewsignori-aot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing the changes, only one last comment to be checked.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Aug 2, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link
Collaborator

@andrewsignori-aot andrewsignori-aot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing the changes, looks good 👍
Please ensure that we have the instructions updated in the next release instructions
https://app.zenhub.com/workspaces/student-information-management-system-5fce9df5aa1b45000e937014/reports/release?release=Z2lkOi8vcmFwdG9yL1JlbGVhc2UvOTQxODU

@github-actions
Copy link

github-actions bot commented Aug 2, 2023

Backend Unit Tests Coverage Report

Totals Coverage
Statements: 17.87% ( 2137 / 11957 )
Methods: 8.26% ( 126 / 1525 )
Lines: 20.68% ( 1873 / 9059 )
Branches: 10.05% ( 138 / 1373 )

@github-actions
Copy link

github-actions bot commented Aug 2, 2023

E2E Workflow Workers Coverage Report

Totals Coverage
Statements: 49.81% ( 267 / 536 )
Methods: 41.56% ( 32 / 77 )
Lines: 55.33% ( 218 / 394 )
Branches: 26.15% ( 17 / 65 )

@github-actions
Copy link

github-actions bot commented Aug 2, 2023

E2E Queue Consumers Coverage Report

Totals Coverage
Statements: 72.5% ( 406 / 560 )
Methods: 63.38% ( 45 / 71 )
Lines: 74.53% ( 357 / 479 )
Branches: 40% ( 4 / 10 )

@github-actions
Copy link

github-actions bot commented Aug 2, 2023

E2E SIMS API Coverage Report

Totals Coverage
Statements: 52.65% ( 3757 / 7136 )
Methods: 49.3% ( 457 / 927 )
Lines: 57.73% ( 3074 / 5325 )
Branches: 25.57% ( 226 / 884 )

Copy link
Contributor

@ann-aot ann-aot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 good work @guru-aot

@guru-aot guru-aot merged commit 9f31199 into main Aug 3, 2023
@guru-aot guru-aot deleted the #1963-Create_Staging_Environment branch August 3, 2023 18:28
@guru-aot guru-aot temporarily deployed to DEV August 3, 2023 18:44 — with GitHub Actions Inactive
@guru-aot guru-aot temporarily deployed to DEV August 3, 2023 18:45 — with GitHub Actions Inactive
@guru-aot guru-aot temporarily deployed to DEV August 3, 2023 18:45 — with GitHub Actions Inactive
@guru-aot guru-aot temporarily deployed to DEV August 3, 2023 18:45 — with GitHub Actions Inactive
@guru-aot guru-aot temporarily deployed to DEV August 3, 2023 18:45 — with GitHub Actions Inactive
@guru-aot guru-aot temporarily deployed to DEV August 3, 2023 18:47 — with GitHub Actions Inactive
@guru-aot guru-aot temporarily deployed to DEV August 3, 2023 18:47 — with GitHub Actions Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Devops Devops
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants