-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wait 20 sec before delete disruptioncron + finalizer (#912)
* cleanedAt on disruptioncron * cleanedAt + finalizer * rely on deletiontimestamp * lint * test * fix tu * fix tu --------- Co-authored-by: Philip Thompson <[email protected]>
- Loading branch information
1 parent
6080afb
commit fddb56b
Showing
7 changed files
with
114 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Unless explicitly stated otherwise all files in this repository are licensed | ||
// under the Apache License Version 2.0. | ||
// This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
// Copyright 2024 Datadog, Inc. | ||
|
||
package v1beta1 | ||
|
||
import ( | ||
"time" | ||
|
||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
var _ = Describe("DisruptionCron Types", func() { | ||
var delay = time.Duration(20 * time.Second) | ||
|
||
Describe("IsReadyToRemoveFinalizer", func() { | ||
Describe("true cases", func() { | ||
When("deletedAt is set and we are ready to remove the finalizer", func() { | ||
It("should return true", func() { | ||
// Arrange | ||
readyTime := time.Now().Add(-1 * time.Duration(21*time.Second)) | ||
|
||
disruptionCron := DisruptionCron{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
DeletionTimestamp: &metav1.Time{Time: readyTime}, | ||
}, | ||
} | ||
|
||
// Act | ||
isReady := disruptionCron.IsReadyToRemoveFinalizer(delay) | ||
|
||
// Assert | ||
Expect(isReady).To(BeTrue()) | ||
}) | ||
}) | ||
}) | ||
|
||
Describe("false cases", func() { | ||
DescribeTable("all false cases", func(disruptionCron DisruptionCron) { | ||
// Act | ||
isReady := disruptionCron.IsReadyToRemoveFinalizer(delay) | ||
|
||
// Assert | ||
Expect(isReady).To(BeFalse()) | ||
}, | ||
Entry("no deletion timestamp set", DisruptionCron{}), | ||
Entry("deletion timestamp is < than required", DisruptionCron{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
DeletionTimestamp: &metav1.Time{Time: time.Now()}, | ||
}, | ||
})) | ||
}) | ||
}) | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters