Skip to content

Commit 7edc583

Browse files
CopilotachamayouCopilot
authored
Remove /node/memory endpoint (#7822)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: achamayou <4016369+achamayou@users.noreply.github.com> Co-authored-by: Amaury Chamayou <amchamay@microsoft.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent fcf6f92 commit 7edc583

13 files changed

Lines changed: 3 additions & 215 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1212
### Removed
1313

1414
- Removed `aes_gcm_encrypt()`, `aes_gcm_decrypt()`, and `default_iv` from `ccf::crypto` (#7811).
15+
- Removed the `/node/memory` endpoint. This endpoint was originally useful for monitoring SGX enclave memory usage, which is no longer relevant now that SGX support has been removed.
1516

1617
## [7.0.0-rc1]
1718

doc/build_apps/release_policy.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ Operator-facing API
3838

3939
As defined under :ref:`operations/operator_rpc_api:Operator RPC API`.
4040

41-
This is the API used to monitor the network topology, memory usage, endpoint metrics etc. The intention is to keep this API compatible without explicit versioning, by making sure that all changes are strict additions (i.e. new fields, new arguments with default values that behave identically to the old call).
42-
Fields/input arguments will never be modified/deleted unless exceptionally and explicitly notified in advance to users.
41+
This is the API used to monitor the network topology, endpoint metrics etc. The intention is to keep this API compatible without explicit versioning, by making additive changes where possible (i.e. new fields, new arguments with default values that behave identically to the old call).
42+
Fields, input arguments, and endpoints are not expected to be modified or removed in normal releases. Any such change must be explicitly notified to users in advance through the deprecation/release notes process, and removals should only occur in a major release.
4343

4444
Member-facing API
4545
~~~~~~~~~~~~~~~~~

doc/schemas/node_openapi.json

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -484,25 +484,6 @@
484484
],
485485
"type": "string"
486486
},
487-
"MemoryUsage__Out": {
488-
"properties": {
489-
"current_allocated_heap_size": {
490-
"$ref": "#/components/schemas/uint64"
491-
},
492-
"max_total_heap_size": {
493-
"$ref": "#/components/schemas/uint64"
494-
},
495-
"peak_allocated_heap_size": {
496-
"$ref": "#/components/schemas/uint64"
497-
}
498-
},
499-
"required": [
500-
"max_total_heap_size",
501-
"current_allocated_heap_size",
502-
"peak_allocated_heap_size"
503-
],
504-
"type": "object"
505-
},
506487
"NodeId": {
507488
"format": "hex",
508489
"pattern": "^[a-f0-9]{64}$",
@@ -1299,29 +1280,6 @@
12991280
}
13001281
]
13011282
},
1302-
"/node/memory": {
1303-
"get": {
1304-
"operationId": "GetNodeMemory",
1305-
"responses": {
1306-
"200": {
1307-
"content": {
1308-
"application/json": {
1309-
"schema": {
1310-
"$ref": "#/components/schemas/MemoryUsage__Out"
1311-
}
1312-
}
1313-
},
1314-
"description": "Default response description"
1315-
},
1316-
"default": {
1317-
"$ref": "#/components/responses/default"
1318-
}
1319-
},
1320-
"x-ccf-forwarding": {
1321-
"$ref": "#/components/x-ccf-forwarding/never"
1322-
}
1323-
}
1324-
},
13251283
"/node/metrics": {
13261284
"get": {
13271285
"operationId": "GetNodeMetrics",

include/ccf/pal/mem.h

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,53 +3,12 @@
33
#pragma once
44

55
#include <cstring>
6-
#include <limits>
76
#include <stdlib.h>
8-
#include <sys/resource.h>
97

108
namespace ccf::pal
119
{
12-
/**
13-
* Malloc information
14-
*/
15-
struct MallocInfo
16-
{
17-
size_t max_total_heap_size = 0;
18-
size_t current_allocated_heap_size = 0;
19-
size_t peak_allocated_heap_size = 0;
20-
};
21-
2210
static inline void* safe_memcpy(void* dest, const void* src, size_t count)
2311
{
2412
return ::memcpy(dest, src, count);
2513
}
26-
27-
static inline bool get_mallinfo(MallocInfo& info)
28-
{
29-
{
30-
rusage ru = {};
31-
auto rc = getrusage(RUSAGE_SELF, &ru);
32-
if (rc != 0)
33-
{
34-
return false;
35-
}
36-
const auto heap_size = ru.ru_maxrss * 1024;
37-
38-
info.current_allocated_heap_size = heap_size;
39-
info.peak_allocated_heap_size = heap_size;
40-
}
41-
42-
{
43-
rlimit rl = {};
44-
auto rc = getrlimit(RLIMIT_AS, &rl);
45-
if (rc != 0)
46-
{
47-
return false;
48-
}
49-
50-
info.max_total_heap_size = rl.rlim_cur;
51-
}
52-
53-
return true;
54-
}
5514
}

src/node/rpc/node_call_types.h

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include "ccf/ds/json_schema.h"
66
#include "ccf/node/cose_signatures_config.h"
77
#include "ccf/node_startup_state.h"
8-
#include "ccf/pal/mem.h"
98
#include "ccf/service/local_sealing.h"
109
#include "ccf/service/node_info_network.h"
1110
#include "ccf/service/tables/code_id.h"
@@ -158,22 +157,4 @@ namespace ccf
158157
};
159158
};
160159

161-
struct MemoryUsage
162-
{
163-
using In = void;
164-
165-
struct Out
166-
{
167-
Out(const pal::MallocInfo& info) :
168-
max_total_heap_size(info.max_total_heap_size),
169-
current_allocated_heap_size(info.current_allocated_heap_size),
170-
peak_allocated_heap_size(info.peak_allocated_heap_size)
171-
{}
172-
Out() = default;
173-
174-
size_t max_total_heap_size = 0;
175-
size_t current_allocated_heap_size = 0;
176-
size_t peak_allocated_heap_size = 0;
177-
};
178-
};
179160
}

src/node/rpc/node_frontend.h

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include "ccf/node/quote.h"
1212
#include "ccf/odata_error.h"
1313
#include "ccf/pal/attestation.h"
14-
#include "ccf/pal/mem.h"
1514
#include "ccf/service/reconfiguration_type.h"
1615
#include "ccf/version.h"
1716
#include "crypto/certs.h"
@@ -1418,27 +1417,6 @@ namespace ccf
14181417
.set_auto_schema<void, ConsensusConfigDetails>()
14191418
.install();
14201419

1421-
auto memory_usage = [](auto& args) {
1422-
ccf::pal::MallocInfo info;
1423-
if (ccf::pal::get_mallinfo(info))
1424-
{
1425-
MemoryUsage::Out mu(info);
1426-
args.rpc_ctx->set_response_status(HTTP_STATUS_OK);
1427-
args.rpc_ctx->set_response_header(
1428-
http::headers::CONTENT_TYPE, http::headervalues::contenttype::JSON);
1429-
args.rpc_ctx->set_response_body(nlohmann::json(mu).dump());
1430-
return;
1431-
}
1432-
1433-
args.rpc_ctx->set_response_status(HTTP_STATUS_INTERNAL_SERVER_ERROR);
1434-
args.rpc_ctx->set_response_body("Failed to read memory usage");
1435-
};
1436-
1437-
make_command_endpoint("/memory", HTTP_GET, memory_usage, no_auth_required)
1438-
.set_forwarding_required(endpoints::ForwardingRequired::Never)
1439-
.set_auto_schema<MemoryUsage>()
1440-
.install();
1441-
14421420
auto node_metrics = [this](auto& args) {
14431421
NodeMetrics nm;
14441422
nm.sessions = node_operation.get_session_metrics();

src/node/rpc/serialization.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,4 @@ namespace ccf
137137
DECLARE_JSON_TYPE(SubmitRecoveryShare::Out);
138138
DECLARE_JSON_REQUIRED_FIELDS(SubmitRecoveryShare::Out, message);
139139

140-
DECLARE_JSON_TYPE(MemoryUsage::Out);
141-
DECLARE_JSON_REQUIRED_FIELDS(
142-
MemoryUsage::Out,
143-
max_total_heap_size,
144-
current_allocated_heap_size,
145-
peak_allocated_heap_size);
146140
}

tests/e2e_common_endpoints.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -185,23 +185,6 @@ def test_node_ids(network, args):
185185
return network
186186

187187

188-
@reqs.description("Memory usage")
189-
def test_memory(network, args):
190-
primary, _ = network.find_primary()
191-
with primary.client() as c:
192-
r = c.get("/node/memory")
193-
assert r.status_code == http.HTTPStatus.OK.value
194-
assert (
195-
r.body.json()["peak_allocated_heap_size"]
196-
<= r.body.json()["max_total_heap_size"]
197-
)
198-
assert (
199-
r.body.json()["current_allocated_heap_size"]
200-
<= r.body.json()["peak_allocated_heap_size"]
201-
)
202-
return network
203-
204-
205188
@reqs.description("Frontend readiness")
206189
def test_readiness(network, args):
207190
primary, _ = network.find_primary()
@@ -335,6 +318,5 @@ def run(args):
335318
test_primary(network, args)
336319
test_network_node_info(network, args)
337320
test_node_ids(network, args)
338-
test_memory(network, args)
339321
test_large_messages(network, args)
340322
test_readiness(network, args)

tests/e2e_suite.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,6 @@ class TestStatus(Enum):
2424
skipped = auto()
2525

2626

27-
def mem_stats(network):
28-
mem = {}
29-
for node in network.get_joined_nodes():
30-
try:
31-
with node.client() as c:
32-
r = c.get("/node/memory", timeout=0.1)
33-
mem[node.local_node_id] = r.body.json()
34-
except Exception:
35-
pass
36-
return mem
37-
38-
3927
def run(args):
4028
chosen_suite = []
4129

@@ -138,7 +126,6 @@ def filter_fun(x):
138126
{
139127
"status": status.name,
140128
"elapsed (s)": round(test_elapsed, 2),
141-
"memory": mem_stats(new_network),
142129
}
143130
)
144131

tests/historical_query_perf.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,6 @@ def test_historical_query_range(network, args):
182182
entries[id_b], duration_b = get_all_entries(c, id_b, timeout=timeout)
183183
entries[id_c], duration_c = get_all_entries(c, id_c, timeout=timeout)
184184

185-
c.get("/node/memory")
186-
187185
id_a_fetch_rate = len(entries[id_a]) / duration_a
188186
id_b_fetch_rate = len(entries[id_b]) / duration_b
189187
id_c_fetch_rate = len(entries[id_c]) / duration_c

0 commit comments

Comments
 (0)