Skip to content

Commit

Permalink
[Bugfix] Fix TLS Hash generation (#1519)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajanikow authored Dec 3, 2023
1 parent 2a25820 commit bc4cfbc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkg/deployment/reconcile/action_tls_status_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (a *actionTLSKeyStatusUpdate) Start(ctx context.Context) (bool, error) {
return true, nil
}

keyHashes := secretKeysToListWithPrefix(f)
keyHashes := tlsSecretKeysToListWithPrefix(f)

if err = a.actionCtx.WithStatusUpdate(ctx, func(s *api.DeploymentStatus) bool {
r := false
Expand Down
2 changes: 1 addition & 1 deletion pkg/deployment/reconcile/plan_builder_tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func (r *Reconciler) createTLSStatusUpdateRequired(apiObject k8sutil.APIObject,
return false
}

keyHashes := secretKeysToListWithPrefix(trusted)
keyHashes := tlsSecretKeysToListWithPrefix(trusted)

if len(keyHashes) == 0 {
return false
Expand Down
15 changes: 12 additions & 3 deletions pkg/deployment/reconcile/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,27 @@ import (
"k8s.io/apimachinery/pkg/types"

api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
"github.com/arangodb/kube-arangodb/pkg/deployment/resources"
"github.com/arangodb/kube-arangodb/pkg/handlers/utils"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/pod"
"github.com/arangodb/kube-arangodb/pkg/util/strings"
)

func secretKeysToListWithPrefix(s *core.Secret) []string {
return strings.PrefixStringArray(secretKeysToList(s), "sha256:")
func tlsSecretKeysToListWithPrefix(s *core.Secret) []string {
return secretKeysToListWithPrefix(s, resources.CACertName)
}

func secretKeysToList(s *core.Secret) []string {
func secretKeysToListWithPrefix(s *core.Secret, skip ...string) []string {
return strings.PrefixStringArray(secretKeysToList(s, skip...), "sha256:")
}

func secretKeysToList(s *core.Secret, skip ...string) []string {
keys := make([]string, 0, len(s.Data))

for key := range s.Data {
if utils.StringList(skip).Has(key) {
continue
}
keys = append(keys, key)
}

Expand Down

0 comments on commit bc4cfbc

Please sign in to comment.