Skip to content

Conversation

@geoserver-bot
Copy link
Collaborator

Backport #1375
Authored by: @groldan

…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 merged commit f0c7f32 into 1.26.x Feb 24, 2025
10 checks passed
@groldan groldan deleted the backport-1375-to-1.26.x branch February 24, 2025 16:39
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.

3 participants