OpenLiberty / open-liberty

Open Liberty is a highly composable, fast to start, dynamic application server runtime environment
https://openliberty.io
Eclipse Public License 2.0
1.15k stars 592 forks source link

How should we configure server-wide options for MicroProfile features #25327

Open Azquelt opened 1 year ago

Azquelt commented 1 year ago

Background

MicroProfile specifications generally allow configuration options to be set using in terms of MP Config. The supported properties are listed in the Open Liberty documentation.

MP Config is a standard way of setting config which works across different application servers. It's also works well in container environments because any MP Config property can be set via an environment variable.

In contrast, most other parts of Open Liberty config are configured using server.xml.

MP Config reads config values from several sources, some of which are specific to an application whereas others are system-wide.

Problem

For mpOpenApi-x.x features, we have some config properties which are server-wide, rather than scoped to a particular application. When we read these config values, we don't consider any config sources which are application-specific.

This behaviour could be unintuitive for users who are used to putting all their config which is known at build time within their application, or who are using custom config sources.

For example mpOpenAPI-2.0+ has the following config properties:

MicroProfile Metrics also has some config properties which are server-wide:

Possible solutions

  1. All server-wide config should be in server.xml. Only app-scoped config properties may be read from MP Config.

    • Users may need to use both MP Config and server.xml to configure the feature
    • If the value needs to be configurable at deployment time, the user must use placeholders in the server.xml
    • Add new server.xml elements for server-wide config properties which are currently read from MP Config.
      • Old options would continue to be supported
  2. Continue to use MP Config for all configuration of MP features

    • Users cannot place server-wide config in application-specific config sources
    • Users cannot use custom config sources for server-wide config
    • This effectively constrains users to using system properties, environment variables and server.xml variables to configure these properties
  3. Read config from both server.xml and MP Config

    • Define a set of guidelines for how liberty should behave if the user configures both
tevans78 commented 1 year ago

Note that some other MP features may be configured via server.xml elements. Some are global, some are scoped by application. Because these server.xml elements are outside of the scope captured by the generic server.xml ConfigSource provided by the mpConfig feature, it is not entirely clear which "source" takes precedence in each case. https://github.com/OpenLiberty/open-liberty/issues/21423

Azquelt commented 1 year ago

Points raised

From the design meeting 2023-05-30

Actions

  1. Where we have a choice, we should prefer to put server-level configuration in server.xml
    • This ensures that as far as possible we maintain the principle that server-level config should be dynamic
  2. Update documentation for existing MP Config properties which cannot be set in application config sources
  3. Make the maven + gradle plugins aware of MP Config properties which cannot be set in application config sources
    • They could move the relevant properties into server.xml, or at least warn the user