Skip to content

Commit 0895240

Browse files
Add non-admin backport design document (#1898)
1 parent 4ba8f18 commit 0895240

File tree

1 file changed

+362
-0
lines changed

1 file changed

+362
-0
lines changed

docs/design/nonadmin_backport.md

Lines changed: 362 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,362 @@
1+
# Non-Admin Backup and Restore Feature Backport Design
2+
## From OADP 1.5 to OADP 1.4
3+
4+
### Executive Summary
5+
6+
This document outlines the design and implementation plan for backporting the Non-Admin Backup and Restore feature from OADP 1.5 to OADP 1.4. The feature enables non-administrative users to perform backup and restore operations in their own namespaces with controlled permissions and enforcement mechanisms.
7+
8+
### Current State Analysis
9+
10+
#### OADP 1.5 Non-Admin Feature Components
11+
12+
Based on analysis of the current implementation, the non-admin feature includes:
13+
14+
1. **New Custom Resource Definitions (CRDs)**:
15+
- `NonAdminBackup` - For creating backup requests
16+
- `NonAdminRestore` - For creating restore requests
17+
- `NonAdminBackupStorageLocation` - For backup storage locations
18+
- `NonAdminBackupStorageLocationRequest` - For requesting BSL access
19+
- `NonAdminDownloadRequest` - For downloading backup logs/data
20+
21+
2. **Core Controller Components**:
22+
- Non-admin controller deployment (`internal/controller/nonadmin_controller.go`)
23+
- Integration with main DPA controller
24+
- Non-admin image management and deployment lifecycle
25+
26+
3. **RBAC Infrastructure**:
27+
- Service account for non-admin controller
28+
- Role and role bindings for controller permissions
29+
- User-facing RBAC roles (admin, editor, viewer) for each CRD
30+
31+
4. **DPA Integration**:
32+
- `NonAdmin` configuration struct in DPA spec
33+
- Enforcement specifications for backup/restore operations
34+
- BSL approval mechanisms
35+
- Garbage collection and sync period configurations
36+
37+
#### OADP 1.4 Current State
38+
39+
OADP 1.4 branch analysis shows:
40+
- No non-admin CRDs present
41+
- No non-admin controller implementation
42+
- Basic DPA structure without NonAdmin field
43+
- Standard RBAC limited to administrative operations
44+
45+
### Implementation Plan
46+
47+
#### Phase 1: API and CRD Implementation
48+
49+
**1.1 Add NonAdmin struct to DPA types** (`api/v1alpha1/dataprotectionapplication_types.go`):
50+
```go
51+
type NonAdmin struct {
52+
Enable *bool `json:"enable,omitempty"`
53+
EnforceBackupSpec *velero.BackupSpec `json:"enforceBackupSpec,omitempty"`
54+
EnforceRestoreSpec *velero.RestoreSpec `json:"enforceRestoreSpec,omitempty"`
55+
EnforceBSLSpec *EnforceBackupStorageLocationSpec `json:"enforceBSLSpec,omitempty"`
56+
RequireApprovalForBSL *bool `json:"requireApprovalForBSL,omitempty"`
57+
GarbageCollectionPeriod *metav1.Duration `json:"garbageCollectionPeriod,omitempty"`
58+
BackupSyncPeriod *metav1.Duration `json:"backupSyncPeriod,omitempty"`
59+
}
60+
```
61+
62+
**1.2 Add required enforcement types**:
63+
- `EnforceBackupStorageLocationSpec`
64+
- `ObjectStorageLocation`
65+
- `StorageType`
66+
67+
**1.3 Create non-admin CRDs** (`config/crd/bases/`):
68+
- `oadp.openshift.io_nonadminbackups.yaml`
69+
- `oadp.openshift.io_nonadminrestores.yaml`
70+
- `oadp.openshift.io_nonadminbackupstoragelocations.yaml`
71+
- `oadp.openshift.io_nonadminbackupstoragelocationrequests.yaml`
72+
- `oadp.openshift.io_nonadmindownloadrequests.yaml`
73+
- Ensure proper validation and OpenAPI schemas
74+
- Add short names and printer columns
75+
76+
**1.4 Update API constants**:
77+
- Add `NonAdminControllerImageKey` to unsupported overrides
78+
- Add NAC (Non-Admin Controller) defaults for periods
79+
80+
**1.5 Update kustomization files**:
81+
- Add non-admin CRDs to `config/crd/kustomization.yaml`
82+
- Add non-admin samples to `config/samples/kustomization.yaml`
83+
84+
#### Phase 2: Controller Implementation
85+
86+
**2.1 Non-admin controller logic** (`internal/controller/nonadmin_controller.go`):
87+
- Copy complete controller implementation
88+
- Deployment lifecycle management
89+
- Environment variable handling including:
90+
- `LOG_LEVEL` - Pass through Velero log level to NAC
91+
- `LOG_FORMAT` - Pass through DPA log format to NAC
92+
- `WATCH_NAMESPACE` - OADP namespace for controller scope
93+
- Resource version tracking for deployment updates
94+
- Add corresponding test file (`internal/controller/nonadmin_controller_test.go`)
95+
96+
**2.2 DPA controller integration** (`internal/controller/dataprotectionapplication_controller.go`):
97+
- Add `ReconcileNonAdminController` call to main reconcile loop
98+
- Implement `checkNonAdminEnabled()` helper
99+
- Add `getNonAdminImage()` functionality
100+
101+
**2.3 Validation logic** (`internal/controller/validator.go`):
102+
- Add non-admin enforcement validation
103+
- Update validation tests (`internal/controller/validator_test.go`)
104+
- Add validation constants like `NACNonEnforceableErr`
105+
106+
**2.4 BSL integration** (`internal/controller/bsl.go`):
107+
- Add non-admin BSL enforcement functions
108+
- Update BSL tests (`internal/controller/bsl_test.go`)
109+
- Integration with BSL approval mechanisms
110+
111+
**2.5 Helper functions and utilities**:
112+
- Container image management
113+
- Label and annotation handling
114+
- Error handling and event recording
115+
116+
#### Phase 3: RBAC Configuration
117+
118+
**3.1 Non-admin controller RBAC** (`config/non-admin-controller_rbac/`):
119+
- Service account creation
120+
- Controller role with required permissions
121+
- Role binding configuration
122+
123+
**3.2 User-facing RBAC** (`config/rbac/`):
124+
- Admin, editor, viewer roles for each CRD
125+
- Proper resource and verb definitions
126+
- Integration with existing kustomization
127+
128+
**3.3 Bundle manifests**:
129+
- Update ClusterServiceVersion
130+
- Add new RBAC cluster roles
131+
- Ensure proper OLM packaging
132+
133+
#### Phase 4: Integration and Dependencies
134+
135+
**4.1 Main application setup** (`cmd/main.go`):
136+
- No direct changes needed for non-admin controller
137+
- Non-admin controller is managed by DPA controller
138+
- Main controller already includes DPA reconciler
139+
140+
**4.2 Common utilities** (`pkg/common/common.go`):
141+
- Add non-admin related constants if needed
142+
- Ensure `LogLevelEnvVar` and `LogFormatEnvVar` constants are available (already present)
143+
- BSL helper functions may need updates
144+
145+
**4.3 Manager configuration** (`config/manager/manager.yaml`):
146+
- Add non-admin controller image environment variable (`RELATED_IMAGE_NON_ADMIN_CONTROLLER`)
147+
- Ensure proper container definitions
148+
149+
**4.4 Default configuration** (`config/default/`):
150+
- Update kustomization to include non-admin resources
151+
- Ensure proper resource ordering
152+
153+
**4.5 Sample configurations**:
154+
- Copy all non-admin sample YAML files to `config/samples/`
155+
- `oadp_v1alpha1_nonadminbackup.yaml`
156+
- `oadp_v1alpha1_nonadminrestore.yaml`
157+
- `oadp_v1alpha1_nonadminbackupstoragelocation.yaml`
158+
- `oadp_v1alpha1_nonadminbackupstoragelocationrequest.yaml`
159+
- `oadp_v1alpha1_nonadmindownloadrequest.yaml`
160+
161+
**4.6 Makefile updates**:
162+
- Add non-admin CRD generation targets
163+
- Update bundle and manifest generation
164+
- Add proper build dependencies
165+
166+
#### Phase 5: Testing and Validation
167+
168+
**5.1 Unit tests**:
169+
- Port existing controller tests (`internal/controller/nonadmin_controller_test.go`)
170+
- Update validation tests (`internal/controller/validator_test.go`)
171+
- Update BSL tests (`internal/controller/bsl_test.go`)
172+
- Minor update to suite test (`internal/controller/suite_test.go` - line 63)
173+
174+
**5.2 Integration tests**:
175+
- Update E2E test helpers (`tests/e2e/lib/dpa_helpers.go`) (minor)
176+
- End-to-end non-admin backup scenarios
177+
- Permission enforcement validation
178+
- BSL approval workflow testing
179+
180+
**5.3 Documentation updates**:
181+
- API reference updates
182+
- Configuration examples
183+
- Feature flag documentation
184+
185+
### Key Dependencies and Considerations
186+
187+
#### Container Image Requirements
188+
189+
**Non-Admin Controller Image**:
190+
- Repository: `quay.io/konveyor/oadp-non-admin`
191+
- The controller is a separate component that must be built and maintained
192+
- Image versioning must align with OADP 1.4 lifecycle
193+
194+
**Environment Variables**:
195+
- `RELATED_IMAGE_NON_ADMIN_CONTROLLER` for image specification
196+
- Fallback to hardcoded image path if not specified
197+
198+
#### Velero Version Compatibility
199+
200+
OADP 1.4 uses Velero 1.14.0, which should be compatible with non-admin CRDs that reference Velero v1 APIs. Key compatibility points:
201+
202+
- BackupSpec and RestoreSpec structures
203+
- BackupStorageLocationSpec compatibility
204+
- Volume snapshot/Datamover functionality
205+
206+
### Implementation Steps
207+
208+
#### Foundation
209+
- [ ] API types and CRD implementation
210+
- [ ] Core controller porting
211+
- [ ] RBAC configuration
212+
213+
#### Integration
214+
- [ ] DPA controller integration
215+
- [ ] Build system and configuration updates
216+
- [ ] Initial testing and validation
217+
218+
#### Testing and Refinement
219+
- [ ] Comprehensive testing
220+
- [ ] Documentation and final adjustments
221+
222+
### Risks and Mitigation Strategies
223+
224+
#### High Risk Items
225+
226+
**1. Container Image Availability**
227+
- **Risk**: Non-admin controller image may not exist for OADP 1.4 timeframe
228+
- **Mitigation**: Build and publish compatible image, coordinate with image pipeline team
229+
- **Owner**: Platform/Release Engineering
230+
231+
**2. Velero API Compatibility**
232+
- **Risk**: Subtle differences in Velero 1.14.0 vs newer versions used in 1.5
233+
- **Mitigation**: Thorough testing of all Velero API interactions, version-specific validation
234+
- **Owner**: Development Team
235+
236+
**3. Resource Version Conflicts**
237+
- **Risk**: CRD conflicts if users have mixed OADP versions
238+
- **Mitigation**: Proper upgrade/downgrade testing, clear documentation
239+
- **Owner**: QE Team
240+
241+
#### Medium Risk Items
242+
243+
**4. Controller Resource Management**
244+
- **Risk**: Non-admin controller deployment failures or resource contention
245+
- **Mitigation**: Resource limit testing, failure scenario validation
246+
- **Owner**: Development Team
247+
248+
**5. Feature Flag Compatibility**
249+
- **Risk**: Dependencies on newer OADP features not available in 1.4
250+
- **Mitigation**: Feature isolation, graceful degradation
251+
- **Owner**: Development Team
252+
253+
#### Low Risk Items
254+
255+
**6. Documentation Gaps**
256+
- **Risk**: Incomplete user/operator documentation
257+
- **Mitigation**: Comprehensive doc review and testing
258+
- **Owner**: Documentation Team
259+
260+
### Success Criteria
261+
262+
#### Functional Requirements
263+
- [ ] Non-admin users can create backup requests in their namespaces
264+
- [ ] Non-admin users can create restore requests in their namespaces
265+
- [ ] Backup Storage Location approval workflow functions correctly
266+
- [ ] Enforcement policies are properly applied
267+
- [ ] RBAC controls prevent unauthorized access
268+
- [ ] Garbage collection works as expected
269+
270+
#### Quality Requirements
271+
- [ ] All existing OADP 1.4 functionality remains intact
272+
- [ ] Performance impact is minimal
273+
- [ ] Memory usage increase is reasonable
274+
- [ ] No security vulnerabilities introduced
275+
- [ ] Comprehensive test coverage
276+
277+
#### Operational Requirements
278+
- [ ] Feature can be cleanly disabled
279+
- [ ] Upgrade/downgrade paths are clear
280+
- [ ] Monitoring and logging are adequate
281+
- [ ] Documentation is complete and accurate
282+
283+
### Testing Strategy
284+
285+
#### Unit Testing
286+
- Controller logic validation
287+
- API validation and conversion
288+
- Error handling scenarios
289+
290+
#### Integration Testing
291+
- End-to-end backup/restore workflows
292+
- Multi-user permission scenarios
293+
- BSL approval workflows
294+
- Resource cleanup validation
295+
296+
297+
### Rollback Plan
298+
299+
If critical issues are discovered:
300+
301+
1. **Immediate**: Disable non-admin feature via DPA configuration
302+
2. **Short-term**: Remove non-admin controller deployment
303+
3. **Long-term**: Remove CRDs and RBAC configurations if necessary
304+
305+
### Complete File Checklist
306+
307+
#### API and Types
308+
- [ ] `api/v1alpha1/dataprotectionapplication_types.go` - Add NonAdmin struct and enforcement types
309+
310+
#### Custom Resource Definitions
311+
- [ ] `config/crd/bases/oadp.openshift.io_nonadminbackups.yaml`
312+
- [ ] `config/crd/bases/oadp.openshift.io_nonadminrestores.yaml`
313+
- [ ] `config/crd/bases/oadp.openshift.io_nonadminbackupstoragelocations.yaml`
314+
- [ ] `config/crd/bases/oadp.openshift.io_nonadminbackupstoragelocationrequests.yaml`
315+
- [ ] `config/crd/bases/oadp.openshift.io_nonadmindownloadrequests.yaml`
316+
- [ ] `config/crd/kustomization.yaml` - Add non-admin CRDs
317+
318+
#### Controllers and Logic
319+
- [ ] `internal/controller/nonadmin_controller.go` - Main non-admin controller
320+
- [ ] `internal/controller/nonadmin_controller_test.go` - Controller tests
321+
- [ ] `internal/controller/dataprotectionapplication_controller.go` - DPA integration
322+
- [ ] `internal/controller/validator.go` - Add validation logic
323+
- [ ] `internal/controller/validator_test.go` - Update validation tests
324+
- [ ] `internal/controller/bsl.go` - BSL enforcement integration
325+
- [ ] `internal/controller/bsl_test.go` - BSL tests
326+
- [ ] `internal/controller/suite_test.go` - Minor test setup change (line 63)
327+
328+
#### RBAC Configuration
329+
- [ ] `config/non-admin-controller_rbac/service_account.yaml`
330+
- [ ] `config/non-admin-controller_rbac/role.yaml` - Controller permissions
331+
- [ ] `config/non-admin-controller_rbac/role_binding.yaml`
332+
- [ ] `config/non-admin-controller_rbac/nonadmindownloadrequest_admin_role.yaml`
333+
- [ ] `config/non-admin-controller_rbac/nonadmindownloadrequest_editor_role.yaml`
334+
- [ ] `config/non-admin-controller_rbac/nonadmindownloadrequest_viewer_role.yaml`
335+
- [ ] `config/non-admin-controller_rbac/kustomization.yaml`
336+
337+
#### Bundle and Manifests
338+
- [ ] `bundle/manifests/oadp-operator.clusterserviceversion.yaml` - Update CSV
339+
- [ ] `bundle/manifests/oadp.openshift.io_nonadminbackups.yaml`
340+
- [ ] `bundle/manifests/oadp.openshift.io_nonadminrestores.yaml`
341+
- [ ] `bundle/manifests/oadp.openshift.io_nonadminbackupstoragelocations.yaml`
342+
- [ ] `bundle/manifests/oadp.openshift.io_nonadminbackupstoragelocationrequests.yaml`
343+
- [ ] `bundle/manifests/oadp.openshift.io_nonadmindownloadrequests.yaml`
344+
- [ ] `bundle/manifests/nonadmindownloadrequest-admin-role_rbac.authorization.k8s.io_v1_clusterrole.yaml`
345+
- [ ] `bundle/manifests/nonadmindownloadrequest-editor-role_rbac.authorization.k8s.io_v1_clusterrole.yaml`
346+
- [ ] `bundle/manifests/nonadmindownloadrequest-viewer-role_rbac.authorization.k8s.io_v1_clusterrole.yaml`
347+
348+
#### Configuration and Samples
349+
- [ ] `config/manager/manager.yaml` - Add non-admin controller image env var
350+
- [ ] `config/samples/kustomization.yaml` - Add non-admin samples
351+
- [ ] `config/samples/oadp_v1alpha1_nonadminbackup.yaml`
352+
- [ ] `config/samples/oadp_v1alpha1_nonadminrestore.yaml`
353+
- [ ] `config/samples/oadp_v1alpha1_nonadminbackupstoragelocation.yaml`
354+
- [ ] `config/samples/oadp_v1alpha1_nonadminbackupstoragelocationrequest.yaml`
355+
- [ ] `config/samples/oadp_v1alpha1_nonadmindownloadrequest.yaml`
356+
357+
#### Utilities and Helpers
358+
- [ ] `pkg/common/common.go` - Verify log level constants (`LogLevelEnvVar`, `LogFormatEnvVar`)
359+
- [ ] `tests/e2e/lib/dpa_helpers.go` - E2E test helper updates
360+
361+
#### Main Application
362+
- [ ] `cmd/main.go` - No changes needed (non-admin controller managed by DPA controller)

0 commit comments

Comments
 (0)