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-813: Fail TLS configuration if provided certificates do not exist #1254

Merged
merged 14 commits into from
Sep 19, 2023

Conversation

t-yrka
Copy link
Contributor

@t-yrka t-yrka commented Jul 17, 2023

K8SPSMDB-813 Powered by Pull Request Badge

CHANGE DESCRIPTION

Problem:
Short explanation of the problem.

Healthcheck runs without TLS appropriately configured (when it is enabled).

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

Invalid TLS configuration is silently dropped.

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

Fail the healthcheck when TLS configuration is provided, but is invalid.

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/L 100-499 lines label Jul 17, 2023
@CLAassistant
Copy link

CLAassistant commented Jul 17, 2023

CLA assistant check
All committers have signed the CLA.

@t-yrka t-yrka changed the title Fail TLS configuration if provided certificates do not exist [healthcheck] Fail TLS configuration if provided certificates do not exist Jul 17, 2023
t-yrka and others added 2 commits July 19, 2023 11:09
egegunes
egegunes previously approved these changes Aug 18, 2023
inelpandzic
inelpandzic previously approved these changes Aug 18, 2023
"--sslCAFile", "/etc/mongodb-ssl/ca.crt",
"--sslPEMKeyFile", "/tmp/tls.pem",
},
Command: []string{"/data/db/mongodb-healthcheck", "k8s", "liveness"},
Copy link
Collaborator

Choose a reason for hiding this comment

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

@egegunes, maybe we need to do it only for cr >= 1.15?

@pooknull pooknull dismissed stale reviews from egegunes and inelpandzic via 06c966e September 18, 2023 13:57
@inelpandzic inelpandzic changed the title [healthcheck] Fail TLS configuration if provided certificates do not exist K8SPSMDB-813: Fail TLS configuration if provided certificates do not exist Sep 19, 2023
@@ -646,7 +649,7 @@ func (nv *NonVotingSpec) SetDefaults(cr *PerconaServerMongoDB, rs *ReplsetSpec)
Command: []string{"/data/db/mongodb-healthcheck", "k8s", "liveness"},
}

if !cr.Spec.UnsafeConf {
if !cr.Spec.UnsafeConf || cr.CompareVersion("1.15.0") < 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

is it correct? before we were adding ssl flags if UnsafeConf is false but with these changes we'll add flags if crVersion is < 1.15 no matter unsafe flag value

Copy link
Contributor

Choose a reason for hiding this comment

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

Before the PR, we had this code without any checks:

 Command: []string{
				"/data/db/mongodb-healthcheck",
				"k8s",
				"liveness",
				"--ssl", "--sslInsecure",
				"--sslCAFile", "/etc/mongodb-ssl/ca.crt",
				"--sslPEMKeyFile", "/tmp/tls.pem",
			},

We should add these flags to crs with < 1.15.0 versions to maintain the old behavior

Comment on lines +240 to +241
if (cr.CompareVersion("1.7.0") >= 0 && cr.CompareVersion("1.15.0") < 0) ||
cr.CompareVersion("1.15.0") >= 0 && !cr.Spec.UnsafeConf {
Copy link
Contributor

Choose a reason for hiding this comment

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

we seem to changed the behavior, with these we'll add these flags to probe command for all clusters <1.15

Copy link
Contributor

Choose a reason for hiding this comment

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

We should check for unsafe option only for clusters with >=1.15.0 version to maintain the old behavior for older cluster versions.

It seems that you checked the diff of only my changes, and not those of the entire pull request.

@JNKPercona
Copy link
Collaborator

Test name Status
arbiter passed
balancer passed
custom-replset-name 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
finalizer 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
pitr-physical 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
split-horizon passed
storage passed
tls-issue-cert-manager passed
upgrade passed
upgrade-consistency passed
upgrade-consistency-sharded passed
upgrade-sharded passed
users passed
version-service passed
We run 45 out of 45

commit: 7d8974c
image: perconalab/percona-server-mongodb-operator:PR-1254-7d8974c6

@hors hors merged commit dcc31ae into percona:main Sep 19, 2023
8 checks passed
@hors
Copy link
Collaborator

hors commented Sep 19, 2023

@t-yrka Thank you for your contribution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community size/L 100-499 lines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants