Skip to content

Commit c4f5f81

Browse files
authored
[E2E] Fix deleteTestResources (#8392)
* [E2E] Fix deleteTestResources
1 parent b60405c commit c4f5f81

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

test/e2e/test/utils.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ func SkipUntilResolution(t *testing.T, knownIssueNumber int) {
189189
t.Skipf("Skip until we understand why it is failing, see https://github.com/elastic/cloud-on-k8s/issues/%d", knownIssueNumber)
190190
}
191191

192-
// This simulates "kubectl delete elastic" in the e2e namespace.
192+
// deleteTestResources simulates "kubectl delete elastic" in the e2e namespace.
193193
func deleteTestResources(ctx context.Context) error {
194194
cfg, err := config.GetConfig()
195195
if err != nil {
@@ -214,8 +214,12 @@ func deleteTestResources(ctx context.Context) error {
214214
}
215215
}
216216

217+
// Dynamic client must be built from the configuration, not by reusing the existing REST client using clntset.RESTClient()
218+
dynamicClient, err := dynamic.NewForConfig(cfg)
219+
if err != nil {
220+
return fmt.Errorf("while creating dynamic client to delete resources: %w", err)
221+
}
217222
for _, namespace := range Ctx().Operator.ManagedNamespaces {
218-
dynamicClient := dynamic.New(clntset.RESTClient())
219223
for gv, resources := range groupVersionToResourceListMap {
220224
gvSlice := strings.Split(gv, "/")
221225
if len(gvSlice) != 2 {

0 commit comments

Comments
 (0)