diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9cfc2020a..93382c838 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -199,10 +199,10 @@ jobs: - name: Test deployments are ready run: | - kubectl wait --for=condition=available deployment/trillian-db -n test --timeout=30s - kubectl wait --for=condition=available deployment/trillian-logserver -n test --timeout=30s - kubectl wait --for=condition=available deployment/trillian-logsigner -n test --timeout=30s - kubectl wait --for=condition=available deployment/fulcio-server -n test --timeout=30s + kubectl wait --for=condition=available deployment/trillian-db -n test --timeout=60s + kubectl wait --for=condition=available deployment/trillian-logserver -n test --timeout=60s + kubectl wait --for=condition=available deployment/trillian-logsigner -n test --timeout=60s + kubectl wait --for=condition=available deployment/fulcio-server -n test --timeout=60s - name: Until shell script to wait for tuf, ctlog, rekor-redis, rekor-server deployment to be created run: | @@ -218,10 +218,10 @@ jobs: - name: Test deployments are ready run: | - kubectl wait --for=condition=available deployment/tuf -n test --timeout=30s - kubectl wait --for=condition=available deployment/ctlog -n test --timeout=30s - kubectl wait --for=condition=available deployment/rekor-redis -n test --timeout=30s - kubectl wait --for=condition=available deployment/rekor-server -n test --timeout=30s + kubectl wait --for=condition=available deployment/tuf -n test --timeout=60s + kubectl wait --for=condition=available deployment/ctlog -n test --timeout=60s + kubectl wait --for=condition=available deployment/rekor-redis -n test --timeout=60s + kubectl wait --for=condition=available deployment/rekor-server -n test --timeout=60s - name: dump the logs of the operator run: kubectl logs -n openshift-rhtas-operator deployment/rhtas-operator-controller-manager diff --git a/api/v1alpha1/common.go b/api/v1alpha1/common.go index 5f7e58a85..9344083a6 100644 --- a/api/v1alpha1/common.go +++ b/api/v1alpha1/common.go @@ -31,7 +31,7 @@ type Pvc struct { Size string `json:"size,omitempty"` // Retain policy for the PVC //+kubebuilder:default:=true - Retain bool `json:"retain,omitempty"` + Retain bool `json:"retain"` // Name of the PVC //+optional Name string `json:"name,omitempty"` diff --git a/api/v1alpha1/rekor_types.go b/api/v1alpha1/rekor_types.go index 316c4e5df..f3719e5d2 100644 --- a/api/v1alpha1/rekor_types.go +++ b/api/v1alpha1/rekor_types.go @@ -20,6 +20,7 @@ type RekorSpec struct { // Signer configuration Signer RekorSigner `json:"signer,omitempty"` // PVC configuration + //+kubebuilder:default:={size: "5Gi", retain: true} Pvc Pvc `json:"pvc,omitempty"` // BackFillRedis CronJob Configuration BackFillRedis BackFillRedis `json:"backFillRedis,omitempty"` diff --git a/api/v1alpha1/trillian_types.go b/api/v1alpha1/trillian_types.go index ccee8a442..496b9d66d 100644 --- a/api/v1alpha1/trillian_types.go +++ b/api/v1alpha1/trillian_types.go @@ -24,7 +24,6 @@ import ( // TrillianSpec defines the desired state of Trillian type TrillianSpec struct { // Define your database connection - //+kubebuilder:default:={create:true,pvc:{retain:true,size:"5Gi"}} Db TrillianDB `json:"database,omitempty"` } @@ -36,7 +35,7 @@ type TrillianDB struct { //+optional DatabaseSecretRef *v1.LocalObjectReference `json:"databaseSecretRef,omitempty"` // PVC configuration - //+kubebuilder:default:={retain:true, size:"5Gi"} + //+kubebuilder:default:={size: "5Gi", retain: true} Pvc Pvc `json:"pvc,omitempty"` } diff --git a/config/crd/bases/rhtas.redhat.com_rekors.yaml b/config/crd/bases/rhtas.redhat.com_rekors.yaml index 7bc8f50bd..d4d83d1b2 100644 --- a/config/crd/bases/rhtas.redhat.com_rekors.yaml +++ b/config/crd/bases/rhtas.redhat.com_rekors.yaml @@ -76,6 +76,9 @@ spec: type: boolean type: object pvc: + default: + retain: true + size: 5Gi description: PVC configuration properties: name: @@ -92,6 +95,8 @@ spec: storageClass: description: Storage class for the PVC type: string + required: + - retain type: object rekorSearchUI: description: Rekor Search UI diff --git a/config/crd/bases/rhtas.redhat.com_securesigns.yaml b/config/crd/bases/rhtas.redhat.com_securesigns.yaml index 0000d5940..64581d225 100644 --- a/config/crd/bases/rhtas.redhat.com_securesigns.yaml +++ b/config/crd/bases/rhtas.redhat.com_securesigns.yaml @@ -328,6 +328,9 @@ spec: type: boolean type: object pvc: + default: + retain: true + size: 5Gi description: PVC configuration properties: name: @@ -344,6 +347,8 @@ spec: storageClass: description: Storage class for the PVC type: string + required: + - retain type: object rekorSearchUI: description: Rekor Search UI @@ -400,11 +405,6 @@ spec: description: TrillianSpec defines the desired state of Trillian properties: database: - default: - create: true - pvc: - retain: true - size: 5Gi description: Define your database connection properties: create: @@ -442,6 +442,8 @@ spec: storageClass: description: Storage class for the PVC type: string + required: + - retain type: object required: - create diff --git a/config/crd/bases/rhtas.redhat.com_trillians.yaml b/config/crd/bases/rhtas.redhat.com_trillians.yaml index 4ee461cdd..c3cf184ee 100644 --- a/config/crd/bases/rhtas.redhat.com_trillians.yaml +++ b/config/crd/bases/rhtas.redhat.com_trillians.yaml @@ -41,11 +41,6 @@ spec: description: TrillianSpec defines the desired state of Trillian properties: database: - default: - create: true - pvc: - retain: true - size: 5Gi description: Define your database connection properties: create: @@ -83,6 +78,8 @@ spec: storageClass: description: Storage class for the PVC type: string + required: + - retain type: object required: - create diff --git a/controllers/trillian/actions/db/pvc.go b/controllers/trillian/actions/db/pvc.go index 53d2e4863..6ae5129b2 100644 --- a/controllers/trillian/actions/db/pvc.go +++ b/controllers/trillian/actions/db/pvc.go @@ -39,8 +39,10 @@ func (i createPvcAction) Handle(ctx context.Context, instance *rhtasv1alpha1.Tri // PVC does not exist, create a new one i.Logger.V(1).Info("Creating new PVC") pvc := k8sutils.CreatePVC(instance.Namespace, actions.DbPvcName, instance.Spec.Db.Pvc.Size, instance.Spec.Db.Pvc.StorageClass, constants.LabelsFor(actions.DbComponentName, actions.DbDeploymentName, instance.Name)) - if err = controllerutil.SetControllerReference(instance, pvc, i.Client.Scheme()); err != nil { - return i.Failed(fmt.Errorf("could not set controller reference for PVC: %w", err)) + if !instance.Spec.Db.Pvc.Retain { + if err = controllerutil.SetControllerReference(instance, pvc, i.Client.Scheme()); err != nil { + return i.Failed(fmt.Errorf("could not set controller reference for PVC: %w", err)) + } } if _, err = i.Ensure(ctx, pvc); err != nil { meta.SetStatusCondition(&instance.Status.Conditions, metav1.Condition{