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 cronjob to periodically purge the DB #295

Merged
merged 1 commit into from
Nov 24, 2023

Conversation

ASBishop
Copy link
Contributor

The cron schedule and the age at which records are purged are configurable in the CRD, with the same default values chosen for TripleO based deployments.

@ASBishop
Copy link
Contributor Author

/retest

Copy link
Contributor

@fmount fmount left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

Copy link
Contributor

@Akrog Akrog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this nice feature!
I have added some questions and change requests.

"github.com/openstack-k8s-operators/lib-common/modules/storage"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

const (
// CinderUserID - Kolla's cinder UID
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: it could be good to point to the source code were it is defined https://github.com/openstack/kolla/blob/master/kolla/common/users.py

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -172,6 +185,32 @@ type Cinder struct {
Status CinderStatus `json:"status,omitempty"`
}

// DBPurge struct is used to model the parameters exposed to the Manila API CronJob
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-1: s/Manila/Cinder

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -86,6 +97,11 @@ func (spec *CinderSpec) Default() {
// This is required, as the loop variable is a by-value copy
spec.CinderVolumes[index] = cinderVolume
}

if (spec.DBPurge.Age == 0) && (spec.DBPurge.Schedule == "") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-1: This seems wrong, shouldn't they be independently checked? What happens when only one of the 2 fields is changed? Or is that not possible?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if it's possible, but I see no reason why these shouldn't be independently checked, so I'll update the code.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I think the main problem we were trying to solve here is when the CR is applied and no dbPurge related section is added. kubebuilder is basically not initializing the fields of the structs with the default values, and itresulted in something like dbPurge: {}.
However, without digging more into the original issue, I think that the latest @ASBishop's PS is good enough, and processing the two params independently works fine (and covers the previous case I mentioned).
I'm going to update the Manila patch the same way, thanks for the great input!

pkg/cinderbackup/statefulset.go Show resolved Hide resolved
@@ -44,8 +44,8 @@ func StatefulSet(
rootUser := int64(0)
// Cinder's uid and gid magic numbers come from the 'cinder-user' in
// https://github.com/openstack/kolla/blob/master/kolla/common/users.py
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-1: Remove these 2 comment lines

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -35,16 +35,16 @@ const (

// StatefulSet func
func StatefulSet(
instance *cinderv1beta1.CinderScheduler,
instance *cinderv1.CinderScheduler,
configHash string,
labels map[string]string,
annotations map[string]string,
) *appsv1.StatefulSet {
rootUser := int64(0)
// Cinder's uid and gid magic numbers come from the 'cinder-user' in
// https://github.com/openstack/kolla/blob/master/kolla/common/users.py
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-1: Remove these 2 comment lines

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -44,8 +44,8 @@ func StatefulSet(
rootUser := int64(0)
// Cinder's uid and gid magic numbers come from the 'cinder-user' in
// https://github.com/openstack/kolla/blob/master/kolla/common/users.py
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-1: Remove this from here.
nit: Move it to the constant definition as mentioned above.

pkg/cinder/cronjob.go Show resolved Hide resolved
pkg/cinder/cronjob.go Show resolved Hide resolved
cronjobDef := cinder.CronJob(instance, serviceLabels, serviceAnnotations)
cronjob := cronjob.NewCronJob(
cronjobDef,
5*time.Second,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Since this is not a job we need "right now" we can probably set a higher reconciliation timeout value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but what would that value be?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question, I don't know :-P

@ASBishop
Copy link
Contributor Author

/retest

looks like temporary issues with ci infrastructure

}

// CinderDebug indicates whether certain stages of Cinder deployment should
// pause in debug mode, or if debug is enabled when purging the DB.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-1: If we are no longer going to pause on these actions we should rephrase this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Um, I thought I did. But I can remove this comment in favor of explicitly describing each flag within the structure.

type CinderDebug struct {
// +kubebuilder:validation:Optional
// +kubebuilder:default=false
// dbSync enable debug
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mention that this debug action pauses the container.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

api/v1beta1/cinder_types.go Show resolved Hide resolved
pkg/cinder/cronjob.go Show resolved Hide resolved
type CinderDebug struct {
// +kubebuilder:validation:Optional
// +kubebuilder:default=false
// DBSync pauses the dbSync container prior to executing the db_sync command.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-1: I hate to downvote for this, but the comment is not correct, it's an infinite sleep, so it will never execute the dbsync command.
Maybe it's not the best command, and we should have a command to sleep until a file is removed, like I did in openstack-must-gather, but it's what we have right now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing "prior to executing" to "instead of executing" per our conversation.

The cron schedule and the age at which records are purged are
configurable in the CRD, with the same default values chosen
for TripleO based deployments.
@Akrog
Copy link
Contributor

Akrog commented Nov 22, 2023

/retest

Copy link
Contributor

@Akrog Akrog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Nov 23, 2023
Copy link
Contributor

openshift-ci bot commented Nov 23, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Akrog, ASBishop, fmount

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@Akrog
Copy link
Contributor

Akrog commented Nov 23, 2023

/retest

1 similar comment
@Akrog
Copy link
Contributor

Akrog commented Nov 24, 2023

/retest

@openshift-merge-bot openshift-merge-bot bot merged commit 3771599 into openstack-k8s-operators:main Nov 24, 2023
1 check passed
@ASBishop ASBishop deleted the db_purge branch November 24, 2023 22:50
ASBishop pushed a commit to ASBishop/cinder-operator that referenced this pull request Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants