Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reflect unsafe status in /node/version #3942

Merged
merged 10 commits into from
Jun 21, 2022
2 changes: 1 addition & 1 deletion .daily_canary
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Splicer
...
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## Unreleased

### Added

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

## [3.0.0-dev0]

### Added
Expand Down Expand Up @@ -1598,3 +1604,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 @@ -761,7 +765,7 @@
"info": {
"description": "This API provides public, uncredentialed access to service and node state.",
"title": "CCF Public Node API",
"version": "2.18.0"
"version": "2.19.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.0";
openapi_info.document_version = "2.19.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