Introduce new preview auto-scaling mode for ARC. (#2153)

Co-authored-by: Cory Miller <cory-miller@github.com>
Co-authored-by: Nikola Jokic <nikola-jokic@github.com>
Co-authored-by: Ava Stancu <AvaStancu@github.com>
Co-authored-by: Ferenc Hammerl <fhammerl@github.com>
Co-authored-by: Francesco Renzi <rentziass@github.com>
Co-authored-by: Bassem Dghaidi <Link-@github.com>
This commit is contained in:
Tingluo Huang
2023-01-17 12:06:20 -05:00
committed by GitHub
parent 619667fc3b
commit 622eaa34f8
75 changed files with 26094 additions and 354 deletions

View File

@@ -5,9 +5,12 @@
package hash
import (
"fmt"
"hash"
"hash/fnv"
"github.com/davecgh/go-spew/spew"
"k8s.io/apimachinery/pkg/util/rand"
)
// DeepHashObject writes specified object to hash using the spew library
@@ -23,3 +26,26 @@ func DeepHashObject(hasher hash.Hash, objectToWrite interface{}) {
}
printer.Fprintf(hasher, "%#v", objectToWrite)
}
// ComputeHash returns a hash value calculated from template and
// a collisionCount to avoid hash collision. The hash will be safe encoded to
// avoid bad words. It expects **template. In other words, you should pass an address
// of a DeepCopy result.
//
// Proudly modified and adopted from k8s.io/kubernetes/pkg/util/hash.DeepHashObject and
// k8s.io/kubernetes/pkg/controller.ComputeHash.
func ComputeTemplateHash(template interface{}) string {
hasher := fnv.New32a()
hasher.Reset()
printer := spew.ConfigState{
Indent: " ",
SortKeys: true,
DisableMethods: true,
SpewKeys: true,
}
printer.Fprintf(hasher, "%#v", template)
return rand.SafeEncodeString(fmt.Sprint(hasher.Sum32()))
}