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

K8SPXC-1230 add labels to k8s objects created by operator #1565

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

nmarukovich
Copy link
Contributor

@nmarukovich nmarukovich commented Dec 21, 2023

K8SPXC-1230 Powered by Pull Request Badge

CHANGE DESCRIPTION

Problem:
Short explanation of the problem.

Cause:
Short explanation of the root cause of the issue if applicable.

Solution:
Short explanation of the solution we are providing with this PR.

CHECKLIST

Jira

  • Is the Jira ticket created and referenced properly?
  • Does the Jira ticket have the proper statuses for documentation (Needs Doc) and QA (Needs QA)?
  • Does the Jira ticket link to the proper milestone (Fix Version field)?

Tests

  • Is an E2E test/test case added for the new feature/change?
  • Are unit tests added where appropriate?
  • Are OpenShift compare files changed for E2E tests (compare/*-oc.yml)?

Config/Logging/Testability

  • Are all needed new/changed options added to default YAML files?
  • Are the manifests (crd/bundle) regenerated if needed?
  • Did we add proper logging messages for operator actions?
  • Did we ensure compatibility with the previous version or cluster upgrade process?
  • Does the change support oldest and newest supported PXC version?
  • Does the change support oldest and newest supported Kubernetes version?

@pull-request-size pull-request-size bot added the size/S 10-29 lines label Dec 21, 2023
pkg/pxc/backup/volume.go Outdated Show resolved Hide resolved
pkg/pxc/backup/volume.go Outdated Show resolved Hide resolved
pkg/pxc/backup/volume.go Outdated Show resolved Hide resolved
@pull-request-size pull-request-size bot added size/M 30-99 lines and removed size/S 10-29 lines labels Dec 21, 2023
pkg/controller/pxc/backup.go Outdated Show resolved Hide resolved
pkg/controller/pxc/secrets.go Outdated Show resolved Hide resolved
pkg/controller/pxc/tls.go Outdated Show resolved Hide resolved
pkg/controller/pxc/tls.go Outdated Show resolved Hide resolved
pkg/controller/pxc/tls.go Outdated Show resolved Hide resolved
pkg/controller/pxc/tls.go Outdated Show resolved Hide resolved
pkg/controller/pxcrestore/controller.go Outdated Show resolved Hide resolved
pkg/pxc/app/config/configmap.go Outdated Show resolved Hide resolved
pkg/pxc/app/config/configmap.go Outdated Show resolved Hide resolved
pkg/pxc/app/deployment/binlog-collector.go Outdated Show resolved Hide resolved
nmarukovich and others added 3 commits December 21, 2023 19:16
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@nmarukovich nmarukovich marked this pull request as ready for review December 22, 2023 09:26
@@ -8,7 +8,17 @@ import (
)

// NewPVC returns the list of PersistentVolumeClaims for the backups
func NewPVC(cr *api.PerconaXtraDBClusterBackup) *corev1.PersistentVolumeClaim {
func NewPVC(cr *api.PerconaXtraDBClusterBackup, cluster *api.PerconaXtraDBCluster) *corev1.PersistentVolumeClaim {
// Copy from the original labels to the backup labels
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of coping these, there is this function k8s.io/apimachinery/pkg/labels.Merge() that will merge two sets of labels, maybe you can use it.

@@ -293,6 +293,12 @@ func (r *ReconcilePerconaXtraDBCluster) deletePITR(cr *api.PerconaXtraDBCluster)
ObjectMeta: metav1.ObjectMeta{
Name: deployment.GetBinlogCollectorDeploymentName(cr),
Namespace: cr.Namespace,
Labels: map[string]string{
"app.kubernetes.io/name": "percona-xtradb-cluster",
Copy link
Contributor

Choose a reason for hiding this comment

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

Wdyt that we use this opportunity and refactor this a bit so we don't repeat these strings dozens of times across the repo? To have some constants and reuse them, maybe a helper func in some labels.go file that will add these common labels.

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 checked the code. I don't know. Does it really make sense to create separate utils file to store their only one label?
As I can see the code will become more implicit, more lines of the code and we don't really win something.
What do you think? I'm ok to add it in terms of coding practice, but I really do not see much motivations for it.

Copy link
Contributor

Choose a reason for hiding this comment

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

What I meant was that instead of having for example "app.kubernetes.io/name": "percona-xtradb-cluster", all over the place, it will be set only in one file and then just invoke a function that will set the labels.

So the idea is that we have these common labels defined in a single place and then just reuse them where they are needed.

@nmarukovich nmarukovich changed the title K8SPXC-1230 add labels to backup pvc K8SPXC-1230 add labels to k8s objects created by operator Dec 22, 2023
@JNKPercona
Copy link
Collaborator

Test name Status
affinity-8-0 passed
auto-tuning-8-0 passed
cross-site-8-0 passed
demand-backup-cloud-8-0 passed
demand-backup-encrypted-with-tls-8-0 passed
demand-backup-8-0 passed
haproxy-5-7 passed
haproxy-8-0 passed
init-deploy-5-7 failure
init-deploy-8-0 failure
limits-8-0 passed
monitoring-2-0-8-0 passed
one-pod-5-7 passed
one-pod-8-0 passed
pitr-8-0 passed
pitr-gap-errors-8-0 passed
proxy-protocol-8-0 passed
proxysql-sidecar-res-limits-8-0 passed
recreate-8-0 passed
restore-to-encrypted-cluster-8-0 passed
scaling-proxysql-8-0 passed
scaling-8-0 passed
scheduled-backup-5-7 passed
scheduled-backup-8-0 passed
security-context-8-0 passed
smart-update1-8-0 failure
smart-update2-8-0 passed
storage-8-0 passed
tls-issue-cert-manager-ref-8-0 failure
tls-issue-cert-manager-8-0 failure
tls-issue-self-8-0 passed
upgrade-consistency-8-0 passed
upgrade-haproxy-8-0 passed
upgrade-proxysql-8-0 passed
users-5-7 passed
users-8-0 failure
validation-hook-8-0 passed
We run 37 out of 37

commit: 5c0e1da
image: perconalab/percona-xtradb-cluster-operator:PR-1565-5c0e1da0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/M 30-99 lines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants