2023-04-25 12:09:20 +00:00
|
|
|
package control
|
|
|
|
|
|
|
|
import (
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key"
|
|
|
|
commonCmd "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common"
|
|
|
|
ircontrol "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/control/ir"
|
|
|
|
ircontrolsrv "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/control/ir/server"
|
2024-11-07 14:32:10 +00:00
|
|
|
rawclient "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/rpc/client"
|
2023-04-25 12:09:20 +00:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
var tickEpochCmd = &cobra.Command{
|
|
|
|
Use: "tick-epoch",
|
|
|
|
Short: "Forces a new epoch",
|
|
|
|
Long: "Forces a new epoch via a notary request. It should be executed on other IR nodes as well.",
|
|
|
|
Run: tickEpoch,
|
|
|
|
}
|
|
|
|
|
|
|
|
func initControlIRTickEpochCmd() {
|
2023-11-07 14:35:09 +00:00
|
|
|
initControlIRFlags(tickEpochCmd)
|
2023-04-25 12:09:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func tickEpoch(cmd *cobra.Command, _ []string) {
|
|
|
|
pk := key.Get(cmd)
|
|
|
|
c := getClient(cmd, pk)
|
|
|
|
|
|
|
|
req := new(ircontrol.TickEpochRequest)
|
2023-11-07 14:35:09 +00:00
|
|
|
req.SetBody(&ircontrol.TickEpochRequest_Body{
|
|
|
|
Vub: parseVUB(cmd),
|
|
|
|
})
|
2023-04-25 12:09:20 +00:00
|
|
|
|
|
|
|
err := ircontrolsrv.SignMessage(pk, req)
|
|
|
|
commonCmd.ExitOnErr(cmd, "could not sign request: %w", err)
|
|
|
|
|
|
|
|
var resp *ircontrol.TickEpochResponse
|
|
|
|
err = c.ExecRaw(func(client *rawclient.Client) error {
|
|
|
|
resp, err = ircontrol.TickEpoch(client, req)
|
|
|
|
return err
|
|
|
|
})
|
|
|
|
commonCmd.ExitOnErr(cmd, "rpc error: %w", err)
|
|
|
|
|
|
|
|
verifyResponse(cmd, resp.GetSignature(), resp.GetBody())
|
|
|
|
|
|
|
|
cmd.Println("Epoch tick requested")
|
2023-11-07 14:35:09 +00:00
|
|
|
printVUB(cmd, resp.GetBody().GetVub())
|
2023-04-25 12:09:20 +00:00
|
|
|
}
|