From 1ca3abe527d30130b4245bb18fc3bde8860d5fd6 Mon Sep 17 00:00:00 2001 From: 0x5459 <0x5459@protonmail.com> Date: Mon, 31 Jul 2023 14:43:54 +0800 Subject: [PATCH] fix(manager): revert the sectors abort command --- .../internal/util_sealer_sectors.go | 66 +++++++++++-------- 1 file changed, 37 insertions(+), 29 deletions(-) diff --git a/damocles-manager/cmd/damocles-manager/internal/util_sealer_sectors.go b/damocles-manager/cmd/damocles-manager/internal/util_sealer_sectors.go index 36b95e2d1..abb6bd077 100644 --- a/damocles-manager/cmd/damocles-manager/internal/util_sealer_sectors.go +++ b/damocles-manager/cmd/damocles-manager/internal/util_sealer_sectors.go @@ -114,36 +114,44 @@ var utilSealerSectorsAbortCmd = &cli.Command{ Name: "abort", Usage: "Abort specified online sector job", ArgsUsage: " ", + Flags: []cli.Flag{ + &cli.BoolFlag{ + Name: "really-do-it", + Usage: "WARNING: This command may result in inconsistent state of damocles-manager and damocles-worker. If you know what you're doing, use it", + Value: false, + }, + }, Action: func(cctx *cli.Context) error { - return fmt.Errorf("this command is not available in the current version, please use the `damocles-worker worker -c resume --state Aborted --index ` or `damocles-manager util worker resume Aborted` commands instead.\n See: https://github.com/ipfs-force-community/damocles/blob/main/docs/en/11.task-status-flow.md#1-for-a-sector-sealing-task-that-has-been-paused-due-to-an-error-and-cannot-be-resumed-such-as-the-ticket-has-expired-you-can-use") - // if count := cctx.Args().Len(); count < 2 { - // return fmt.Errorf("both miner actor id & sector number are required, only %d args provided", count) - // } - - // miner, err := ShouldActor(cctx.Args().Get(0), true) - // if err != nil { - // return fmt.Errorf("invalid miner actor id: %w", err) - // } - - // sectorNum, err := strconv.ParseUint(cctx.Args().Get(1), 10, 64) - // if err != nil { - // return fmt.Errorf("invalid sector number: %w", err) - // } - - // cli, gctx, stop, err := extractAPI(cctx) - // if err != nil { - // return err - // } - - // defer stop() - - // _, err = cli.Sealer.ReportAborted(gctx, abi.SectorID{ - // Miner: miner, - // Number: abi.SectorNumber(sectorNum), - // }, "aborted via CLI") - // if err != nil { - // return fmt.Errorf("abort sector failed: %w", err) - // } + // return fmt.Errorf("this command is not available in the current version, please use the `damocles-worker worker -c resume --state Aborted --index ` or `damocles-manager util worker resume Aborted` commands instead.\n See: https://github.com/ipfs-force-community/damocles/blob/main/docs/en/11.task-status-flow.md#1-for-a-sector-sealing-task-that-has-been-paused-due-to-an-error-and-cannot-be-resumed-such-as-the-ticket-has-expired-you-can-use") + if count := cctx.Args().Len(); count < 2 { + return fmt.Errorf("both miner actor id & sector number are required, only %d args provided", count) + } + + miner, err := ShouldActor(cctx.Args().Get(0), true) + if err != nil { + return fmt.Errorf("invalid miner actor id: %w", err) + } + + sectorNum, err := strconv.ParseUint(cctx.Args().Get(1), 10, 64) + if err != nil { + return fmt.Errorf("invalid sector number: %w", err) + } + + cli, gctx, stop, err := extractAPI(cctx) + if err != nil { + return err + } + + defer stop() + + _, err = cli.Damocles.ReportAborted(gctx, abi.SectorID{ + Miner: miner, + Number: abi.SectorNumber(sectorNum), + }, "aborted via CLI") + if err != nil { + return fmt.Errorf("abort sector failed: %w", err) + } + return nil }, }