mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 18:43:34 +00:00
vendor cleanup: remove unused,non-go and test files
This commit is contained in:
48
vendor/k8s.io/kubernetes/pkg/kubelet/checkpointmanager/BUILD
generated
vendored
48
vendor/k8s.io/kubernetes/pkg/kubelet/checkpointmanager/BUILD
generated
vendored
@ -1,48 +0,0 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
"go_test",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["checkpoint_manager.go"],
|
||||
importpath = "k8s.io/kubernetes/pkg/kubelet/checkpointmanager",
|
||||
deps = [
|
||||
"//pkg/kubelet/checkpointmanager/errors:go_default_library",
|
||||
"//pkg/kubelet/util/store:go_default_library",
|
||||
"//pkg/util/filesystem:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["checkpoint_manager_test.go"],
|
||||
embed = [":go_default_library"],
|
||||
deps = [
|
||||
"//pkg/kubelet/checkpointmanager/checksum:go_default_library",
|
||||
"//pkg/kubelet/checkpointmanager/testing:go_default_library",
|
||||
"//pkg/kubelet/checkpointmanager/testing/example_checkpoint_formats/v1:go_default_library",
|
||||
"//vendor/github.com/stretchr/testify/assert:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [
|
||||
":package-srcs",
|
||||
"//pkg/kubelet/checkpointmanager/checksum:all-srcs",
|
||||
"//pkg/kubelet/checkpointmanager/errors:all-srcs",
|
||||
"//pkg/kubelet/checkpointmanager/testing:all-srcs",
|
||||
],
|
||||
tags = ["automanaged"],
|
||||
)
|
25
vendor/k8s.io/kubernetes/pkg/kubelet/checkpointmanager/README.md
generated
vendored
25
vendor/k8s.io/kubernetes/pkg/kubelet/checkpointmanager/README.md
generated
vendored
@ -1,25 +0,0 @@
|
||||
## DISCLAIMER
|
||||
- Sig-Node community has reached a general consensus, as a best practice, to
|
||||
avoid introducing any new checkpointing support. We reached this understanding
|
||||
after struggling with some hard-to-debug issues in the production environments
|
||||
caused by the checkpointing.
|
||||
- Any changes to the checkpointed data structure would be considered incompatible and a component should add its own handling if it needs to ensure backward compatibility of reading old-format checkpoint files.
|
||||
|
||||
## Introduction
|
||||
This folder contains a framework & primitives, Checkpointing Manager, which is
|
||||
used by several other Kubelet submodules, `dockershim`, `devicemanager`, `pods`
|
||||
and `cpumanager`, to implement checkpointing at each submodule level. As already
|
||||
explained in above `Disclaimer` section, think twice before introducing any further
|
||||
checkpointing in Kubelet. If still checkpointing is required, then this folder
|
||||
provides the common APIs and the framework for implementing checkpointing.
|
||||
Using same APIs across all the submodules will help maintaining consistency at
|
||||
Kubelet level.
|
||||
|
||||
Below is the history of checkpointing support in Kubelet.
|
||||
|
||||
| Package | First checkpointing support merged on | PR link |
|
||||
| ------- | --------------------------------------| ------- |
|
||||
|kubelet/dockershim | Feb 3, 2017 | [[CRI] Implement Dockershim Checkpoint](https://github.com/kubernetes/kubernetes/pull/39903)
|
||||
|devicemanager| Sep 6, 2017 | [Deviceplugin checkpoint](https://github.com/kubernetes/kubernetes/pull/51744)
|
||||
| kubelet/pod | Nov 22, 2017 | [Initial basic bootstrap-checkpoint support](https://github.com/kubernetes/kubernetes/pull/50984)
|
||||
|cpumanager| Oct 27, 2017 |[Add file backed state to cpu manager ](https://github.com/kubernetes/kubernetes/pull/54408)
|
110
vendor/k8s.io/kubernetes/pkg/kubelet/checkpointmanager/checkpoint_manager.go
generated
vendored
110
vendor/k8s.io/kubernetes/pkg/kubelet/checkpointmanager/checkpoint_manager.go
generated
vendored
@ -1,110 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes 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 checkpointmanager
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"k8s.io/kubernetes/pkg/kubelet/checkpointmanager/errors"
|
||||
utilstore "k8s.io/kubernetes/pkg/kubelet/util/store"
|
||||
utilfs "k8s.io/kubernetes/pkg/util/filesystem"
|
||||
)
|
||||
|
||||
// Checkpoint provides the process checkpoint data
|
||||
type Checkpoint interface {
|
||||
MarshalCheckpoint() ([]byte, error)
|
||||
UnmarshalCheckpoint(blob []byte) error
|
||||
VerifyChecksum() error
|
||||
}
|
||||
|
||||
// CheckpointManager provides the interface to manage checkpoint
|
||||
type CheckpointManager interface {
|
||||
// CreateCheckpoint persists checkpoint in CheckpointStore. checkpointKey is the key for utilstore to locate checkpoint.
|
||||
// For file backed utilstore, checkpointKey is the file name to write the checkpoint data.
|
||||
CreateCheckpoint(checkpointKey string, checkpoint Checkpoint) error
|
||||
// GetCheckpoint retrieves checkpoint from CheckpointStore.
|
||||
GetCheckpoint(checkpointKey string, checkpoint Checkpoint) error
|
||||
// WARNING: RemoveCheckpoint will not return error if checkpoint does not exist.
|
||||
RemoveCheckpoint(checkpointKey string) error
|
||||
// ListCheckpoint returns the list of existing checkpoints.
|
||||
ListCheckpoints() ([]string, error)
|
||||
}
|
||||
|
||||
// impl is an implementation of CheckpointManager. It persists checkpoint in CheckpointStore
|
||||
type impl struct {
|
||||
path string
|
||||
store utilstore.Store
|
||||
mutex sync.Mutex
|
||||
}
|
||||
|
||||
// NewCheckpointManager returns a new instance of a checkpoint manager
|
||||
func NewCheckpointManager(checkpointDir string) (CheckpointManager, error) {
|
||||
fstore, err := utilstore.NewFileStore(checkpointDir, utilfs.DefaultFs{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &impl{path: checkpointDir, store: fstore}, nil
|
||||
}
|
||||
|
||||
// CreateCheckpoint persists checkpoint in CheckpointStore.
|
||||
func (manager *impl) CreateCheckpoint(checkpointKey string, checkpoint Checkpoint) error {
|
||||
manager.mutex.Lock()
|
||||
defer manager.mutex.Unlock()
|
||||
blob, err := checkpoint.MarshalCheckpoint()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return manager.store.Write(checkpointKey, blob)
|
||||
}
|
||||
|
||||
// GetCheckpoint retrieves checkpoint from CheckpointStore.
|
||||
func (manager *impl) GetCheckpoint(checkpointKey string, checkpoint Checkpoint) error {
|
||||
manager.mutex.Lock()
|
||||
defer manager.mutex.Unlock()
|
||||
blob, err := manager.store.Read(checkpointKey)
|
||||
if err != nil {
|
||||
if err == utilstore.ErrKeyNotFound {
|
||||
return errors.ErrCheckpointNotFound
|
||||
}
|
||||
return err
|
||||
}
|
||||
err = checkpoint.UnmarshalCheckpoint(blob)
|
||||
if err == nil {
|
||||
err = checkpoint.VerifyChecksum()
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// RemoveCheckpoint will not return error if checkpoint does not exist.
|
||||
func (manager *impl) RemoveCheckpoint(checkpointKey string) error {
|
||||
manager.mutex.Lock()
|
||||
defer manager.mutex.Unlock()
|
||||
return manager.store.Delete(checkpointKey)
|
||||
}
|
||||
|
||||
// ListCheckpoints returns the list of existing checkpoints.
|
||||
func (manager *impl) ListCheckpoints() ([]string, error) {
|
||||
manager.mutex.Lock()
|
||||
defer manager.mutex.Unlock()
|
||||
keys, err := manager.store.List()
|
||||
if err != nil {
|
||||
return []string{}, fmt.Errorf("failed to list checkpoint store: %v", err)
|
||||
}
|
||||
return keys, nil
|
||||
}
|
245
vendor/k8s.io/kubernetes/pkg/kubelet/checkpointmanager/checkpoint_manager_test.go
generated
vendored
245
vendor/k8s.io/kubernetes/pkg/kubelet/checkpointmanager/checkpoint_manager_test.go
generated
vendored
@ -1,245 +0,0 @@
|
||||
/*
|
||||
Copyright 2017 The Kubernetes 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 checkpointmanager
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"sort"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"k8s.io/kubernetes/pkg/kubelet/checkpointmanager/checksum"
|
||||
utilstore "k8s.io/kubernetes/pkg/kubelet/checkpointmanager/testing"
|
||||
"k8s.io/kubernetes/pkg/kubelet/checkpointmanager/testing/example_checkpoint_formats/v1"
|
||||
)
|
||||
|
||||
var testStore *utilstore.MemStore
|
||||
|
||||
type FakeCheckpoint interface {
|
||||
Checkpoint
|
||||
GetData() ([]*PortMapping, bool)
|
||||
}
|
||||
|
||||
// Data contains all types of data that can be stored in the checkpoint.
|
||||
type Data struct {
|
||||
PortMappings []*PortMapping `json:"port_mappings,omitempty"`
|
||||
HostNetwork bool `json:"host_network,omitempty"`
|
||||
}
|
||||
|
||||
type CheckpointDataV2 struct {
|
||||
PortMappings []*PortMapping `json:"port_mappings,omitempty"`
|
||||
HostNetwork bool `json:"host_network,omitempty"`
|
||||
V2Field string `json:"v2field"`
|
||||
}
|
||||
|
||||
type protocol string
|
||||
|
||||
// portMapping is the port mapping configurations of a sandbox.
|
||||
type PortMapping struct {
|
||||
// protocol of the port mapping.
|
||||
Protocol *protocol
|
||||
// Port number within the container.
|
||||
ContainerPort *int32
|
||||
// Port number on the host.
|
||||
HostPort *int32
|
||||
}
|
||||
|
||||
// CheckpointData is a sample example structure to be used in test cases for checkpointing
|
||||
type CheckpointData struct {
|
||||
Version string
|
||||
Name string
|
||||
Data *Data
|
||||
Checksum checksum.Checksum
|
||||
}
|
||||
|
||||
func newFakeCheckpointV1(name string, portMappings []*PortMapping, hostNetwork bool) FakeCheckpoint {
|
||||
return &CheckpointData{
|
||||
Version: "v1",
|
||||
Name: name,
|
||||
Data: &Data{
|
||||
PortMappings: portMappings,
|
||||
HostNetwork: hostNetwork,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (cp *CheckpointData) MarshalCheckpoint() ([]byte, error) {
|
||||
cp.Checksum = checksum.New(*cp.Data)
|
||||
return json.Marshal(*cp)
|
||||
}
|
||||
|
||||
func (cp *CheckpointData) UnmarshalCheckpoint(blob []byte) error {
|
||||
return json.Unmarshal(blob, cp)
|
||||
}
|
||||
|
||||
func (cp *CheckpointData) VerifyChecksum() error {
|
||||
return cp.Checksum.Verify(*cp.Data)
|
||||
}
|
||||
|
||||
func (cp *CheckpointData) GetData() ([]*PortMapping, bool) {
|
||||
return cp.Data.PortMappings, cp.Data.HostNetwork
|
||||
}
|
||||
|
||||
type checkpointDataV2 struct {
|
||||
Version string
|
||||
Name string
|
||||
Data *CheckpointDataV2
|
||||
Checksum checksum.Checksum
|
||||
}
|
||||
|
||||
func newFakeCheckpointV2(name string, portMappings []*PortMapping, hostNetwork bool) FakeCheckpoint {
|
||||
return &checkpointDataV2{
|
||||
Version: "v2",
|
||||
Name: name,
|
||||
Data: &CheckpointDataV2{
|
||||
PortMappings: portMappings,
|
||||
HostNetwork: hostNetwork,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func newFakeCheckpointRemoteV1(name string, portMappings []*v1.PortMapping, hostNetwork bool) Checkpoint {
|
||||
return &v1.CheckpointData{
|
||||
Version: "v1",
|
||||
Name: name,
|
||||
Data: &v1.Data{
|
||||
PortMappings: portMappings,
|
||||
HostNetwork: hostNetwork,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (cp *checkpointDataV2) MarshalCheckpoint() ([]byte, error) {
|
||||
cp.Checksum = checksum.New(*cp.Data)
|
||||
return json.Marshal(*cp)
|
||||
}
|
||||
|
||||
func (cp *checkpointDataV2) UnmarshalCheckpoint(blob []byte) error {
|
||||
return json.Unmarshal(blob, cp)
|
||||
}
|
||||
|
||||
func (cp *checkpointDataV2) VerifyChecksum() error {
|
||||
return cp.Checksum.Verify(*cp.Data)
|
||||
}
|
||||
|
||||
func (cp *checkpointDataV2) GetData() ([]*PortMapping, bool) {
|
||||
return cp.Data.PortMappings, cp.Data.HostNetwork
|
||||
}
|
||||
|
||||
func newTestCheckpointManager() CheckpointManager {
|
||||
return &impl{store: testStore}
|
||||
}
|
||||
|
||||
func TestCheckpointManager(t *testing.T) {
|
||||
var err error
|
||||
testStore = utilstore.NewMemStore()
|
||||
manager := newTestCheckpointManager()
|
||||
port80 := int32(80)
|
||||
port443 := int32(443)
|
||||
proto := protocol("tcp")
|
||||
|
||||
portMappings := []*PortMapping{
|
||||
{
|
||||
&proto,
|
||||
&port80,
|
||||
&port80,
|
||||
},
|
||||
{
|
||||
&proto,
|
||||
&port443,
|
||||
&port443,
|
||||
},
|
||||
}
|
||||
checkpoint1 := newFakeCheckpointV1("check1", portMappings, true)
|
||||
|
||||
checkpoints := []struct {
|
||||
checkpointKey string
|
||||
checkpoint FakeCheckpoint
|
||||
expectHostNetwork bool
|
||||
}{
|
||||
{
|
||||
"key1",
|
||||
checkpoint1,
|
||||
true,
|
||||
},
|
||||
{
|
||||
"key2",
|
||||
newFakeCheckpointV1("check2", nil, false),
|
||||
false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range checkpoints {
|
||||
// Test CreateCheckpoints
|
||||
err = manager.CreateCheckpoint(tc.checkpointKey, tc.checkpoint)
|
||||
assert.NoError(t, err)
|
||||
|
||||
// Test GetCheckpoints
|
||||
checkpointOut := newFakeCheckpointV1("", nil, false)
|
||||
err := manager.GetCheckpoint(tc.checkpointKey, checkpointOut)
|
||||
assert.NoError(t, err)
|
||||
actualPortMappings, actualHostNetwork := checkpointOut.GetData()
|
||||
expPortMappings, expHostNetwork := tc.checkpoint.GetData()
|
||||
assert.Equal(t, actualPortMappings, expPortMappings)
|
||||
assert.Equal(t, actualHostNetwork, expHostNetwork)
|
||||
}
|
||||
// Test it fails if tried to read V1 structure into V2, a different structure from the structure which is checkpointed
|
||||
checkpointV2 := newFakeCheckpointV2("", nil, false)
|
||||
err = manager.GetCheckpoint("key1", checkpointV2)
|
||||
assert.EqualError(t, err, "checkpoint is corrupted")
|
||||
|
||||
// Test it fails if tried to read V1 structure into the same structure but defined in another package
|
||||
checkpointRemoteV1 := newFakeCheckpointRemoteV1("", nil, false)
|
||||
err = manager.GetCheckpoint("key1", checkpointRemoteV1)
|
||||
assert.EqualError(t, err, "checkpoint is corrupted")
|
||||
|
||||
// Test it works if tried to read V1 structure using into a new V1 structure
|
||||
checkpointV1 := newFakeCheckpointV1("", nil, false)
|
||||
err = manager.GetCheckpoint("key1", checkpointV1)
|
||||
assert.NoError(t, err)
|
||||
|
||||
// Test corrupt checksum case
|
||||
checkpointOut := newFakeCheckpointV1("", nil, false)
|
||||
blob, err := checkpointOut.MarshalCheckpoint()
|
||||
assert.NoError(t, err)
|
||||
testStore.Write("key1", blob)
|
||||
err = manager.GetCheckpoint("key1", checkpoint1)
|
||||
assert.EqualError(t, err, "checkpoint is corrupted")
|
||||
|
||||
// Test ListCheckpoints
|
||||
keys, err := manager.ListCheckpoints()
|
||||
assert.NoError(t, err)
|
||||
sort.Strings(keys)
|
||||
assert.Equal(t, keys, []string{"key1", "key2"})
|
||||
|
||||
// Test RemoveCheckpoints
|
||||
err = manager.RemoveCheckpoint("key1")
|
||||
assert.NoError(t, err)
|
||||
// Test Remove Nonexisted Checkpoints
|
||||
err = manager.RemoveCheckpoint("key1")
|
||||
assert.NoError(t, err)
|
||||
|
||||
// Test ListCheckpoints
|
||||
keys, err = manager.ListCheckpoints()
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, keys, []string{"key2"})
|
||||
|
||||
// Test Get NonExisted Checkpoint
|
||||
checkpointNE := newFakeCheckpointV1("NE", nil, false)
|
||||
err = manager.GetCheckpoint("key1", checkpointNE)
|
||||
assert.Error(t, err)
|
||||
}
|
26
vendor/k8s.io/kubernetes/pkg/kubelet/checkpointmanager/checksum/BUILD
generated
vendored
26
vendor/k8s.io/kubernetes/pkg/kubelet/checkpointmanager/checksum/BUILD
generated
vendored
@ -1,26 +0,0 @@
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["checksum.go"],
|
||||
importpath = "k8s.io/kubernetes/pkg/kubelet/checkpointmanager/checksum",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//pkg/kubelet/checkpointmanager/errors:go_default_library",
|
||||
"//pkg/util/hash:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
46
vendor/k8s.io/kubernetes/pkg/kubelet/checkpointmanager/checksum/checksum.go
generated
vendored
46
vendor/k8s.io/kubernetes/pkg/kubelet/checkpointmanager/checksum/checksum.go
generated
vendored
@ -1,46 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes 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 checksum
|
||||
|
||||
import (
|
||||
"hash/fnv"
|
||||
|
||||
"k8s.io/kubernetes/pkg/kubelet/checkpointmanager/errors"
|
||||
hashutil "k8s.io/kubernetes/pkg/util/hash"
|
||||
)
|
||||
|
||||
// Data to be stored as checkpoint
|
||||
type Checksum uint64
|
||||
|
||||
// VerifyChecksum verifies that passed checksum is same as calculated checksum
|
||||
func (cs Checksum) Verify(data interface{}) error {
|
||||
if cs != New(data) {
|
||||
return errors.ErrCorruptCheckpoint
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func New(data interface{}) Checksum {
|
||||
return Checksum(getChecksum(data))
|
||||
}
|
||||
|
||||
// Get returns calculated checksum of checkpoint data
|
||||
func getChecksum(data interface{}) uint64 {
|
||||
hash := fnv.New32a()
|
||||
hashutil.DeepHashObject(hash, data)
|
||||
return uint64(hash.Sum32())
|
||||
}
|
25
vendor/k8s.io/kubernetes/pkg/kubelet/checkpointmanager/errors/BUILD
generated
vendored
25
vendor/k8s.io/kubernetes/pkg/kubelet/checkpointmanager/errors/BUILD
generated
vendored
@ -1,25 +0,0 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["errors.go"],
|
||||
importpath = "k8s.io/kubernetes/pkg/kubelet/checkpointmanager/errors",
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
)
|
25
vendor/k8s.io/kubernetes/pkg/kubelet/checkpointmanager/errors/errors.go
generated
vendored
25
vendor/k8s.io/kubernetes/pkg/kubelet/checkpointmanager/errors/errors.go
generated
vendored
@ -1,25 +0,0 @@
|
||||
/*
|
||||
Copyright 2017 The Kubernetes 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 errors
|
||||
|
||||
import "fmt"
|
||||
|
||||
// ErrCorruptCheckpoint error is reported when checksum does not match
|
||||
var ErrCorruptCheckpoint = fmt.Errorf("checkpoint is corrupted")
|
||||
|
||||
// ErrCheckpointNotFound is reported when checkpoint is not found for a given key
|
||||
var ErrCheckpointNotFound = fmt.Errorf("checkpoint is not found")
|
28
vendor/k8s.io/kubernetes/pkg/kubelet/checkpointmanager/testing/BUILD
generated
vendored
28
vendor/k8s.io/kubernetes/pkg/kubelet/checkpointmanager/testing/BUILD
generated
vendored
@ -1,28 +0,0 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["util.go"],
|
||||
importpath = "k8s.io/kubernetes/pkg/kubelet/checkpointmanager/testing",
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [
|
||||
":package-srcs",
|
||||
"//pkg/kubelet/checkpointmanager/testing/example_checkpoint_formats/v1:all-srcs",
|
||||
],
|
||||
tags = ["automanaged"],
|
||||
)
|
@ -1,23 +0,0 @@
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["types.go"],
|
||||
importpath = "k8s.io/kubernetes/pkg/kubelet/checkpointmanager/testing/example_checkpoint_formats/v1",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = ["//pkg/kubelet/checkpointmanager/checksum:go_default_library"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
@ -1,62 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 The Kubernetes 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 v1
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"k8s.io/kubernetes/pkg/kubelet/checkpointmanager/checksum"
|
||||
)
|
||||
|
||||
type protocol string
|
||||
|
||||
// portMapping is the port mapping configurations of a sandbox.
|
||||
type PortMapping struct {
|
||||
// protocol of the port mapping.
|
||||
Protocol *protocol
|
||||
// Port number within the container.
|
||||
ContainerPort *int32
|
||||
// Port number on the host.
|
||||
HostPort *int32
|
||||
}
|
||||
|
||||
// CheckpointData contains all types of data that can be stored in the checkpoint.
|
||||
type Data struct {
|
||||
PortMappings []*PortMapping `json:"port_mappings,omitempty"`
|
||||
HostNetwork bool `json:"host_network,omitempty"`
|
||||
}
|
||||
|
||||
// CheckpointData is a sample example structure to be used in test cases for checkpointing
|
||||
type CheckpointData struct {
|
||||
Version string
|
||||
Name string
|
||||
Data *Data
|
||||
Checksum checksum.Checksum
|
||||
}
|
||||
|
||||
func (cp *CheckpointData) MarshalCheckpoint() ([]byte, error) {
|
||||
cp.Checksum = checksum.New(*cp.Data)
|
||||
return json.Marshal(*cp)
|
||||
}
|
||||
|
||||
func (cp *CheckpointData) UnmarshalCheckpoint(blob []byte) error {
|
||||
return json.Unmarshal(blob, cp)
|
||||
}
|
||||
|
||||
func (cp *CheckpointData) VerifyChecksum() error {
|
||||
return cp.Checksum.Verify(*cp.Data)
|
||||
}
|
71
vendor/k8s.io/kubernetes/pkg/kubelet/checkpointmanager/testing/util.go
generated
vendored
71
vendor/k8s.io/kubernetes/pkg/kubelet/checkpointmanager/testing/util.go
generated
vendored
@ -1,71 +0,0 @@
|
||||
/*
|
||||
Copyright 2017 The Kubernetes 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 testing
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
)
|
||||
|
||||
// MemStore is an implementation of CheckpointStore interface which stores checkpoint in memory.
|
||||
type MemStore struct {
|
||||
mem map[string][]byte
|
||||
sync.Mutex
|
||||
}
|
||||
|
||||
// NewMemStore returns an instance of MemStore
|
||||
func NewMemStore() *MemStore {
|
||||
return &MemStore{mem: make(map[string][]byte)}
|
||||
}
|
||||
|
||||
// Write writes the data to the store
|
||||
func (mstore *MemStore) Write(key string, data []byte) error {
|
||||
mstore.Lock()
|
||||
defer mstore.Unlock()
|
||||
mstore.mem[key] = data
|
||||
return nil
|
||||
}
|
||||
|
||||
// Read returns data read from store
|
||||
func (mstore *MemStore) Read(key string) ([]byte, error) {
|
||||
mstore.Lock()
|
||||
defer mstore.Unlock()
|
||||
data, ok := mstore.mem[key]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("checkpoint is not found")
|
||||
}
|
||||
return data, nil
|
||||
}
|
||||
|
||||
// Delete deletes data from the store
|
||||
func (mstore *MemStore) Delete(key string) error {
|
||||
mstore.Lock()
|
||||
defer mstore.Unlock()
|
||||
delete(mstore.mem, key)
|
||||
return nil
|
||||
}
|
||||
|
||||
// List returns all the keys from the store
|
||||
func (mstore *MemStore) List() ([]string, error) {
|
||||
mstore.Lock()
|
||||
defer mstore.Unlock()
|
||||
keys := make([]string, 0)
|
||||
for key := range mstore.mem {
|
||||
keys = append(keys, key)
|
||||
}
|
||||
return keys, nil
|
||||
}
|
Reference in New Issue
Block a user