Skip to content

Commit

Permalink
Merge branch 'main' into test/forms-1621
Browse files Browse the repository at this point in the history
  • Loading branch information
nimya-aot authored Dec 23, 2024
2 parents 9f10bea + 6fb6b64 commit 056cd96
Show file tree
Hide file tree
Showing 35 changed files with 2,052 additions and 6 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/pr_undeploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install OpenShift CLI tools
uses: redhat-actions/openshift-tools-installer@v1
with:
oc: "4.14"
- name: Login to OpenShift Cluster
uses: redhat-actions/oc-login@v1
with:
Expand Down
17 changes: 11 additions & 6 deletions app/frontend/src/components/designer/FormViewerActions.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup>
import { storeToRefs } from 'pinia';
import { computed, onMounted, inject, ref } from 'vue';
import { computed, inject, ref, watch } from 'vue';
import { useI18n } from 'vue-i18n';
import ManageSubmissionUsers from '~/components/forms/submission/ManageSubmissionUsers.vue';
Expand Down Expand Up @@ -61,7 +61,7 @@ const properties = defineProps({
},
});
const isWideLayout = ref(false);
const isWideLayout = ref(properties.wideFormLayout);
const formStore = useFormStore();
Expand All @@ -74,14 +74,19 @@ const showEditToggle = computed(
properties.permissions.includes(FormPermissions.SUBMISSION_UPDATE)
);
onMounted(() => {
setWideLayout(isWideLayout.value);
});
function toggleWideLayout() {
isWideLayout.value = !isWideLayout.value;
setWideLayout(isWideLayout.value);
}
// Sync the local copy with the prop when it changes
watch(
() => properties.wideFormLayout,
(newValue) => {
isWideLayout.value = newValue;
setWideLayout(newValue);
},
{ immediate: true }
);
</script>

<template>
Expand Down
1 change: 1 addition & 0 deletions app/frontend/src/components/forms/FormSubmission.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ onMounted(async () => {
await formStore.getFormPermissionsForUser(form.value.id);
loading.value = false;
// set wide layout
isWideLayout.value = form.value.wideFormLayout;
setWideLayout(isWideLayout.value);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,26 @@ describe('FormDisclaimer.vue', () => {
expect(wrapper.vm.showEditToggle).toBeTruthy();
});

it('when props.wideFormLayout is set from parent call setWideLayout', async () => {
const setWideLayout = vi.fn();
setWideLayout.mockImplementation(() => {});
const wrapper = mount(FormViewerActions, {
props: {
wideFormLayout: true,
},
global: {
plugins: [pinia],
provide: {
setWideLayout: setWideLayout,
},
stubs: STUBS,
},
});

expect(wrapper.vm.isWideLayout).toBeTruthy();
expect(setWideLayout).toBeCalledTimes(1);
});

it('toggleWideLayout will toggle isWideLayout and call setWideLayout', async () => {
const setWideLayout = vi.fn();
setWideLayout.mockImplementation(() => {});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ describe('FormSubmission.vue', () => {
formStore.form = {
id: 0,
name: 'This is a form title',
wideFormLayout: true,
};
const fetchSubmissionSpy = vi.spyOn(formStore, 'fetchSubmission');
fetchSubmissionSpy.mockImplementation(() => {});
Expand Down Expand Up @@ -88,6 +89,8 @@ describe('FormSubmission.vue', () => {
expect(wrapper.text()).toContain('trans.formSubmission.submitted');
expect(wrapper.text()).toContain('trans.formSubmission.submission');
expect(wrapper.html()).toContain(formStore.form.name);
expect(setWideLayout).toHaveBeenCalledTimes(1);
expect(wrapper.vm.isWideLayout).toBeTruthy();
});

it('onDelete should push to the FormSubmissions page', async () => {
Expand Down
19 changes: 19 additions & 0 deletions openshift/crunchydb/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# CrunchyDB

CHEFS uses CrunchyDB for all of its highly available databases. CrunchyDB uses
Patroni for replication and failovers, and Patroni uses PostgreSQL as the
underlying database.

## Installation

The CrunchyDB installations use the
[Helm charts](https://github.com/bcgov/crunchy-postgres) provided by the fine
folks over at platform services. Huge thanks go to that team for doing the hard
work of figuring out the CrunchyDB setup and making it easier for the community
to use CrunchyDB.

The `charts` directory has been copied here so that changes to the upstream repo
don't unexpectedly change our deployments. This stability and consistency comes
at the cost of added maintenance effort to stay in sync.

This code is current to commit `91d32cb` in December 2024.
23 changes: 23 additions & 0 deletions openshift/crunchydb/charts/crunchy-postgres/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
26 changes: 26 additions & 0 deletions openshift/crunchydb/charts/crunchy-postgres/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: v2
name: crunchy-postgres
description: A Helm chart for Kubernetes

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.6.3

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.

# Crunchy Postgres Operator version
appVersion: "5.0.4"
131 changes: 131 additions & 0 deletions openshift/crunchydb/charts/crunchy-postgres/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# Crunchy Postgres chart

A chart to provision a [Crunchy Postgres](https://www.crunchydata.com/) cluster.

## Configuration

### Crunchy Options

| Parameter | Description | Default |
| ------------------ | ---------------------- | ------------------ |
| `fullnameOverride` | Override release name | `crunchy-postgres` |
| `crunchyImage` | Crunchy Postgres image | |
| `postgresVersion` | Postgres version | `14` |

---

### Instances

| Parameter | Description | Default |
| ------------------------------------------- | ------------------------------ | ------------------------ |
| `instances.name` | Instance name | `ha` (high availability) |
| `instances.replicas` | Number of replicas | `2` |
| `instances.dataVolumeClaimSpec.storage` | Amount of storage for each PVC | `480Mi` |
| `instances.requests.cpu` | CPU requests | `1m` |
| `instances.requests.memory` | Memory requests | `256Mi` |
| `instances.limits.cpu` | CPU limits | `100m` |
| `instances.limits.memory` | Memory limits | `512Mi` |
| `instances.replicaCertCopy.requests.cpu` | replicaCertCopy CPU requests | `1m` |
| `instances.replicaCertCopy.requests.memory` | replicaCertCopyMemory requests | `32Mi` |
| `instances.replicaCertCopy.limits.cpu` | replicaCertCopyCPU limits | `50m` |
| `instances.replicaCertCopy.limits.memory` | replicaCertCopy Memory limits | `64Mi` |

---

### pgBackRest - Reliable PostgreSQL Backup & Restore

[pgBackRest site](https://pgbackrest.org/)
[Crunchy pgBackRest docs](https://access.crunchydata.com/documentation/pgbackrest/latest/)

| Parameter | Description | Default |
| ---------------------------------------------------- | ------------------------------------------------------------- | ---------------------- |
| `pgBackRest.image` | Crunchy pgBackRest | |
| `pgBackRest.retention` | Number of backups/days to keep depending on retentionFullType | `2` |
| `pgBackRest.retentionFullType` | Either 'count' or 'time' | `count` |
| `pgBackRest.repos.schedules.full` | Full backup schedule | `0 8 * * *` |
| `pgBackRest.repos.schedules.incremental` | Incremental backup schedule | `0 0,4,12,16,20 * * *` |
| `pgBackRest.repos.schedules.volume.addessModes` | Access modes | `ReadWriteOnce` |
| `pgBackRest.repos.schedules.volume.storage` | Access modes | `64Mi` |
| `pgBackRest.repos.schedules.volume.storageClassName` | Storage class name modes | `netapp-file-backup` |
| `pgBackRest.repoHost.requests.cpu` | CPU requests | `1m` |
| `pgBackRest.repoHost.requests.memory` | Memory requests | `64Mi` |
| `pgBackRest.repoHost.limits.cpu` | CPU limits | `50m` |
| `pgBackRest.repoHost.limits.memory` | Memory limits | `128Mi` |
| `pgBackRest.sidecars.requests.cpu` | sidecars CPU requests | `1m` |
| `pgBackRest.sidecars.requests.memory` | sidecars Memory requests | `64Mi` |
| `pgBackRest.sidecars.limits.cpu` | sidecars CPU limits | `50m` |
| `pgBackRest.sidecars.limits.memory` | sidecars Memory limits | `128Mi` |
| `pgBackRest.s3.enabled` | Enables the s3 repo backups | `false` |
| `pgBackRest.s3.createS3Secret` | Creates the s3 secret based on key and keySecret | `true` |
| `pgBackRest.s3.s3Secret` | The secret name to be created or read from | `s3-pgbackrest` |
| `pgBackRest.s3.s3Path` | The path inside the bucket where the backups will be saved to, set it to `/` to use the root of the bucket. | `/dbbackup` |
| `pgBackRest.s3.s3UriStyle` | Style of URL to use for S3 communication. [More Info](https://pgbackrest.org/configuration.html#section-repository/option-repo-s3-uri-style) | `path` |
| `pgBackRest.s3.bucket` | The bucket to use for backups | `bucketName` |
| `pgBackRest.s3.endpoint` | The endpoint to use, for example s3.ca-central-1.amazonaws.com | `endpointName` |
| `pgBackRest.s3.region` | The region to use, not necessary if your S3 system does not specify one | `ca-central-1` |
| `pgBackRest.s3.key` | The key to use to access the bucket. MUST BE KEPT SECRET | `s3KeyValue` |
| `pgBackRest.s3.keySecret` | The key secret for the key set above. MUST BE KEPT SECRET | `s3SecretValue` |
---

### Patroni

[Patroni docs](https://patroni.readthedocs.io/en/latest/)
[Crunchy Patroni docs](https://access.crunchydata.com/documentation/patroni/latest/)

| Parameter | Description | Default |
| ------------------------------------------- | ------------------------------------------------------------------- | --------------------------------- |
| `patroni.postgresql.pg_hba` | pg_hba permissions | `"host all all 0.0.0.0/0 md5"` |
| `crunchyImage` | Crunchy Postgres image | `...crunchy-postgres:ubi8-14.7-0` |
| `patroni.parameters.shared_buffers` | The number of shared memory buffers used by the server | `16MB` |
| `patroni.parameters.wal_buffers` | The number of disk-page buffers in shared memory for WAL | `64KB` |
| `patroni.parameters.min_wal_size` | The minimum size to shrink the WAL to | `32MB` |
| `patroni.parameters.max_wal_size` | Sets the WAL size that triggers a checkpoint | `64MB` |
| `patroni.parameters.max_slot_wal_keep_size` | Sets the maximum WAL size that can be reserved by replication slots | `128MB` |

---

### pgBouncer

A lightweight connection pooler for PostgreSQL

[pgBouncer site](https://www.pgbouncer.org/)
[Crunchy Postgres pgBouncer docs](https://access.crunchydata.com/documentation/pgbouncer/latest/)

| Parameter | Description | Default |
| --------------------------------- | ----------------------- | ------- |
| `proxy.pgBouncer.image` | Crunchy pgBouncer image | |
| `proxy.pgBouncer.replicas` | Number of replicas | `2` |
| `proxy.pgBouncer.requests.cpu` | CPU requests | `1m` |
| `proxy.pgBouncer.requests.memory` | Memory requests | `64Mi` |
| `proxy.pgBouncer.limits.cpu` | CPU limits | `50m` |
| `proxy.pgBouncer.limits.memory` | Memory limits | `128Mi` |

---

## PG Monitor

[Crunchy Postgres PG Monitor docs](https://access.crunchydata.com/documentation/pgmonitor/latest/)

| Parameter | Description | Default |
| ------------------------------------ | ---------------------------------------------- | ------- |
| `pgmonitor.enabled` | Enable PG Monitor (currently only PG exporter) | `false` |
| `pgmonitor.exporter.requests.cpu` | PG Monitor CPU requests | `1m` |
| `pgmonitor.exporter.requests.memory` | PG Monitor Memory requests | `64Mi` |
| `pgmonitor.exporter.limits.cpu` | PG Monitor CPU limits | `50m` |
| `pgmonitor.exporter.limits.memory` | PG Monitor Memory limits | `128Mi` |

#### Postgres Exporter

A [Prometheus](https://prometheus.io/) exporter for PostgreSQL

[Postgres Exporter](https://github.com/prometheus-community/postgres_exporter)

| Parameter | Description | Default |
| ------------------------------------ | ------------------------- | ------- |
| `pgmonitor.exporter.image` | Crunchy PG Exporter image | |
| `pgmonitor.exporter.requests.cpu` | CPU requests | `1m` |
| `pgmonitor.exporter.requests.memory` | Memory requests | `64Mi` |
| `pgmonitor.exporter.limits.cpu` | CPU limits | `50m` |
| `pgmonitor.exporterr.limits.memory` | Memory limits | `128Mi` |

---
Loading

0 comments on commit 056cd96

Please sign in to comment.