|
|
@ -84,14 +84,13 @@ func (c *Client) Create(namespace string, reader io.Reader, timeout int64, shoul
|
|
|
|
if buildErr != nil {
|
|
|
|
if buildErr != nil {
|
|
|
|
return buildErr
|
|
|
|
return buildErr
|
|
|
|
}
|
|
|
|
}
|
|
|
|
err = perform(c, namespace, infos, createResource)
|
|
|
|
if err := perform(c, namespace, infos, createResource); err != nil {
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if shouldWait {
|
|
|
|
if shouldWait {
|
|
|
|
err = c.waitForResources(time.Duration(timeout)*time.Second, infos)
|
|
|
|
return c.waitForResources(time.Duration(timeout)*time.Second, infos)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return err
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (c *Client) newBuilder(namespace string, reader io.Reader) *resource.Result {
|
|
|
|
func (c *Client) newBuilder(namespace string, reader io.Reader) *resource.Result {
|
|
|
@ -264,9 +263,9 @@ func (c *Client) Update(namespace string, originalReader, targetReader io.Reader
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if shouldWait {
|
|
|
|
if shouldWait {
|
|
|
|
err = c.waitForResources(time.Duration(timeout)*time.Second, target)
|
|
|
|
return c.waitForResources(time.Duration(timeout)*time.Second, target)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return err
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Delete deletes kubernetes resources from an io.reader
|
|
|
|
// Delete deletes kubernetes resources from an io.reader
|
|
|
@ -338,8 +337,7 @@ func createResource(info *resource.Info) error {
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
info.Refresh(obj, true)
|
|
|
|
return info.Refresh(obj, true)
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func deleteResource(c *Client, info *resource.Info) error {
|
|
|
|
func deleteResource(c *Client, info *resource.Info) error {
|
|
|
@ -398,8 +396,8 @@ func updateResource(c *Client, target *resource.Info, currentObj runtime.Object,
|
|
|
|
|
|
|
|
|
|
|
|
// send patch to server
|
|
|
|
// send patch to server
|
|
|
|
helper := resource.NewHelper(target.Client, target.Mapping)
|
|
|
|
helper := resource.NewHelper(target.Client, target.Mapping)
|
|
|
|
var obj runtime.Object
|
|
|
|
obj, err := helper.Patch(target.Namespace, target.Name, patchType, patch)
|
|
|
|
if obj, err = helper.Patch(target.Namespace, target.Name, patchType, patch); err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -407,8 +405,7 @@ func updateResource(c *Client, target *resource.Info, currentObj runtime.Object,
|
|
|
|
client, _ := c.ClientSet()
|
|
|
|
client, _ := c.ClientSet()
|
|
|
|
return recreatePods(client, target.Namespace, extractSelector(currentObj))
|
|
|
|
return recreatePods(client, target.Namespace, extractSelector(currentObj))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
target.Refresh(obj, true)
|
|
|
|
return target.Refresh(obj, true)
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func extractSelector(obj runtime.Object) map[string]string {
|
|
|
|
func extractSelector(obj runtime.Object) map[string]string {
|
|
|
@ -431,7 +428,6 @@ func recreatePods(client *internalclientset.Clientset, namespace string, selecto
|
|
|
|
FieldSelector: fields.Everything(),
|
|
|
|
FieldSelector: fields.Everything(),
|
|
|
|
LabelSelector: labels.Set(selector).AsSelector(),
|
|
|
|
LabelSelector: labels.Set(selector).AsSelector(),
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -445,7 +441,6 @@ func recreatePods(client *internalclientset.Clientset, namespace string, selecto
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -491,9 +486,6 @@ func watchUntilReady(timeout time.Duration, info *resource.Info) error {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func podsReady(pods []api.Pod) bool {
|
|
|
|
func podsReady(pods []api.Pod) bool {
|
|
|
|
if len(pods) == 0 {
|
|
|
|
|
|
|
|
return true
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, pod := range pods {
|
|
|
|
for _, pod := range pods {
|
|
|
|
if !api.IsPodReady(&pod) {
|
|
|
|
if !api.IsPodReady(&pod) {
|
|
|
|
return false
|
|
|
|
return false
|
|
|
@ -503,9 +495,6 @@ func podsReady(pods []api.Pod) bool {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func servicesReady(svc []api.Service) bool {
|
|
|
|
func servicesReady(svc []api.Service) bool {
|
|
|
|
if len(svc) == 0 {
|
|
|
|
|
|
|
|
return true
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, s := range svc {
|
|
|
|
for _, s := range svc {
|
|
|
|
if !api.IsServiceIPSet(&s) {
|
|
|
|
if !api.IsServiceIPSet(&s) {
|
|
|
|
return false
|
|
|
|
return false
|
|
|
@ -519,9 +508,6 @@ func servicesReady(svc []api.Service) bool {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func volumesReady(vols []api.PersistentVolumeClaim) bool {
|
|
|
|
func volumesReady(vols []api.PersistentVolumeClaim) bool {
|
|
|
|
if len(vols) == 0 {
|
|
|
|
|
|
|
|
return true
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, v := range vols {
|
|
|
|
for _, v := range vols {
|
|
|
|
if v.Status.Phase != api.ClaimBound {
|
|
|
|
if v.Status.Phase != api.ClaimBound {
|
|
|
|
return false
|
|
|
|
return false
|
|
|
@ -535,10 +521,7 @@ func getPods(client *internalclientset.Clientset, namespace string, selector map
|
|
|
|
FieldSelector: fields.Everything(),
|
|
|
|
FieldSelector: fields.Everything(),
|
|
|
|
LabelSelector: labels.Set(selector).AsSelector(),
|
|
|
|
LabelSelector: labels.Set(selector).AsSelector(),
|
|
|
|
})
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
return list.Items, err
|
|
|
|
return nil, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return list.Items, nil
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// waitForResources polls to get the current status of all pods, PVCs, and Services
|
|
|
|
// waitForResources polls to get the current status of all pods, PVCs, and Services
|
|
|
|