mirror of
https://github.com/kubernetes/kubernetes.git
synced 2026-05-28 04:04:39 -04:00
Revert "Fix kubelet startup failure when restoring legacy V3 CPU manager checkpoints"
This reverts commit a8f751c0b5.
This commit is contained in:
parent
22c85984b3
commit
f9a879be4d
2 changed files with 3 additions and 57 deletions
|
|
@ -267,25 +267,8 @@ func (cp *CPUManagerCheckpointV3) VerifyChecksum() error {
|
|||
ck := cp.Checksum
|
||||
cp.Checksum = 0
|
||||
err := ck.Verify(cp)
|
||||
if err == nil {
|
||||
cp.Checksum = ck
|
||||
return nil
|
||||
}
|
||||
|
||||
object := dump.ForHash(cp)
|
||||
object = strings.Replace(object, "CPUManagerCheckpointV3", "CPUManagerCheckpoint", 1)
|
||||
cp.Checksum = ck
|
||||
|
||||
hash := fnv.New32a()
|
||||
_, _ = fmt.Fprintf(hash, "%v", object)
|
||||
actualCS := checksum.Checksum(hash.Sum32())
|
||||
if cp.Checksum != actualCS {
|
||||
return &errors.CorruptCheckpointError{
|
||||
ActualCS: uint64(actualCS),
|
||||
ExpectedCS: uint64(cp.Checksum),
|
||||
}
|
||||
}
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
|
||||
// VerifyChecksum verifies that current checksum of checkpoint is valid in v4 format
|
||||
|
|
|
|||
|
|
@ -322,7 +322,7 @@ func TestCheckpointStateRestore(t *testing.T) {
|
|||
"cpuSet":"7-9"
|
||||
}
|
||||
},
|
||||
"checksum": 766259872
|
||||
"checksum": 2284712151
|
||||
}`,
|
||||
"static",
|
||||
containermap.ContainerMap{},
|
||||
|
|
@ -354,7 +354,7 @@ func TestCheckpointStateRestore(t *testing.T) {
|
|||
"cpuSet":"7-9"
|
||||
}
|
||||
},
|
||||
"checksum": 766259872
|
||||
"checksum": 2284712151
|
||||
}`,
|
||||
"static",
|
||||
containermap.ContainerMap{},
|
||||
|
|
@ -775,43 +775,6 @@ func TestCPUManagerCheckpoint_MarshalCheckpoint_HashCompatibility(t *testing.T)
|
|||
}
|
||||
}
|
||||
|
||||
func TestCPUManagerCheckpointV3_VerifyChecksum_Compatibility(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
checksum checksum.Checksum
|
||||
}{
|
||||
{
|
||||
name: "accepts legacy v3 checksum",
|
||||
checksum: 766259872,
|
||||
},
|
||||
{
|
||||
name: "accepts current v3 checksum",
|
||||
checksum: 2284712151,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
cp := &CPUManagerCheckpointV3{
|
||||
PolicyName: "static",
|
||||
DefaultCPUSet: "1-2",
|
||||
Entries: map[string]map[string]string{
|
||||
"pod1": {
|
||||
"container1": "5-6",
|
||||
"container2": "3-4",
|
||||
},
|
||||
},
|
||||
PodEntries: PodCPUAssignments{
|
||||
"pod2": {CPUSet: cpuset.New(7, 8, 9)},
|
||||
},
|
||||
Checksum: tc.checksum,
|
||||
}
|
||||
|
||||
require.NoError(t, cp.VerifyChecksum())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func removeAll(dir string, t *testing.T) {
|
||||
t.Helper()
|
||||
if err := os.RemoveAll(dir); err != nil {
|
||||
|
|
|
|||
Loading…
Reference in a new issue