cmd/mbf: abort remote cures
All checks were successful
Test / Create distribution (push) Successful in 1m5s
Test / Sandbox (push) Successful in 2m53s
Test / Hakurei (push) Successful in 3m47s
Test / ShareFS (push) Successful in 3m50s
Test / Sandbox (race detector) (push) Successful in 5m17s
Test / Hakurei (race detector) (push) Successful in 6m21s
Test / Flake checks (push) Successful in 1m15s
All checks were successful
Test / Create distribution (push) Successful in 1m5s
Test / Sandbox (push) Successful in 2m53s
Test / Hakurei (push) Successful in 3m47s
Test / ShareFS (push) Successful in 3m50s
Test / Sandbox (race detector) (push) Successful in 5m17s
Test / Hakurei (race detector) (push) Successful in 6m21s
Test / Flake checks (push) Successful in 1m15s
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>
This commit is contained in:
@@ -70,6 +70,9 @@ const (
|
|||||||
// specialCancel is a message consisting of a single identifier referring
|
// specialCancel is a message consisting of a single identifier referring
|
||||||
// to a curing artifact to be cancelled.
|
// to a curing artifact to be cancelled.
|
||||||
specialCancel = iota
|
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 denotes a special message with custom layout.
|
||||||
remoteSpecial = math.MaxUint64
|
remoteSpecial = math.MaxUint64
|
||||||
@@ -189,6 +192,10 @@ func serve(
|
|||||||
pkg.Encode(*id),
|
pkg.Encode(*id),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case specialAbort:
|
||||||
|
log.Println("aborting all pending cures")
|
||||||
|
cm.c.Abort()
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
@@ -291,7 +298,7 @@ func cureRemote(
|
|||||||
return p, err
|
return p, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// cureRemote cancels a [pkg.Artifact] curing on a daemon.
|
// cancelRemote cancels a [pkg.Artifact] curing on a daemon.
|
||||||
func cancelRemote(
|
func cancelRemote(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
addr *net.UnixAddr,
|
addr *net.UnixAddr,
|
||||||
@@ -316,3 +323,18 @@ func cancelRemote(
|
|||||||
}
|
}
|
||||||
return conn.Close()
|
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())
|
||||||
|
}
|
||||||
|
|||||||
@@ -110,6 +110,10 @@ func TestDaemon(t *testing.T) {
|
|||||||
t.Fatalf("cancelRemote: error = %v", err)
|
t.Fatalf("cancelRemote: error = %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err = abortRemote(ctx, &addr); err != nil {
|
||||||
|
t.Fatalf("abortRemote: error = %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
// keep this last for synchronisation
|
// keep this last for synchronisation
|
||||||
var p *check.Absolute
|
var p *check.Absolute
|
||||||
p, err = cureRemote(ctx, &addr, pkg.NewFile("check", []byte{0}), 0)
|
p, err = cureRemote(ctx, &addr, pkg.NewFile("check", []byte{0}), 0)
|
||||||
@@ -127,6 +131,7 @@ func TestDaemon(t *testing.T) {
|
|||||||
|
|
||||||
wantLog := []string{
|
wantLog := []string{
|
||||||
"",
|
"",
|
||||||
|
"daemon: aborting all pending cures",
|
||||||
"daemon: attempting to cancel invalid artifact kQm9fmnCmXST1-MMmxzcau2oKZCXXrlZydo4PkeV5hO_2PKfeC8t98hrbV_ZZx_j",
|
"daemon: attempting to cancel invalid artifact kQm9fmnCmXST1-MMmxzcau2oKZCXXrlZydo4PkeV5hO_2PKfeC8t98hrbV_ZZx_j",
|
||||||
"daemon: fulfilled artifact fiZf-ZY_Yq6qxJNrHbMiIPYCsGkUiKCRsZrcSELXTqZWtCnESlHmzV5ThhWWGGYG",
|
"daemon: fulfilled artifact fiZf-ZY_Yq6qxJNrHbMiIPYCsGkUiKCRsZrcSELXTqZWtCnESlHmzV5ThhWWGGYG",
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -520,6 +520,12 @@ func main() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c.NewCommand(
|
||||||
|
"abort",
|
||||||
|
"Abort all pending cures on the daemon",
|
||||||
|
func([]string) error { return abortRemote(ctx, &addr) },
|
||||||
|
)
|
||||||
|
|
||||||
{
|
{
|
||||||
var (
|
var (
|
||||||
flagNet bool
|
flagNet bool
|
||||||
|
|||||||
Reference in New Issue
Block a user