Skip to content

Commit

Permalink
Merge pull request #2306 from simonpasquier/OCPBUGS-28766
Browse files Browse the repository at this point in the history
[release-4.12] OCPBUGS-28766: fix generation of telemeter token hash
  • Loading branch information
openshift-merge-bot[bot] committed Apr 22, 2024
2 parents 60117fa + 303b83d commit 8906207
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 3 additions & 3 deletions pkg/manifests/manifests.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package manifests

import (
"crypto/md5"
"crypto/sha256"
"crypto/tls"
"encoding/base64"
"encoding/json"
Expand Down Expand Up @@ -3617,8 +3616,9 @@ func (f *Factory) TelemeterClientDeployment(proxyCABundleCM *v1.ConfigMap, s *v1

// Set annotation on deployment to trigger redeployments
if s != nil {
hash := sha256.New()
d.Spec.Template.Annotations["telemeter-token-hash"] = string(hash.Sum(s.Data["token"]))
h := fnv.New64()
h.Write(s.Data["token"])
d.Spec.Template.Annotations["telemeter-token-hash"] = strconv.FormatUint(h.Sum64(), 32)
}

for i, container := range d.Spec.Template.Spec.Containers {
Expand Down
4 changes: 1 addition & 3 deletions pkg/manifests/manifests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package manifests

import (
"context"
"crypto/sha256"
"errors"
"fmt"
"net/url"
Expand Down Expand Up @@ -3194,8 +3193,7 @@ func TestTelemeterConfiguration(t *testing.T) {
}
}

hash := sha256.New()
expectedTokenHash := string(hash.Sum([]byte("test")))
expectedTokenHash := "8o29vfqfspfr9"

if tokenHash, ok := d.Spec.Template.Annotations["telemeter-token-hash"]; !ok {
t.Fatalf("telemeter-token-hash annotation not set in telemeter-client deployment")
Expand Down

0 comments on commit 8906207

Please sign in to comment.