yangwwei commented on a change in pull request #222:
URL:
https://github.com/apache/incubator-yunikorn-core/pull/222#discussion_r530688714
##########
File path: pkg/webservice/routes.go
##########
@@ -197,4 +197,11 @@ var webRoutes = routes{
Pattern: "/debug/pprof/trace",
HandlerFunc: pprof.Trace,
},
+ // endpoint to check health status
+ route{
+ "Scheduler",
+ "GET",
+ "/ws/v1/scheduler/health",
Review comment:
better to rename this "/ws/v1/scheduler/healthcheck", which is more
self-explanatory
##########
File path: pkg/webservice/dao/scheduler-health.go
##########
@@ -0,0 +1,37 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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.
+*/
+
+package dao
+
+type SchedulerHealthDAOInfo struct {
+ Healthy bool `json:"healthy"`
+ SchedulingErrors int
`json:"schedulingErrors"`
+ FailedNodes int `json:"failedNodes"`
+ UnhealthyPartition map[string]*PartitionDAOInfo
`json:"unhealthyPartitions"`
+ UnhealthyNodes map[string]*NodeDAOInfo
`json:"unhealthyNodes"`
+ ReservationNodeRatio float32
`json:"reservationRatio"`
+}
+
+func (s *SchedulerHealthDAOInfo) SetHealthStatus() {
+ s.Healthy =
+ s.SchedulingErrors == 0 &&
+ s.FailedNodes == 0 &&
+ len(s.UnhealthyPartition) == 0 &&
+ len(s.UnhealthyNodes) == 0
+ //TODO: what is a healthy reservation/node ratio?
Review comment:
if we do not know what's the reasonable ratio, can we add this value to
the returned message and mark this check always passed? So we can observe what
kind of values we can get from the real cluster. maybe later we have a better
idea of how to set this up.
##########
File path: pkg/webservice/dao/scheduler-health.go
##########
@@ -0,0 +1,37 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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.
+*/
+
+package dao
+
+type SchedulerHealthDAOInfo struct {
+ Healthy bool `json:"healthy"`
+ SchedulingErrors int
`json:"schedulingErrors"`
+ FailedNodes int `json:"failedNodes"`
+ UnhealthyPartition map[string]*PartitionDAOInfo
`json:"unhealthyPartitions"`
+ UnhealthyNodes map[string]*NodeDAOInfo
`json:"unhealthyNodes"`
+ ReservationNodeRatio float32
`json:"reservationRatio"`
Review comment:
```
type SchedulerHealthDAOInfo struct {
Healthy bool
HealthChecks []HealthCheckInfo
}
type HealthCheckInfo struct {
Name string
Description string // describe what we are checking here
Succeed bool
DiagnosisMessage string // non-empty if succeed=false, some
human-readable message to explain why this fails
}
```
##########
File path: pkg/webservice/handlers.go
##########
@@ -494,6 +495,95 @@ func updateConfig(w http.ResponseWriter, r *http.Request) {
}
buildUpdateResponse(nil, w)
}
+func checkScheduingErrors(metrics metrics2.CoreSchedulerMetrics, w
http.ResponseWriter, result *dao.SchedulerHealthDAOInfo) {
+ schedulingErrors, err := metrics.GetSchedulingErrors()
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusInternalServerError)
+ }
Review comment:
what the error message looks like when multiple of these checks are
failed?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]