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
go/control/api: Improve node registration status clarity #5256
Conversation
56faf51
to
d243d97
Compare
Codecov Report
@@ Coverage Diff @@
## master #5256 +/- ##
==========================================
+ Coverage 66.87% 67.09% +0.22%
==========================================
Files 515 516 +1
Lines 54757 54814 +57
==========================================
+ Hits 36620 36780 +160
+ Misses 13663 13574 -89
+ Partials 4474 4460 -14
|
0328a4f
to
5bab05a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested and works. Left some comments.
"registration": {
"successful": false,
"error": "registry: no such entity",
"last_registration": "0001-01-01T00:00:00Z"
},
go/control/api/api.go
Outdated
// Successful is true if the current registration has been successful. | ||
Successful bool `json:"successful"` | ||
|
||
// Error contains the error message if the current registration has not been successful. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Error contains the error message if the current registration has not been successful. | |
// Error contains the error message if the last registration has not been successful. |
To be concise with last successful registration
. Same for Successful
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The last registration can be successful, but the current one can fail -- this field only shows the status of the current one.
For example, the node successfully registers and sets Successful
to true
, LastRegistration
contains the timestamp and Descriptor
the descriptor. Then before the existing registration expires, the node can try to re-register and fail, in which case, its registration would still be valid (as well as the Descriptor
), but Successful
would be false
.
go/control/api/api.go
Outdated
Successful bool `json:"successful"` | ||
|
||
// Error contains the error message if the current registration has not been successful. | ||
Error string `json:"error,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error string `json:"error,omitempty"` | |
ErrorMessage string `json:"error_message,omitempty"` |
Maybe I would change this, as I expect that Error
has error
type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I initially had this as the error
type, but apparently it can't be serialized properly, so this is the most straightforward way to do it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type error
is an interface and will marshal to {}
, so you cannot use it, unfortunately.
go/control/api/api.go
Outdated
@@ -124,6 +124,12 @@ type IdentityStatus struct { | |||
|
|||
// RegistrationStatus is the node registration status. | |||
type RegistrationStatus struct { | |||
// Successful is true if the current registration has been successful. | |||
Successful bool `json:"successful"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have mixed fillings about this field as it duplicates data (e.g currently a bug could return true
and error
) and is ambiguous (looking only at the json without reading the comment).
I prefer having the following data: Registered
(bool), LastRegistration
(timestamp), LastAttempt
(timestamp) and ErrorMessage
(string) if last attempt failed. I think that when we delete the descriptor we say that we are not registered anymore, so the Registration
field could be optional/removed or maybe not, as timestamp is kept.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I'm not sure... Registered
in your case is basically the same as checking if Descriptor
is not nil
. Adding a timestamp for the last registration attempt is a good idea, I'll do that. And I need to add better comments for the existing fields.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about this, I:
- add the field
LastAttempt
(timestamp) - rename
Successful
toLastAttemptSuccessful
- rename
Error
toLastAtemptError
This will make it more clear what the new fields actually mean. I think that having the bool and the error separate is still useful for quickly checking if the node has problems (especially when using automation) and once I change the status updating as you've suggested above, there's really no way that the bool and the error could be out of sync :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, have no better suggestions. Putting this under last_attempt
with fields timestamp
, successful
and error_message
would probably be an overkill.
5bab05a
to
2922d29
Compare
.changelog/5256.feature.md
Outdated
under the registration status section: | ||
|
||
- `successful` - true if the registration succeeded. | ||
- `error` - error message if the registration failed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs to be updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, fixed! :)
2ea8ba4
to
a8edce8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌
"registration": {
"last_attempt_successful": false,
"last_attempt_error_message": "registry: no such entity",
"last_attempt": "2023-05-03T11:37:29+02:00",
"last_registration": "2023-05-03T11:36:37+02:00",
}
addrs, err := w.gatherConsensusAddresses(sentryConsensusAddrs) | ||
if err != nil { | ||
return fmt.Errorf("error gathering consensus addresses: %w", err) | ||
addrs, grr := w.gatherConsensusAddresses(sentryConsensusAddrs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addrs, grr := w.gatherConsensusAddresses(sentryConsensusAddrs) | |
addrs, err := w.gatherConsensusAddresses(sentryConsensusAddrs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Linter complains about this, so I'll revert this change :)
@@ -941,28 +965,22 @@ func (w *Worker) registerNode(epoch beacon.EpochTime, hook RegisterNodeHook) err | |||
nodeSigners = append([]signature.Signer{w.identity.NodeSigner}, nodeSigners...) | |||
} | |||
|
|||
sigNode, err := node.MultiSignNode(nodeSigners, registry.RegisterNodeSignatureContext, &nodeDesc) | |||
if err != nil { | |||
sigNode, grr := node.MultiSignNode(nodeSigners, registry.RegisterNodeSignatureContext, &nodeDesc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sigNode, grr := node.MultiSignNode(nodeSigners, registry.RegisterNodeSignatureContext, &nodeDesc) | |
sigNode, err := node.MultiSignNode(nodeSigners, registry.RegisterNodeSignatureContext, &nodeDesc) |
w.logger.Error("failed to register node", | ||
"err", err, | ||
) | ||
return err | ||
} | ||
|
||
// Update the registration status on successful registration. | ||
w.RLock() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this has been a bug for 3 years.
a8edce8
to
97d1487
Compare
97d1487
to
b8a572a
Compare
This PR adds three new fields to the node's
control status
output under the registration status section:last_attempt_successful
- true if the last registration attempt succeeded.last_attempt_error_message
- error message if the last registration attempt failed.last_attempt
- time of the last registration attempt.Also, if the registration descriptor is expired, it is no longer shown in the output.