Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
3bdc3f25
Commit
3bdc3f25
authored
Jan 23, 2017
by
Harry Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use fnv.New32a() in hash instead adler32
parent
a57967f4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
10 deletions
+11
-10
lookup_cache.go
pkg/controller/lookup_cache.go
+2
-2
mount_linux.go
pkg/util/mount/mount_linux.go
+2
-2
mount_linux_test.go
pkg/util/mount/mount_linux_test.go
+5
-4
equivalence_cache.go
plugin/pkg/scheduler/core/equivalence_cache.go
+2
-2
No files found.
pkg/controller/lookup_cache.go
View file @
3bdc3f25
...
...
@@ -17,7 +17,7 @@ limitations under the License.
package
controller
import
(
"hash/
adler32
"
"hash/
fnv
"
"sync"
"github.com/golang/groupcache/lru"
...
...
@@ -33,7 +33,7 @@ type objectWithMeta interface {
// Since we match objects by namespace and Labels/Selector, so if two objects have the same namespace and labels,
// they will have the same key.
func
keyFunc
(
obj
objectWithMeta
)
uint64
{
hash
:=
adler32
.
New
()
hash
:=
fnv
.
New32a
()
hashutil
.
DeepHashObject
(
hash
,
&
equivalenceLabelObj
{
namespace
:
obj
.
GetNamespace
(),
labels
:
obj
.
GetLabels
(),
...
...
pkg/util/mount/mount_linux.go
View file @
3bdc3f25
...
...
@@ -21,7 +21,7 @@ package mount
import
(
"bufio"
"fmt"
"hash/
adler32
"
"hash/
fnv
"
"io"
"os"
"os/exec"
...
...
@@ -282,7 +282,7 @@ func readProcMounts(mountFilePath string, out *[]MountPoint) (uint32, error) {
}
func
readProcMountsFrom
(
file
io
.
Reader
,
out
*
[]
MountPoint
)
(
uint32
,
error
)
{
hash
:=
adler32
.
New
()
hash
:=
fnv
.
New32a
()
scanner
:=
bufio
.
NewReader
(
file
)
for
{
line
,
err
:=
scanner
.
ReadString
(
'\n'
)
...
...
pkg/util/mount/mount_linux_test.go
View file @
3bdc3f25
...
...
@@ -29,20 +29,21 @@ func TestReadProcMountsFrom(t *testing.T) {
/dev/1 /path/to/1 type1 flags 1 1
/dev/2 /path/to/2 type2 flags,1,2=3 2 2
`
// NOTE: readProcMountsFrom has been updated to using fnv.New32a()
hash
,
err
:=
readProcMountsFrom
(
strings
.
NewReader
(
successCase
),
nil
)
if
err
!=
nil
{
t
.
Errorf
(
"expected success"
)
}
if
hash
!=
0xa
3522051
{
t
.
Errorf
(
"expected 0xa
3522051
, got %#x"
,
hash
)
if
hash
!=
0xa
290ff0b
{
t
.
Errorf
(
"expected 0xa
290ff0b
, got %#x"
,
hash
)
}
mounts
:=
[]
MountPoint
{}
hash
,
err
=
readProcMountsFrom
(
strings
.
NewReader
(
successCase
),
&
mounts
)
if
err
!=
nil
{
t
.
Errorf
(
"expected success"
)
}
if
hash
!=
0xa
3522051
{
t
.
Errorf
(
"expected 0xa
3522051
, got %#x"
,
hash
)
if
hash
!=
0xa
290ff0b
{
t
.
Errorf
(
"expected 0xa
290ff0b
, got %#x"
,
hash
)
}
if
len
(
mounts
)
!=
3
{
t
.
Fatalf
(
"expected 3 mounts, got %d"
,
len
(
mounts
))
...
...
plugin/pkg/scheduler/core/equivalence_cache.go
View file @
3bdc3f25
...
...
@@ -17,7 +17,7 @@ limitations under the License.
package
core
import
(
"hash/
adler32
"
"hash/
fnv
"
"github.com/golang/groupcache/lru"
...
...
@@ -128,7 +128,7 @@ func (ec *EquivalenceCache) SendClearAllCacheReq() {
// hashEquivalencePod returns the hash of equivalence pod.
func
(
ec
*
EquivalenceCache
)
hashEquivalencePod
(
pod
*
v1
.
Pod
)
uint64
{
equivalencePod
:=
ec
.
getEquivalencePod
(
pod
)
hash
:=
adler32
.
New
()
hash
:=
fnv
.
New32a
()
hashutil
.
DeepHashObject
(
hash
,
equivalencePod
)
return
uint64
(
hash
.
Sum32
())
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment