mirror of
https://github.com/gravitl/netmaker.git
synced 2025-09-07 21:54:54 +08:00
return {} if no records found for acls/metrics
This commit is contained in:
parent
8697b12679
commit
3e0d7720c8
2 changed files with 13 additions and 0 deletions
|
@ -170,6 +170,12 @@ func getNetworkACL(w http.ResponseWriter, r *http.Request) {
|
|||
var networkACL acls.ACLContainer
|
||||
networkACL, err := networkACL.Get(acls.ContainerID(netname))
|
||||
if err != nil {
|
||||
if database.IsEmptyRecord(err) {
|
||||
networkACL = acls.ACLContainer{}
|
||||
w.WriteHeader(http.StatusOK)
|
||||
json.NewEncoder(w).Encode(networkACL)
|
||||
return
|
||||
}
|
||||
logger.Log(0, r.Header.Get("user"),
|
||||
fmt.Sprintf("failed to fetch ACLs for network [%s]: %v", netname, err))
|
||||
logic.ReturnErrorResponse(w, r, logic.FormatError(err, "internal"))
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"net/http"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/gravitl/netmaker/database"
|
||||
"github.com/gravitl/netmaker/logger"
|
||||
"github.com/gravitl/netmaker/logic"
|
||||
"github.com/gravitl/netmaker/models"
|
||||
|
@ -91,6 +92,12 @@ func getNetworkExtMetrics(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
clients, err := logic.GetNetworkExtClients(network) // grab all the network ext clients
|
||||
if err != nil {
|
||||
if database.IsEmptyRecord(err) {
|
||||
var metrics struct{}
|
||||
w.WriteHeader(http.StatusOK)
|
||||
json.NewEncoder(w).Encode(metrics)
|
||||
return
|
||||
}
|
||||
logger.Log(1, r.Header.Get("user"), "failed to fetch metrics of ext clients in network", network, err.Error())
|
||||
logic.ReturnErrorResponse(w, r, logic.FormatError(err, "internal"))
|
||||
return
|
||||
|
|
Loading…
Add table
Reference in a new issue