openshift / openshift/oadp-operator

Use CRD defaults

Open
#1,557 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

lifecycle/frozen
Dominant language
Go
Stars
92
Forks
93
Avg merge
1d 23h
Merged PRs (30d)
43

Description

Problem

OADP does not use default value markers for generating its CRDs

// +kubebuilder:default=<value>

The adoption of this would be better for:

Examples

If user creates a DPA with this spec

spec:
  configuration:
    velero:
      logLevel: debug

it would have this spec in the cluster

spec:
  configuration:
    velero:
      client-burst: 100
      client-qps: 100
      defaultItemOperationTimeout: 1h
      disableInformerCache: false
      itemOperationSyncFrequency: 2m
      logLevel: debug
      noDefaultBackupLocation: false
      resourceTimeout: 10m

Note: default disallows user to remove field from object. If user try to remove a field with default from spec, API just adds it back with the default value.

Upgrades would work with these changes. A sample DPA prior to upgrade

apiVersion: oadp.openshift.io/v1alpha1
kind: DataProtectionApplication
metadata:
  creationTimestamp: '2024-10-14T14:47:20Z'
  generation: 3
  managedFields:
    ...
  name: velero-sample
  namespace: test-oadp-operator
  resourceVersion: '566563332'
  uid: 9f8ff5f5-041b-40bd-ba2e-6f7e658c7515
spec:
  backupImages: false
  configuration:
    velero:
      logLevel: debug
      noDefaultBackupLocation: true

The same DPA after upgarde

apiVersion: oadp.openshift.io/v1alpha1
kind: DataProtectionApplication
metadata:
  creationTimestamp: '2024-10-14T14:47:20Z'
  generation: 3
  managedFields:
    ...
  name: velero-sample
  namespace: test-oadp-operator
  resourceVersion: '566563332'
  uid: 9f8ff5f5-041b-40bd-ba2e-6f7e658c7515
spec:
  backupImages: false
  configuration:
    velero:
      client-burst: 100
      client-qps: 100
      defaultItemOperationTimeout: 1h
      disableInformerCache: false
      itemOperationSyncFrequency: 2m
      logLevel: debug
      noDefaultBackupLocation: true
      resourceTimeout: 10m

Note: even though the object changed, note that metadata.generation is the same on both objects.

References

https://book.kubebuilder.io/reference/markers/crd-validation
https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#defaulting

Note: some default values are not static, so they may be added with other strategies.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in api/v1alpha1/oadp_types.go around lines 614-617, then review the Kubebuilder CRD validation marker reference linked in the issue. Identify the static defaults represented by helper functions and determine how they should appear in generated CRDs. Done means applicable defaults are visible and applied to existing and newly created DataProtectionApplications, while non-static defaults use another strategy.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api, devops
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.