Skip to content

Commit 99bd94c

Browse files
committed
Remove concurrency
1 parent cec8446 commit 99bd94c

File tree

3 files changed

+84
-2
lines changed

3 files changed

+84
-2
lines changed

pkg/debug_package/shared/gen.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
"github.com/arangodb/kube-arangodb/pkg/debug_package/cli"
3131
"github.com/arangodb/kube-arangodb/pkg/util"
3232
"github.com/arangodb/kube-arangodb/pkg/util/errors"
33+
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
3334
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/kerrors"
3435
"github.com/arangodb/kube-arangodb/pkg/util/kclient"
3536
"github.com/arangodb/kube-arangodb/pkg/util/shutdown"
@@ -67,7 +68,11 @@ func WithKubernetesItems[T meta.Object](extract Extract[T], iterators ...Iterate
6768
})
6869

6970
for _, item := range items {
70-
if err := WithItem[T](shutdown.Context(), logger, k, files, item, iterators...); err != nil {
71+
cp, ok := k8sutil.Copy(item)
72+
if !ok {
73+
return errors.Errorf("Unable to copy item")
74+
}
75+
if err := WithItem[T](shutdown.Context(), logger, k, files, cp, iterators...); err != nil {
7176
return err
7277
}
7378
}
@@ -80,7 +85,11 @@ func WithItem[T meta.Object](ctx context.Context, logger zerolog.Logger, client
8085
files, c := WithPrefix(files, "/%s/", item.GetName())
8186
defer c()
8287
for _, iter := range iterators {
83-
if err := iter(ctx, logger, client, files, item); err != nil {
88+
cp, ok := k8sutil.Copy(item)
89+
if !ok {
90+
return errors.Errorf("Unable to copy item")
91+
}
92+
if err := iter(ctx, logger, client, files, cp); err != nil {
8493
return err
8594
}
8695
}

pkg/util/k8sutil/object.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//
2+
// DISCLAIMER
3+
//
4+
// Copyright 2025 ArangoDB GmbH, Cologne, Germany
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
// Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
//
20+
21+
package k8sutil
22+
23+
import (
24+
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
25+
26+
"github.com/arangodb/kube-arangodb/pkg/util"
27+
)
28+
29+
func Copy[T meta.Object](obj T) (T, bool) {
30+
type Q interface {
31+
DeepCopy() T
32+
}
33+
34+
if q, ok := any(obj).(Q); ok {
35+
println("OK")
36+
return q.DeepCopy(), true
37+
}
38+
39+
return util.Default[T](), false
40+
}

pkg/util/k8sutil/object_test.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//
2+
// DISCLAIMER
3+
//
4+
// Copyright 2025 ArangoDB GmbH, Cologne, Germany
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
// Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
//
20+
21+
package k8sutil
22+
23+
import (
24+
"testing"
25+
26+
"github.com/stretchr/testify/require"
27+
core "k8s.io/api/core/v1"
28+
)
29+
30+
func Test_Copy(t *testing.T) {
31+
_, ok := Copy(&core.Pod{})
32+
require.True(t, ok)
33+
}

0 commit comments

Comments
 (0)