"gerrit.o-ran-sc.org/r/aiml-fw/aihp/ips/kserve-adapter/pkg/api/v1/deployment"
"gerrit.o-ran-sc.org/r/aiml-fw/aihp/ips/kserve-adapter/pkg/api/v1/healthcheck"
"gerrit.o-ran-sc.org/r/aiml-fw/aihp/ips/kserve-adapter/pkg/api/v1/revision"
+ "gerrit.o-ran-sc.org/r/aiml-fw/aihp/ips/kserve-adapter/pkg/api/v1/status"
"gerrit.o-ran-sc.org/r/aiml-fw/aihp/ips/kserve-adapter/pkg/commons/logger"
)
deploymentExecutor deployment.Command
healthcheckExecutor healthcheck.Command
reivisonExecutor revision.Command
+ statusExecutor status.Command
)
func init() {
deploymentExecutor = deployment.Executor{}
healthcheckExecutor = healthcheck.Executor{}
reivisonExecutor = revision.Executor{}
+ statusExecutor = status.Executor{}
}
func setupRouter() (router *gin.Engine) {
}
status := v1.Group(url.IPS() + url.Status())
- // status.GET()
+ {
+ status.GET("", statusExecutor.Get)
+ }
info := v1.Group(url.IPS() + url.Info())
// info.GET()
--- /dev/null
+/*
+==================================================================================
+
+Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved.
+
+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.
+==================================================================================
+*/
+
+package status
+
+import (
+ "encoding/json"
+ "net/http"
+
+ "github.com/gin-gonic/gin"
+
+ "gerrit.o-ran-sc.org/r/aiml-fw/aihp/ips/kserve-adapter/pkg/api/commons/utils"
+ "gerrit.o-ran-sc.org/r/aiml-fw/aihp/ips/kserve-adapter/pkg/commons/errors"
+ "gerrit.o-ran-sc.org/r/aiml-fw/aihp/ips/kserve-adapter/pkg/commons/logger"
+ "gerrit.o-ran-sc.org/r/aiml-fw/aihp/ips/kserve-adapter/pkg/controller/v1/adapter"
+)
+
+type Command interface {
+ Get(c *gin.Context)
+}
+
+type Executor struct {
+ Command
+}
+
+var ipsAdapter adapter.Command
+
+func init() {
+ ipsAdapter = adapter.Executor{}
+}
+
+func (Executor) Get(c *gin.Context) {
+ logger.Logging(logger.DEBUG, "IN")
+ defer logger.Logging(logger.DEBUG, "OUT")
+
+ name := c.Query("name")
+
+ statusList, err := ipsAdapter.Status(name)
+ if err != nil {
+ utils.WriteError(c.Writer, errors.InternalServerError{Message: err.Error()})
+ return
+ }
+
+ data, err := json.Marshal(statusList)
+ if err != nil {
+ utils.WriteError(c.Writer, err)
+ return
+ }
+
+ utils.WriteSuccess(c.Writer, http.StatusAccepted, data)
+}
Get(name string) (*api_v1beta1.InferenceService, error)
Update(values types.Values) (string, error)
Revision(name string) (revisionList types.Revision, err error)
+ Status(name string) (statusList types.Status, err error)
}
type Client struct {
return
}
+
+func (c *Client) Status(name string) (statusList types.Status, err error) {
+ logger.Logging(logger.DEBUG, "IN")
+ defer logger.Logging(logger.DEBUG, "OUT")
+
+ statusList.Status = make(map[string][]types.StatusItem)
+
+ if name == "" {
+ ifsvList, e := c.api.List(v1.ListOptions{})
+ if e != nil {
+ err = errors.InternalServerError{Message: e.Error()}
+ return
+ }
+
+ for _, ifsv := range ifsvList.Items {
+ status, e := makeStatus(ifsv)
+ if e != nil {
+ err = errors.InternalServerError{Message: e.Error()}
+ return
+ }
+ statusList.Status[ifsv.Name] = status
+ }
+
+ } else {
+ ifsv, e := c.Get(name)
+ if e != nil {
+ err = e
+ return
+ }
+
+ status, e := makeStatus(*ifsv)
+ if e != nil {
+ err = e
+ return
+ }
+ statusList.Status[ifsv.Name] = status
+ }
+
+ return
+}
json.Unmarshal(data, &revision)
return
}
+
+func makeStatus(ifsv api_v1beta1.InferenceService) (status []types.StatusItem, err error) {
+ logger.Logging(logger.DEBUG, "IN")
+ defer logger.Logging(logger.DEBUG, "OUT")
+
+ if len(ifsv.Status.Conditions) == 0 {
+ logger.Logging(logger.ERROR, "condition is empty")
+ err = errors.InternalServerError{
+ Message: "condition is empty",
+ }
+ return
+ }
+
+ for _, condition := range ifsv.Status.Conditions {
+ status = append(status, types.StatusItem{
+ Type: string(condition.Type),
+ Status: string(condition.Status),
+ Severity: string(condition.Severity),
+ Reason: condition.Reason,
+ Message: condition.Message,
+ LastTransitionTime: condition.LastTransitionTime.Inner.String(),
+ })
+ }
+ return
+}
LatestRolledoutRevision string `json:"latestRolledoutRevision,omitempty" example:"{revision}" format:"string"`
}
+type StatusItem struct {
+ Type string `json:"type" example:"{status type}" format:"string"`
+ Status string `json:"status" example:"{True / False}" format:"string"`
+ Severity string `json:"severity,omitempty" example:"{severity}" format:"string"`
+ LastTransitionTime string `json:"lastTransitionTime,omitempty" example:"{time stamp}" format:"string"`
+ Reason string `json:"reason,omitempty" example:"{reason}" format:"string"`
+ Message string `json:"message,omitempty" example:"{message}" format:"string"`
+}
+
type Revision struct {
Revision map[string]RevisionItem `json:"revision"`
}
+
+type Status struct {
+ Status map[string][]StatusItem `json:"status"`
+}
Delete(name string) error
Update(name string, version string, canaryTrafficRatio string) (string, error)
Revision(name string) (revisionList types.Revision, err error)
+ Status(name string) (types.Status, error)
}
type Executor struct {
result, err = kserveClient.Revision(name)
return
}
+
+func (Executor) Status(name string) (result types.Status, err error) {
+ logger.Logging(logger.DEBUG, "IN")
+ defer logger.Logging(logger.DEBUG, "OUT")
+
+ result, err = kserveClient.Status(name)
+ return
+}