Skip to content

feat: allow job-run on non-service and stopped containers#413

Open
nekrich wants to merge 1 commit intomcuadros:masterfrom
nekrich:feat/run-job-labels-on-stopped-container
Open

feat: allow job-run on non-service and stopped containers#413
nekrich wants to merge 1 commit intomcuadros:masterfrom
nekrich:feat/run-job-labels-on-stopped-container

Conversation

@nekrich
Copy link

@nekrich nekrich commented Feb 13, 2026

Closes #412 😅

Summary

This PR allows job-run to be defined on non-service and stopped containers. Ofelia now parses labels from all matching containers (including stopped ones) and accepts run jobs from any container labels. local and service-run jobs remain restricted to the ofelia service container.

Changes

  • Label source includes stopped containers
    GetDockerLabels() now calls ListContainers(..., All: true), so stopped containers are listed, and their labels are read. This enables one-off run jobs that target stopped containers.

  • New DockerContainerInfo type
    Labels are keyed by container name and running state: map[DockerContainerInfo]map[string]string instead of map[string]map[string]string. This allows treating running vs. stopped containers differently.

  • Job type rules

    • Stopped containers: Only job-run is allowed. Exec, local, and service-run labels on stopped containers are ignored.
    • Non–service containers: job-exec and job-run are allowed. job-local and job-service-run are still only allowed on the ofelia service container; labels on other containers log a warning and are ignored.
  • Improvement: dockerLabelsUpdate now sets parsedLabelConfig.logger = c.logger before calling buildFromDockerLabels, avoiding a nil pointer dereference, and there is a warning if some parameters are incorrect.

  • Tests

    • Tests updated to use DockerContainerInfo and to set a test logger so buildFromDockerLabels and DeepEquals still behave correctly.
    • New cases: run job from non-service container, run job with explicit container label, and "only run jobs allowed on stopped containers."

nekrich pushed a commit to nekrich/ofelia that referenced this pull request Feb 13, 2026
## Summary
- Add new linters: testifylint, usestdlibvars, fatcontext, intrange,
dupword, err113
- Create static error definitions for err113 compliance (cli/errors.go,
middlewares/errors.go, core/errors.go)
- Fix all surfacing linter issues (100+ issues → 0)
- Add comprehensive test file exclusions for practical linting

## Changes

### New Linters Added
| Linter | Purpose |
|--------|---------|
| testifylint | Enforce testify best practices |
| usestdlibvars | Use stdlib constants (http.MethodGet, etc.) |
| fatcontext | Detect context.Context in structs |
| intrange | Go 1.22+ integer range syntax |
| dupword | Detect duplicate words in comments |
| err113 | Require static error definitions |

### Static Error Definitions
- `cli/errors.go` - Validation errors for CLI
- `middlewares/errors.go` - Preset, webhook, and security errors
- Extended `core/errors.go` with scheduler, shutdown, resilience errors

### Test File Exclusions
Relaxed linting for test files (practical trade-off):
- errcheck, dupl, errorlint, gocritic, predeclared, staticcheck, unparam

### Configuration
- goconst min-occurrences: 5 (avoids struct tag false positives)
- paralleltest/tparallel exclusions for integration/mutation tests

## Test plan
- [x] `golangci-lint run` → 0 issues
- [x] `go test ./...` → All passing
- [x] `go test ./... -tags=integration,e2e` → All passing

## Metrics
| Metric | Value |
|--------|-------|
| Files changed | 66 |
| Linter (uncached) | 11.5s |
| Unit tests | 2.3s |
| All tests (integration+e2e) | 25s |
nekrich pushed a commit to nekrich/ofelia that referenced this pull request Feb 13, 2026
## Summary

Updates CHANGELOG.md with release notes for v0.17.0 including:

- **Secure Web Authentication** (mcuadros#408)
- **Doctor Command Enhancements** (mcuadros#408)
- **ntfy-token Preset** (mcuadros#409)
- **Webhook Host Whitelist** (mcuadros#410)
- **CronClock Interface** (mcuadros#412)
- **Cookie Security Hardening** (mcuadros#411)
- **GitHub Actions Pinning** (mcuadros#411)
- **Test Infrastructure Improvements** (mcuadros#412)
- **Performance Optimizations** (mcuadros#412)
- **Linting Audit** (mcuadros#413)

## Test Plan

- [x] Changelog follows Keep a Changelog format
- [x] All PR references are correct
- [x] Date is correct (2025-12-22)
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.

Ofelia does not parse labels from stopped containers; need job-run for one-off runs

1 participant