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

Add DB purge CronJob #698

Merged
merged 4 commits into from
Feb 29, 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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ golint: get-ci-tools

.PHONY: operator-lint
operator-lint: $(LOCALBIN) gowork ## Runs operator-lint
GOBIN=$(LOCALBIN) go install github.com/gibizer/operator-lint@v0.3.0
GOBIN=$(LOCALBIN) go install github.com/gibizer/operator-lint@v0.5.0
go vet -vettool=$(LOCALBIN)/operator-lint ./... ./api/...

.PHONY: gowork
Expand Down
22 changes: 22 additions & 0 deletions api/bases/nova.openstack.org_nova.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,28 @@ spec:
type: object
type: object
type: object
dbPurge:
description: DBPurge defines the parameters for the DB archiving
and purging cron job
properties:
archiveAge:
default: 30
description: ArchiveAge defines the minimuma age of the
records in days that can be moved to the shadow tables.
minimum: 1
type: integer
purgeAge:
default: 90
description: PurgeAge defines the minimum age of the records
in days that can be deleted from the shadow tables
minimum: 1
type: integer
schedule:
default: 0 0 * * *
description: Schedule defines when to run the DB maintenance
job in a cron format. By default it runs every midnight.
type: string
type: object
hasAPIAccess:
description: HasAPIAccess defines if this Cell is configured
to have access to the API DB and message bus.
Expand Down
22 changes: 22 additions & 0 deletions api/bases/nova.openstack.org_novacells.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,28 @@ spec:
type: object
type: object
type: object
dbPurge:
description: DBPurge defines the parameters for the DB archiving and
purging cron job
properties:
archiveAge:
default: 30
description: ArchiveAge defines the minimuma age of the records
in days that can be moved to the shadow tables.
minimum: 1
type: integer
purgeAge:
default: 90
description: PurgeAge defines the minimum age of the records in
days that can be deleted from the shadow tables
minimum: 1
type: integer
schedule:
default: 0 0 * * *
description: Schedule defines when to run the DB maintenance job
in a cron format. By default it runs every midnight.
type: string
type: object
keystoneAuthURL:
description: KeystoneAuthURL - the URL that the service in the cell
can use to talk to keystone
Expand Down
22 changes: 22 additions & 0 deletions api/bases/nova.openstack.org_novaconductors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,28 @@ spec:
added to to /etc/<service>/<service>.conf.d directory as custom.conf
file.
type: string
dbPurge:
description: DBPurge defines the parameters for the DB archiving and
purging cron job
properties:
archiveAge:
default: 30
description: ArchiveAge defines the minimuma age of the records
in days that can be moved to the shadow tables.
minimum: 1
type: integer
purgeAge:
default: 90
description: PurgeAge defines the minimum age of the records in
days that can be deleted from the shadow tables
minimum: 1
type: integer
schedule:
default: 0 0 * * *
description: Schedule defines when to run the DB maintenance job
in a cron format. By default it runs every midnight.
type: string
type: object
keystoneAuthURL:
description: KeystoneAuthURL - the URL that the nova-conductor service
can use to talk to keystone
Expand Down
32 changes: 32 additions & 0 deletions api/v1beta1/novacell_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ type NovaCellTemplate struct {
// MemcachedInstance is the name of the Memcached CR that the services in the cell will use.
// If defined then this takes precedence over Nova.Spec.MemcachedInstance for this cel
MemcachedInstance string `json:"memcachedInstance"`

// +kubebuilder:validation:Optional
// DBPurge defines the parameters for the DB archiving and purging cron job
DBPurge NovaCellDBPurge `json:"dbPurge"`
}

// NovaCellSpec defines the desired state of NovaCell
Expand Down Expand Up @@ -188,6 +192,34 @@ type NovaCellSpec struct {
// +kubebuilder:validation:Required
// MemcachedInstance is the name of the Memcached CR that all nova service will use.
MemcachedInstance string `json:"memcachedInstance"`

// +kubebuilder:validation:Optional
// DBPurge defines the parameters for the DB archiving and purging cron job
DBPurge NovaCellDBPurge `json:"dbPurge"`
}

// NovaCellDBPurge defines the parameters for the DB archiving and purging
// cron job
type NovaCellDBPurge struct {
// +kubebuilder:validation:Optional
// +kubebuilder:default="0 0 * * *"
// Schedule defines when to run the DB maintenance job in a cron format.
// By default it runs every midnight.
Schedule *string `json:"schedule"`

// +kubebuilder:validation:Optional
// +kubebuilder:default=30
// +kubebuilder:validation:Minimum=1
// ArchiveAge defines the minimuma age of the records in days that can be
// moved to the shadow tables.
ArchiveAge *int `json:"archiveAge"`

// +kubebuilder:validation:Optional
// +kubebuilder:default=90
// +kubebuilder:validation:Minimum=1
// PurgeAge defines the minimum age of the records in days that can be
// deleted from the shadow tables
PurgeAge *int `json:"purgeAge"`
mrkisaolamb marked this conversation as resolved.
Show resolved Hide resolved
}

// NovaCellStatus defines the observed state of NovaCell
Expand Down
5 changes: 5 additions & 0 deletions api/v1beta1/novaconductor_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ type NovaConductorSpec struct {
// +kubebuilder:validation:Required
// MemcachedInstance is the name of the Memcached CR that all nova service will use.
MemcachedInstance string `json:"memcachedInstance"`

// +kubebuilder:validation:Optional
// DBPurge defines the parameters for the DB archiving and purging cron job
DBPurge NovaCellDBPurge `json:"dbPurge"`
}

// NovaConductorStatus defines the observed state of NovaConductor
Expand Down Expand Up @@ -202,6 +206,7 @@ func NewNovaConductorSpec(
TLS: novaCell.TLS,
PreserveJobs: novaCell.PreserveJobs,
MemcachedInstance: novaCell.MemcachedInstance,
DBPurge: novaCell.DBPurge,
}
return conductorSpec
}
Expand Down
33 changes: 33 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions config/crd/bases/nova.openstack.org_nova.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,28 @@ spec:
type: object
type: object
type: object
dbPurge:
description: DBPurge defines the parameters for the DB archiving
and purging cron job
properties:
archiveAge:
default: 30
description: ArchiveAge defines the minimuma age of the
records in days that can be moved to the shadow tables.
minimum: 1
type: integer
purgeAge:
default: 90
description: PurgeAge defines the minimum age of the records
in days that can be deleted from the shadow tables
minimum: 1
type: integer
schedule:
default: 0 0 * * *
description: Schedule defines when to run the DB maintenance
job in a cron format. By default it runs every midnight.
type: string
type: object
hasAPIAccess:
description: HasAPIAccess defines if this Cell is configured
to have access to the API DB and message bus.
Expand Down
22 changes: 22 additions & 0 deletions config/crd/bases/nova.openstack.org_novacells.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,28 @@ spec:
type: object
type: object
type: object
dbPurge:
description: DBPurge defines the parameters for the DB archiving and
purging cron job
properties:
archiveAge:
default: 30
description: ArchiveAge defines the minimuma age of the records
in days that can be moved to the shadow tables.
minimum: 1
type: integer
purgeAge:
default: 90
description: PurgeAge defines the minimum age of the records in
days that can be deleted from the shadow tables
minimum: 1
type: integer
schedule:
default: 0 0 * * *
description: Schedule defines when to run the DB maintenance job
in a cron format. By default it runs every midnight.
type: string
type: object
keystoneAuthURL:
description: KeystoneAuthURL - the URL that the service in the cell
can use to talk to keystone
Expand Down
22 changes: 22 additions & 0 deletions config/crd/bases/nova.openstack.org_novaconductors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,28 @@ spec:
added to to /etc/<service>/<service>.conf.d directory as custom.conf
file.
type: string
dbPurge:
description: DBPurge defines the parameters for the DB archiving and
purging cron job
properties:
archiveAge:
default: 30
description: ArchiveAge defines the minimuma age of the records
in days that can be moved to the shadow tables.
minimum: 1
type: integer
purgeAge:
default: 90
description: PurgeAge defines the minimum age of the records in
days that can be deleted from the shadow tables
minimum: 1
type: integer
schedule:
default: 0 0 * * *
description: Schedule defines when to run the DB maintenance job
in a cron format. By default it runs every midnight.
type: string
type: object
keystoneAuthURL:
description: KeystoneAuthURL - the URL that the nova-conductor service
can use to talk to keystone
Expand Down
12 changes: 12 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@ rules:
- patch
- update
- watch
- apiGroups:
- batch
resources:
- cronjobs
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- batch
resources:
Expand Down
1 change: 1 addition & 0 deletions controllers/nova_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,7 @@ func (r *NovaReconciler) ensureCell(
TLS: instance.Spec.APIServiceTemplate.TLS.Ca,
PreserveJobs: instance.Spec.PreserveJobs,
MemcachedInstance: getMemcachedInstance(instance, cellTemplate),
DBPurge: cellTemplate.DBPurge,
}
if cellTemplate.HasAPIAccess {
cellSpec.APIDatabaseHostname = apiDB.GetDatabaseHostname()
Expand Down
Loading
Loading