Closed joshuakarp closed 3 years ago
With respect to #211. The tests for Nodes CLI and all other CLI tests except session-specific commands in agent subcommands should just use a fixture that creates the session, and then share that session token for all command tests that end up using the grpc commands calling into client service. So you should plan out a common fixture mechanism for this.
This is done in client-refactoring but it is going to take time for me to fully review and create new issues for things to polish on. I'll post links.
Post-merge review for subsequent fix (this will be updated and posted onto new issue/issues):
NodeGraph
, this should allow us to maintain the try except style of start
in all of our domains and the started
.NodeManager
, there are multiple in-memory states that you are managing that may need to be kept consistent. Either way it will future proof future enhancements of NodeManager
, also make sure you're doing this against the other stateful classes.NodeManager
cannot expect to "catch" these networking exceptions on a single control flow branch. They must attach handlers to each NodeConnection
. This means the "handling" of exceptions itself is a stateful live operation. You must then design and consider the NodeManager
as a state machine managing multiple connection state machines. Ensure that all errors caught are network domain level errors, you shouldn't be catching naked UTP_ETIMEDOUT
errors.src/bin/errors.ts
are not properly written, they should be named in such a way that they can be grouped into the relevant domain commands. For example ErrorPingNodeFailed
vs ErrorNodePingFailed
.src/bin/errors.ts
should be kept pretty minimal. Most of the errors there should just be handled immediately in the relevant CLI code that uses the commander, I can see errors that relate to validation of the command line arguments for specific commands. They should not even be exceptions at all in this case. Only when the exception is general across all CLI commands should they go there. In particular ErrorPingNodeFailed
does not make sense to be in src/bin/errors
, that sounds like a nodes domain error. I believe errors coming from ErrorCLI
should be "final errors" that is caught by the src/bin/polykey
main function and given a message format of last resort.console.log
. They should be replaced with the logger if debug/info statements, and stdout output if they are legitimate output. Use ag console.log
to find them. They are only meant to be used during development.nodesGetLocalDetails
and nodesGetDetails
should be refactored. Getting information about the current node should be composed of individual commands to each domain. There isn't a need for a "one stop shop" of getting node details. See comment about this: https://gitlab.com/MatrixAI/Engineering/Polykey/js-polykey/-/merge_requests/198#note_635099080 This should propagate to the GUI.createMetadata
function seems rather useless. It just does new grpc.Metadata()
. Is that necessary to wrap it? It's not even being used by anything else. It should be removed.src/nodes/NodeConnection.ts
.//
for inline comments. You can have block comments on top of classes and methods, and don't specify parameters, the typescript automatically takes care of them.NotStarted
exceptions. I sometimes forget to add them in. But technically they should exist on all the instance methods. This is mostly there to enforce state machine mechanics.getRootCertChain
, if it is expected that a NodeConnection
represents a live connection, and therefore has a root certificate available, then it indeed an exception. If it is expected that there may be times where it doesn't have it, then it should be optionally return undefined
and not an exception.getRootCertChain
should just use the getServerCertChain
method provided by the GRPC client. You already have the GRPCClientClient
object under this.client
.._x
property when I want to expose the property to the external caller but not allow them to set it. This is combined with a getter get x()
pattern. This is only needed when we cannot use the readable
prefix which fixes it at construction and even prevents mutation in the methods. Combine with Readable
type constructor when available.Regarding point 14:
Between agent to agent, tls is on the networking layer and the grpc is plaintext, but client (CLI & GUI) to agent, no networking layer is used, and therefore tls occurs on the grpc level. So I realised that therefore you ignore point 14.
Specification
Now that gestalt discovery and identities CLI has been merged in,
nodes
is the next domain that needs to be integrated into the CLI.Additional context
Previous work on the nodes domain can be found in the following MRs:
Tasks