Skip to content

Commit 7918e87

Browse files
author
Miguel Varela Ramos
committed
Fix rebase conflicts
1 parent 435c61b commit 7918e87

File tree

6 files changed

+87
-85
lines changed

6 files changed

+87
-85
lines changed

images/operator-crd/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ COPY go.sum go.sum
1010
RUN go mod download
1111

1212
# Copy the go source
13+
COPY pkg/config pkg/config
1314
COPY pkg/consts pkg/consts
15+
COPY pkg/crds pkg/crds
1416
COPY pkg/lib pkg/lib
1517
COPY pkg/types pkg/types
16-
COPY pkg/crds pkg/crds
18+
COPY pkg/workloads pkg/workloads
1719

1820
WORKDIR /workspace/pkg/crds
1921

images/operator/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ COPY go.mod go.sum /go/src/github.com/cortexlabs/cortex/
77
WORKDIR /go/src/github.com/cortexlabs/cortex
88
RUN go mod download
99

10+
COPY pkg/config /go/src/github.com/cortexlabs/cortex/pkg/config
1011
COPY pkg/consts /go/src/github.com/cortexlabs/cortex/pkg/consts
1112
COPY pkg/lib /go/src/github.com/cortexlabs/cortex/pkg/lib
1213
COPY pkg/operator /go/src/github.com/cortexlabs/cortex/pkg/operator
1314
COPY pkg/types /go/src/github.com/cortexlabs/cortex/pkg/types
1415
COPY pkg/crds /go/src/github.com/cortexlabs/cortex/pkg/crds
16+
COPY pkg/workloads /go/src/github.com/cortexlabs/cortex/pkg/workloads
1517
WORKDIR /go/src/github.com/cortexlabs/cortex/pkg/operator
1618
RUN GO111MODULE=on CGO_ENABLED=0 GOOS=linux go build -installsuffix cgo -o operator .
1719

pkg/crds/controllers/batch/batchjob_controller_helpers.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -256,13 +256,13 @@ func (r *BatchJobReconciler) desiredWorkerJob(batchJob batch.BatchJob, apiSpec s
256256
var containers []kcore.Container
257257
var volumes []kcore.Volume
258258

259-
switch apiSpec.Predictor.Type {
260-
case userconfig.PythonPredictorType:
261-
containers, volumes = workloads.PythonPredictorContainers(&apiSpec)
262-
case userconfig.TensorFlowPredictorType:
259+
switch apiSpec.Handler.Type {
260+
case userconfig.PythonHandlerType:
261+
containers, volumes = workloads.PythonHandlerContainers(&apiSpec)
262+
case userconfig.TensorFlowHandlerType:
263263
panic("not implemented!") // FIXME: implement
264264
default:
265-
return nil, fmt.Errorf("unexpected predictor type (%s)", apiSpec.Predictor.Type)
265+
return nil, fmt.Errorf("unexpected handler type (%s)", apiSpec.Handler.Type)
266266
}
267267

268268
for i, container := range containers {
@@ -285,7 +285,7 @@ func (r *BatchJobReconciler) desiredWorkerJob(batchJob batch.BatchJob, apiSpec s
285285
"apiName": batchJob.Spec.APIName,
286286
"apiID": batchJob.Spec.APIId,
287287
"specID": apiSpec.SpecID,
288-
"predictorID": apiSpec.PredictorID,
288+
"handlerID": apiSpec.HandlerID,
289289
"jobID": batchJob.Name,
290290
"cortex.dev/api": "true",
291291
},
@@ -456,7 +456,7 @@ func (r *BatchJobReconciler) uploadJobSpec(batchJob batch.BatchJob, api spec.API
456456
},
457457
APIID: api.ID,
458458
SpecID: api.SpecID,
459-
PredictorID: api.PredictorID,
459+
HandlerID: api.HandlerID,
460460
SQSUrl: queueURL,
461461
StartTime: batchJob.CreationTimestamp.Time,
462462
TotalBatchCount: maxBatchCount,

pkg/crds/controllers/batch/batchjob_controller_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,16 @@ func uploadTestAPISpec(apiName string, apiID string) error {
4242
Name: apiName,
4343
Kind: userconfig.BatchAPIKind,
4444
},
45-
Predictor: &userconfig.Predictor{
46-
Type: userconfig.PythonPredictorType,
45+
Handler: &userconfig.Handler{
46+
Type: userconfig.PythonHandlerType,
4747
Image: "quay.io/cortexlabs/python-predictor-cpu:master",
4848
Dependencies: &userconfig.Dependencies{},
4949
},
5050
Compute: &userconfig.Compute{},
5151
},
5252
ID: apiID,
5353
SpecID: random.String(5),
54-
PredictorID: random.String(5),
54+
HandlerID: random.String(5),
5555
DeploymentID: random.String(5),
5656
}
5757
apiSpecKey := spec.Key(apiName, apiID, clusterConfig.ClusterName)

pkg/workloads/helpers.go

Lines changed: 17 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@ package workloads
1818

1919
import (
2020
"fmt"
21-
"strings"
2221

23-
"github.com/cortexlabs/cortex/pkg/types/spec"
2422
"github.com/cortexlabs/cortex/pkg/types/userconfig"
25-
"k8s.io/api/core/v1"
23+
kcore "k8s.io/api/core/v1"
2624
)
2725

2826
func K8sName(apiName string) string {
@@ -44,58 +42,41 @@ type downloadContainerArg struct {
4442
HideUnzippingLog bool `json:"hide_unzipping_log"` // if true, don't log when unzipping
4543
}
4644

47-
func downloaderEnvVars(api *spec.API) []v1.EnvVar {
48-
if api.Kind == userconfig.TaskAPIKind {
49-
return []v1.EnvVar{
50-
{
51-
Name: "CORTEX_LOG_LEVEL",
52-
Value: strings.ToUpper(api.TaskDefinition.LogLevel.String()),
53-
},
54-
}
55-
}
56-
return []v1.EnvVar{
57-
{
58-
Name: "CORTEX_LOG_LEVEL",
59-
Value: strings.ToUpper(api.Predictor.LogLevel.String()),
60-
},
61-
}
62-
}
63-
64-
func FileExistsProbe(fileName string) *v1.Probe {
65-
return &v1.Probe{
45+
func FileExistsProbe(fileName string) *kcore.Probe {
46+
return &kcore.Probe{
6647
InitialDelaySeconds: 3,
6748
TimeoutSeconds: 5,
6849
PeriodSeconds: 5,
6950
SuccessThreshold: 1,
7051
FailureThreshold: 1,
71-
Handler: v1.Handler{
72-
Exec: &v1.ExecAction{
52+
Handler: kcore.Handler{
53+
Exec: &kcore.ExecAction{
7354
Command: []string{"/bin/bash", "-c", fmt.Sprintf("test -f %s", fileName)},
7455
},
7556
},
7657
}
7758
}
7859

79-
func socketExistsProbe(socketName string) *v1.Probe {
80-
return &v1.Probe{
60+
func socketExistsProbe(socketName string) *kcore.Probe {
61+
return &kcore.Probe{
8162
InitialDelaySeconds: 3,
8263
TimeoutSeconds: 5,
8364
PeriodSeconds: 5,
8465
SuccessThreshold: 1,
8566
FailureThreshold: 1,
86-
Handler: v1.Handler{
87-
Exec: &v1.ExecAction{
67+
Handler: kcore.Handler{
68+
Exec: &kcore.ExecAction{
8869
Command: []string{"/bin/bash", "-c", fmt.Sprintf("test -S %s", socketName)},
8970
},
9071
},
9172
}
9273
}
9374

94-
func nginxGracefulStopper(apiKind userconfig.Kind) *v1.Lifecycle {
75+
func nginxGracefulStopper(apiKind userconfig.Kind) *kcore.Lifecycle {
9576
if apiKind == userconfig.RealtimeAPIKind {
96-
return &v1.Lifecycle{
97-
PreStop: &v1.Handler{
98-
Exec: &v1.ExecAction{
77+
return &kcore.Lifecycle{
78+
PreStop: &kcore.Handler{
79+
Exec: &kcore.ExecAction{
9980
// the sleep is required to wait for any k8s-related race conditions
10081
// as described in https://medium.com/codecademy-engineering/kubernetes-nginx-and-zero-downtime-in-production-2c910c6a5ed8
10182
Command: []string{"/bin/sh", "-c", "sleep 5; /usr/sbin/nginx -s quit; while pgrep -x nginx; do sleep 1; done"},
@@ -106,11 +87,11 @@ func nginxGracefulStopper(apiKind userconfig.Kind) *v1.Lifecycle {
10687
return nil
10788
}
10889

109-
func waitAPIContainerToStop(apiKind userconfig.Kind) *v1.Lifecycle {
90+
func waitAPIContainerToStop(apiKind userconfig.Kind) *kcore.Lifecycle {
11091
if apiKind == userconfig.RealtimeAPIKind {
111-
return &v1.Lifecycle{
112-
PreStop: &v1.Handler{
113-
Exec: &v1.ExecAction{
92+
return &kcore.Lifecycle{
93+
PreStop: &kcore.Handler{
94+
Exec: &kcore.ExecAction{
11495
Command: []string{"/bin/sh", "-c", fmt.Sprintf("while curl localhost:%s/nginx_status; do sleep 1; done", DefaultPortStr)},
11596
},
11697
},

0 commit comments

Comments
 (0)