aboutsummaryrefslogtreecommitdiffhomepage
path: root/cmd/mbf
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-04-17 22:47:02 +0900
committerOphestra <cat@gensokyo.uk>2026-04-17 22:47:02 +0900
commitb80ea91a42c994b1bcb74d8bcecefc150b899136 (patch)
treedfe1e69454429a41ab08feafecbbe72aa29c4fb2 /cmd/mbf
parent30a9dfa4b84859a38af8a149f4ce3ea8f69a7001 (diff)
cmd/mbf: abort remote cures
This command arranges for all pending cures to be aborted. It does not wait for cures to complete. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'cmd/mbf')
-rw-r--r--cmd/mbf/daemon.go24
-rw-r--r--cmd/mbf/daemon_test.go5
-rw-r--r--cmd/mbf/main.go6
3 files changed, 34 insertions, 1 deletions
diff --git a/cmd/mbf/daemon.go b/cmd/mbf/daemon.go
index cadbf57e..a40eb27d 100644
--- a/cmd/mbf/daemon.go
+++ b/cmd/mbf/daemon.go
@@ -70,6 +70,9 @@ const (
// specialCancel is a message consisting of a single identifier referring
// to a curing artifact to be cancelled.
specialCancel = iota
+ // specialAbort requests for all pending cures to be aborted. It has no
+ // message body.
+ specialAbort
// remoteSpecial denotes a special message with custom layout.
remoteSpecial = math.MaxUint64
@@ -189,6 +192,10 @@ func serve(
pkg.Encode(*id),
)
}
+
+ case specialAbort:
+ log.Println("aborting all pending cures")
+ cm.c.Abort()
}
return
@@ -291,7 +298,7 @@ func cureRemote(
return p, err
}
-// cureRemote cancels a [pkg.Artifact] curing on a daemon.
+// cancelRemote cancels a [pkg.Artifact] curing on a daemon.
func cancelRemote(
ctx context.Context,
addr *net.UnixAddr,
@@ -316,3 +323,18 @@ func cancelRemote(
}
return conn.Close()
}
+
+// abortRemote aborts all [pkg.Artifact] curing on a daemon.
+func abortRemote(
+ ctx context.Context,
+ addr *net.UnixAddr,
+) error {
+ done, conn, err := dial(ctx, addr)
+ if err != nil {
+ return err
+ }
+ defer close(done)
+
+ err = writeSpecialHeader(conn, specialAbort)
+ return errors.Join(err, conn.Close())
+}
diff --git a/cmd/mbf/daemon_test.go b/cmd/mbf/daemon_test.go
index 3306eea3..d1d00eaa 100644
--- a/cmd/mbf/daemon_test.go
+++ b/cmd/mbf/daemon_test.go
@@ -110,6 +110,10 @@ func TestDaemon(t *testing.T) {
t.Fatalf("cancelRemote: error = %v", err)
}
+ if err = abortRemote(ctx, &addr); err != nil {
+ t.Fatalf("abortRemote: error = %v", err)
+ }
+
// keep this last for synchronisation
var p *check.Absolute
p, err = cureRemote(ctx, &addr, pkg.NewFile("check", []byte{0}), 0)
@@ -127,6 +131,7 @@ func TestDaemon(t *testing.T) {
wantLog := []string{
"",
+ "daemon: aborting all pending cures",
"daemon: attempting to cancel invalid artifact kQm9fmnCmXST1-MMmxzcau2oKZCXXrlZydo4PkeV5hO_2PKfeC8t98hrbV_ZZx_j",
"daemon: fulfilled artifact fiZf-ZY_Yq6qxJNrHbMiIPYCsGkUiKCRsZrcSELXTqZWtCnESlHmzV5ThhWWGGYG",
}
diff --git a/cmd/mbf/main.go b/cmd/mbf/main.go
index 4369565a..cbb6f7b2 100644
--- a/cmd/mbf/main.go
+++ b/cmd/mbf/main.go
@@ -520,6 +520,12 @@ func main() {
)
}
+ c.NewCommand(
+ "abort",
+ "Abort all pending cures on the daemon",
+ func([]string) error { return abortRemote(ctx, &addr) },
+ )
+
{
var (
flagNet bool