Skip to content

Commit

Permalink
Merge pull request #317 from shiftstack/OSPRH-7546
Browse files Browse the repository at this point in the history
🐛 OSPRH-7546 - return a fatal error if server CA pass secret isn't found
  • Loading branch information
openshift-merge-bot[bot] authored Jun 11, 2024
2 parents 3b6b876 + cc02722 commit 5414e8c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion controllers/octavia_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ func (r *OctaviaReconciler) reconcileNormal(ctx context.Context, instance *octav
condition.RabbitMqTransportURLReadyMessage)
instance.Status.Conditions.MarkTrue(condition.InputReadyCondition, condition.InputReadyMessage)

err = octavia.EnsureAmphoraCerts(ctx, instance, helper, &Log)
err = octavia.EnsureAmphoraCerts(ctx, instance, helper)
if err != nil {
instance.Status.Conditions.Set(condition.FalseCondition(
octaviav1.OctaviaAmphoraCertsReadyCondition,
Expand Down
9 changes: 3 additions & 6 deletions pkg/octavia/amphora_certs.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"math/big"
"time"

"github.com/go-logr/logr"
"github.com/openstack-k8s-operators/lib-common/modules/common/helper"
"github.com/openstack-k8s-operators/lib-common/modules/common/secret"
octaviav1 "github.com/openstack-k8s-operators/octavia-operator/api/v1beta1"
Expand Down Expand Up @@ -149,8 +148,7 @@ func generateClientCert(caTemplate *x509.Certificate, certPrivKey *rsa.PrivateKe
func EnsureAmphoraCerts(
ctx context.Context,
instance *octaviav1.Octavia,
h *helper.Helper,
log *logr.Logger) error {
h *helper.Helper) error {
var oAmpSecret *corev1.Secret
var serverCAPass []byte

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

serverCAKey, serverCAKeyPEM, err := generateKey(serverCAPass)
if err != nil {
Expand Down

0 comments on commit 5414e8c

Please sign in to comment.