Prometheus X Vector
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"oc-datacenter/infrastructure"
|
||||
"oc-datacenter/infrastructure/monitor"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
@@ -123,7 +124,7 @@ var upgrader = websocket.Upgrader{
|
||||
// @Success 200 {booking} models.booking
|
||||
// @router /:id [get]
|
||||
func (o *BookingController) Log() {
|
||||
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
|
||||
// user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
|
||||
id := o.Ctx.Input.Param(":id")
|
||||
conn, err := upgrader.Upgrade(o.Ctx.ResponseWriter, o.Ctx.Request, nil)
|
||||
if err != nil {
|
||||
@@ -131,7 +132,13 @@ func (o *BookingController) Log() {
|
||||
return
|
||||
}
|
||||
defer conn.Close()
|
||||
infrastructure.NewPrometheusService().Stream(id, 1*time.Second, user, peerID, groups, conn)
|
||||
monitors, err := monitor.NewMonitorService()
|
||||
if err != nil {
|
||||
o.Ctx.WriteString("Monitor service unavailable: " + err.Error())
|
||||
return
|
||||
}
|
||||
ctx := monitor.StreamRegistry.Register(id)
|
||||
monitors.Stream(ctx, id, 1*time.Second, conn)
|
||||
}
|
||||
|
||||
// @Title Update
|
||||
@@ -246,7 +253,7 @@ func (o *BookingController) Post() {
|
||||
o.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
if resp.ResourceType == tools.COMPUTE_RESOURCE {
|
||||
// later should check... health for any such as docker...
|
||||
res := oclib.NewRequest(oclib.LibDataEnum(oclib.COMPUTE_RESOURCE), user, peerID, groups, nil).LoadOne(resp.ResourceID)
|
||||
@@ -308,10 +315,14 @@ func (o *BookingController) Post() {
|
||||
return
|
||||
}
|
||||
if b.Data.(*booking.Booking).ResourceType == tools.COMPUTE_RESOURCE {
|
||||
go func() {
|
||||
time.Sleep(time.Until(b.Data.(*booking.Booking).ExpectedStartDate))
|
||||
infrastructure.NewPrometheusService().Stream(b.Data.GetID(), 1*time.Second, user, peerID, groups, nil)
|
||||
}()
|
||||
monitors, monErr := monitor.NewMonitorService()
|
||||
if monErr == nil {
|
||||
go func() {
|
||||
time.Sleep(time.Until(b.Data.(*booking.Booking).ExpectedStartDate))
|
||||
ctx := monitor.StreamRegistry.Register(b.Data.(*booking.Booking).ExecutionsID)
|
||||
monitors.Stream(ctx, b.Data.GetID(), 1*time.Second, nil)
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
logger.Info().Msg("Creating new namespace : " + resp.ExecutionsID)
|
||||
@@ -452,7 +463,7 @@ func (o *BookingController) createNamespace(ns string) error {
|
||||
}
|
||||
|
||||
ok, err := serv.GetNamespace(o.Ctx.Request.Context(), ns)
|
||||
if ok != nil && err == nil {
|
||||
if ok != nil && err == nil {
|
||||
logger.Debug().Msg("A namespace with name " + ns + " already exists")
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user