Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix of retain functionality #203

Merged
merged 1 commit into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion api/v1alpha1/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
1 change: 1 addition & 0 deletions api/v1alpha1/rekor_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
3 changes: 1 addition & 2 deletions api/v1alpha1/trillian_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}

Expand All @@ -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"`
}

Expand Down
5 changes: 5 additions & 0 deletions config/crd/bases/rhtas.redhat.com_rekors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ spec:
type: boolean
type: object
pvc:
default:
retain: true
size: 5Gi
description: PVC configuration
properties:
name:
Expand All @@ -92,6 +95,8 @@ spec:
storageClass:
description: Storage class for the PVC
type: string
required:
- retain
type: object
rekorSearchUI:
description: Rekor Search UI
Expand Down
12 changes: 7 additions & 5 deletions config/crd/bases/rhtas.redhat.com_securesigns.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,9 @@ spec:
type: boolean
type: object
pvc:
default:
retain: true
size: 5Gi
description: PVC configuration
properties:
name:
Expand All @@ -344,6 +347,8 @@ spec:
storageClass:
description: Storage class for the PVC
type: string
required:
- retain
type: object
rekorSearchUI:
description: Rekor Search UI
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -442,6 +442,8 @@ spec:
storageClass:
description: Storage class for the PVC
type: string
required:
- retain
type: object
required:
- create
Expand Down
7 changes: 2 additions & 5 deletions config/crd/bases/rhtas.redhat.com_trillians.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -83,6 +78,8 @@ spec:
storageClass:
description: Storage class for the PVC
type: string
required:
- retain
type: object
required:
- create
Expand Down
6 changes: 4 additions & 2 deletions controllers/trillian/actions/db/pvc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
Loading