Compare commits
4 Commits
387785b40c
...
bugfix/boo
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
778ffa05a1 | ||
|
|
3c15907427 | ||
|
|
9ae5f3b91d | ||
|
|
3a2141aab5 |
@@ -4,6 +4,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"cloud.o-forge.io/core/oc-lib/dbs"
|
"cloud.o-forge.io/core/oc-lib/dbs"
|
||||||
|
"cloud.o-forge.io/core/oc-lib/logs"
|
||||||
"cloud.o-forge.io/core/oc-lib/models/common/enum"
|
"cloud.o-forge.io/core/oc-lib/models/common/enum"
|
||||||
"cloud.o-forge.io/core/oc-lib/models/utils"
|
"cloud.o-forge.io/core/oc-lib/models/utils"
|
||||||
"cloud.o-forge.io/core/oc-lib/tools"
|
"cloud.o-forge.io/core/oc-lib/tools"
|
||||||
@@ -39,6 +40,8 @@ func (wfa *Booking) Check(id string, start time.Time, end *time.Time, parrallelA
|
|||||||
end = &e
|
end = &e
|
||||||
}
|
}
|
||||||
accessor := NewAccessor(nil)
|
accessor := NewAccessor(nil)
|
||||||
|
l := logs.GetLogger().With().Str("Search Check", "Booking").Logger()
|
||||||
|
l.Debug().Msg("Starting to search")
|
||||||
res, code, err := accessor.Search(&dbs.Filters{
|
res, code, err := accessor.Search(&dbs.Filters{
|
||||||
And: map[string][]dbs.Filter{ // check if there is a booking on the same compute resource by filtering on the compute_resource_id, the state and the execution date
|
And: map[string][]dbs.Filter{ // check if there is a booking on the same compute resource by filtering on the compute_resource_id, the state and the execution date
|
||||||
"resource_id": {{Operator: dbs.EQUAL.String(), Value: id}},
|
"resource_id": {{Operator: dbs.EQUAL.String(), Value: id}},
|
||||||
@@ -49,6 +52,9 @@ func (wfa *Booking) Check(id string, start time.Time, end *time.Time, parrallelA
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, "", wfa.IsDraft)
|
}, "", wfa.IsDraft)
|
||||||
|
|
||||||
|
l.Debug().Msg("Search finished")
|
||||||
|
|
||||||
if code != 200 {
|
if code != 200 {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
"cloud.o-forge.io/core/oc-lib/dbs/mongo"
|
"cloud.o-forge.io/core/oc-lib/dbs/mongo"
|
||||||
"cloud.o-forge.io/core/oc-lib/logs"
|
"cloud.o-forge.io/core/oc-lib/logs"
|
||||||
beego "github.com/beego/beego/v2/server/web"
|
beego "github.com/beego/beego/v2/server/web"
|
||||||
|
"github.com/google/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
type APIRequest struct {
|
type APIRequest struct {
|
||||||
@@ -135,8 +136,10 @@ func (a *API) CheckRemotePeer(url string) (State, map[string]int) {
|
|||||||
|
|
||||||
// CheckRemoteAPIs checks the state of remote APIs from your proper OC
|
// CheckRemoteAPIs checks the state of remote APIs from your proper OC
|
||||||
func (a *API) CheckRemoteAPIs(apis []DataType) (State, map[string]string, error) {
|
func (a *API) CheckRemoteAPIs(apis []DataType) (State, map[string]string, error) {
|
||||||
|
id := uuid.New()
|
||||||
|
l := logs.GetLogger().With().Str("id",id.String()).Logger()
|
||||||
|
l.Debug().Msg("Start checking")
|
||||||
// Check if the database is up
|
// Check if the database is up
|
||||||
l := logs.GetLogger()
|
|
||||||
new := map[string]string{}
|
new := map[string]string{}
|
||||||
caller := NewHTTPCaller(map[DataType]map[METHOD]string{}) // Create a new http caller
|
caller := NewHTTPCaller(map[DataType]map[METHOD]string{}) // Create a new http caller
|
||||||
code := 0
|
code := 0
|
||||||
@@ -144,10 +147,10 @@ func (a *API) CheckRemoteAPIs(apis []DataType) (State, map[string]string, error)
|
|||||||
state := ALIVE
|
state := ALIVE
|
||||||
reachable := false
|
reachable := false
|
||||||
for _, api := range apis { // Check the state of each remote API in the list
|
for _, api := range apis { // Check the state of each remote API in the list
|
||||||
|
l.Debug().Msg("Checking : " + api.String() + " at " + api.API())
|
||||||
var resp APIStatusResponse
|
var resp APIStatusResponse
|
||||||
b, err := caller.CallGet("http://"+api.API()+":8080", "/oc/version/status") // Call the status endpoint of the remote API (standard OC status endpoint)
|
b, err := caller.CallGet("http://"+api.API()+":8080", "/oc/version/status") // Call the status endpoint of the remote API (standard OC status endpoint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.Error().Msg(api.String() + " not reachable")
|
|
||||||
state = REDUCED_SERVICE // If a remote API is not reachable, return reduced service
|
state = REDUCED_SERVICE // If a remote API is not reachable, return reduced service
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -164,7 +167,6 @@ func (a *API) CheckRemoteAPIs(apis []DataType) (State, map[string]string, error)
|
|||||||
reachable = true // If the remote API is reachable, set reachable to true cause we are not dead
|
reachable = true // If the remote API is reachable, set reachable to true cause we are not dead
|
||||||
}
|
}
|
||||||
if !reachable {
|
if !reachable {
|
||||||
l.Error().Msg("Peer check returned no answers")
|
|
||||||
state = DEAD // If no remote API is reachable, return dead, nobody is alive
|
state = DEAD // If no remote API is reachable, return dead, nobody is alive
|
||||||
}
|
}
|
||||||
if code > 0 {
|
if code > 0 {
|
||||||
|
|||||||
Reference in New Issue
Block a user