Skip to content

Commit

Permalink
Tracking pull request to bring release-1.6.23 to master (#1709)
Browse files Browse the repository at this point in the history
* udpate to KNP (#1705)
* Update nagios for rabbitmq (#1706)
* Maintenance page (#1707)
* Fixing the minio issue by removing the headers for keycloak when uploading (#1708)
* Changed the fix to use transformrequest instead (#1710)
* Upload Fix (#1711)
* Changed the fix to use transformrequest instead
* Fixed upload not uploading anything
* pipeline updates
  • Loading branch information
kuanfandevops authored Mar 6, 2021
1 parent 7026e46 commit ed39730
Show file tree
Hide file tree
Showing 33 changed files with 1,340 additions and 185 deletions.
2 changes: 1 addition & 1 deletion .pipeline/clean-nsps.js → .pipeline/clean-knps.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';
const settings = require('./lib/config.js')
const task = require('./lib/clean-nsps.js')
const task = require('./lib/clean-knps.js')

task(Object.assign(settings, { phase: settings.options.env}));
2 changes: 1 addition & 1 deletion .pipeline/deploy-nsps.js → .pipeline/deploy-db.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';
const settings = require('./lib/config.js')
const task = require('./lib/deploy-nsps.js')
const task = require('./lib/deploy-db.js')

task(Object.assign(settings, { phase: settings.options.env}));
5 changes: 5 additions & 0 deletions .pipeline/deploy-knps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';
const settings = require('./lib/config.js')
const task = require('./lib/deploy-knps.js')

task(Object.assign(settings, { phase: settings.options.env}));
6 changes: 3 additions & 3 deletions .pipeline/lib/clean-nsps.js → .pipeline/lib/clean-knps.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ module.exports = settings => {
oc.namespace(phase.namespace);

//remove all custom security policies create for specific pull request
const nsps = oc.get("networksecuritypolicies", {
const knps = oc.get("networkpolicies", {
selector: `app=${phase.name}${phase.suffix}`,
namespace: phase.namespace,
});
nsps.forEach(nsp => {
oc.delete([`networksecuritypolicy/${nsp.metadata.name}`], {
knps.forEach(knp => {
oc.delete([`networkpolicy/${knp.metadata.name}`], {
"ignore-not-found": "true",
wait: "true",
namespace: phase.namespace,
Expand Down
2 changes: 1 addition & 1 deletion .pipeline/lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const ocpName = 'apps.silver.devops'
const phases = {
build: { namespace:'0ab226-tools' , name: `${name}`, phase: 'build' , changeId:changeId, suffix: `-build-${changeId}` ,
instance: `${name}-build-${changeId}` , version:`${version}-${changeId}`, tag:`build-${version}-${changeId}`,
releaseBranch: 'openshift-v4-migration'
releaseBranch: 'release-1.6.23'
},
dev: {namespace:'0ab226-dev' , name: `${name}`, phase: 'dev' , changeId:changeId, suffix: `-dev-${changeId}` ,
instance: `${name}-dev-${changeId}` , version:`${version}-${changeId}`, tag:`dev-${version}-${changeId}`,
Expand Down
76 changes: 76 additions & 0 deletions .pipeline/lib/deploy-db.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
"use strict";
const { OpenShiftClientX } = require("@bcgov/pipeline-cli");
const path = require("path");

module.exports = settings => {
const phases = settings.phases;
const options = settings.options;
const phase = options.env;
const changeId = phases[phase].changeId;
const oc = new OpenShiftClientX(Object.assign({ namespace: phases[phase].namespace }, options));

const templatesLocalBaseUrl = oc.toFileUrl(path.resolve(__dirname, "../../openshift-v4"));
var objects = [];

//The deployment of your cool app goes here ▼▼▼

if(phases[phase].phase === 'dev') {

//deploy Patroni
objects = objects.concat(oc.processDeploymentTemplate(`${templatesLocalBaseUrl}/templates/patroni/deployment-prereq.yaml`, {
'param': {
'NAME': 'patroni',
'SUFFIX': phases[phase].suffix
}
}))
objects = objects.concat(oc.processDeploymentTemplate(`${templatesLocalBaseUrl}/templates/patroni/deployment.yaml`, {
'param': {
'NAME': 'patroni',
'ENV_NAME': phases[phase].phase,
'SUFFIX': phases[phase].suffix,
'CPU_REQUEST': phases[phase].patroniCpuRequest,
'CPU_LIMIT': phases[phase].patroniCpuLimit,
'MEMORY_REQUEST': phases[phase].patroniMemoryRequest,
'MEMORY_LIMIT': phases[phase].patroniMemoryLimit,
'IMAGE_REGISTRY': 'image-registry.openshift-image-registry.svc:5000',
'IMAGE_STREAM_NAMESPACE': phases[phase].namespace,
'IMAGE_STREAM_TAG': 'patroni:v10-stable',
'REPLICA': phases[phase].patroniReplica,
'PVC_SIZE': phases[phase].patroniPvcSize,
'STORAGE_CLASS': phases[phase].storageClass
}
}))

//deploy rabbitmq, use docker image directly
//POST_START_SLEEP is harded coded in the rabbitmq template, replacement was not successful
objects = objects.concat(oc.processDeploymentTemplate(`${templatesLocalBaseUrl}/templates/rabbitmq/rabbitmq-cluster-dc.yaml`, {
'param': {
'NAME': phases[phase].name,
'ENV_NAME': phases[phase].phase,
'SUFFIX': phases[phase].suffix,
'NAMESPACE': phases[phase].namespace,
'CLUSTER_NAME': 'rabbitmq-cluster',
'ISTAG': 'rabbitmq:3.8.3-management',
'SERVICE_ACCOUNT': 'rabbitmq-discovery',
'VOLUME_SIZE': phases[phase].rabbitmqPvcSize,
'CPU_REQUEST': phases[phase].rabbitmqCpuRequest,
'CPU_LIMIT': phases[phase].rabbitmqCpuLimit,
'MEMORY_REQUEST': phases[phase].rabbitmqMemoryRequest,
'MEMORY_LIMIT': phases[phase].rabbitmqMemoryLimit,
'REPLICA': phases[phase].rabbitmqReplica,
'POST_START_SLEEP': phases[phase].rabbitmqPostStartSleep,
'STORAGE_CLASS': phases[phase].storageClass
}
}))
}

oc.applyRecommendedLabels(
objects,
phases[phase].name,
phase,
`${changeId}`,
phases[phase].instance,
);
oc.importImageStreams(objects, phases[phase].tag, phases.build.namespace, phases.build.tag);
oc.applyAndDeploy(objects, phases[phase].instance);
};
8 changes: 3 additions & 5 deletions .pipeline/lib/deploy-nsps.js → .pipeline/lib/deploy-knps.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@ module.exports = settings => {

//The deployment of your cool app goes here ▼▼▼

objects = objects.concat(oc.processDeploymentTemplate(`${templatesLocalBaseUrl}/templates/nsp/nsp-env.yaml`, {
objects = objects.concat(oc.processDeploymentTemplate(`${templatesLocalBaseUrl}/templates/knp/knp-env-pr.yaml`, {
'param': {
'NAME': phases[phase].name,
'ENV_NAME': phases[phase].phase,
'SUFFIX': phases[phase].suffix,
'API_VERSION': 'security.devops.gov.bc.ca/v1alpha1'
'ENVIRONMENT': phases[phase].phase,
'SUFFIX': phases[phase].suffix
}
}))

Expand Down
121 changes: 35 additions & 86 deletions .pipeline/lib/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,57 +14,6 @@ module.exports = settings => {
var objects = [];

//The deployment of your cool app goes here ▼▼▼
/*
if(phases[phase].phase === 'dev') {
//deploy Patroni
objects = objects.concat(oc.processDeploymentTemplate(`${templatesLocalBaseUrl}/templates/patroni/deployment-prereq.yaml`, {
'param': {
'NAME': 'patroni',
'SUFFIX': phases[phase].suffix
}
}))
objects = objects.concat(oc.processDeploymentTemplate(`${templatesLocalBaseUrl}/templates/patroni/deployment.yaml`, {
'param': {
'NAME': 'patroni',
'ENV_NAME': phases[phase].phase,
'SUFFIX': phases[phase].suffix,
'CPU_REQUEST': phases[phase].patroniCpuRequest,
'CPU_LIMIT': phases[phase].patroniCpuLimit,
'MEMORY_REQUEST': phases[phase].patroniMemoryRequest,
'MEMORY_LIMIT': phases[phase].patroniMemoryLimit,
'IMAGE_REGISTRY': 'image-registry.openshift-image-registry.svc:5000',
'IMAGE_STREAM_NAMESPACE': phases[phase].namespace,
'IMAGE_STREAM_TAG': 'patroni:v10-stable',
'REPLICA': phases[phase].patroniReplica,
'PVC_SIZE': phases[phase].patroniPvcSize,
'STORAGE_CLASS': phases[phase].storageClass
}
}))
//deploy rabbitmq, use docker image directly
//POST_START_SLEEP is harded coded in the rabbitmq template, replacement was not successful
objects = objects.concat(oc.processDeploymentTemplate(`${templatesLocalBaseUrl}/templates/rabbitmq/rabbitmq-cluster-dc.yaml`, {
'param': {
'NAME': phases[phase].name,
'ENV_NAME': phases[phase].phase,
'SUFFIX': phases[phase].suffix,
'NAMESPACE': phases[phase].namespace,
'CLUSTER_NAME': 'rabbitmq-cluster',
'ISTAG': 'rabbitmq:3.8.3-management',
'SERVICE_ACCOUNT': 'rabbitmq-discovery',
'VOLUME_SIZE': phases[phase].rabbitmqPvcSize,
'CPU_REQUEST': phases[phase].rabbitmqCpuRequest,
'CPU_LIMIT': phases[phase].rabbitmqCpuLimit,
'MEMORY_REQUEST': phases[phase].rabbitmqMemoryRequest,
'MEMORY_LIMIT': phases[phase].rabbitmqMemoryLimit,
'REPLICA': phases[phase].rabbitmqReplica,
'POST_START_SLEEP': phases[phase].rabbitmqPostStartSleep,
'STORAGE_CLASS': phases[phase].storageClass
}
}))
}
*/

//deploy backend
objects = objects.concat(oc.processDeploymentTemplate(`${templatesLocalBaseUrl}/templates/backend/backend-dc.yaml`, {
Expand All @@ -90,31 +39,6 @@ module.exports = settings => {
}
}))

/*
//deploy backend others
objects = objects.concat(oc.processDeploymentTemplate(`${templatesLocalBaseUrl}/templates/backend/backend-dc-others.yaml`, {
'param': {
'NAME': phases[phase].name,
'SUFFIX': phases[phase].suffix,
'BACKEND_HOST':phases[phase].backendHost
}
}))
//deploy frontend
objects = objects.concat(oc.processDeploymentTemplate(`${templatesLocalBaseUrl}/templates/frontend/frontend-dc-others.yaml`, {
'param': {
'NAME': phases[phase].name,
'SUFFIX': phases[phase].suffix,
'VERSION': phases[phase].tag,
'KEYCLOAK_AUTHORITY': phases[phase].frontendKeycloakAuthority,
'KEYCLOAK_CLIENT_ID': phases[phase].frontendKeycloakClientId,
'KEYCLOAK_CALLBACK_URL': phases[phase].frontendKeycloakCallbackUrl,
'KEYCLOAK_LOGOUT_URL': phases[phase].frontendKeycloakLogoutUrl,
'FRONTEND_HOST': phases[phase].frontendHost,
'BACKEND_HOST': phases[phase].backendHost
}
}))
objects = objects.concat(oc.processDeploymentTemplate(`${templatesLocalBaseUrl}/templates/frontend/frontend-dc.yaml`, {
'param': {
'NAME': phases[phase].name,
Expand Down Expand Up @@ -144,15 +68,6 @@ module.exports = settings => {
}
}))

//deploy notification server
objects = objects.concat(oc.processDeploymentTemplate(`${templatesLocalBaseUrl}/templates/notification/notification-server-others-dc.yaml`, {
'param': {
'NAME': phases[phase].name,
'SUFFIX': phases[phase].suffix,
'FRONTEND_HOST': phases[phase].frontendHost
}
}))
//deploy notification server
objects = objects.concat(oc.processDeploymentTemplate(`${templatesLocalBaseUrl}/templates/notification/notification-server-dc.yaml`, {
'param': {
Expand Down Expand Up @@ -197,6 +112,40 @@ module.exports = settings => {
}
}))

//only deploy on dev for Tracking PR
if(phases[phase].phase === 'dev') {

objects = objects.concat(oc.processDeploymentTemplate(`${templatesLocalBaseUrl}/templates/frontend/frontend-dc-others.yaml`, {
'param': {
'NAME': phases[phase].name,
'SUFFIX': phases[phase].suffix,
'VERSION': phases[phase].tag,
'KEYCLOAK_AUTHORITY': phases[phase].frontendKeycloakAuthority,
'KEYCLOAK_CLIENT_ID': phases[phase].frontendKeycloakClientId,
'KEYCLOAK_CALLBACK_URL': phases[phase].frontendKeycloakCallbackUrl,
'KEYCLOAK_LOGOUT_URL': phases[phase].frontendKeycloakLogoutUrl,
'FRONTEND_HOST': phases[phase].frontendHost,
'BACKEND_HOST': phases[phase].backendHost
}
}))

objects = objects.concat(oc.processDeploymentTemplate(`${templatesLocalBaseUrl}/templates/notification/notification-server-others-dc.yaml`, {
'param': {
'NAME': phases[phase].name,
'SUFFIX': phases[phase].suffix,
'FRONTEND_HOST': phases[phase].frontendHost
}
}))

objects = objects.concat(oc.processDeploymentTemplate(`${templatesLocalBaseUrl}/templates/backend/backend-dc-others.yaml`, {
'param': {
'NAME': phases[phase].name,
'SUFFIX': phases[phase].suffix,
'BACKEND_HOST':phases[phase].backendHost
}
}))
}

//only deploy schemaspy for test and prod
if(phases[phase].phase === 'test' || phases[phase].phase === 'prod') {
objects = objects.concat(oc.processDeploymentTemplate(`${templatesLocalBaseUrl}/templates/schema-spy/schemaspy-dc.yaml`, {
Expand All @@ -215,7 +164,7 @@ module.exports = settings => {
}
}))
}
*/

oc.applyRecommendedLabels(
objects,
phases[phase].name,
Expand Down
5 changes: 3 additions & 2 deletions .pipeline/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
"scripts": {
"build": "node build.js",
"clean": "node clean.js",
"clean-nsps": "node clean-nsps.js",
"clean-knps": "node clean-knps.js",
"deploy": "node deploy.js",
"deploy-nsps": "node deploy-nsps.js",
"deploy-knps": "node deploy-knps.js",
"deploy-unittest": "node deploy-unittest.js",
"deploy-db": "node deploy-db.js",
"version": "echo \"node@$(node --version) ($(which node))\" && echo \"npm@$(npm --version) ($(which npm))\" && npm ls"
},
"repository": {
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/actions/documentUploads.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,10 @@ const updateDocumentUploadSuccess = response => ({

const uploadDocument = (url, blob, callback = null) => dispatch => (
axios.put(url, blob, {
'content-type': 'multipart/form-data',
transformRequest: (data, headers) => {
headers.Authorization = null;
return data;
},
onUploadProgress: (progressEvent) => {
if (callback) {
callback(progressEvent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ const SecureFileSubmissionFileAttachments = props => (
className="text"
onClick={() => {
axios.get(attachment.url, {
transformRequest: (data, headers) => {
headers.Authorization = null;
},
responseType: 'blob'
}).then((response) => {
const objectURL =
Expand Down
7 changes: 0 additions & 7 deletions maintenance/Caddyfile

This file was deleted.

29 changes: 29 additions & 0 deletions openshift-v4/templates/Readmd.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
## Create tracking PR
* Create release branch from master and make it as the default branch
* Create a Tracking PR to bring the release branch to master
* All other PRs target the release PR
* Only deploy the Tracking PR to Dev, test and Prod, not any other single PR

## Build tracking PR
* Update .pipeline/config.js releaseBranch to be the release branch
* Under .pipeline, npm run build -- --pr= --env=build

## Deploy tracking PR

### deploy database for the PR on Dev
* Create knps for the PR
npm run deploy-knps -- --pr= --env=dev
* Deploy the patroni
npm run deploy-db -- --pr= --env=dev
* Update user and restore the backup to database
Refer to the last section of openshift-v4/templates/patroni/README.md, remember to verify the Dev database user
* Add tfrs user and /tfrs vhost to rabbitmq
Refer to the last section of penshift-v4/templates/rabbitmq
* Deploy PR
npm run deploy -- --pr= --env=dev

### deploy database for the PR on Test or Prod
* Only need to deploy compiled components, nothing else as all others are already there
npm run deploy -- --pr= --env=test
npm run deploy -- --pr= --env=prod

2 changes: 2 additions & 0 deletions openshift-v4/templates/celery/celery-bc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ objects:
strategy:
type: Docker
dockerStrategy:
pullSecret:
name: docker-creds
noCache: true
env:
- name: tfrs_release
Expand Down
Loading

0 comments on commit ed39730

Please sign in to comment.