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

Configurable docroot via MicroProfile Config #9819

Merged
merged 23 commits into from Oct 13, 2023

Conversation

poikilotherm
Copy link
Contributor

@poikilotherm poikilotherm commented Aug 22, 2023

What this PR does / why we need it:

This pull request solves the problem that inside of containers you want to store anything underneath docroot etc on a different, usually bind-mounted filesystem. This PR makes the necessary code changes to

  1. use non-hardcoded paths in Dataverse,
  2. make the paths configurable, and
  3. test during startup of the app if these paths exist and are writeable (try to create if not exist)

Which issue(s) this PR closes:

Special notes for your reviewer:
None

Suggestions on how to test this:
Watch /dv and its subfolders when starting a container env via mvn -Pct package docker:run and storing data like fileuploads, collection themes, etc.

Does this PR introduce a user interface change? If mockups are available, please link/include them here:
None.

Is there a release notes update needed for this change?:
Maybe? Please leave a comment.

Additional documentation:
None.

The default from microprofile-config.properties does NOT work,
as the location must already be resolvable while the servlet is
being initialized - the app shipped defaults file is not yet read
at this point.

This is similar to the database options, which must be set using one
of the other Payara included config sources. (Non-easily resolvable
timing issue). The solution for containers is to add an env var to
the docker file, which can be overriden by any env var from compose
or K8s etc. (Problem is the high ordinal of the env source though)
Instead of trying to provide a default using STORAGE_DIR env var from
microprofile-config.properties as before, using this env var reference
in glassfish-web.xml directly now. By defaulting to "." if not present
(as in classic installations), it is fully equivalent to the former
hardcoded default value.

Providing a synced variant of it in microprofile-config.properties
and leaving a hint about the pitfalls, we can reuse the setting for
other purposes within the codebase as well (and expect the same
behaviour because same defaults).
…IQSS#9572

Starting with important local storage locations for the Dataverse application,
this service uses EJB startup mechanisms to verify configuration bits on startup.

Checks for the temp storage location and JSF upload location as crucial parts
of the app, which, if not exist or write protected, while only cause errors and
failures on the first data upload attempt. This is not desirable as it might cause
users to be blocked.
Add JVM Setting and add to config checker on startup to ensure target location is in good shape.
By introducing a new static method ThemeWidgetFragment.getLogoDir
all other places (api.Access, api.Dataverse, UpdateDataverseThemeCommand,
DataverseServiceBean) can use a lookup function from one central place
instead of building the path on their own.

Reducing code duplication also means we can more easily get the location
from a setting, enabling relocation of the data. That is especially
important for container usage.

Also, we can now use ConfigCheckService to detect if the folders we configured
are read/write accessible to us.
…IQSS#9662

Payara does not support looking up variables in default values of a lookup.
As a consequence, we must return to the hardcoded "./docroot" and "./uploads"
and instead supply default values using two environment variables in the
applications' Dockerfile. This way they stay configurable from cmdline or
other sources of env vars.
With Files.notExist if some folder does not have the "execute"
attribute, it cannot detect a folder does not exist.
Inverting the Files.exists call solves the problem.

Also adding tests for the business logic.
@poikilotherm poikilotherm added Feature: Installation Guide Component: Containers Anything related to cloudy Dataverse, shipped in containers. Size: 3 A percentage of a sprint. 2.1 hours. Feature: Container Guide labels Aug 22, 2023
@poikilotherm poikilotherm self-assigned this Aug 22, 2023
@poikilotherm poikilotherm changed the title 9662 docroot mpc Configurable docroot via MicroProfile Config Aug 22, 2023
This is also used in ConfigCheckServiceTest to verify the checks are
working. This property is picked up when sitemap util looks up the
storage location via MPCONFIG, parsing the default values during
testing from src/test/resources/META-INF/microprofile-config.properties
By providing a sane default unter /tmp, we enable a few tests that
do not use a custom testclass scoped directory to run
- No more profile to work around Payaras bug with overriding profiled
  values
- Group together because every item using $STORAGE_DIR and a default
  to match classic installs now
@poikilotherm poikilotherm marked this pull request as ready for review August 23, 2023 09:52
Copy link
Contributor

@bencomp bencomp left a comment

Choose a reason for hiding this comment

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

With lots of TODOs all around the codebase I feel that adding new ones should only be allowed under strict circumstances. Otherwise their status will be hard to keep track of.

@coveralls
Copy link

coveralls commented Sep 15, 2023

Coverage Status

coverage: 20.053% (+0.02%) from 20.038% when pulling fce664f on poikilotherm:9662-docroot-mpc into 7e0738e on IQSS:develop.

@cmbz cmbz added this to the 6.1 milestone Sep 18, 2023
@cmbz
Copy link

cmbz commented Sep 18, 2023

2023/09/18: Moved to Sprint Ready as per discussion in prioritization meeting.

@cmbz cmbz added this to Ready for Review ⏩ in IQSS/dataverse (TO BE RETIRED / DELETED in favor of project 34) via automation Sep 18, 2023
@poikilotherm poikilotherm removed their assignment Sep 20, 2023
@landreev landreev self-assigned this Sep 26, 2023
@landreev landreev moved this from Ready for Review ⏩ to In Review 🔎 in IQSS/dataverse (TO BE RETIRED / DELETED in favor of project 34) Sep 26, 2023
@poikilotherm
Copy link
Contributor Author

@landreev I just merged develop, so ready when you are 😸

Copy link
Contributor

@landreev landreev left a comment

Choose a reason for hiding this comment

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

Sorry for the delay! - I kept getting distracted by other things.

IQSS/dataverse (TO BE RETIRED / DELETED in favor of project 34) automation moved this from In Review 🔎 to Ready for QA ⏩ Oct 4, 2023
@kcondon kcondon self-assigned this Oct 13, 2023
@kcondon kcondon merged commit 64808ce into IQSS:develop Oct 13, 2023
15 of 16 checks passed
IQSS/dataverse (TO BE RETIRED / DELETED in favor of project 34) automation moved this from Ready for QA ⏩ to Done 🚀 Oct 13, 2023
pdurbin added a commit that referenced this pull request Oct 18, 2023
Jenkins is failing. Maybe disabling this will help.

It was added in this PR: #9819
pdurbin added a commit that referenced this pull request Oct 26, 2023
Jenkins is failing. Maybe disabling this will help.

It was added in this PR: #9819
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Containers Anything related to cloudy Dataverse, shipped in containers. Feature: Container Guide Feature: Installation Guide Size: 3 A percentage of a sprint. 2.1 hours.
Projects
Status: No status
6 participants