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

Support loading the xml configuration from a read-only filesystem #1375

Merged
merged 1 commit into from
Feb 24, 2025

Conversation

groldan
Copy link
Member

@groldan groldan commented Feb 19, 2025

Refactor XMLFileResourceProvider to support read-only configuration directories.

Enhances XMLFileResourceProvider to allow GeoWebCache to start with a read-only configuration directory and geowebcache.xml file. Previously, the provider assumed that the configuration directory was always writable, which caused startup failures when running in environments with restricted file permissions.

  • Support read-only configuration directories:

    • hasInput() now correctly returns true if the configuration file exists or if a template is available and the directory is writable.
    • hasOutput() ensures that the configuration file can be written before allowing output operations.
    • Improved error handling when checking directory and file writability.
  • Refactored file existence checks:

    • Consolidated logic for checking configuration file existence and writability into findConfigFile().
    • Moved the directory writability check from findConfigFile() to findOrCreateConfFile() to prevent premature failures.
  • Improved logging and exception handling:

    • hasInput() and hasOutput() now log warnings when encountering errors instead of failing silently.
    • findOrCreateConfFile() now explicitly throws an exception when it cannot create a new configuration file due to permission issues.
  • GeoWebCache can now start successfully with a pre-existing, read-only configuration directory.

  • Configurations stored in a read-only filesystem (e.g., mounted from a read-only volume) can still be used without requiring write access.

  • The provider only attempts to create a configuration file when explicitly required, eliminating side effects from query methods hasInput() and hasOutput().

This change improves the resilience of GeoWebCache in constrained environments while maintaining backward compatibility for writable configurations.

@groldan groldan force-pushed the readonly_gwc_config_dir branch from aa930f4 to e719b0e Compare February 19, 2025 23:14
@groldan groldan changed the title Refactor XMLFileResourceProvider to support read-only configuration directories Support loading the xml configuration from a read-only filesystem Feb 19, 2025
@groldan groldan force-pushed the readonly_gwc_config_dir branch from e719b0e to 39c4318 Compare February 19, 2025 23:17
…irectories

Enhance `XMLFileResourceProvider` to allow GeoWebCache to start with a
read-only configuration directory and `geowebcache.xml` file. Previously, the provider
assumed that the configuration directory was always writable, which caused startup
failures when running in environments with restricted file permissions.

- **Support read-only configuration directories**:
  - `hasInput()` now correctly returns `true` if the configuration file
     exists or if a template is available and the directory is writable.
  - `hasOutput()` ensures that the configuration file can be written before
     allowing output operations.
  - Improved error handling when checking directory and file writability.

- **Refactored file existence checks**:
  - Consolidated logic for checking configuration file existence and writability
    into `findConfigFile()`.
  - Moved the directory writability check from `findConfigFile()` to
    `findOrCreateConfFile()` to prevent premature failures.

- **Improved logging and exception handling**:
  - `hasInput()` and `hasOutput()` now log warnings when encountering errors
     instead of failing silently.
  - `findOrCreateConfFile()` now explicitly throws an exception when it cannot
     create a new configuration file due to permission issues.

- GeoWebCache can now start successfully with a pre-existing, read-only configuration directory.
- Configurations stored in a read-only filesystem (e.g., mounted from a
  read-only volume) can still be used without requiring write access.
- The provider only attempts to create a configuration file when explicitly
  required, eliminating side effects from query methods `hasInput()` and
  `hasOutput()`.

This change improves the resilience of GeoWebCache in constrained environments
while maintaining backward compatibility for writable configurations.
@groldan groldan force-pushed the readonly_gwc_config_dir branch from 39c4318 to 9177305 Compare February 19, 2025 23:29
Copy link
Member

@aaime aaime 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 to me

@aaime aaime merged commit 02add09 into GeoWebCache:main Feb 24, 2025
11 checks passed
@groldan groldan deleted the readonly_gwc_config_dir branch February 24, 2025 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants