Allow to pass custom VUB for IR service calls #790

Merged
fyrchik merged 1 commit from dstepanov-yadro/frostfs-node:fix/ir_vub into master 2024-09-04 19:51:04 +00:00

Closes #787

Now it is possible to specify valid until block for frostfs-cli control ir calls.

Example:

r01:/# /frostfs-cli control ir remove-container --endpoint localhost:16512 --cid FReCwdX12o6tc7SVSVFyHvSFHCgZKsPz91NzHUP1SBVw --wallet /wallet.json 
Enter password > 
Container scheduled to removal
Transaction's valid until block is 300

ir01:/# /frostfs-cli control ir remove-container --endpoint localhost:16512 --cid FReCwdX12o6tc7SVSVFyHvSFHCgZKsPz91NzHUP1SBVw --wallet /wallet.json --vub 400
Enter password > 
Container scheduled to removal
Transaction's valid until block is 400

ir01:/# /frostfs-cli control ir tick-epoch --endpoint localhost:16512  --wallet /wallet.json --vub 400
Enter password > 
rpc error: rpc error: code = Unknown desc = forcing new epoch: could not invoke method (newEpoch): failed to submit notary request: Expired transaction (-510) - transaction has expired: ValidUntilBlock = 400, current height = 423

ir01:/# /frostfs-cli control ir tick-epoch --endpoint localhost:16512  --wallet /wallet.json --vub 450
Enter password > 
Epoch tick requested
Transaction's valid until block is 450
Closes #787 Now it is possible to specify valid until block for `frostfs-cli control ir` calls. Example: ``` r01:/# /frostfs-cli control ir remove-container --endpoint localhost:16512 --cid FReCwdX12o6tc7SVSVFyHvSFHCgZKsPz91NzHUP1SBVw --wallet /wallet.json Enter password > Container scheduled to removal Transaction's valid until block is 300 ir01:/# /frostfs-cli control ir remove-container --endpoint localhost:16512 --cid FReCwdX12o6tc7SVSVFyHvSFHCgZKsPz91NzHUP1SBVw --wallet /wallet.json --vub 400 Enter password > Container scheduled to removal Transaction's valid until block is 400 ir01:/# /frostfs-cli control ir tick-epoch --endpoint localhost:16512 --wallet /wallet.json --vub 400 Enter password > rpc error: rpc error: code = Unknown desc = forcing new epoch: could not invoke method (newEpoch): failed to submit notary request: Expired transaction (-510) - transaction has expired: ValidUntilBlock = 400, current height = 423 ir01:/# /frostfs-cli control ir tick-epoch --endpoint localhost:16512 --wallet /wallet.json --vub 450 Enter password > Epoch tick requested Transaction's valid until block is 450 ```
dstepanov-yadro force-pushed fix/ir_vub from 4b42110e42 to 316a6dd43a 2023-11-07 15:19:12 +00:00 Compare
dstepanov-yadro reviewed 2023-11-08 09:37:03 +00:00
@ -787,3 +790,1 @@
height, err := c.getTransactionHeight(hash)
if err != nil {
return 0, 0, fmt.Errorf("could not get transaction height: %w", err)
if hash != nil {
Author
Member

This fix doesn't relates to task, but fixes the situation when vub is computed in different places: in this function when hash != nil, and in notary, when hash == nil.

This fix doesn't relates to task, but fixes the situation when vub is computed in different places: in this function when hash != nil, and in notary, when hash == nil.
dstepanov-yadro requested review from storage-core-committers 2023-11-08 09:44:40 +00:00
dstepanov-yadro requested review from storage-core-developers 2023-11-08 09:44:40 +00:00
dstepanov-yadro changed title from WIP: Allow to pass custom VUB for IR service calls to Allow to pass custom VUB for IR service calls 2023-11-08 09:44:48 +00:00
acid-ant approved these changes 2023-11-08 10:19:49 +00:00
fyrchik reviewed 2023-11-08 10:47:28 +00:00
@ -22,0 +30,4 @@
func parseVUB(cmd *cobra.Command) uint32 {
var err error
var vub uint32
if cmd.Flags().Lookup(irFlagNameVUB).Changed {
Owner

Why do we need this check? Default value is 0 and it is logically invalid.
I believe cmd.Flags().GetUint32() returns an error if the flag is missing in definitions and cobra prints error immediately otherwise, but this needs check.

Why do we need this check? Default value is 0 and it is logically invalid. I believe `cmd.Flags().GetUint32()` returns an error if the flag is missing in definitions and cobra prints error immediately otherwise, but this needs check.
Author
Member

you are right, fixed

you are right, fixed
fyrchik marked this conversation as resolved
fyrchik reviewed 2023-11-08 13:29:47 +00:00
@ -13,2 +13,3 @@
// to ensure all nodes produce the same transaction with high probability.
func (c *Client) NewEpoch(epoch uint64, force bool) error {
// If vub > 0, vub will be used as valid until block value.
func (c *Client) NewEpoch(epoch uint64, vub uint32, force bool) (uint32, error) {
Owner

I feel like the interface is starting to blow up: we have 2 parameters specifically to cover IR control service needs.
How about using a separate method? #781 would be easier later and clients are not oblidged to provide unnecessary parameters.

I feel like the interface is starting to blow up: we have 2 parameters specifically to cover IR control service needs. How about using a separate method? #781 would be easier later and clients are not oblidged to provide unnecessary parameters.
Author
Member

This method called by IR and by wrapper, that passes 0 and false. So looks like not complex.

This method called by IR and by wrapper, that passes `0` and `false`. So looks like not complex.
Author
Member

I have simplified wrapper's intrface.

I have simplified wrapper's intrface.
Author
Member

Done

Done
fyrchik marked this conversation as resolved
@ -801,0 +810,4 @@
if hash != nil {
return binary.LittleEndian.Uint32(hash.BytesLE()), height + c.notary.txValidTime, nil
}
return height + c.notary.txValidTime, height + c.notary.txValidTime, nil
Owner

Some comments are needed here, it could easily be a typo

Some comments are needed here, it could easily be a typo
Author
Member

Done

Done
fyrchik marked this conversation as resolved
dstepanov-yadro force-pushed fix/ir_vub from de828db8f9 to 0a082e4ba4 2023-11-08 14:57:18 +00:00 Compare
dstepanov-yadro force-pushed fix/ir_vub from 0a082e4ba4 to a59c538729 2023-11-08 15:08:10 +00:00 Compare
dstepanov-yadro force-pushed fix/ir_vub from a59c538729 to c327543c43 2023-11-08 15:13:57 +00:00 Compare
aarifullin approved these changes 2023-11-09 15:36:28 +00:00
dstepanov-yadro force-pushed fix/ir_vub from c327543c43 to c8a62ffedd 2023-11-13 14:14:19 +00:00 Compare
dstepanov-yadro added 1 commit 2023-11-13 14:24:22 +00:00
[#787] netmap: Refactor NewEpoch method
All checks were successful
DCO action / DCO (pull_request) Successful in 3m58s
Vulncheck / Vulncheck (pull_request) Successful in 4m51s
Build / Build Components (1.21) (pull_request) Successful in 5m47s
Build / Build Components (1.20) (pull_request) Successful in 5m57s
Tests and linters / Tests (1.20) (pull_request) Successful in 6m25s
Tests and linters / Staticcheck (pull_request) Successful in 6m31s
Tests and linters / Lint (pull_request) Successful in 7m15s
Tests and linters / Tests (1.21) (pull_request) Successful in 7m16s
Tests and linters / Tests with -race (pull_request) Successful in 8m30s
8088063195
Split for user and control methods.

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
fyrchik approved these changes 2023-11-13 14:38:57 +00:00
fyrchik merged commit 8088063195 into master 2023-11-13 14:39:13 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
4 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: TrueCloudLab/frostfs-node#790
No description provided.