1
0
Fork 0
mirror of https://github.com/kastenhq/kubestr.git synced 2024-12-14 11:57:56 +00:00

Update Kanister to 4dca8c82ae9d (#137)

This commit is contained in:
Andrei Khoriakov 2022-10-25 21:02:47 +02:00 committed by GitHub
parent e2f62a3728
commit af3a5387f4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 112 additions and 462 deletions

39
go.mod
View file

@ -7,14 +7,14 @@ replace github.com/graymeta/stow => github.com/kastenhq/stow v0.1.2-kasten
require (
github.com/briandowns/spinner v1.19.0
github.com/golang/mock v1.6.0
github.com/kanisterio/kanister v0.0.0-20220712181324-befdee224291
github.com/kanisterio/kanister v0.0.0-20221021092747-4dca8c82ae9d
github.com/kubernetes-csi/external-snapshotter/client/v4 v4.2.0
github.com/pkg/errors v0.9.1
github.com/spf13/cobra v1.6.0
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c
k8s.io/api v0.24.3
k8s.io/apimachinery v0.24.3
k8s.io/client-go v0.24.3
k8s.io/api v0.24.4
k8s.io/apimachinery v0.24.4
k8s.io/client-go v0.24.4
)
require (
@ -33,13 +33,12 @@ require (
github.com/fatih/color v1.12.0 // indirect
github.com/go-errors/errors v1.0.1 // indirect
github.com/go-logr/logr v1.2.0 // indirect
github.com/go-openapi/errors v0.19.8 // indirect
github.com/go-openapi/errors v0.20.2 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.19.5 // indirect
github.com/go-openapi/strfmt v0.21.2 // indirect
github.com/go-openapi/strfmt v0.21.3 // indirect
github.com/go-openapi/swag v0.19.14 // indirect
github.com/go-stack/stack v1.8.0 // indirect
github.com/gofrs/uuid v4.2.0+incompatible // indirect
github.com/gofrs/uuid v4.3.0+incompatible // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/btree v1.0.1 // indirect
@ -74,29 +73,29 @@ require (
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/russross/blackfriday v1.5.2 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/testify v1.7.1 // indirect
github.com/stretchr/testify v1.8.0 // indirect
github.com/xlab/treeprint v0.0.0-20181112141820-a009c3971eca // indirect
go.mongodb.org/mongo-driver v1.7.5 // indirect
go.mongodb.org/mongo-driver v1.10.1 // indirect
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect
golang.org/x/net v0.0.0-20220617184016-355a448f1bc9 // indirect
golang.org/x/oauth2 v0.0.0-20220608161450-d0670ef3b1eb // indirect
golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c // indirect
golang.org/x/net v0.0.0-20220725212005-46097bf591d3 // indirect
golang.org/x/oauth2 v0.0.0-20220622183110-fd043fe589d2 // indirect
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/text v0.4.0 // indirect
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.28.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.24.1 // indirect
k8s.io/cli-runtime v0.24.1 // indirect
k8s.io/component-base v0.24.1 // indirect
k8s.io/apiextensions-apiserver v0.24.4 // indirect
k8s.io/cli-runtime v0.24.4 // indirect
k8s.io/component-base v0.24.4 // indirect
k8s.io/klog/v2 v2.60.1 // indirect
k8s.io/kube-openapi v0.0.0-20220328201542-3ee0da9b0b42 // indirect
k8s.io/kubectl v0.24.1 // indirect
k8s.io/kubectl v0.24.4 // indirect
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 // indirect
sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 // indirect
sigs.k8s.io/kustomize/api v0.11.4 // indirect

465
go.sum

File diff suppressed because it is too large Load diff

View file

@ -31,10 +31,10 @@ import (
)
const (
defaultReadyWaitTimeout = 2 * time.Minute
defaultReadyWaitTimeout = 2 * time.Minute
PVCKind = "PersistentVolumeClaim"
PodKind ="Pod"
PodKind = "Pod"
)
//go:generate go run github.com/golang/mock/mockgen -destination=mocks/mock_argument_validator.go -package=mocks . ArgumentValidator
@ -98,7 +98,7 @@ type ApplicationCreator interface {
}
type applicationCreate struct {
kubeCli kubernetes.Interface
kubeCli kubernetes.Interface
k8sObjectReadyTimeout time.Duration
}
@ -365,7 +365,7 @@ func (c *snapshotCreate) CreateFromSourceCheck(ctx context.Context, snapshotter
Driver: snapSrc.Driver,
VolumeSnapshotClassName: targetSnapClassName,
}
err = snapshotter.CreateFromSource(ctx, src, snapshotCFSCloneName, args.Namespace, true)
err = snapshotter.CreateFromSource(ctx, src, snapshotCFSCloneName, args.Namespace, true, nil)
if err != nil {
return errors.Wrapf(err, "Failed to clone snapshot from source (%s)", snapshotCFSCloneName)
}

View file

@ -9,10 +9,10 @@ import (
kansnapshot "github.com/kanisterio/kanister/pkg/kube/snapshot"
"github.com/kanisterio/kanister/pkg/kube/snapshot/apis/v1alpha1"
"github.com/kanisterio/kanister/pkg/kube/snapshot/apis/v1beta1"
pkgerrors "github.com/pkg/errors"
"github.com/kastenhq/kubestr/pkg/common"
"github.com/kastenhq/kubestr/pkg/csi/types"
snapv1 "github.com/kubernetes-csi/external-snapshotter/client/v4/apis/volumesnapshot/v1"
pkgerrors "github.com/pkg/errors"
. "gopkg.in/check.v1"
v1 "k8s.io/api/core/v1"
sv1 "k8s.io/api/storage/v1"
@ -473,7 +473,7 @@ func (s *CSITestSuite) TestCreatePod(c *C) {
}{
{
description: "pod with container image and runAsUser 1000 created",
cli: fake.NewSimpleClientset(),
cli: fake.NewSimpleClientset(),
args: &types.CreatePodArgs{
GenerateName: "name",
PVCName: "pvcname",
@ -487,7 +487,7 @@ func (s *CSITestSuite) TestCreatePod(c *C) {
},
{
description: "Pod creation error on kubeCli",
cli: fake.NewSimpleClientset(),
cli: fake.NewSimpleClientset(),
args: &types.CreatePodArgs{
GenerateName: "name",
PVCName: "pvcname",
@ -500,7 +500,7 @@ func (s *CSITestSuite) TestCreatePod(c *C) {
},
{
description: "Pod generate name arg not set",
cli: fake.NewSimpleClientset(),
cli: fake.NewSimpleClientset(),
args: &types.CreatePodArgs{
GenerateName: "",
PVCName: "pvcname",
@ -512,7 +512,7 @@ func (s *CSITestSuite) TestCreatePod(c *C) {
},
{
description: "PVC name not set error",
cli: fake.NewSimpleClientset(),
cli: fake.NewSimpleClientset(),
args: &types.CreatePodArgs{
GenerateName: "name",
PVCName: "",
@ -524,7 +524,7 @@ func (s *CSITestSuite) TestCreatePod(c *C) {
},
{
description: "default namespace pod is created",
cli: fake.NewSimpleClientset(),
cli: fake.NewSimpleClientset(),
args: &types.CreatePodArgs{
GenerateName: "name",
PVCName: "pvcname",
@ -536,7 +536,7 @@ func (s *CSITestSuite) TestCreatePod(c *C) {
},
{
description: "ns namespace pod is created",
cli: fake.NewSimpleClientset(),
cli: fake.NewSimpleClientset(),
args: &types.CreatePodArgs{
GenerateName: "name",
PVCName: "pvcname",
@ -548,10 +548,10 @@ func (s *CSITestSuite) TestCreatePod(c *C) {
},
{
description: "kubeCli not initialized",
cli: nil,
args: &types.CreatePodArgs{},
errChecker: NotNil,
podChecker: IsNil,
cli: nil,
args: &types.CreatePodArgs{},
errChecker: NotNil,
podChecker: IsNil,
},
} {
fmt.Println("test:", tc.description)
@ -885,13 +885,13 @@ func (f *fakeSnapshotter) Delete(ctx context.Context, name, namespace string) (*
return nil, nil
}
func (f *fakeSnapshotter) DeleteContent(ctx context.Context, name string) error { return nil }
func (f *fakeSnapshotter) Clone(ctx context.Context, name, namespace, cloneName, cloneNamespace string, waitForReady bool) error {
func (f *fakeSnapshotter) Clone(ctx context.Context, name, namespace, cloneName, cloneNamespace string, waitForReady bool, labels map[string]string) error {
return nil
}
func (f *fakeSnapshotter) GetSource(ctx context.Context, snapshotName, namespace string) (*kansnapshot.Source, error) {
return f.gsSrc, f.gsErr
}
func (f *fakeSnapshotter) CreateFromSource(ctx context.Context, source *kansnapshot.Source, snapshotName, namespace string, waitForReady bool) error {
func (f *fakeSnapshotter) CreateFromSource(ctx context.Context, source *kansnapshot.Source, snapshotName, namespace string, waitForReady bool, labels map[string]string) error {
return f.cfsErr
}
func (f *fakeSnapshotter) CreateContentFromSource(ctx context.Context, source *kansnapshot.Source, contentName, snapshotName, namespace, deletionPolicy string) error {
@ -1167,7 +1167,7 @@ func (s *CSITestSuite) TestWaitForPVCReady(c *C) {
boundPVC := s.getPVC(ns, pvc, v1.ClaimBound)
claimLostPVC := s.getPVC(ns, pvc, v1.ClaimLost)
stuckPVC := s.getPVC(ns, pvc, "")
normalGetFunc := func(action k8stesting.Action) (handled bool, ret runtime.Object, err error) {
normalGetFunc := func(action k8stesting.Action) (handled bool, ret runtime.Object, err error) {
return
}
deadlineExceededGetFunc := func(action k8stesting.Action) (handled bool, ret runtime.Object, err error) {
@ -1175,29 +1175,29 @@ func (s *CSITestSuite) TestWaitForPVCReady(c *C) {
}
warningEvent := v1.Event{
Type: v1.EventTypeWarning,
Type: v1.EventTypeWarning,
Message: "waiting for a volume to be created, either by external provisioner \"ceph.com/rbd\" or manually created by system administrator",
}
for _, tc := range []struct {
description string
cli kubernetes.Interface
pvcGetFunc func(action k8stesting.Action) (handled bool, ret runtime.Object, err error)
eventsList []v1.Event
errChecker Checker
errString string
cli kubernetes.Interface
pvcGetFunc func(action k8stesting.Action) (handled bool, ret runtime.Object, err error)
eventsList []v1.Event
errChecker Checker
errString string
}{
{
description: "Happy path",
cli: fake.NewSimpleClientset(boundPVC),
pvcGetFunc: normalGetFunc,
errChecker: IsNil,
cli: fake.NewSimpleClientset(boundPVC),
pvcGetFunc: normalGetFunc,
errChecker: IsNil,
},
{
description: "Missing PVC",
cli: fake.NewSimpleClientset(),
pvcGetFunc: normalGetFunc,
errChecker: NotNil,
errString: "Could not find PVC",
cli: fake.NewSimpleClientset(),
pvcGetFunc: normalGetFunc,
errChecker: NotNil,
errString: "Could not find PVC",
},
{
description: "PVC ClaimLost",
@ -1221,7 +1221,7 @@ func (s *CSITestSuite) TestWaitForPVCReady(c *C) {
errChecker: NotNil,
errString: warningEvent.Message,
},
}{
} {
fmt.Println("test:", tc.description)
creator := &applicationCreate{kubeCli: tc.cli}
creator.kubeCli.(*fake.Clientset).PrependReactor("get", "persistentvolumeclaims", tc.pvcGetFunc)
@ -1239,11 +1239,11 @@ func (s *CSITestSuite) TestWaitForPVCReady(c *C) {
func (s *CSITestSuite) getPVC(ns, pvc string, phase v1.PersistentVolumeClaimPhase) *v1.PersistentVolumeClaim {
return &v1.PersistentVolumeClaim{
ObjectMeta: metav1.ObjectMeta{
Name: pvc,
Name: pvc,
Namespace: ns,
},
Status: v1.PersistentVolumeClaimStatus {
Status: v1.PersistentVolumeClaimStatus{
Phase: phase,
},
}
}
}