Skip to content

Collective lift and shift updates#188

Merged
jonrandahl merged 43 commits intodev-infrastructurefrom
spike/collective-lift-and-shift-updates
May 23, 2023
Merged

Collective lift and shift updates#188
jonrandahl merged 43 commits intodev-infrastructurefrom
spike/collective-lift-and-shift-updates

Conversation

@jonrandahl
Copy link
Contributor

@jonrandahl jonrandahl commented Jan 24, 2023

This PR includes the following updates and resolves the linked issues:

  • Refactors the elapsed time calculated for API requests to be resolved as microseconds rather than milliseconds. This is to improve the reporting of the elapsed time in the system tooling logs. #104/#111
  • Minor text changes to the Gemfile to include instructions for running Epimorphics specific gems locally during the development of those gems.
  • Updated the production data_services_api gem version to be at least the current version~>1.3.2 (this is to cover out of sync release versions)
  • Updated the production lr_common_styles gem version to be at least the current version ~>1.9.0 (this is to cover out of sync release versions)
  • Refactored better guards in entrypoint.sh to ensure the required env vars are set accordingly or deployment will fail noisily.
  • Refactored the error messages displayed to be semantically formatted as well as incorporated ALL lines for the returned message to be held in the variable instead of being possibly displayed outside of the intended context.
  • Adjusted the processing of error status to use the application template; also includes adjustments to not double render the error response. #103
  • Added the updated configuration for the AWS credential improvements as per other readme's; included further info to run the application locally; resolved a markdown linting issue with using HTML in markdown.

Refactored the version cadence creation to include a SUFFIX value if provided; otherwise no SUFFIX is included in the version number.
Expands Method block  length rule to allow for slightly longer method names
Following community guidance for measuring elapsed time in rails the logging mechanism has been changed to use the CPU time instead of RealTime. This also has the added benefit to return the results in the requested `microseconds` unit without further mathematical manipulation.
Refined text changes to the `Gemfile` to include instructions for running Epimorphics specific gems locally during the development of those gems. Updated the production environment gem versions to be at least the current version to cover out of sync release versions. Also includes slight reordering of specific groups of included gems for different environments.
This sets the cache control headers for HMLR apps to be public and cacheable in the production environment. 
Price Paid Data uses a time limit of 5 minutes (300 seconds)

epimorphics/hmlr-linked-data#114
In Production no default URL values are passed on the basis that missing configuration options represent a category of bug, and in that case the deployment should fail fast and noisily. This does include a default value of `true` for the `RAILS_SERVE_STATIC_FILES` nonetheless.

https://github.com/epimorphics/ijd-transfer-notes/blob/main/rails-app-pattern.md#environment-variables-and-run-time-configuration
In order to improve the ux minor tweaks have been made to the layout and formatting of the returned error message and reference code presentation.
Following lengthy internal discussions the global env variable `RAILS_RELATIVE_URL_ROOT` has been renamed to `APPLICATION_PATH` to be more clear on it's use; needs to be monitored once deployed. Also includes better guards in `entrypoint.sh` to ensure the required env vars are set accordingly or deployment will fail noisily.
Refactored the `StandardError` rescue block to use the provided status from the current exception outside of `MalformedSearchError` and `ArgumentError` types and otherwise fall back to a generic 500 status;
Refactored the error messages displayed to be semantically formatted as well as incorporated ALL lines for the returned message to be held in the variable instead of being possibly displayed outside of the intended context.
Also includes minor update to layout format for older entries
@jonrandahl jonrandahl self-assigned this Jan 26, 2023
jonrandahl and others added 10 commits January 27, 2023 09:29
…epimorphics/ppd-explorer into spike/collective-lift-and-shift-updates
Adjusted the processing of error status to use the application template; also includes adjustments to not double render the error response.

epimorphics/hmlr-linked-data#103
…updates' into spike/collective-lift-and-shift-updates
refactored the gem paths to use the remote Epimorphics repository locations, also includes the regenerated gemfile.lock reflecting as such.
Added the updated configuration for the AWS credential improvements as per other readme's; included further info to run the application locally; resolved a markdown linting issue with using HTML in markdown.
@jonrandahl jonrandahl marked this pull request as ready for review March 10, 2023 17:50
jonrandahl and others added 3 commits March 13, 2023 11:24
This resolves that Rails would want the `RAILS_RELATIVE_URL_ROOT` env var set, while using `APPLICATION_ROOT` is clearer in the `entrypoint.sh` code - this also updates the readme’s to reflect this change
Fixed typo for `APPLICATION_ROOT` env var
fixes variable for development environments
@jonrandahl jonrandahl changed the title Spike/collective lift and shift updates Collective lift and shift updates Mar 13, 2023
Copy link
Contributor

@bogdanadrianmarc bogdanadrianmarc left a comment

Choose a reason for hiding this comment

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

Looks good 👍

Copy link
Member

@der der left a comment

Choose a reason for hiding this comment

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

Looks fine, just one comment in line.

Implements unification approach to Make, Docker and other associated build files to ensure the image process completes as expected.
as these are not used in the app they were actually causing more issue on production images and therefore were removed.
now mirrors other app structures
`config.assets.precompile` and `config.assets.version` have moved to `config/initializers/assets.rb`
Updated the matching configuration settings on each environment configuration file to uniify the settings for all apps
Makefile Outdated
COMMIT=$(shell git rev-parse --short HEAD)
VERSION?=$(shell /usr/bin/env ruby -e 'require "./app/lib/version" ; puts Version::VERSION')
TAG?=$(shell printf '%s-%s-%08d' ${VERSION} ${COMMIT} ${GITHUB_RUN_NUMBER})
TAG?=$(shell printf '%s_%s_%08d' ${VERSION} ${COMMIT} ${GITHUB_RUN_NUMBER})
Copy link
Contributor

Choose a reason for hiding this comment

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

Has it been confirmed that changing the Tag format doesn't break deployment?

README.md Outdated
| name | description | typical value |
| -------------------------- | -------------------------------------------------------------------- | -------------------------- |
| `RAILS_RELATIVE_URL_ROOT` | The path from the server root to the application | `/app/ppd` |
| `APPLICATION_ROOT` | The path from the server root to the application | `/app/ppd` |
Copy link
Contributor

Choose a reason for hiding this comment

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

NO. This shouldn't be an environment variable unless the image has no knowledge of the path from build time. I VERY much suspect this is not the case.

What does "Typical Value" mean?

entrypoint.sh Outdated
fi

export RAILS_RELATIVE_URL_ROOT=${RAILS_RELATIVE_URL_ROOT:-'/app/ppd'}
export RAILS_RELATIVE_URL_ROOT=${APPLICATION_ROOT:-'/app/ppd'}
Copy link
Contributor

Choose a reason for hiding this comment

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

No. Don't use environment variables.

entrypoint.sh Outdated
export SCRIPT_NAME=${RAILS_RELATIVE_URL_ROOT}

echo "{'ts': '`date -u +%FT%T.%3NZ`', 'message': {'text: 'Starting Standard Reports UI. API_SERVICE_URL=${API_SERVICE_URL} RAILS_ENV=${RAILS_ENV} RAILS_RELATIVE_URL_ROOT=${RAILS_RELATIVE_URL_ROOT}', 'level': 'INFO'}}"
echo "{\"ts\": $(date -u +%FT%T.%3NZ), \"level\": \"INFO\", \"message\": \"Starting ${PUBLIC_NAME} application with RAILS_ENV=\"${RAILS_ENV}\", \"RAILS_RELATIVE_URL_ROOT\"=\"${RAILS_RELATIVE_URL_ROOT}\", \"SCRIPT_NAME\"=\"${SCRIPT_NAME}\"}"
Copy link
Contributor

Choose a reason for hiding this comment

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

No. Don't use environment variables.

Copy link
Member

@der der left a comment

Choose a reason for hiding this comment

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

Looks fine to me apart from not understanding the point of SCRIPT_NAME.

Don't understand @andrew-pickin-epi 's concern about use of environment variable to set RAILS_RELATIVE_URL_ROOT but once that's resolved to mutual satisfaction I don't think I need to re-review so approving now.

entrypoint.sh Outdated

export RAILS_RELATIVE_URL_ROOT=${RAILS_RELATIVE_URL_ROOT:-'/app/ppd'}
export RAILS_RELATIVE_URL_ROOT=${APPLICATION_ROOT:-'/app/ppd'}
export SCRIPT_NAME=${RAILS_RELATIVE_URL_ROOT}
Copy link
Member

Choose a reason for hiding this comment

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

Is this needed? I thought we only used RAILS_RELATIVE_URL_ROOT

improvements for handling error pages. will need to be ported onto the other apps as well post lift & shift testing
specific to epimorphics internal gems
Copy link
Contributor

@andrew-pickin-epi andrew-pickin-epi left a comment

Choose a reason for hiding this comment

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

I suspect there a broken merge going on here.
The Makefile is certainly in error.

- (Jon) Refactored the version cadence creation to include a SUFFIX value if
provided; otherwise no SUFFIX is included in the version number.
- (Jon) Adjusted the processing of error status to use the application template;
also includes adjustments to not double render the error response.
Copy link
Contributor

Choose a reason for hiding this comment

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

APPLICATION_ROOT has been dropped.

README.md Outdated

| name | description | typical value |
| -------------------------- | -------------------------------------------------------------------- | -------------------------- |
| `APPLICATION_ROOT` | The path from the server root to the application | `/app/ppd` |
Copy link
Contributor

Choose a reason for hiding this comment

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

APPLICATION_ROOT has been dropped.

Makefile Outdated
COMMIT=$(shell git rev-parse --short HEAD)
VERSION?=$(shell /usr/bin/env ruby -e 'require "./app/lib/version" ; puts Version::VERSION')
TAG?=$(shell printf '%s-%s-%08d' ${VERSION} ${COMMIT} ${GITHUB_RUN_NUMBER})
TAG?=$(shell printf '%s_%s_%08d' ${VERSION} ${COMMIT} ${GITHUB_RUN_NUMBER})
Copy link
Contributor

Choose a reason for hiding this comment

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

This still using the wrong path for the bundle conf.
Broken merge?

Removed `${HOME}/` from path
Includes further clarification on running the app individually, or as part of the HMLR suite of apps; alongside using Docker containers and accessing the Data API locally.
@jonrandahl jonrandahl merged commit a54f447 into dev-infrastructure May 23, 2023
@jonrandahl jonrandahl deleted the spike/collective-lift-and-shift-updates branch May 23, 2023 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants