[NRF] Don't abort if there are too many registered NF instances (#1579)
Reply with an error instead.
This commit is contained in:
parent
7dd5d27a71
commit
a6abe1fffb
|
@ -494,6 +494,11 @@ int ogs_sbi_context_parse_config(const char *local, const char *remote)
|
|||
return OGS_OK;
|
||||
}
|
||||
|
||||
bool ogs_sbi_nf_instance_maximum_number_is_reached()
|
||||
{
|
||||
return nf_instance_pool.avail <= 0;
|
||||
}
|
||||
|
||||
ogs_sbi_nf_instance_t *ogs_sbi_nf_instance_add(char *id)
|
||||
{
|
||||
ogs_sbi_nf_instance_t *nf_instance = NULL;
|
||||
|
|
|
@ -246,6 +246,7 @@ void ogs_sbi_context_final(void);
|
|||
ogs_sbi_context_t *ogs_sbi_self(void);
|
||||
int ogs_sbi_context_parse_config(const char *local, const char *remote);
|
||||
|
||||
bool ogs_sbi_nf_instance_maximum_number_is_reached(void);
|
||||
ogs_sbi_nf_instance_t *ogs_sbi_nf_instance_add(char *id);
|
||||
void ogs_sbi_nf_instance_add_allowed_nf_type(
|
||||
ogs_sbi_nf_instance_t *nf_instance, OpenAPI_nf_type_e allowed_nf_type);
|
||||
|
|
|
@ -105,6 +105,19 @@ void nrf_state_operational(ogs_fsm_t *s, nrf_event_t *e)
|
|||
if (!nf_instance) {
|
||||
SWITCH(message.h.method)
|
||||
CASE(OGS_SBI_HTTP_METHOD_PUT)
|
||||
if (ogs_sbi_nf_instance_maximum_number_is_reached()) {
|
||||
ogs_warn("Can't add instance [%s] "
|
||||
"due to insufficient space",
|
||||
message.h.resource.component[1]);
|
||||
ogs_assert(
|
||||
true ==
|
||||
ogs_sbi_server_send_error(
|
||||
stream,
|
||||
OGS_SBI_HTTP_STATUS_PAYLOAD_TOO_LARGE,
|
||||
&message, "Insufficient space",
|
||||
message.h.resource.component[1]));
|
||||
break;
|
||||
}
|
||||
nf_instance = ogs_sbi_nf_instance_add(
|
||||
message.h.resource.component[1]);
|
||||
ogs_assert(nf_instance);
|
||||
|
|
Loading…
Reference in New Issue