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

K8SPSMDB-958 fix mongos metrics #1289

Merged
merged 13 commits into from
Aug 30, 2023
Merged

K8SPSMDB-958 fix mongos metrics #1289

merged 13 commits into from
Aug 30, 2023

Conversation

nmarukovich
Copy link
Contributor

@nmarukovich nmarukovich commented Aug 15, 2023

K8SPSMDB-958 Powered by Pull Request Badge

CHANGE DESCRIPTION

Problem:
Short explanation of the problem.
On mongos we do not have
Cause:
Short explanation of the root cause of the issue if applicable.
PMM fails to monitor mongoS due to lack of permission
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 MongoDB 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 Aug 15, 2023
Comment on lines 179 to 183
if platform == version.PlatformKubernetes {
var tp int64 = 1001
fsgroup = &tp
}

Copy link
Contributor

Choose a reason for hiding this comment

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

[gofmt] reported by reviewdog 🐶

Suggested change
if platform == version.PlatformKubernetes {
var tp int64 = 1001
fsgroup = &tp
}
if platform == version.PlatformKubernetes {
var tp int64 = 1001
fsgroup = &tp
}

Comment on lines 185 to 196
tvar := true
cr.Spec.Sharding.Mongos.ContainerSecurityContext = &corev1.SecurityContext{
RunAsNonRoot: &tvar,
RunAsUser: fsgroup,
}
}

if cr.Spec.Sharding.Mongos.PodSecurityContext == nil {
cr.Spec.Sharding.Mongos.PodSecurityContext = &corev1.PodSecurityContext{
FSGroup: fsgroup,
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

[gofmt] reported by reviewdog 🐶

Suggested change
tvar := true
cr.Spec.Sharding.Mongos.ContainerSecurityContext = &corev1.SecurityContext{
RunAsNonRoot: &tvar,
RunAsUser: fsgroup,
}
}
if cr.Spec.Sharding.Mongos.PodSecurityContext == nil {
cr.Spec.Sharding.Mongos.PodSecurityContext = &corev1.PodSecurityContext{
FSGroup: fsgroup,
}
}
tvar := true
cr.Spec.Sharding.Mongos.ContainerSecurityContext = &corev1.SecurityContext{
RunAsNonRoot: &tvar,
RunAsUser: fsgroup,
}
}
if cr.Spec.Sharding.Mongos.PodSecurityContext == nil {
cr.Spec.Sharding.Mongos.PodSecurityContext = &corev1.PodSecurityContext{
FSGroup: fsgroup,
}
}

@nmarukovich nmarukovich marked this pull request as ready for review August 17, 2023 09:14
@pull-request-size pull-request-size bot added size/M 30-99 lines and removed size/S 10-29 lines labels Aug 18, 2023
pooknull
pooknull previously approved these changes Aug 18, 2023
@@ -176,6 +176,26 @@ func (cr *PerconaServerMongoDB) CheckNSetDefaults(platform version.Platform, log
}
}

var fsgroup *int64
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we need to set it only for >- 1.15

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree.

@nmarukovich nmarukovich requested a review from hors August 22, 2023 06:26
nmarukovich and others added 2 commits August 22, 2023 10:27
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
}

if cr.Spec.Sharding.Mongos.ContainerSecurityContext == nil {
tvar := true
Copy link
Contributor

@inelpandzic inelpandzic Aug 28, 2023

Choose a reason for hiding this comment

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

I don't think we should do this here by modifying user CR. I think we should do it directly where we define mongos sts, in pkg/psmdb/mongos.go.

Wdyt @egegunes @hors

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why is it better to do it in sts? @inelpandzic

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we should touch CR if not necessary, it can be easily removed by the user. In the end, it is something internal that we need to ensure, just like we, for example, set init container or sidecar containers. We don't do it by updating the CR, but internally set it in our sts/deployment specs.

Copy link
Contributor Author

@nmarukovich nmarukovich Aug 28, 2023

Choose a reason for hiding this comment

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

As for me, we should either change this feature in CR or STS for all types of resources. Because for now we change it for cfg and rs in CR.
@egegunes @hors @inelpandzic
What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

Aha, I just saw that we do the same thing for other objects, like backup, and in this case, I think we should do it as you did it now @nmarukovich because of the consistency even though I think that generally it should be done where we create specs themselves rather than in CR.

Copy link
Contributor Author

@nmarukovich nmarukovich Aug 28, 2023

Choose a reason for hiding this comment

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

Aha, I just saw that we do the same thing for other objects, like backup, and in this case, I think we should do it as you did it now @nmarukovich because of the consistency even though I think that generally it should be done where we create specs themselves rather than in CR.

Despite the fact, that we already did it, I still want to discuss what we want to have ideally. In this case we can plan to refactor it or add a comment that decided to do like this (just avoid next time the same discussion )

Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally these should be (or close to) where we define sts for given component. Currently this place is the correct one IMO.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok! So let's merge in this case (=

@JNKPercona
Copy link
Collaborator

Test name Status
arbiter passed
cross-site-sharded passed
data-at-rest-encryption passed
data-sharded passed
demand-backup passed
demand-backup-eks-credentials passed
demand-backup-physical passed
demand-backup-physical-sharded passed
demand-backup-sharded passed
expose-sharded passed
ignore-labels-annotations passed
init-deploy passed
limits passed
liveness passed
mongod-major-upgrade passed
mongod-major-upgrade-sharded passed
monitoring-2-0 passed
multi-cluster-service passed
non-voting passed
one-pod passed
operator-self-healing-chaos passed
pitr passed
pitr-sharded passed
recover-no-primary passed
rs-shard-migration passed
scaling passed
scheduled-backup passed
security-context passed
self-healing-chaos passed
service-per-pod passed
serviceless-external-nodes passed
smart-update passed
storage passed
upgrade passed
upgrade-consistency passed
upgrade-sharded passed
users passed
version-service passed
We run 38 out of 38

commit: b24a013
image: perconalab/percona-server-mongodb-operator:PR-1289-b24a0130

@nmarukovich nmarukovich merged commit 3d4ed9c into main Aug 30, 2023
10 checks passed
@nmarukovich nmarukovich deleted the K8SPSMDB-958 branch August 30, 2023 05:54
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.

6 participants