Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle metricscollector case worker container have no command #914

Merged
merged 2 commits into from
Nov 8, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
172 changes: 158 additions & 14 deletions Gopkg.lock

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

37 changes: 23 additions & 14 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ required = [
name = "github.com/golang/mock"
version = "1.1.1"

[[override]]
name = "github.com/google/go-containerregistry"
# HEAD as of 2019-03-20
revision = "8d4083db9aa0d2fae6588c1acdbe6a1f5db461e3"

[[constraint]]
name = "github.com/golang/protobuf"
version = "1.2.0"
Expand All @@ -48,28 +53,32 @@ required = [
version = "1.3.0"

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

[[override]]
name = "k8s.io/api"
version = "kubernetes-1.12.3"
version = "kubernetes-1.12.9"

[[constraint]]
[[override]]
name = "k8s.io/apimachinery"
version = "kubernetes-1.12.3"

[[constraint]]
name = "k8s.io/client-go"
version = "kubernetes-1.12.3"
version = "kubernetes-1.12.9"

[[constraint]]
[[override]]
name = "k8s.io/code-generator"
version = "kubernetes-1.12.3"
version = "kubernetes-1.12.9"

[[constraint]]
name = "sigs.k8s.io/controller-runtime"
version = "0.1.9"
[[override]]
name = "k8s.io/client-go"
version = "kubernetes-1.12.9"

[[override]]
name = "k8s.io/apiextensions-apiserver"
version = "kubernetes-1.12.9"

[[override]]
name="k8s.io/apiextensions-apiserver"
version="kubernetes-1.12.3"
name = "k8s.io/kubernetes"
version = "v1.13.3"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if we can upgrade now. /cc @johnugeorge

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried, it works well.


[[override]]
name = "gopkg.in/fsnotify.v1"
Expand Down
1 change: 1 addition & 0 deletions cmd/katib-controller/v1alpha3/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ RUN if [ "$(uname -m)" = "ppc64le" ]; then \
# Copy the controller-manager into a thin image
FROM alpine:3.7
WORKDIR /app
RUN apk update && apk add ca-certificates
COPY --from=build-env /go/src/github.com/kubeflow/katib/cmd/katib-controller/katib-controller .
ENTRYPOINT ["./katib-controller"]
16 changes: 6 additions & 10 deletions pkg/webhook/v1alpha3/pod/inject_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func (s *sidecarInjector) Mutate(pod *v1.Pod, namespace string) (*v1.Pod, error)
}
}
if needWrapWorkerContainer(trial.Spec.MetricsCollector) {
if err = wrapWorkerContainer(mutatedPod, kind, mountPath, pathKind, trial.Spec.MetricsCollector); err != nil {
if err = wrapWorkerContainer(mutatedPod, namespace, kind, mountPath, pathKind, trial.Spec.MetricsCollector); err != nil {
return nil, err
}
}
Expand Down Expand Up @@ -223,7 +223,7 @@ func needWrapWorkerContainer(mc common.MetricsCollectorSpec) bool {
}

func wrapWorkerContainer(
pod *v1.Pod, jobKind, metricsFile string,
pod *v1.Pod, namespace, jobKind, metricsFile string,
pathKind common.FileSystemKind,
mc common.MetricsCollectorSpec) error {
index := -1
Expand All @@ -238,22 +238,18 @@ func wrapWorkerContainer(
}
}
if index >= 0 {
// TODO(hougangliu): handle container.command is nil case
c := &pod.Spec.Containers[index]
command := []string{"sh", "-c"}
args := []string{}
if c.Command != nil {
args = append(args, c.Command...)
}
if c.Args != nil {
args = append(args, c.Args...)
args, err := getImageCommand(pod, namespace, index)
if err != nil {
return err
}
if mc.Collector.Kind == common.StdOutCollector {
redirectStr := fmt.Sprintf("1>%s 2>&1", metricsFile)
args = append(args, redirectStr)
}
args = append(args, "&&", getMarkCompletedCommand(metricsFile, pathKind))
argsStr := strings.Join(args, " ")
c := &pod.Spec.Containers[index]
c.Command = command
c.Args = []string{argsStr}
}
Expand Down
Loading