[Bug]: Maintenance window does not activate when using "Same as Server Timezone" in containerized deployments
- Lenguaje dominante
- Go
- Estrellas
- 1.2k
- Forks
- 69
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
**Describe the bug**
Maintenance window does not activate when timezone is set to `Same as Server Timezone` in containerized (Kubernetes/Docker) deployments. The issue is in `time_utils.go` where `LoadTimezone` resolves `SAME_AS_SERVER` using `time.Now().Location().String()` – which returns `UTC` in distroless/scratch images that lack tzdata and `/usr/share/zoneinfo`, even when `TZ` environment variable is set correctly.
**Database**
- PostgreSQL
**To Reproduce**
1. Deploy Peekaping in Kubernetes using official Helm chart with `TZ=Europe/Kyiv` in config env
2. Create a Maintenance window with timezone `Same as Server Timezone`
3. Set start/end time to current local time
4. Observe that maintenance does not activate
**Expected behavior**
Maintenance window should activate at the specified local time. `SAME_AS_SERVER` should resolve timezone from the `TZ` environment variable, not from `time.Now().Location()`.
**Root cause**
In `apps/server/internal/modules/maintenance/utils/time_utils.go`:
```go
if timezone == "SAME_AS_SERVER" {
timezone = time.Now().Location().String() // always returns "UTC" in distroless images
}
```
`time.Now().Location()` returns `UTC` in containers without tzdata regardless of `TZ` env var.
**Proposed fix**
```go
if timezone == "SAME_AS_SERVER" {
tz := os.Getenv("TZ")
if tz == "" {
tz = "UTC"
}
timezone = tz
}
```
**Desktop:**
- OS: Linux
- Browser: Chrome
- Version: 0.0.45
**Additional context**
Workaround: set timezone explicitly to `UTC` in maintenance form and input times in UTC manually.
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Línea de trabajo
The bug is in `apps/server/internal/modules/maintenance/utils/time_utils.go`. Start by locating the `LoadTimezone` function and the `SAME_AS_SERVER` handling. Read the Go `time` package documentation about `Location` in containers. The fix is to read the `TZ` environment variable via `os.Getenv`. Test by building a minimal container image and verifying the timezone resolution. 'Done' is when a maintenance window set to 'Same as Server Timezone' activates at the correct local time in a distroless container.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- docker, go, kubernetes, postgresql
- Área
- backend, devops
- Tipo de issue
- Error
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Estado de actividad
- Estancado
- Claridad
- Bien especificado
- Aptitud para principiantes
- 70/100