Uploaded image for project: 'Magnolia'
  1. Magnolia
  2. MAGNOLIA-7781

Follow-up - Improve profile and magnolia.properties handling in cloud bundle

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Normal Normal
    • 6.2.2
    • None
    • None
    • None
    • Yes
    • Yes
    • TE 1, TE 2, TE 3
    • 5

      Introduce profile based configuration

      Background

      Follow-up and align with proposal from ONDEMAND-2649;

      • Approach should be mostly applicable to defaults in magnolia-core: info.magnolia.init.DefaultMagnoliaPropertiesResolver#DEFAULT_INITIALIZATION_PARAMETER
      • and/or to magnolia-empty webapp (default properties files)

      Current situation

      By default Magnolia property files are resolved based on the host name, context path and name of the webapp. This default is specified in DefaultMagnoliaPropertiesResolver#DEFAULT_INITIALIZATION_PARAMETER and can be overridden via the magnolia.initialization.file context parameter.

      Proposal

      Introduce an alternative way to resolve Magnolia property files based on profiles. A profile is simply a name that can be further parametrized on the instance type and deployment stage. For profile based configuration we would change magnolia.initialization.file to something along the lines of

      WEB-INF/config/${env/MAGNOLIA_PROFILE}/magnolia_${env/MAGNOLIA_INSTANCE_TYPE}.${env/MAGNOLIA_STAGE}.properties,
      WEB-INF/config/${env/MAGNOLIA_PROFILE}/magnolia_${env/MAGNOLIA_INSTANCE_TYPE}.properties,
      WEB-INF/config/${env/MAGNOLIA_PROFILE}/magnolia.properties,
      WEB-INF/config/default/magnolia_${env/MAGNOLIA_INSTANCE_TYPE}.${env/MAGNOLIA_STAGE}.properties, 
      WEB-INF/config/default/magnolia_${env/MAGNOLIA_INSTANCE_TYPE}.properties,
      WEB-INF/config/default/magnolia.properties

       The profiles dev and cloud are reserved for development and cloud profiles, respectively. We include defaults for them for explicitness and convenience. The dev profile should simplify local development and we could draw inspirations from the dev webapp. The cloud profile should simplify Magnolia cloud deployments and cover ONDEMAND-2649 as much as possible.

      Related concerns

      • Magnolia should log activated profiles and failures to resolve them to facilitate debugging.
      • Handling of non expanded $(variables) in DefaultMagnoliaPropertiesResolver should be improved: such configuration sources should be skipped explicitly instead of attempting resolution with the literal, non expanded name.
      • DefaultMagnoliaPropertiesResolver relies on PropertiesInitializer#processPropertyFilesString, which is deprecated. We could replace this method with a new implementation.

      Compatibility

      • Profile based configuration must be explicitly enabled (command line argument, environment variable, context or init property)
      • Consider deprecating the server based configuration in favour of profile based configuration. Sketch a migration path for those who still rely on server based configuration.

      Potential further improvements

      • The dev profile could be treated specially and include non resource files (e.g. from ~/.magnolia).
      • Cloud native ways for injection the configuration. E.g. AWS Systems Manager Parameter Store.

      If considered worthwhile we should discuss implications such as additional complexity, security, etc. of in follow up tickets.

        Acceptance criteria

              mduerig Michael Duerig
              mgeljic Mikaël Geljić
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved:

                  Task DoD