-
Notifications
You must be signed in to change notification settings - Fork 29
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
Expose DBPurge Age and Schedule #170
Expose DBPurge Age and Schedule #170
Conversation
651645a
to
dd80992
Compare
Let's see the CI in action with this change |
From the CI execution we can see that the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition to some (very minor) comments noted in the code, I have another suggestion that I'll describe here:
As things currently stand:
- main.go calls manilav1beta1.SetupDefaults()
- But that function is defined in common_types.go, which doesn't feel write to me (it's a function, not a type)
- SetupDefaults (in common_types.go) initializes a local variable with the default values, and then calls SetupManilaDefaults()
- SetupManilaDefaults is implemented in manila_webhook.go, and it essentially saves a copy of the input parameter to the "manilaDefaults" variable defined in the file
This seems overly convoluted. I suggest:
- (Re)move the SetupDefaults() function from common_types.go entirely
- In manila_webhook.go, rename SetupManilaDefaults() to SetupDefaults(), and add the initialization code that was previously done in common_types.go. It would look like this:
// SetupDefaults - initialize Manila spec defaults for use with either internal or external webhooks
func SetupDefaults() {
// Acquire environmental defaults and initialize Manila defaults with them
manilaDefaults = ManilaDefaults{
APIContainerImageURL: util.GetEnvVar("RELATED_IMAGE_MANILA_API_IMAGE_URL_DEFAULT", ManilaAPIContainerImage),
SchedulerContainerImageURL: util.GetEnvVar("RELATED_IMAGE_MANILA_SCHEDULER_IMAGE_URL_DEFAULT", ManilaSchedulerContainerImage),
ShareContainerImageURL: util.GetEnvVar("RELATED_IMAGE_MANILA_SHARE_IMAGE_URL_DEFAULT", ManilaShareContainerImage),
DBPurgeAge: DBPurgeDefaultAge,
DBPurgeSchedule: DBPurgeDefaultSchedule,
}
manilalog.Info("Manila defaults initialized", "defaults", manilaDefaults)
}
api/v1beta1/manila_types.go
Outdated
// +kubebuilder:validation:Optional | ||
// +kubebuilder:default=false | ||
// DBPurge enables debug mode on the DBPurge CronJob | ||
DBPurge bool `json:"debug,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the json name should be dbPurge:
DBPurge bool `json:"dbPurge,omitempty"`
Otherwise the CRD looks like this:
spec:
debug:
dbSync: false
debug: false <=== spec.debug.debug looks odd to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 it's odd, basically I didn't pay too much attention, I'll fix it in my next PS
But this is looking good, so I think you can promote if from a mere WIP! |
This is interesting, thanks for this suggestion that I think is in line w/ the effort around code dedup and help with the whole webhooks related logic. |
Build failed (check pipeline). Post https://review.rdoproject.org/zuul/buildset/647d757cf0c5482485f276037169f8d2 ❌ openstack-k8s-operators-content-provider FAILURE in 10m 46s |
@viroel I think the zuul kuttl test is still not ready to manage changes in the API, and I'm wondering if we have a way to set it as "non-voting" or override the result. |
Build failed (check pipeline). Post https://review.rdoproject.org/zuul/buildset/b5d87a480e164b108c8ade9edc0a43cc ❌ openstack-k8s-operators-content-provider FAILURE in 10m 42s |
d5f7a85
to
9e7b87e
Compare
Yes, you just need to set the job to |
Zuul encountered a syntax error while parsing its configuration in the expected str for dictionary value @ data['github-check']['jobs'][1]['voting'] The error appears in the following project stanza: project: in "openstack-k8s-operators/manila-operator/zuul.d/projects.yaml@main", line 2, column 3 |
/test manila-operator-build-deploy-tempest |
api/v1beta1/manila_webhook.go
Outdated
@@ -82,6 +94,11 @@ func (spec *ManilaSpec) Default() { | |||
spec.ManilaShares[key] = manilaShare | |||
} | |||
} | |||
|
|||
if (spec.DBPurge.Age == 0) && (spec.DBPurge.Schedule == "") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See Gorka's comment for the corresponding code in openstack-k8s-operators/cinder-operator#295
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 and thanks for sharing, just commented and updated the patch. I think it's ok to process these two struct fields independently.
// +kubebuilder:validation:Optional | ||
// +kubebuilder:default=30 | ||
// Age is the DBPurgeAge parameter and indicates the number of days of purging DB records | ||
Age int `json:"age"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will you add the "+kubebuilder:validation:Minimum=1" in this PR (after CI issues are resolved) or in a follow-up patch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to add this line in a follow up patch because I have that one line change that allows me to focus more on the CI (zuul based) execution rather than the change introduced by the patch.
Build failed (check pipeline). Post https://review.rdoproject.org/zuul/buildset/e59184c3a0ee459da818438c95693abc ❌ openstack-k8s-operators-content-provider FAILURE in 8m 49s |
/retest |
/override rdoproject.org/github-check |
@fmount: Overrode contexts on behalf of fmount: rdoproject.org/github-check In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
This patch updates the current manila CR to expose both dbPurgeAge and dbPurgeSchedule as customizable parameters. They were previously hardcoded as constants in the code, and it makes sense removing that part as long as the human operator has the ability to customize them. Signed-off-by: Francesco Pantano <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: 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 |
f465db7
into
openstack-k8s-operators:main
This patch updates the current
manila
CR
to expose bothdbPurgeAge
anddbPurgeSchedule
as customizable parameters. They were previously hardcoded asconst
in the code, and it makes sense removing that part as long as the human operator has the ability to customize them.