Skip to content

Commit

Permalink
Fix cassandra_url handling to be http / https depending on SSL (#1221)
Browse files Browse the repository at this point in the history
  • Loading branch information
burmanm authored Feb 24, 2024
1 parent 018e846 commit 524f520
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
11 changes: 7 additions & 4 deletions pkg/medusa/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ func CreateMedusaIni(kc *k8ss.K8ssandraCluster, dcConfig *cassandra.DatacenterCo
level = DEBUG
[kubernetes]
cassandra_url = http://127.0.0.1:8080/api/v0/ops/node/snapshots
use_mgmt_api = 1
enabled = 1`

Expand All @@ -141,9 +140,13 @@ func CreateMedusaIni(kc *k8ss.K8ssandraCluster, dcConfig *cassandra.DatacenterCo
// Create Kubernetes config here and append it
if dcConfig.ManagementApiAuth != nil && dcConfig.ManagementApiAuth.Manual != nil {
medusaConfiig += `
ca_cert = /etc/encryption/mgmt/ca.crt
tls_cert = /etc/encryption/mgmt/tls.crt
tls_key = /etc/encryption/mgmt/tls.key`
cassandra_url = https://127.0.0.1:8080/api/v0/ops/node/snapshots
ca_cert = /etc/encryption/mgmt/ca.crt
tls_cert = /etc/encryption/mgmt/tls.crt
tls_key = /etc/encryption/mgmt/tls.key`
} else {
medusaConfiig += `
cassandra_url = http://127.0.0.1:8080/api/v0/ops/node/snapshots`
}

return medusaConfiig
Expand Down
5 changes: 5 additions & 0 deletions pkg/medusa/reconcile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ func testMedusaIniNoPrefix(t *testing.T) {
assert.Contains(t, medusaIni, "port = 9001")
assert.Contains(t, medusaIni, "secure = False")
assert.Contains(t, medusaIni, "backup_grace_period_in_days = 7")
assert.Contains(t, medusaIni, "cassandra_url = http://127.0.0.1:8080/api/v0/ops/node/snapshots")
}

func testMedusaIniSecured(t *testing.T) {
Expand Down Expand Up @@ -234,6 +235,9 @@ func testMedusaIniSecured(t *testing.T) {
assert.Contains(medusaIni, "ca_cert = /etc/encryption/mgmt/ca.crt")
assert.Contains(medusaIni, "tls_cert = /etc/encryption/mgmt/tls.crt")
assert.Contains(medusaIni, "tls_key = /etc/encryption/mgmt/tls.key")
assert.Contains(medusaIni, "cassandra_url = https://127.0.0.1:8080/api/v0/ops/node/snapshots")

assert.NotContains(medusaIni, "\t")
}

func testMedusaIniSecuredDcLevelSetting(t *testing.T) {
Expand Down Expand Up @@ -296,6 +300,7 @@ func testMedusaIniSecuredDcLevelSetting(t *testing.T) {
assert.Contains(medusaIni, "ca_cert = /etc/encryption/mgmt/ca.crt")
assert.Contains(medusaIni, "tls_cert = /etc/encryption/mgmt/tls.crt")
assert.Contains(medusaIni, "tls_key = /etc/encryption/mgmt/tls.key")
assert.Contains(medusaIni, "cassandra_url = https://127.0.0.1:8080/api/v0/ops/node/snapshots")
}

func testMedusaIniUnsecured(t *testing.T) {
Expand Down

0 comments on commit 524f520

Please sign in to comment.