Skip to content

CaaS - batch probe fixes #2220

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

Merged
merged 3 commits into from
Jun 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 18 additions & 19 deletions cmd/dequeuer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ func main() {
log.Fatal("--api-name is a required option")
case apiKind == "":
log.Fatal("--api-kind is a required option")
case adminPort == 0:
log.Fatal("--admin-port is a required option")
}

targetURL := "http://127.0.0.1:" + strconv.Itoa(userContainerPort)
Expand Down Expand Up @@ -142,8 +144,6 @@ func main() {
var dequeuerConfig dequeuer.SQSDequeuerConfig
var messageHandler dequeuer.MessageHandler

errCh := make(chan error)

switch apiKind {
case userconfig.BatchAPIKind.String():
if jobID == "" {
Expand All @@ -169,9 +169,6 @@ func main() {
if clusterUID == "" {
log.Fatal("--cluster-uid is a required option")
}
if adminPort == 0 {
log.Fatal("--admin-port is a required option")
}

config := dequeuer.AsyncMessageHandlerConfig{
ClusterUID: clusterUID,
Expand All @@ -187,24 +184,26 @@ func main() {
StopIfNoMessages: false,
}

adminHandler := http.NewServeMux()
adminHandler.Handle("/healthz", dequeuer.HealthcheckHandler(func() bool {
return probe.AreProbesHealthy(probes)
}))

go func() {
server := &http.Server{
Addr: ":" + strconv.Itoa(adminPort),
Handler: adminHandler,
}
log.Infof("Starting %s server on %s", "admin", server.Addr)
errCh <- server.ListenAndServe()
}()

default:
exit(log, err, fmt.Sprintf("kind %s is not supported", apiKind))
}

errCh := make(chan error)

adminHandler := http.NewServeMux()
adminHandler.Handle("/healthz", dequeuer.HealthcheckHandler(func() bool {
return probe.AreProbesHealthy(probes)
}))

go func() {
server := &http.Server{
Addr: ":" + strconv.Itoa(adminPort),
Handler: adminHandler,
}
log.Infof("Starting %s server on %s", "admin", server.Addr)
errCh <- server.ListenAndServe()
}()

sigint := make(chan os.Signal, 1)
signal.Notify(sigint, os.Interrupt)

Expand Down
4 changes: 3 additions & 1 deletion pkg/probe/probe.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@ func (p *Probe) httpProbe() error {
"http://",
)

httpClient := &http.Client{}
httpClient := &http.Client{
Timeout: time.Duration(p.TimeoutSeconds) * time.Second,
}
req, err := http.NewRequest(http.MethodGet, targetURL, nil)
if err != nil {
return err
Expand Down
18 changes: 16 additions & 2 deletions pkg/workloads/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func asyncDequeuerProxyContainer(api spec.API, queueURL string) (kcore.Container
},
InitialDelaySeconds: 1,
TimeoutSeconds: 1,
PeriodSeconds: 5,
PeriodSeconds: 10,
SuccessThreshold: 1,
FailureThreshold: 1,
},
Expand Down Expand Up @@ -180,6 +180,7 @@ func batchDequeuerProxyContainer(api spec.API, jobID, queueURL string) (kcore.Co
"--job-id", jobID,
"--user-port", s.Int32(*api.Pod.Port),
"--statsd-port", consts.StatsDPortStr,
"--admin-port", consts.AdminPortStr,
},
Env: append(baseEnvVars, kcore.EnvVar{
Name: "HOST_IP",
Expand All @@ -189,6 +190,19 @@ func batchDequeuerProxyContainer(api spec.API, jobID, queueURL string) (kcore.Co
},
},
}),
ReadinessProbe: &kcore.Probe{
Handler: kcore.Handler{
HTTPGet: &kcore.HTTPGetAction{
Path: "/healthz",
Port: intstr.FromInt(int(consts.AdminPortInt32)),
Copy link
Collaborator

Choose a reason for hiding this comment

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

intstr.FromInt32(adminPort)

Copy link
Member Author

Choose a reason for hiding this comment

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

There doesn't seem to be a FromInt32 method. It's just FromInt.

Copy link
Collaborator

Choose a reason for hiding this comment

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

in any case it the port shouldn't be hardcoded to the const

},
},
InitialDelaySeconds: 1,
TimeoutSeconds: 1,
PeriodSeconds: 10,
SuccessThreshold: 1,
FailureThreshold: 1,
},
VolumeMounts: []kcore.VolumeMount{
ClusterConfigMount(),
CortexMount(),
Expand Down Expand Up @@ -233,7 +247,7 @@ func realtimeProxyContainer(api spec.API) (kcore.Container, kcore.Volume) {
},
InitialDelaySeconds: 1,
TimeoutSeconds: 1,
PeriodSeconds: 5,
PeriodSeconds: 10,
SuccessThreshold: 1,
FailureThreshold: 1,
},
Expand Down