Skip to content

Commit

Permalink
As snr no longer deals with VAs remove VA logic from test
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Shitrit <mshitrit@redhat.com>
  • Loading branch information
mshitrit committed Jan 18, 2024
1 parent f9938ae commit d46a054
Showing 1 changed file with 0 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
. "github.com/onsi/gomega"

v1 "k8s.io/api/core/v1"
storagev1 "k8s.io/api/storage/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -35,7 +34,6 @@ const (
var _ = Describe("SNR Controller", func() {
var snr *v1alpha1.SelfNodeRemediation
var remediationStrategy v1alpha1.RemediationStrategyType
var vaName = "some-va"
var nodeRebootCapable = "true"
var isAdditionalSetupNeeded = false

Expand All @@ -49,9 +47,6 @@ var _ = Describe("SNR Controller", func() {

JustBeforeEach(func() {
if isAdditionalSetupNeeded {
createVolumeAttachment(vaName)
verifyVaNotDeleted(vaName)

createSelfNodeRemediationPod()
verifySelfNodeRemediationPodExist()
}
Expand All @@ -66,7 +61,6 @@ var _ = Describe("SNR Controller", func() {
isAdditionalSetupNeeded = false
deleteRemediations()
deleteSelfNodeRemediationPod()
deleteVolumeAttachment(vaName, false)
//clear node's state, this is important to remove taints, label etc.
Expect(k8sClient.Update(context.Background(), getNode(shared.UnhealthyNodeName)))
Expect(k8sClient.Update(context.Background(), getNode(shared.PeerNodeName)))
Expand Down Expand Up @@ -235,8 +229,6 @@ var _ = Describe("SNR Controller", func() {

verifyNoWatchdogFood()

verifyVaNotDeleted(vaName)

// The kube-api calls for VA fail intentionally. In this case, we expect the snr agent to try
// to delete node resources again. So LastError is set to the error every time Reconcile()
// is triggered. If it becomes another error, it means something unintended happens.
Expand All @@ -246,8 +238,6 @@ var _ = Describe("SNR Controller", func() {

verifySelfNodeRemediationPodDoesntExist()

deleteVolumeAttachment(vaName, true)

deleteSNR(snr)

removeUnschedulableTaint()
Expand Down Expand Up @@ -322,8 +312,6 @@ var _ = Describe("SNR Controller", func() {
// simulate the out-of-service taint by Pod GC Controller
deleteTerminatingPod()

deleteVolumeAttachment(vaName, true)

verifyOutOfServiceTaintRemoved()

verifyEvent("Normal", "RemoveOutOfService", "Remediation process - remove out-of-service taint from node")
Expand Down Expand Up @@ -456,23 +444,6 @@ var _ = Describe("SNR Controller", func() {
})
})

func createVolumeAttachment(vaName string) {
va := &storagev1.VolumeAttachment{
ObjectMeta: metav1.ObjectMeta{
Name: vaName,
Namespace: shared.Namespace,
},
Spec: storagev1.VolumeAttachmentSpec{
Attacher: "foo",
Source: storagev1.VolumeAttachmentSource{},
NodeName: shared.UnhealthyNodeName,
},
}
foo := "foo"
va.Spec.Source.PersistentVolumeName = &foo
ExpectWithOffset(1, k8sClient.Create(context.Background(), va)).To(Succeed())
}

func verifyTypeConditions(nodeName string, expectedProcessingConditionStatus, expectedSucceededConditionStatus metav1.ConditionStatus, expectedReason string) {
By("Verify that SNR Processing status condition is correct")
snr := &v1alpha1.SelfNodeRemediation{}
Expand All @@ -491,35 +462,6 @@ func verifyTypeConditions(nodeName string, expectedProcessingConditionStatus, ex
}, 5*time.Second, 250*time.Millisecond).Should(BeTrue())
}

func deleteVolumeAttachment(vaName string, verifyExist bool) {
va := &storagev1.VolumeAttachment{
ObjectMeta: metav1.ObjectMeta{
Name: vaName,
Namespace: shared.Namespace,
},
}

err := k8sClient.Delete(context.Background(), va)
if !verifyExist && apierrors.IsNotFound(err) {
return
}
ExpectWithOffset(1, err).To(Succeed())
}

func verifyVaNotDeleted(vaName string) {
vaKey := client.ObjectKey{
Namespace: shared.Namespace,
Name: vaName,
}

ConsistentlyWithOffset(1, func() bool {
va := &storagev1.VolumeAttachment{}
err := k8sClient.Get(context.Background(), vaKey, va)
return apierrors.IsNotFound(err)

}, 5*time.Second, 250*time.Millisecond).Should(BeFalse())
}

func verifyLastErrorKeepsApiError() {
By("Verify that LastError in SNR status has been kept")
snr := &v1alpha1.SelfNodeRemediation{}
Expand Down

0 comments on commit d46a054

Please sign in to comment.