Skip to content

Commit

Permalink
unit test for exportserver deadline and fix review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Henriksen <[email protected]>
  • Loading branch information
mhenriks committed Jun 15, 2022
1 parent fa60d07 commit 20273df
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 6 deletions.
1 change: 0 additions & 1 deletion pkg/virt-operator/kubevirt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,6 @@ func exportProxyEnabled(kv *v1.KubeVirt) bool {
return false
}
for _, fg := range kv.Spec.Configuration.DeveloperConfiguration.FeatureGates {
// XXX TODO confirm this
if fg == "VMExport" {
return true
}
Expand Down
1 change: 1 addition & 0 deletions pkg/virt-operator/resource/apply/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ go_library(
"//pkg/certificates/triple:go_default_library",
"//pkg/certificates/triple/cert:go_default_library",
"//pkg/controller:go_default_library",
"//pkg/virt-config:go_default_library",
"//pkg/virt-operator/resource/generate/components:go_default_library",
"//pkg/virt-operator/resource/generate/install:go_default_library",
"//pkg/virt-operator/resource/generate/rbac:go_default_library",
Expand Down
6 changes: 2 additions & 4 deletions pkg/virt-operator/resource/apply/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import (
"kubevirt.io/kubevirt/pkg/certificates/triple"
"kubevirt.io/kubevirt/pkg/certificates/triple/cert"
"kubevirt.io/kubevirt/pkg/controller"
virtconfig "kubevirt.io/kubevirt/pkg/virt-config"
"kubevirt.io/kubevirt/pkg/virt-operator/resource/generate/install"
"kubevirt.io/kubevirt/pkg/virt-operator/util"
)
Expand Down Expand Up @@ -500,7 +501,6 @@ func (r *Reconciler) Sync(queue workqueue.RateLimitingInterface) (bool, error) {
apiDeploymentsRolledOver := haveApiDeploymentsRolledOver(r.targetStrategy, r.kv, r.stores)
controllerDeploymentsRolledOver := haveControllerDeploymentsRolledOver(r.targetStrategy, r.kv, r.stores)

// XXX TODO update with appropriate featuregate
exportProxyEnabled := r.exportProxyEnabled()
exportProxyDeploymentsRolledOver := !exportProxyEnabled || haveExportProxyDeploymentsRolledOver(r.targetStrategy, r.kv, r.stores)

Expand Down Expand Up @@ -673,7 +673,6 @@ func (r *Reconciler) createOrRollBackSystem(apiDeploymentsRolledOver bool) (bool

// create/update ExportProxy Deployments
for _, deployment := range r.targetStrategy.ExportProxyDeployments() {
// XXX TODO use appropriate feature gate
if r.exportProxyEnabled() {
deployment, err := r.syncDeployment(deployment)
if err != nil {
Expand Down Expand Up @@ -1211,8 +1210,7 @@ func (r *Reconciler) exportProxyEnabled() bool {
}

for _, fg := range r.kv.Spec.Configuration.DeveloperConfiguration.FeatureGates {
// XXX TODO use const
if fg == "VMExport" {
if fg == virtconfig.VMExportGate {
return true
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/virt-operator/resource/generate/components/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Copyright 2019 Red Hat, Inc.
* Copyright 2022 Red Hat, Inc.
*
*/
package components
Expand Down
34 changes: 34 additions & 0 deletions tests/storage/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -738,4 +738,38 @@ var _ = SIGDescribe("Export", func() {
return condReady
}, 60*time.Second, 1*time.Second).Should(BeTrue(), "export is expected to become ready")
})

It("should be possibe to observe exportserver pod exiting", func() {
sc, exists := libstorage.GetRWOFileSystemStorageClass()
if !exists {
Skip("Skip test when Filesystem storage is not present")
}
vmExport := createRunningExport(sc, k8sv1.PersistentVolumeFilesystem)
By("looking up the exporter pod")
exporterPod := getExporterPod(vmExport)
Expect(exporterPod).ToNot(BeNil())
By("creating new exporterpod")
newExportPod := exporterPod.DeepCopy()
newExportPod.ObjectMeta = metav1.ObjectMeta{
Name: exporterPod.Name + "-xxx",
Namespace: exporterPod.Namespace,
}
newExportPod.Status = k8sv1.PodStatus{}
deadline := time.Now().Add(10 * time.Second).Format(time.RFC3339)
for i, e := range newExportPod.Spec.Containers[0].Env {
if e.Name == "DEADLINE" {
newExportPod.Spec.Containers[0].Env[i].Value = deadline
break
}
}
newExportPod, err := virtClient.CoreV1().Pods(newExportPod.Namespace).Create(context.TODO(), newExportPod, metav1.CreateOptions{})
Expect(err).ToNot(HaveOccurred())
Eventually(func() bool {
p, err := virtClient.CoreV1().Pods(exporterPod.Namespace).Get(context.TODO(), newExportPod.Name, metav1.GetOptions{})
Expect(err).ToNot(HaveOccurred())
return p.Status.Phase == k8sv1.PodSucceeded
}, 90*time.Second, 1*time.Second).Should(BeTrue())
err = virtClient.CoreV1().Pods(newExportPod.Namespace).Delete(context.Background(), newExportPod.Name, metav1.DeleteOptions{})
Expect(err).ToNot(HaveOccurred())
})
})

0 comments on commit 20273df

Please sign in to comment.