Skip to content

Commit

Permalink
Reflect unsafe status in /node/version (microsoft#3942)
Browse files Browse the repository at this point in the history
  • Loading branch information
achamayou authored Jun 21, 2022
1 parent 353f2cd commit ad3fb89
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## Unreleased

### Added

- `/node/version` now contains an `unsafe` flag reflecting the status of the build.

### Changed

- Generated OpenAPI now describes whether each endpoint is forwarded (#3935).
Expand Down Expand Up @@ -1604,3 +1608,4 @@ Initial pre-release
[0.4]: https://github.com/microsoft/CCF/releases/tag/v0.4
[0.3]: https://github.com/microsoft/CCF/releases/tag/v0.3
[2.0.0-rc8]: https://github.com/microsoft/CCF/releases/tag/ccf-2.0.0-rc8
[unreleased]: https://github.com/microsoft/CCF/releases/tag/ccf-Unreleased
3 changes: 3 additions & 0 deletions cmake/version.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ option(UNSAFE_VERSION "Produce build with unsafe logging levels" OFF)
set(CCF_PROJECT "ccf")
if(UNSAFE_VERSION)
set(CCF_PROJECT "${CCF_PROJECT}_unsafe")
add_compile_definitions(UNSAFE_VERSION)
file(WRITE ${CMAKE_BINARY_DIR}/UNSAFE "UNSAFE")
install(FILES ${CMAKE_BINARY_DIR}/UNSAFE DESTINATION share)
endif()

# If possible, deduce project version from git environment
Expand Down
8 changes: 6 additions & 2 deletions doc/schemas/node_openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -390,11 +390,15 @@
},
"quickjs_version": {
"$ref": "#/components/schemas/string"
},
"unsafe": {
"$ref": "#/components/schemas/boolean"
}
},
"required": [
"ccf_version",
"quickjs_version"
"quickjs_version",
"unsafe"
],
"type": "object"
},
Expand Down Expand Up @@ -775,7 +779,7 @@
"info": {
"description": "This API provides public, uncredentialed access to service and node state.",
"title": "CCF Public Node API",
"version": "2.18.1"
"version": "2.20.0"
},
"openapi": "3.0.0",
"paths": {
Expand Down
1 change: 1 addition & 0 deletions src/node/rpc/node_call_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ namespace ccf
{
std::string ccf_version;
std::string quickjs_version;
bool unsafe;
};
};

Expand Down
8 changes: 7 additions & 1 deletion src/node/rpc/node_frontend.h
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ namespace ccf
openapi_info.description =
"This API provides public, uncredentialed access to service and node "
"state.";
openapi_info.document_version = "2.18.1";
openapi_info.document_version = "2.20.0";
}

void init_handlers() override
Expand Down Expand Up @@ -1302,6 +1302,12 @@ namespace ccf
GetVersion::Out result;
result.ccf_version = ccf::ccf_version;
result.quickjs_version = ccf::quickjs_version;
#ifdef UNSAFE_VERSION
result.unsafe = true;
#else
result.unsafe = false;
#endif

return make_success(result);
};

Expand Down
3 changes: 2 additions & 1 deletion src/node/rpc/serialization.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ namespace ccf
GetState::Out, recovery_target_seqno, last_recovered_seqno)

DECLARE_JSON_TYPE(GetVersion::Out)
DECLARE_JSON_REQUIRED_FIELDS(GetVersion::Out, ccf_version, quickjs_version)
DECLARE_JSON_REQUIRED_FIELDS(
GetVersion::Out, ccf_version, quickjs_version, unsafe)

DECLARE_JSON_TYPE_WITH_OPTIONAL_FIELDS(JoinNetworkNodeToNode::In)
DECLARE_JSON_REQUIRED_FIELDS(
Expand Down
3 changes: 3 additions & 0 deletions tests/reconfiguration.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,9 @@ def test_version(network, args):
with node.client() as c:
r = c.get("/node/version")
assert r.body.json()["ccf_version"] == args.ccf_version
assert r.body.json()["unsafe"] == os.path.exists(
os.path.join(args.binary_dir, "UNSAFE")
)


@reqs.description("Replace a node on the same addresses")
Expand Down

0 comments on commit ad3fb89

Please sign in to comment.