Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
helm3
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
helm3
Commits
5437dd4d
Unverified
Commit
5437dd4d
authored
Oct 04, 2019
by
Taylor Thomas
Committed by
GitHub
Oct 04, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5611 from cgetzen/cg/kube_create_goroutine
Performance: Batch kube API operations
parents
ed8f17a8
6b2f408f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
2 deletions
+24
-2
client.go
pkg/kube/client.go
+24
-2
No files found.
pkg/kube/client.go
View file @
5437dd4d
...
...
@@ -26,6 +26,7 @@ import (
"log"
"sort"
"strings"
"sync"
"time"
"k8s.io/apimachinery/pkg/api/meta"
...
...
@@ -616,14 +617,35 @@ func perform(infos Result, fn ResourceActorFunc) error {
return
ErrNoObjectsVisited
}
for
_
,
info
:=
range
infos
{
if
err
:=
fn
(
info
);
err
!=
nil
{
errs
:=
make
(
chan
error
)
go
batchPerform
(
infos
,
fn
,
errs
)
for
range
infos
{
err
:=
<-
errs
if
err
!=
nil
{
return
err
}
}
return
nil
}
func
batchPerform
(
infos
Result
,
fn
ResourceActorFunc
,
errs
chan
<-
error
)
{
var
kind
string
var
wg
sync
.
WaitGroup
for
_
,
info
:=
range
infos
{
currentKind
:=
info
.
Object
.
GetObjectKind
()
.
GroupVersionKind
()
.
Kind
if
kind
!=
currentKind
{
wg
.
Wait
()
kind
=
currentKind
}
wg
.
Add
(
1
)
go
func
(
i
*
resource
.
Info
)
{
errs
<-
fn
(
i
)
wg
.
Done
()
}(
info
)
}
}
func
createResource
(
info
*
resource
.
Info
)
error
{
obj
,
err
:=
resource
.
NewHelper
(
info
.
Client
,
info
.
Mapping
)
.
Create
(
info
.
Namespace
,
true
,
info
.
Object
,
nil
)
if
err
!=
nil
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment