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
12db1f94
Commit
12db1f94
authored
Feb 24, 2017
by
Adam Reese
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(kube): fix wait and recreate
fixes #2006
parent
2806c0d5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
10 deletions
+32
-10
client.go
pkg/kube/client.go
+32
-10
No files found.
pkg/kube/client.go
View file @
12db1f94
...
...
@@ -34,7 +34,6 @@ import (
apps
"k8s.io/kubernetes/pkg/apis/apps/v1beta1"
batchinternal
"k8s.io/kubernetes/pkg/apis/batch"
batch
"k8s.io/kubernetes/pkg/apis/batch/v1"
extensionsinternal
"k8s.io/kubernetes/pkg/apis/extensions"
extensions
"k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
conditions
"k8s.io/kubernetes/pkg/client/unversioned"
...
...
@@ -408,7 +407,15 @@ func updateResource(c *Client, target *resource.Info, currentObj runtime.Object,
return
nil
}
selector
,
err
:=
getSelectorFromObject
(
currentObj
)
versioned
,
err
:=
c
.
AsVersionedObject
(
target
.
Object
)
if
runtime
.
IsNotRegisteredError
(
err
)
{
return
nil
}
if
err
!=
nil
{
return
err
}
selector
,
err
:=
getSelectorFromObject
(
versioned
)
if
err
!=
nil
{
return
nil
}
...
...
@@ -536,6 +543,17 @@ func getPods(client *internalclientset.Clientset, namespace string, selector map
return
list
.
Items
,
err
}
// AsVersionedObject converts a runtime.object to a versioned object.
func
(
c
*
Client
)
AsVersionedObject
(
obj
runtime
.
Object
)
(
runtime
.
Object
,
error
)
{
json
,
err
:=
runtime
.
Encode
(
runtime
.
UnstructuredJSONScheme
,
obj
)
if
err
!=
nil
{
return
nil
,
err
}
versions
:=
&
runtime
.
VersionedObjects
{}
err
=
runtime
.
DecodeInto
(
c
.
Decoder
(
true
),
json
,
versions
)
return
versions
.
First
(),
err
}
// waitForResources polls to get the current status of all pods, PVCs, and Services
// until all are ready or a timeout is reached
func
(
c
*
Client
)
waitForResources
(
timeout
time
.
Duration
,
created
Result
)
error
{
...
...
@@ -546,20 +564,24 @@ func (c *Client) waitForResources(timeout time.Duration, created Result) error {
services
:=
[]
api
.
Service
{}
pvc
:=
[]
api
.
PersistentVolumeClaim
{}
for
_
,
v
:=
range
created
{
switch
value
:=
v
.
Object
.
(
type
)
{
case
(
*
api
.
ReplicationController
)
:
obj
,
err
:=
c
.
AsVersionedObject
(
v
.
Object
)
if
err
!=
nil
&&
!
runtime
.
IsNotRegisteredError
(
err
)
{
return
false
,
err
}
switch
value
:=
obj
.
(
type
)
{
case
(
*
v1
.
ReplicationController
)
:
list
,
err
:=
getPods
(
client
,
value
.
Namespace
,
value
.
Spec
.
Selector
)
if
err
!=
nil
{
return
false
,
err
}
pods
=
append
(
pods
,
list
...
)
case
(
*
api
.
Pod
)
:
case
(
*
v1
.
Pod
)
:
pod
,
err
:=
client
.
Pods
(
value
.
Namespace
)
.
Get
(
value
.
Name
)
if
err
!=
nil
{
return
false
,
err
}
pods
=
append
(
pods
,
*
pod
)
case
(
*
extensions
internal
.
Deployment
)
:
case
(
*
extensions
.
Deployment
)
:
// Get the RS children first
rs
,
err
:=
client
.
ReplicaSets
(
value
.
Namespace
)
.
List
(
api
.
ListOptions
{
FieldSelector
:
fields
.
Everything
(),
...
...
@@ -575,7 +597,7 @@ func (c *Client) waitForResources(timeout time.Duration, created Result) error {
}
pods
=
append
(
pods
,
list
...
)
}
case
(
*
extensions
internal
.
DaemonSet
)
:
case
(
*
extensions
.
DaemonSet
)
:
list
,
err
:=
getPods
(
client
,
value
.
Namespace
,
value
.
Spec
.
Selector
.
MatchLabels
)
if
err
!=
nil
{
return
false
,
err
...
...
@@ -587,19 +609,19 @@ func (c *Client) waitForResources(timeout time.Duration, created Result) error {
return
false
,
err
}
pods
=
append
(
pods
,
list
...
)
case
(
*
extensions
internal
.
ReplicaSet
)
:
case
(
*
extensions
.
ReplicaSet
)
:
list
,
err
:=
getPods
(
client
,
value
.
Namespace
,
value
.
Spec
.
Selector
.
MatchLabels
)
if
err
!=
nil
{
return
false
,
err
}
pods
=
append
(
pods
,
list
...
)
case
(
*
api
.
PersistentVolumeClaim
)
:
case
(
*
v1
.
PersistentVolumeClaim
)
:
claim
,
err
:=
client
.
PersistentVolumeClaims
(
value
.
Namespace
)
.
Get
(
value
.
Name
)
if
err
!=
nil
{
return
false
,
err
}
pvc
=
append
(
pvc
,
*
claim
)
case
(
*
api
.
Service
)
:
case
(
*
v1
.
Service
)
:
svc
,
err
:=
client
.
Services
(
value
.
Namespace
)
.
Get
(
value
.
Name
)
if
err
!=
nil
{
return
false
,
err
...
...
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