Skip to content

Commit

Permalink
feat(backend): Enable logging for KFP components (#10288)
Browse files Browse the repository at this point in the history
  • Loading branch information
DharmitD authored Jan 5, 2024
1 parent dcab051 commit 5399585
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 3 deletions.
3 changes: 2 additions & 1 deletion backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ ARG COMMIT_SHA=unknown
ENV COMMIT_SHA=${COMMIT_SHA}
ARG TAG_NAME=unknown
ENV TAG_NAME=${TAG_NAME}
ENV LOG_LEVEL info

WORKDIR /bin

Expand All @@ -82,4 +83,4 @@ RUN sed -E "s#/(blob|tree)/master/#/\1/${COMMIT_SHA}/#g" -i /config/sample_confi
EXPOSE 8888

# Start the apiserver
CMD /bin/apiserver --config=/config --sampleconfig=/config/sample_config.json -logtostderr=true
CMD /bin/apiserver --config=/config --sampleconfig=/config/sample_config.json -logtostderr=true --logLevel=${LOG_LEVEL}
3 changes: 2 additions & 1 deletion backend/Dockerfile.persistenceagent
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,6 @@ ENV TTL_SECONDS_AFTER_WORKFLOW_FINISH 86400

# NUM_WORKERS indicates now many worker goroutines
ENV NUM_WORKERS 2
ENV LOG_LEVEL info

CMD persistence_agent --logtostderr=true --namespace=${NAMESPACE} --ttlSecondsAfterWorkflowFinish=${TTL_SECONDS_AFTER_WORKFLOW_FINISH} --numWorker ${NUM_WORKERS}
CMD persistence_agent --logtostderr=true --namespace=${NAMESPACE} --ttlSecondsAfterWorkflowFinish=${TTL_SECONDS_AFTER_WORKFLOW_FINISH} --numWorker ${NUM_WORKERS} --logLevel=${LOG_LEVEL}
3 changes: 2 additions & 1 deletion backend/Dockerfile.scheduledworkflow
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,6 @@ 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}
CMD /bin/controller --logtostderr=true --namespace=${NAMESPACE} --logLevel=${LOG_LEVEL}
13 changes: 13 additions & 0 deletions backend/src/agent/persistence/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (

var (
masterURL string
logLevel string
kubeconfig string
initializeTimeout time.Duration
timeout time.Duration
Expand All @@ -47,6 +48,7 @@ var (
)

const (
logLevelFlagName = "logLevel"
kubeconfigFlagName = "kubeconfig"
masterFlagName = "master"
initializationTimeoutFlagName = "initializeTimeout"
Expand Down Expand Up @@ -86,6 +88,16 @@ func main() {
log.Fatalf("Error building schedule clientset: %s", err.Error())
}

if logLevel == "" {
logLevel = "info"
}

level, err := log.ParseLevel(logLevel)
if err != nil {
log.Fatal("Invalid log level:", err)
}
log.SetLevel(level)

clientParam := util.ClientParameters{QPS: float64(cfg.QPS), Burst: cfg.Burst}
execInformer := util.NewExecutionInformerOrFatal(util.ArgoWorkflow, namespace, time.Second*30, clientParam)

Expand Down Expand Up @@ -131,6 +143,7 @@ func main() {
func init() {
flag.StringVar(&kubeconfig, kubeconfigFlagName, "", "Path to a kubeconfig. Only required if out-of-cluster.")
flag.StringVar(&masterURL, masterFlagName, "", "The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.")
flag.StringVar(&logLevel, logLevelFlagName, "", "Defines the log level for the application.")
flag.DurationVar(&initializeTimeout, initializationTimeoutFlagName, 2*time.Minute, "Duration to wait for initialization of the ML pipeline API server.")
flag.DurationVar(&timeout, timeoutFlagName, 1*time.Minute, "Duration to wait for calls to complete.")
flag.StringVar(&mlPipelineAPIServerName, mlPipelineAPIServerNameFlagName, "ml-pipeline", "Name of the ML pipeline API server.")
Expand Down
13 changes: 13 additions & 0 deletions backend/src/apiserver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@ import (
"github.com/kubeflow/pipelines/backend/src/apiserver/resource"
"github.com/kubeflow/pipelines/backend/src/apiserver/server"
"github.com/prometheus/client_golang/prometheus/promhttp"
log "github.com/sirupsen/logrus"
"github.com/spf13/viper"
"google.golang.org/grpc"
"google.golang.org/grpc/reflection"
)

var (
logLevelFlag = flag.String("logLevel", "", "Defines the log level for the application.")
rpcPortFlag = flag.String("rpcPortFlag", ":8887", "RPC Port")
httpPortFlag = flag.String("httpPortFlag", ":8888", "Http Proxy Port")
configPath = flag.String("config", "", "Path to JSON file containing config")
Expand Down Expand Up @@ -77,6 +79,17 @@ func main() {
}
}

logLevel := *logLevelFlag
if logLevel == "" {
logLevel = "info"
}

level, err := log.ParseLevel(logLevel)
if err != nil {
log.Fatal("Invalid log level:", err)
}
log.SetLevel(level)

go startRpcServer(resourceManager)
startHttpProxy(resourceManager)

Expand Down
12 changes: 12 additions & 0 deletions backend/src/crd/controller/scheduledworkflow/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
)

var (
logLevel string
masterURL string
kubeconfig string
namespace string
Expand All @@ -53,6 +54,16 @@ func main() {
cfg.QPS = float32(clientQPS)
cfg.Burst = clientBurst

if logLevel == "" {
logLevel = "info"
}

level, err := log.ParseLevel(logLevel)
if err != nil {
log.Fatal("Invalid log level:", err)
}
log.SetLevel(level)

kubeClient, err := kubernetes.NewForConfig(cfg)
if err != nil {
log.Fatalf("Error building kubernetes clientset: %s", err.Error())
Expand Down Expand Up @@ -102,6 +113,7 @@ func initEnv() {
func init() {
initEnv()

flag.StringVar(&logLevel, "logLevel", "", "Defines the log level for the application.")
flag.StringVar(&kubeconfig, "kubeconfig", "", "Path to a kubeconfig. Only required if out-of-cluster.")
flag.StringVar(&masterURL, "master", "", "The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.")
flag.StringVar(&namespace, "namespace", "", "The namespace name used for Kubernetes informers to obtain the listers.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,4 @@ data:
## If this value doesn't include a unit abbreviation, the units will be assumed
## to be nanoseconds.
ConMaxLifeTime: "120s"
LOG_LEVEL: "info"
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ spec:
spec:
containers:
- env:
- name: LOG_LEVEL
value: "info"
- name: AUTO_UPDATE_PIPELINE_DEFAULT_VERSION
valueFrom:
configMapKeyRef:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ spec:
value: "86400"
- name: NUM_WORKERS
value: "2"
- name: LOG_LEVEL
value: "info"
image: gcr.io/ml-pipeline/persistenceagent:dummy
imagePullPolicy: IfNotPresent
name: ml-pipeline-persistenceagent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ spec:
imagePullPolicy: IfNotPresent
name: ml-pipeline-scheduledworkflow
env:
- name: LOG_LEVEL
value: "info"
- name: NAMESPACE
valueFrom:
fieldRef:
Expand Down

0 comments on commit 5399585

Please sign in to comment.