Skip to content

Commit

Permalink
issue-11296 - WIP
Browse files Browse the repository at this point in the history
Signed-off-by: Helber Belmiro <helber.belmiro@gmail.com>
  • Loading branch information
hbelmiro committed Dec 16, 2024
1 parent cb07619 commit bbb83ad
Show file tree
Hide file tree
Showing 16 changed files with 2,107 additions and 1,185 deletions.
2 changes: 1 addition & 1 deletion backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ ARG COMMIT_SHA=unknown
ENV COMMIT_SHA=${COMMIT_SHA}
ARG TAG_NAME=unknown
ENV TAG_NAME=${TAG_NAME}
ENV LOG_LEVEL info
ENV LOG_LEVEL info

WORKDIR /bin

Expand Down
99 changes: 99 additions & 0 deletions backend/Dockerfile.debug
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Copyright 2021-2022 The Kubeflow Authors
#
# 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.

# 1. Build api server application
FROM golang:1.21.7 as builder
RUN apt-get update && apt-get install -y cmake clang musl-dev openssl
WORKDIR /go/src/github.com/kubeflow/pipelines

RUN GO111MODULE=on GOOS=linux GOARCH=arm64 go install github.com/go-delve/delve/cmd/dlv@latest

COPY ./go.mod ./
COPY ./go.sum ./
#COPY ./hack/install-go-licenses.sh ./hack/

RUN GO111MODULE=on GOOS=linux GOARCH=arm64 go mod download
RUN #./hack/install-go-licenses.sh

COPY . .
RUN GO111MODULE=on GOOS=linux GOARCH=arm64 go build -gcflags "all=-N -l" -o /bin/apiserver backend/src/apiserver/*.go
# Check licenses and comply with license terms.
# First, make sure there's no forbidden license.
#RUN go-licenses check ./backend/src/apiserver
#RUN go-licenses csv ./backend/src/apiserver > /tmp/licenses.csv && \
# diff /tmp/licenses.csv backend/third_party_licenses/apiserver.csv && \
# go-licenses save ./backend/src/apiserver --save_path /tmp/NOTICES

# 2. Compile preloaded pipeline samples
FROM python:3.9 as compiler
RUN apt-get update -y && apt-get install --no-install-recommends -y -q default-jdk python3-setuptools python3-dev jq
RUN wget https://bootstrap.pypa.io/get-pip.py && python3 get-pip.py
COPY backend/requirements.txt .
RUN python3 -m pip install -r requirements.txt --no-cache-dir

# Downloading Argo CLI so that the samples are validated
ENV ARGO_VERSION v3.4.17
RUN curl -sLO https://github.com/argoproj/argo-workflows/releases/download/${ARGO_VERSION}/argo-linux-amd64.gz && \
gunzip argo-linux-amd64.gz && \
chmod +x argo-linux-amd64 && \
mv ./argo-linux-amd64 /usr/local/bin/argo

WORKDIR /
COPY ./samples /samples
COPY backend/src/apiserver/config/sample_config.json /samples/

# Compiling the preloaded samples.
# The default image is replaced with the GCR-hosted python image.
RUN set -e; \
< /samples/sample_config.json jq .[].file --raw-output | while read pipeline_yaml; do \
pipeline_py="${pipeline_yaml%.yaml}"; \
python3 "$pipeline_py"; \
done

# 3. Start api web server
FROM debian:stable

ARG COMMIT_SHA=unknown
ENV COMMIT_SHA=${COMMIT_SHA}
ARG TAG_NAME=unknown
ENV TAG_NAME=${TAG_NAME}
ENV LOG_LEVEL info

WORKDIR /bin

COPY --from=builder /go/bin/dlv .

COPY backend/src/apiserver/config/ /config
COPY --from=builder /bin/apiserver /bin/apiserver

# Copy licenses and notices.
#COPY --from=builder /tmp/licenses.csv /third_party/licenses.csv
#COPY --from=builder /tmp/NOTICES /third_party/NOTICES
#COPY --from=compiler /samples/ /samples/
RUN chmod +x /bin/apiserver

# Adding CA certificate so API server can download pipeline through URL and wget is used for liveness/readiness probe command
RUN apt-get update && apt-get install -y ca-certificates wget

# Pin sample doc links to the commit that built the backend image
RUN sed -E "s#/(blob|tree)/master/#/\1/${COMMIT_SHA}/#g" -i /config/sample_config.json && \
sed -E "s/%252Fmaster/%252F${COMMIT_SHA}/#g" -i /config/sample_config.json

# Expose apiserver port
EXPOSE 8888

# Start the apiserver
#CMD /bin/apiserver --config=/config --sampleconfig=/config/sample_config.json -logtostderr=true --logLevel=${LOG_LEVEL}
CMD ["dlv", "--headless=true", "--listen=:2345", "--api-version=2", "--accept-multiclient", "--log", "exec", "/bin/apiserver", "--", "--config=/config", "--sampleconfig=/config/sample_config.json", "-logtostderr=true", "--logLevel=info"]

63 changes: 63 additions & 0 deletions backend/Dockerfile.scheduledworkflow.debug
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Copyright 2021 The Kubeflow Authors
#
# 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.

FROM golang:1.21.7-alpine3.19 as builder

WORKDIR /go/src/github.com/kubeflow/pipelines

RUN GO111MODULE=on GOOS=linux GOARCH=arm64 go install github.com/go-delve/delve/cmd/dlv@latest

COPY ./go.mod ./
COPY ./go.sum ./
COPY ./hack/install-go-licenses.sh ./hack/

RUN GO111MODULE=on GOOS=linux GOARCH=arm64 go mod download
RUN ./hack/install-go-licenses.sh

COPY . .

# Needed musl-dev for github.com/mattn/go-sqlite3
RUN apk update && apk upgrade && \
apk add --no-cache bash git openssh gcc musl-dev

RUN GO111MODULE=on GOOS=linux GOARCH=arm64 go build -gcflags "all=-N -l" -o /bin/controller backend/src/crd/controller/scheduledworkflow/*.go
# Check licenses and comply with license terms.
# First, make sure there's no forbidden license.
#RUN go-licenses check ./backend/src/crd/controller/scheduledworkflow
#RUN go-licenses csv ./backend/src/crd/controller/scheduledworkflow > /tmp/licenses.csv && \
# diff /tmp/licenses.csv backend/third_party_licenses/swf.csv && \
# go-licenses save ./backend/src/crd/controller/scheduledworkflow --save_path /tmp/NOTICES

FROM alpine:3.19

RUN apk --no-cache add tzdata file

RUN adduser -S appuser
USER appuser

WORKDIR /bin

COPY --from=builder /go/bin/dlv .
#COPY --from=builder /go/src/github.com/kubeflow/pipelines /go/src/github.com/kubeflow/pipelines

COPY --from=builder /bin/controller /bin/controller
# Copy licenses and notices.
#COPY --from=builder /tmp/licenses.csv /third_party/licenses.csv
#COPY --from=builder /tmp/NOTICES /third_party/NOTICES

ENV NAMESPACE ""
ENV LOG_LEVEL info

#CMD /bin/controller --logtostderr=true --namespace=${NAMESPACE} --logLevel=${LOG_LEVEL}
CMD ["dlv", "--headless=true", "--listen=:2345", "--api-version=2", "--accept-multiclient", "--log", "--log-output=debugger,rpc", "exec", "/bin/controller", "--", "--logtostderr=true", "--namespace=kubeflow", "--logLevel=info"]
23 changes: 15 additions & 8 deletions backend/src/apiserver/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"encoding/base64"
"encoding/json"
"fmt"
"math"
"reflect"
"strings"

Expand Down Expand Up @@ -97,6 +98,15 @@ type Options struct {
*token
}

func EmptyOptions() Options {
return Options{
math.MaxInt32,
&token{
SortByFieldName: "UUID",
},
}
}

// Matches returns trues if the sorting and filtering criteria in o matches that
// of the one supplied in opts.
func (o *Options) Matches(opts *Options) bool {
Expand Down Expand Up @@ -188,7 +198,9 @@ func (o *Options) AddSortingToSelect(sqlBuilder sq.SelectBuilder) sq.SelectBuild
// When sorting by a direct field in the listable model (i.e., name in Run or uuid in Pipeline), a sortByFieldPrefix can be specified; when sorting by a field in an array-typed dictionary (i.e., a run metric inside the metrics in Run), a sortByFieldPrefix is not needed.
// If next row's value is specified, set those values in the clause.
if o.SortByFieldValue != nil && o.KeyFieldValue != nil {
order := "ASC"
if o.IsDesc {
order = "DESC"
sqlBuilder = sqlBuilder.
Where(sq.Or{
sq.Lt{o.SortByFieldPrefix + o.SortByFieldName: o.SortByFieldValue},
Expand All @@ -207,16 +219,11 @@ func (o *Options) AddSortingToSelect(sqlBuilder sq.SelectBuilder) sq.SelectBuild
},
})
}
sqlBuilder = sqlBuilder.
OrderBy(fmt.Sprintf("%v %v", o.SortByFieldPrefix+o.SortByFieldName, order)).
OrderBy(fmt.Sprintf("%v %v", o.KeyFieldPrefix+o.KeyFieldName, order))
}

order := "ASC"
if o.IsDesc {
order = "DESC"
}
sqlBuilder = sqlBuilder.
OrderBy(fmt.Sprintf("%v %v", o.SortByFieldPrefix+o.SortByFieldName, order)).
OrderBy(fmt.Sprintf("%v %v", o.KeyFieldPrefix+o.KeyFieldName, order))

return sqlBuilder
}

Expand Down
7 changes: 7 additions & 0 deletions backend/src/apiserver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ func main() {
}
log.SetLevel(level)

ctx, cancel := context.WithTimeout(context.Background(), time.Hour) // TODO: Helber - revert to a reasonable timeout
defer cancel()
err = resourceManager.RefreshSwf(ctx)
if err != nil {
log.Errorf("Could not refresh the ScheduledWorkflow Kubernetes resources: %v", err)
}

go startRpcServer(resourceManager)
startHttpProxy(resourceManager)

Expand Down
Loading

0 comments on commit bbb83ad

Please sign in to comment.