fix (storage) : use operator podSecurityContext for PVC cleanup job on OpenShift#1638
fix (storage) : use operator podSecurityContext for PVC cleanup job on OpenShift#1638rohanKanojia wants to merge 1 commit into
Conversation
…n OpenShift Apply workspace.Config.Workspace.PodSecurityContext to the cleanup Job pod spec, matching the workspace deployment behavior. Signed-off-by: Rohan Kumar <rohaan@redhat.com>
|
Skipping CI for Draft Pull Request. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: rohanKanojia The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
📝 WalkthroughWalkthroughThis PR removes OpenShift-specific conditional logic from the cleanup job pod security context setup. The cleanup Job now always uses the workspace configuration's pod security context directly, eliminating the prior dependency on the ChangesPod Security Context Simplification
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pkg/provision/storage/cleanup_test.go`:
- Line 2: Update the copyright header string in this Go source to reflect the
current year: change the header text that reads "// Copyright (c) 2019-2025 Red
Hat, Inc." to "// Copyright (c) 2019-2026 Red Hat, Inc." so it matches the
required pattern for Go files (the header followed by the Apache License 2.0
text); ensure the exact header line in the file is replaced accordingly.
- Around line 18-33: Reorder the import block in cleanup_test.go into three
groups separated by single blank lines: first put standard library imports
(context, testing), then third-party + Kubernetes imports
(github.com/stretchr/testify/assert, sigs.k8s.io/controller-runtime/pkg/log/zap,
sigs.k8s.io/controller-runtime/pkg/client/fake, k8s.io/api/core/v1,
k8s.io/apimachinery/pkg/apis/meta/v1, and any other non-local packages), and
finally project-local imports (github.com/devfile/api/v2/...,
github.com/devfile/devworkspace-operator/...,
github.com/devfile/devworkspace-operator/pkg/..., etc.); run make fmt or
goimports to enforce formatting. Ensure the import names shown in the diff
(context, testing, dw, assert, corev1, metav1, fake, zap and project packages
like common, constants, infrastructure, sync, v1alpha1) are placed into the
correct groups.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: f316ac07-7b25-41eb-9d5b-7755d159173f
📒 Files selected for processing (2)
pkg/provision/storage/cleanup.gopkg/provision/storage/cleanup_test.go
| @@ -0,0 +1,81 @@ | |||
| // | |||
| // Copyright (c) 2019-2025 Red Hat, Inc. | |||
There was a problem hiding this comment.
Update the copyright year in the file header.
Line 2 still uses 2019-2025; this should be 2019-2026 for current-year compliance.
As per coding guidelines: **/*.go: All Go source files MUST start with the copyright header: '// Copyright (c) 2019-{CURRENT_YEAR} Red Hat, Inc.' followed by Apache License 2.0 license text.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@pkg/provision/storage/cleanup_test.go` at line 2, Update the copyright header
string in this Go source to reflect the current year: change the header text
that reads "// Copyright (c) 2019-2025 Red Hat, Inc." to "// Copyright (c)
2019-2026 Red Hat, Inc." so it matches the required pattern for Go files (the
header followed by the Apache License 2.0 text); ensure the exact header line in
the file is replaced accordingly.
| import ( | ||
| "context" | ||
| "testing" | ||
|
|
||
| dw "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" | ||
| "github.com/devfile/devworkspace-operator/apis/controller/v1alpha1" | ||
| "github.com/devfile/devworkspace-operator/pkg/common" | ||
| "github.com/devfile/devworkspace-operator/pkg/constants" | ||
| "github.com/devfile/devworkspace-operator/pkg/infrastructure" | ||
| "github.com/devfile/devworkspace-operator/pkg/provision/sync" | ||
| "github.com/stretchr/testify/assert" | ||
| corev1 "k8s.io/api/core/v1" | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| "sigs.k8s.io/controller-runtime/pkg/client/fake" | ||
| "sigs.k8s.io/controller-runtime/pkg/log/zap" | ||
| ) |
There was a problem hiding this comment.
Reorder imports into the required three groups.
Lines 18-33 currently mix third-party/Kubernetes and project-local imports in one block; split into: standard library, third-party+Kubernetes, then project-local (or run make fmt).
As per coding guidelines: **/*.go: Organize imports into three groups separated by blank lines: (1) standard library, (2) third-party + Kubernetes, (3) project-local. Run 'make fmt' to enforce automatically.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@pkg/provision/storage/cleanup_test.go` around lines 18 - 33, Reorder the
import block in cleanup_test.go into three groups separated by single blank
lines: first put standard library imports (context, testing), then third-party +
Kubernetes imports (github.com/stretchr/testify/assert,
sigs.k8s.io/controller-runtime/pkg/log/zap,
sigs.k8s.io/controller-runtime/pkg/client/fake, k8s.io/api/core/v1,
k8s.io/apimachinery/pkg/apis/meta/v1, and any other non-local packages), and
finally project-local imports (github.com/devfile/api/v2/...,
github.com/devfile/devworkspace-operator/...,
github.com/devfile/devworkspace-operator/pkg/..., etc.); run make fmt or
goimports to enforce formatting. Ensure the import names shown in the diff
(context, testing, dw, assert, corev1, metav1, fake, zap and project packages
like common, constants, infrastructure, sync, v1alpha1) are placed into the
correct groups.
What does this PR do?
Apply
workspace.Config.Workspace.PodSecurityContextto the cleanup Job pod spec, matching the workspace deployment behavior.What issues does this PR fix or reference?
https://redhat.atlassian.net/browse/CRW-10864
Is it tested? How?
Deploy DevWorkspaceOperator and follow these steps:
Expected:
Behavior on main:
PR Checklist
/test v8-devworkspace-operator-e2e, v8-che-happy-pathto trigger)v8-devworkspace-operator-e2e: DevWorkspace e2e testv8-che-happy-path: Happy path for verification integration with CheSummary by CodeRabbit
Tests
Refactor