Skip to content

Commit

Permalink
Single Queue and Expectations (kubevirt#249)
Browse files Browse the repository at this point in the history
* Pull in expectations code from kubevirt

Signed-off-by: David Vossel <davidvossel@gmail.com>

* add expectations to datavolume controller

Signed-off-by: David Vossel <davidvossel@gmail.com>

* Refactor importer pod to use single queue and expectations

Signed-off-by: David Vossel <davidvossel@gmail.com>

* update utils tests to use single queue

Signed-off-by: David Vossel <davidvossel@gmail.com>

* re-introduce import controller test suite

Signed-off-by: David Vossel <davidvossel@gmail.com>

* make clone controllers pass after utils refactor

Signed-off-by: David Vossel <davidvossel@gmail.com>

* Use log level constants in cdi controllers

Signed-off-by: David Vossel <davidvossel@gmail.com>

* Remove useless shadow variables in expectations pkg

Signed-off-by: David Vossel <davidvossel@gmail.com>

* required changes to get owner references working with openshift 1.10

Signed-off-by: David Vossel <davidvossel@gmail.com>

* update functional tests to work with importer controller refactor

Signed-off-by: David Vossel <davidvossel@gmail.com>

* Rename AnnImportPVC to LabelImportPvc in order to reflect its use

Signed-off-by: David Vossel <davidvossel@gmail.com>

* Add comment about expectations code

Signed-off-by: David Vossel <davidvossel@gmail.com>
  • Loading branch information
davidvossel authored and copejon committed Jul 30, 2018
1 parent eb2190e commit fdb1b27
Show file tree
Hide file tree
Showing 41 changed files with 2,803 additions and 1,036 deletions.
4 changes: 2 additions & 2 deletions cmd/cdi-controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ func main() {
dataVolumeInformer)

importController := controller.NewImportController(client,
pvcInformer.Informer(),
podInformer.Informer(),
pvcInformer,
podInformer,
importerImage,
pullPolicy,
verbose)
Expand Down
11 changes: 8 additions & 3 deletions glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions manifests/controller/cdi-controller-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,19 @@ rules:
resources: ["events"]
verbs: ["create", "update", "patch"]
- apiGroups: [""]
resources: ["persistentvolumeclaims"]
resources: ["persistentvolumeclaims", "persistentvolumeclaims/finalizers"]
verbs: ["get", "list", "watch", "create", "update", "patch"]
- apiGroups: [""]
resources: ["pods"]
resources: ["pods", "pods/finalizers"]
verbs: ["get", "list", "watch", "create"]
- apiGroups: [""]
resources: ["secrets"]
verbs: ["get", "list", "watch", "create"]
- apiGroups: ["cdi.kubevirt.io"]
resources: ["datavolumes"]
verbs: ["get", "list", "watch", "update"]
resources:
- '*'
verbs:
- '*'
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
Expand Down
18 changes: 9 additions & 9 deletions pkg/controller/clone-controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func TestNewCloneController(t *testing.T) {
func TestCloneController_ProcessNextPodItem(t *testing.T) {
//create pod and pvc
pvcWithEndPointAnno := createPvc("testPvcWithEndPointAnno", "default", map[string]string{AnnEndpoint: "http://test"}, nil)
podWithCdiAnno := createPod(pvcWithEndPointAnno, DataVolName)
podWithCdiAnno := createPodWithName(pvcWithEndPointAnno, DataVolName)

//create and run the informers
c, _, _, err := createCloneController(pvcWithEndPointAnno, podWithCdiAnno, "default")
Expand Down Expand Up @@ -116,9 +116,9 @@ func TestCloneController_processPodItem(t *testing.T) {

// create pod specs with pvc reference
stagePods := make([]*v1.Pod, stageCount)
stagePods[0] = createPod(stagePvcs[0], ImagePathName)
stagePods[1] = createPod(stagePvcs[1], "myvolume")
stagePods[2] = createPod(stagePvcs[2], ImagePathName)
stagePods[0] = createPodWithName(stagePvcs[0], ImagePathName)
stagePods[1] = createPodWithName(stagePvcs[1], "myvolume")
stagePods[2] = createPodWithName(stagePvcs[2], ImagePathName)

//create and run the informers passing back v1 processed pods
c, _, pods, err := createCloneControllerMultiObject(stagePvcs, stagePods, stageNs)
Expand Down Expand Up @@ -181,10 +181,10 @@ func TestCloneController_ProcessNextPvcItem(t *testing.T) {

// create pod specs with pvc reference
stagePods := make([]*v1.Pod, stageCount)
stagePods[0] = createPod(stagePvcs[0], DataVolName)
stagePods[1] = createPod(stagePvcs[1], DataVolName)
stagePods[2] = createPod(stagePvcs[2], DataVolName)
stagePods[3] = createPod(stagePvcs[3], DataVolName)
stagePods[0] = createPodWithName(stagePvcs[0], DataVolName)
stagePods[1] = createPodWithName(stagePvcs[1], DataVolName)
stagePods[2] = createPodWithName(stagePvcs[2], DataVolName)
stagePods[3] = createPodWithName(stagePvcs[3], DataVolName)

//create and run queues and informers
c, _, _, err := createCloneControllerMultiObject(stagePvcs, stagePods, stageNs)
Expand Down Expand Up @@ -308,7 +308,7 @@ func TestCloneController_processPvcItem(t *testing.T) {
func TestCloneController_forgetKey(t *testing.T) {
//create staging pvc and pod
pvcWithEndPointAnno := createPvc("testPvcWithEndPointAnno", "default", map[string]string{AnnEndpoint: "http://test"}, nil)
podWithCdiAnno := createPod(pvcWithEndPointAnno, DataVolName)
podWithCdiAnno := createPodWithName(pvcWithEndPointAnno, DataVolName)

//run the informers
c, _, _, err := createCloneController(pvcWithEndPointAnno, podWithCdiAnno, "default")
Expand Down
Loading

0 comments on commit fdb1b27

Please sign in to comment.