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
4d939ec9
Commit
4d939ec9
authored
Apr 12, 2017
by
Adam Reese
Committed by
GitHub
Apr 12, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2260 from adamreese/fix/wait-apps
fix(helm): correct import for apps api
parents
0ab38a99
7a141a10
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
10 deletions
+11
-10
wait.go
pkg/kube/wait.go
+11
-10
No files found.
pkg/kube/wait.go
View file @
4d939ec9
...
...
@@ -25,33 +25,34 @@ import (
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/pkg/apis/apps"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
apps
"k8s.io/kubernetes/pkg/apis/apps/v1beta1"
extensions
"k8s.io/kubernetes/pkg/apis/extensions/v1beta1"
"k8s.io/kubernetes/pkg/client/clientset_generated/clientset"
core
"k8s.io/kubernetes/pkg/client/clientset_generated/clientset/typed/core/v1"
extensions
"k8s.io/kubernetes/pkg/client/clientset_generated/clientset/typed/extensions/v1beta1"
extensions
client
"k8s.io/kubernetes/pkg/client/clientset_generated/clientset/typed/extensions/v1beta1"
internalclientset
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
deploymentutil
"k8s.io/kubernetes/pkg/controller/deployment/util"
)
// deployment holds associated replicaSets for a deployment
type
deployment
struct
{
replicaSets
*
v1beta1
.
ReplicaSet
deployment
*
v1beta1
.
Deployment
replicaSets
*
extensions
.
ReplicaSet
deployment
*
extensions
.
Deployment
}
// 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
{
log
.
Printf
(
"beginning wait for resources with timeout of %v"
,
timeout
)
cs
,
_
:=
c
.
ClientSet
()
client
:=
versionedClientsetForDeployment
(
cs
)
return
wait
.
Poll
(
2
*
time
.
Second
,
timeout
,
func
()
(
bool
,
error
)
{
pods
:=
[]
v1
.
Pod
{}
services
:=
[]
v1
.
Service
{}
pvc
:=
[]
v1
.
PersistentVolumeClaim
{}
replicaSets
:=
[]
*
v1beta1
.
ReplicaSet
{}
replicaSets
:=
[]
*
extensions
.
ReplicaSet
{}
deployments
:=
[]
deployment
{}
for
_
,
v
:=
range
created
{
obj
,
err
:=
c
.
AsVersionedObject
(
v
.
Object
)
...
...
@@ -71,7 +72,7 @@ func (c *Client) waitForResources(timeout time.Duration, created Result) error {
return
false
,
err
}
pods
=
append
(
pods
,
*
pod
)
case
(
*
v1beta1
.
Deployment
)
:
case
(
*
extensions
.
Deployment
)
:
// Get the RS children first
rs
,
err
:=
client
.
Extensions
()
.
ReplicaSets
(
value
.
Namespace
)
.
List
(
metav1
.
ListOptions
{
FieldSelector
:
fields
.
Everything
()
.
String
(),
...
...
@@ -99,7 +100,7 @@ func (c *Client) waitForResources(timeout time.Duration, created Result) error {
currentDeployment
,
}
deployments
=
append
(
deployments
,
newDeployment
)
case
(
*
v1beta1
.
DaemonSet
)
:
case
(
*
extensions
.
DaemonSet
)
:
list
,
err
:=
getPods
(
client
,
value
.
Namespace
,
value
.
Spec
.
Selector
.
MatchLabels
)
if
err
!=
nil
{
return
false
,
err
...
...
@@ -111,7 +112,7 @@ func (c *Client) waitForResources(timeout time.Duration, created Result) error {
return
false
,
err
}
pods
=
append
(
pods
,
list
...
)
case
(
*
v1beta1
.
ReplicaSet
)
:
case
(
*
extensions
.
ReplicaSet
)
:
list
,
err
:=
getPods
(
client
,
value
.
Namespace
,
value
.
Spec
.
Selector
.
MatchLabels
)
if
err
!=
nil
{
return
false
,
err
...
...
@@ -190,6 +191,6 @@ func versionedClientsetForDeployment(internalClient internalclientset.Interface)
}
return
&
clientset
.
Clientset
{
CoreV1Client
:
core
.
New
(
internalClient
.
Core
()
.
RESTClient
()),
ExtensionsV1beta1Client
:
extensions
.
New
(
internalClient
.
Extensions
()
.
RESTClient
()),
ExtensionsV1beta1Client
:
extensions
client
.
New
(
internalClient
.
Extensions
()
.
RESTClient
()),
}
}
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