Skip to content

Commit cc02722

Browse files
committed
amphora certs: return a fatal error if server CA pass secret isn't found
If the server CA passphrase secret is not found, we need to return an error because later on, Octavia worker won't be able to sign the certificate. Cryptography will complain: ``` Password was given but private key is not encrypted ```
1 parent 3a1a634 commit cc02722

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

controllers/octavia_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ func (r *OctaviaReconciler) reconcileNormal(ctx context.Context, instance *octav
506506
}
507507
instance.Status.Conditions.MarkTrue(condition.InputReadyCondition, condition.InputReadyMessage)
508508

509-
err = octavia.EnsureAmphoraCerts(ctx, instance, helper, &Log)
509+
err = octavia.EnsureAmphoraCerts(ctx, instance, helper)
510510
if err != nil {
511511
instance.Status.Conditions.Set(condition.FalseCondition(
512512
octaviav1.OctaviaAmphoraCertsReadyCondition,

pkg/octavia/amphora_certs.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
"math/big"
2727
"time"
2828

29-
"github.com/go-logr/logr"
3029
"github.com/openstack-k8s-operators/lib-common/modules/common/helper"
3130
"github.com/openstack-k8s-operators/lib-common/modules/common/secret"
3231
octaviav1 "github.com/openstack-k8s-operators/octavia-operator/api/v1beta1"
@@ -149,8 +148,7 @@ func generateClientCert(caTemplate *x509.Certificate, certPrivKey *rsa.PrivateKe
149148
func EnsureAmphoraCerts(
150149
ctx context.Context,
151150
instance *octaviav1.Octavia,
152-
h *helper.Helper,
153-
log *logr.Logger) error {
151+
h *helper.Helper) error {
154152
var oAmpSecret *corev1.Secret
155153
var serverCAPass []byte
156154

@@ -165,10 +163,9 @@ func EnsureAmphoraCerts(
165163
cAPassSecret, _, err := secret.GetSecret(
166164
ctx, h, serverCAPassSecretName, instance.Namespace)
167165
if err != nil {
168-
log.Info("Could not read server CA passphrase. No encryption will be applied to the generated key.")
169-
} else {
170-
serverCAPass = cAPassSecret.Data["server-ca-passphrase"]
166+
return fmt.Errorf("Error retrieving secret %s needed to encrypt the generated key - %w", serverCAPassSecretName, err)
171167
}
168+
serverCAPass = cAPassSecret.Data["server-ca-passphrase"]
172169

173170
serverCAKey, serverCAKeyPEM, err := generateKey(serverCAPass)
174171
if err != nil {

0 commit comments

Comments
 (0)