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
Merged
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions pkg/apis/psmdb/v1/psmdb_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ func (cr *PerconaServerMongoDB) CheckNSetDefaults(platform version.Platform, log
},
}

if cr.CompareVersion("1.7.0") >= 0 && !cr.Spec.UnsafeConf {
if (cr.CompareVersion("1.7.0") >= 0 && cr.CompareVersion("1.15.0") < 0) ||
cr.CompareVersion("1.15.0") >= 0 && !cr.Spec.UnsafeConf {
cr.Spec.Sharding.Mongos.LivenessProbe.Exec.Command =
append(cr.Spec.Sharding.Mongos.LivenessProbe.Exec.Command,
"--ssl", "--sslInsecure",
Expand Down Expand Up @@ -236,7 +237,8 @@ func (cr *PerconaServerMongoDB) CheckNSetDefaults(platform version.Platform, log
},
}

if cr.CompareVersion("1.7.0") >= 0 && !cr.Spec.UnsafeConf {
if (cr.CompareVersion("1.7.0") >= 0 && cr.CompareVersion("1.15.0") < 0) ||
cr.CompareVersion("1.15.0") >= 0 && !cr.Spec.UnsafeConf {
Comment on lines +240 to +241
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.

cr.Spec.Sharding.Mongos.ReadinessProbe.Exec.Command =
append(cr.Spec.Sharding.Mongos.ReadinessProbe.Exec.Command,
"--ssl", "--sslInsecure",
Expand Down Expand Up @@ -362,7 +364,8 @@ func (cr *PerconaServerMongoDB) CheckNSetDefaults(platform version.Platform, log

if cr.CompareVersion("1.6.0") >= 0 {
replset.LivenessProbe.Probe.Exec.Command[0] = "/data/db/mongodb-healthcheck"
if cr.CompareVersion("1.7.0") >= 0 && !cr.Spec.UnsafeConf {
if (cr.CompareVersion("1.7.0") >= 0 && cr.CompareVersion("1.15.0") < 0) ||
cr.CompareVersion("1.15.0") >= 0 && !cr.Spec.UnsafeConf {
replset.LivenessProbe.Probe.Exec.Command =
append(replset.LivenessProbe.Probe.Exec.Command,
"--ssl", "--sslInsecure",
Expand Down Expand Up @@ -646,7 +649,7 @@ func (nv *NonVotingSpec) SetDefaults(cr *PerconaServerMongoDB, rs *ReplsetSpec)
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?

}

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

nv.LivenessProbe.Probe.ProbeHandler.Exec.Command = append(
nv.LivenessProbe.Probe.ProbeHandler.Exec.Command,
"--ssl", "--sslInsecure", "--sslCAFile", "/etc/mongodb-ssl/ca.crt", "--sslPEMKeyFile", "/tmp/tls.pem",
Expand Down
Loading