Merge pull request #690 from humblec/rbac

replace serviceAccountName key, rbac and cleanup in the code
This commit is contained in:
Kubernetes Prow Robot
2022-04-25 07:39:39 -07:00
committed by GitHub
19 changed files with 69 additions and 67 deletions

View File

@@ -112,14 +112,18 @@ type controllerTest struct {
type testCall func(ctrl *csiSnapshotCommonController, reactor *snapshotReactor, test controllerTest) error
const testNamespace = "default"
const mockDriverName = "csi-mock-plugin"
const (
testNamespace = "default"
mockDriverName = "csi-mock-plugin"
)
var errVersionConflict = errors.New("VersionError")
var nocontents []*crdv1.VolumeSnapshotContent
var nosnapshots []*crdv1.VolumeSnapshot
var noevents = []string{}
var noerrors = []reactorError{}
var (
errVersionConflict = errors.New("VersionError")
nocontents []*crdv1.VolumeSnapshotContent
nosnapshots []*crdv1.VolumeSnapshot
noevents = []string{}
noerrors = []reactorError{}
)
// snapshotReactor is a core.Reactor that simulates etcd and API server. It
// stores:
@@ -921,6 +925,7 @@ func withSnapshotContentInvalidLabel(contents []*crdv1.VolumeSnapshotContent) []
}
return contents
}
func withContentAnnotations(contents []*crdv1.VolumeSnapshotContent, annotations map[string]string) []*crdv1.VolumeSnapshotContent {
for i := range contents {
if contents[i].ObjectMeta.Annotations == nil {
@@ -1200,7 +1205,6 @@ func testSyncSnapshot(ctrl *csiSnapshotCommonController, reactor *snapshotReacto
func testSyncSnapshotError(ctrl *csiSnapshotCommonController, reactor *snapshotReactor, test controllerTest) error {
err := ctrl.syncSnapshot(test.initialSnapshots[0])
if err != nil {
return nil
}
@@ -1303,7 +1307,6 @@ var (
// controller waits for the operation lock. Controller is then resumed and we
// check how it behaves.
func wrapTestWithInjectedOperation(toWrap testCall, injectBeforeOperation func(ctrl *csiSnapshotCommonController, reactor *snapshotReactor)) testCall {
return func(ctrl *csiSnapshotCommonController, reactor *snapshotReactor, test controllerTest) error {
// Inject a hook before async operation starts
klog.V(4).Infof("reactor:injecting call")

View File

@@ -77,8 +77,10 @@ import (
// bi-directional binding is complete and readyToUse becomes true. Error field
// in the snapshot status will be updated accordingly when failure occurs.
const snapshotKind = "VolumeSnapshot"
const snapshotAPIGroup = crdv1.GroupName
const (
snapshotKind = "VolumeSnapshot"
snapshotAPIGroup = crdv1.GroupName
)
const controllerUpdateFailMsg = "snapshot controller failed to update"
@@ -829,7 +831,6 @@ func (ctrl *csiSnapshotCommonController) updateSnapshotErrorStatusWithEvent(snap
// addContentFinalizer adds a Finalizer for VolumeSnapshotContent.
func (ctrl *csiSnapshotCommonController) addContentFinalizer(content *crdv1.VolumeSnapshotContent) error {
var patches []utils.PatchOp
if len(content.Finalizers) > 0 {
// Add to the end of the finalizers if we have any other finalizers
@@ -838,7 +839,6 @@ func (ctrl *csiSnapshotCommonController) addContentFinalizer(content *crdv1.Volu
Path: "/metadata/finalizers/-",
Value: utils.VolumeSnapshotContentFinalizer,
})
} else {
// Replace finalizers with new array if there are no other finalizers
patches = append(patches, utils.PatchOp{

View File

@@ -111,7 +111,6 @@ func TestControllerCacheParsingError(t *testing.T) {
}
func TestGetManagedByNode(t *testing.T) {
// Test that a matching node is found
node1 := &v1.Node{

View File

@@ -26,18 +26,22 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
var timeNow = time.Now()
var timeNowStamp = timeNow.UnixNano()
var False = false
var True = true
var (
timeNow = time.Now()
timeNowStamp = timeNow.UnixNano()
False = false
True = true
)
var metaTimeNowUnix = &metav1.Time{
Time: timeNow,
}
var defaultSize int64 = 1000
var deletePolicy = crdv1.VolumeSnapshotContentDelete
var retainPolicy = crdv1.VolumeSnapshotContentRetain
var (
defaultSize int64 = 1000
deletePolicy = crdv1.VolumeSnapshotContentDelete
retainPolicy = crdv1.VolumeSnapshotContentRetain
)
// Test single call to SyncSnapshot, expecting create snapshot to happen.
// 1. Fill in the controller with initial data

View File

@@ -40,8 +40,8 @@ var class3Parameters = map[string]string{
}
var class4Parameters = map[string]string{
//utils.SnapshotterSecretNameKey: "emptysecret",
//utils.SnapshotterSecretNamespaceKey: "default",
// utils.SnapshotterSecretNameKey: "emptysecret",
// utils.SnapshotterSecretNamespaceKey: "default",
}
var class5Parameters = map[string]string{
@@ -51,8 +51,10 @@ var class5Parameters = map[string]string{
var timeNowMetav1 = metav1.Now()
var content31 = "content3-1"
var claim31 = "claim3-1"
var (
content31 = "content3-1"
claim31 = "claim3-1"
)
var snapshotClasses = []*crdv1.VolumeSnapshotClass{
{

View File

@@ -26,7 +26,6 @@ import (
// Test single call to ensurePVCFinalizer, checkandRemovePVCFinalizer, addSnapshotFinalizer, removeSnapshotFinalizer
// expecting finalizers to be added or removed
func TestSnapshotFinalizer(t *testing.T) {
tests := []controllerTest{
{
name: "1-1 - successful add PVC finalizer",