-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: update config & options for network plugin * feat: implement state checkpoint for network plugin * feat: implement the bandwidth allocation * feat: add unit tests and fix some bugs * fix: fix lint errors * fix: add missed licenses * fix: fix lint errors * fix: update per Wei's comments * feat: implement GetTopologyawareXXX * feat: use general.LoggerWithPrefix to replace klog with function prefix * fix: bump up go.mod * fix: update per Jianyu's comments * fix: update per Jianyu's comments * fix: set IsNodeResource to true * fix: set IsNodeResource to true in unit tests * fix: return min(egress, ingress) as node capacity and allocatable * fix: remove resourceIdentifier prefix if ns is empty * fix: fix a problem caused by the previous rebase * fix: fix the resourceIdentifier inconsistency problem
- Loading branch information
Showing
12 changed files
with
2,099 additions
and
241 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
Copyright 2022 The Katalyst Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package state | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"k8s.io/kubernetes/pkg/kubelet/checkpointmanager" | ||
"k8s.io/kubernetes/pkg/kubelet/checkpointmanager/checksum" | ||
) | ||
|
||
var _ checkpointmanager.Checkpoint = &NetworkPluginCheckpoint{} | ||
|
||
type NetworkPluginCheckpoint struct { | ||
PolicyName string `json:"policyName"` | ||
MachineState NICMap `json:"machineState"` | ||
PodEntries PodEntries `json:"pod_entries"` | ||
Checksum checksum.Checksum `json:"checksum"` | ||
} | ||
|
||
func NewNetworkPluginCheckpoint() *NetworkPluginCheckpoint { | ||
return &NetworkPluginCheckpoint{ | ||
PodEntries: make(PodEntries), | ||
MachineState: make(NICMap), | ||
} | ||
} | ||
|
||
// MarshalCheckpoint returns marshaled checkpoint | ||
func (cp *NetworkPluginCheckpoint) MarshalCheckpoint() ([]byte, error) { | ||
// make sure checksum wasn't set before, so it doesn't affect output checksum | ||
cp.Checksum = 0 | ||
cp.Checksum = checksum.New(cp) | ||
return json.Marshal(*cp) | ||
} | ||
|
||
// UnmarshalCheckpoint tries to unmarshal passed bytes to checkpoint | ||
func (cp *NetworkPluginCheckpoint) UnmarshalCheckpoint(blob []byte) error { | ||
return json.Unmarshal(blob, cp) | ||
} | ||
|
||
// VerifyChecksum verifies that current checksum of checkpoint is valid | ||
func (cp *NetworkPluginCheckpoint) VerifyChecksum() error { | ||
ck := cp.Checksum | ||
cp.Checksum = 0 | ||
err := ck.Verify(cp) | ||
cp.Checksum = ck | ||
return err | ||
} |
Oops, something went wrong.