Skip to content

Commit 444c66e

Browse files
authored
fix: fast namespace deletion (part 2) (#2621)
* fix: fast namespace deletion (part 2) Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * fix tests Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> --------- Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
1 parent dfe897e commit 444c66e

30 files changed

+119
-16
lines changed

.crds/chainsaw.kyverno.io_configurations.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,9 @@ spec:
874874
description: FailFast determines whether the test should stop upon
875875
encountering the first failure.
876876
type: boolean
877+
fastNamespaceDeletion:
878+
description: FastNamespaceDeletion skips waiting for namespace deletion.
879+
type: boolean
877880
forceTerminationGracePeriod:
878881
description: ForceTerminationGracePeriod forces the termination grace
879882
period on pods, statefulsets, daemonsets and deployments.
@@ -890,7 +893,7 @@ spec:
890893
description: |-
891894
Namespace defines the namespace to use for tests.
892895
If not specified, every test will execute in a random ephemeral namespace
893-
unless the namespace is overridden in a the test spec.
896+
unless the namespace is overridden in the test spec.
894897
type: string
895898
namespaceTemplate:
896899
description: NamespaceTemplate defines a template to create the test
@@ -1912,6 +1915,9 @@ spec:
19121915
- jp
19131916
- cel
19141917
type: string
1918+
fastDelete:
1919+
description: FastDelete skips waiting for namespace deletion.
1920+
type: boolean
19151921
name:
19161922
description: |-
19171923
Name defines the namespace to use for tests.

.crds/chainsaw.kyverno.io_tests.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,9 @@ spec:
905905
description: FailFast determines whether the test should stop upon
906906
encountering the first failure.
907907
type: boolean
908+
fastNamespaceDeletion:
909+
description: FastNamespaceDeletion skips waiting for namespace deletion.
910+
type: boolean
908911
forceTerminationGracePeriod:
909912
description: ForceTerminationGracePeriod forces the termination grace
910913
period on pods, statefulsets, daemonsets and deployments.

.schemas/json/configuration-chainsaw-v1alpha1.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1729,6 +1729,13 @@
17291729
"null"
17301730
]
17311731
},
1732+
"fastNamespaceDeletion": {
1733+
"description": "FastNamespaceDeletion skips waiting for namespace deletion.",
1734+
"type": [
1735+
"boolean",
1736+
"null"
1737+
]
1738+
},
17321739
"forceTerminationGracePeriod": {
17331740
"description": "ForceTerminationGracePeriod forces the termination grace period on pods, statefulsets, daemonsets and deployments.",
17341741
"type": [
@@ -1751,7 +1758,7 @@
17511758
]
17521759
},
17531760
"namespace": {
1754-
"description": "Namespace defines the namespace to use for tests.\nIf not specified, every test will execute in a random ephemeral namespace\nunless the namespace is overridden in a the test spec.",
1761+
"description": "Namespace defines the namespace to use for tests.\nIf not specified, every test will execute in a random ephemeral namespace\nunless the namespace is overridden in the test spec.",
17551762
"type": [
17561763
"string",
17571764
"null"

.schemas/json/configuration-chainsaw-v1alpha2.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1846,6 +1846,13 @@
18461846
"cel"
18471847
]
18481848
},
1849+
"fastDelete": {
1850+
"description": "FastDelete skips waiting for namespace deletion.",
1851+
"type": [
1852+
"boolean",
1853+
"null"
1854+
]
1855+
},
18491856
"name": {
18501857
"description": "Name defines the namespace to use for tests.\nIf not specified, every test will execute in a random ephemeral namespace\nunless the namespace is overridden in a the test spec.",
18511858
"type": [

.schemas/json/test-chainsaw-v1alpha1.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1786,6 +1786,13 @@
17861786
"null"
17871787
]
17881788
},
1789+
"fastNamespaceDeletion": {
1790+
"description": "FastNamespaceDeletion skips waiting for namespace deletion.",
1791+
"type": [
1792+
"boolean",
1793+
"null"
1794+
]
1795+
},
17891796
"forceTerminationGracePeriod": {
17901797
"description": "ForceTerminationGracePeriod forces the termination grace period on pods, statefulsets, daemonsets and deployments.",
17911798
"type": [

pkg/apis/conversion/configuration.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ func Convert_v1alpha2_ConfigurationSpec_To_v1alpha1_ConfigurationSpec(in *v1alph
2323
out.Namespace = in.Namespace.Name
2424
out.NamespaceTemplate = in.Namespace.Template
2525
out.NamespaceTemplateCompiler = in.Namespace.Compiler
26+
out.FastNamespaceDeletion = in.Namespace.FastDelete
2627
if in := in.Report; in != nil {
2728
out.ReportFormat = v1alpha1.ReportFormatType(in.Format)
2829
out.ReportPath = in.Path
@@ -59,9 +60,10 @@ func Convert_v1alpha1_ConfigurationSpec_To_v1alpha2_ConfigurationSpec(in *v1alph
5960
ForceTerminationGracePeriod: in.ForceTerminationGracePeriod,
6061
}
6162
out.Namespace = v1alpha2.NamespaceOptions{
62-
Name: in.Namespace,
63-
Compiler: in.NamespaceTemplateCompiler,
64-
Template: in.NamespaceTemplate,
63+
Name: in.Namespace,
64+
Compiler: in.NamespaceTemplateCompiler,
65+
Template: in.NamespaceTemplate,
66+
FastDelete: in.FastNamespaceDeletion,
6567
}
6668
out.Report = &v1alpha2.ReportOptions{
6769
Format: v1alpha2.ReportFormatType(in.ReportFormat),

pkg/apis/v1alpha1/configuration.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ type ConfigurationSpec struct {
7575

7676
// Namespace defines the namespace to use for tests.
7777
// If not specified, every test will execute in a random ephemeral namespace
78-
// unless the namespace is overridden in a the test spec.
78+
// unless the namespace is overridden in the test spec.
7979
// +optional
8080
Namespace string `json:"namespace,omitempty"`
8181

@@ -87,6 +87,10 @@ type ConfigurationSpec struct {
8787
// +optional
8888
NamespaceTemplate *Projection `json:"namespaceTemplate,omitempty"`
8989

90+
// FastNamespaceDeletion skips waiting for namespace deletion.
91+
// +optional
92+
FastNamespaceDeletion bool `json:"fastNamespaceDeletion,omitempty"`
93+
9094
// FullName makes use of the full test case folder path instead of the folder name.
9195
// +optional
9296
FullName bool `json:"fullName,omitempty"`

pkg/apis/v1alpha1/test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ type TestSpec struct {
7676
// +optional
7777
NamespaceTemplateCompiler *Compiler `json:"namespaceTemplateCompiler,omitempty"`
7878

79+
// FastNamespaceDeletion skips waiting for namespace deletion.
80+
// +optional
81+
FastNamespaceDeletion *bool `json:"fastNamespaceDeletion,omitempty"`
82+
7983
// Scenarios defines test scenarios.
8084
// +optional
8185
Scenarios []Scenario `json:"scenarios,omitempty"`

pkg/apis/v1alpha1/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/v1alpha2/options.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ type NamespaceOptions struct {
9393
// Template defines a template to create the test namespace.
9494
// +optional
9595
Template *Projection `json:"template,omitempty"`
96+
97+
// FastDelete skips waiting for namespace deletion.
98+
// +optional
99+
FastDelete bool `json:"fastDelete,omitempty"`
96100
}
97101

98102
type ReportFormatType string

0 commit comments

Comments
 (0)