Skip to content

Commit

Permalink
Downgrade kubernetes dependency to 1.10.1 (#256)
Browse files Browse the repository at this point in the history
* downgrade to 1.10.1

* Delete pods

* Fix job-name

* Set successfulJobsHistoryLimit to 0

* Add comments
  • Loading branch information
richardsliu authored and k8s-ci-robot committed Nov 28, 2018
1 parent b7145b3 commit 24160cb
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 98 deletions.
112 changes: 24 additions & 88 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,19 @@ required = [

[[constraint]]
name = "k8s.io/api"
version = "kubernetes-1.11.2"
version = "kubernetes-1.10.1"

[[constraint]]
name = "k8s.io/apimachinery"
version = "kubernetes-1.11.2"
version = "kubernetes-1.10.1"

[[constraint]]
name = "k8s.io/client-go"
version = "kubernetes-1.11.2"
version = "kubernetes-1.10.1"

[[constraint]]
name = "sigs.k8s.io/controller-runtime"
version = "0.1.3"
version = "0.1.1"

[[override]]
name="k8s.io/apiextensions-apiserver"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ data:
namespace: kubeflow
spec:
schedule: "*/1 * * * *"
successfulJobsHistoryLimit: 1
successfulJobsHistoryLimit: 0
failedJobsHistoryLimit: 1
jobTemplate:
spec:
Expand Down
61 changes: 61 additions & 0 deletions pkg/controller/studyjob/pod_control.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package studyjob

import (
"log"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clientset "k8s.io/client-go/kubernetes"
restclient "k8s.io/client-go/rest"
)

type PodControl struct {
kubeClient clientset.Interface
}

func NewPodControl() (*PodControl, error) {
config, err := restclient.InClusterConfig()
if err != nil {
return nil, err
}
kc, err := clientset.NewForConfig(config)
if err != nil {
return nil, err
}
return &PodControl{
kubeClient: kc,
}, nil
}

func (c PodControl) DeletePodsForWorker(namespace string, wid string) error {
selector, err := metav1.LabelSelectorAsSelector(&metav1.LabelSelector{
MatchLabels: map[string]string{"job-name":wid},
})
if err != nil {
return err
}
log.Printf("Deleting pods with selector %v", selector.String())
listOptions := metav1.ListOptions{
LabelSelector: selector.String(),
}
err = c.kubeClient.CoreV1().Pods(namespace).DeleteCollection(&metav1.DeleteOptions{}, listOptions)
if err != nil {
return err
}
log.Printf("Deleted pods with selector %v.", selector.String())
return nil
}
Loading

0 comments on commit 24160cb

Please sign in to comment.