Skip to content

Commit

Permalink
DAOS-16312 control: Always use --force for dmg system stop
Browse files Browse the repository at this point in the history
Allow-unstable-test: true
Features: control
Signed-off-by: Tom Nabarro <[email protected]>
  • Loading branch information
tanabarr committed Jan 29, 2025
1 parent e1393d8 commit 6e9e271
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/control/cmd/dmg/system.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//
// (C) Copyright 2019-2023 Intel Corporation.
// (C) Copyright 2025 Hewlett Packard Enterprise Development LP
//
// SPDX-License-Identifier: BSD-2-Clause-Patent
//
Expand Down Expand Up @@ -185,7 +186,8 @@ func (cmd *systemStopCmd) Execute(_ []string) (errOut error) {
if err := cmd.validateHostsRanks(); err != nil {
return err
}
req := &control.SystemStopReq{Force: cmd.Force}
// DAOS-16312: Always use force when stopping ranks.
req := &control.SystemStopReq{Force: true}
req.Hosts.Replace(&cmd.Hosts.HostSet)
req.Ranks.Replace(&cmd.Ranks.RankSet)

Expand Down
12 changes: 8 additions & 4 deletions src/control/cmd/dmg/system_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//
// (C) Copyright 2019-2023 Intel Corporation.
// (C) Copyright 2025 Hewlett Packard Enterprise Development LP
//
// SPDX-License-Identifier: BSD-2-Clause-Patent
//
Expand Down Expand Up @@ -144,7 +145,7 @@ func TestDmg_SystemCommands(t *testing.T) {
"system stop with no arguments",
"system stop",
strings.Join([]string{
printRequest(t, &control.SystemStopReq{}),
printRequest(t, &control.SystemStopReq{Force: true}),
}, " "),
nil,
},
Expand All @@ -160,23 +161,26 @@ func TestDmg_SystemCommands(t *testing.T) {
"system stop with single rank",
"system stop --ranks 0",
strings.Join([]string{
printRequest(t, withRanks(&control.SystemStopReq{}, 0)),
printRequest(t, withRanks(&control.SystemStopReq{Force: true}, 0)),
}, " "),
nil,
},
{
"system stop with multiple ranks",
"system stop --ranks 0,1,4",
strings.Join([]string{
printRequest(t, withRanks(&control.SystemStopReq{}, 0, 1, 4)),
printRequest(t,
withRanks(&control.SystemStopReq{Force: true}, 0, 1, 4)),
}, " "),
nil,
},
{
"system stop with multiple hosts",
"system stop --rank-hosts bar9,foo-[0-100]",
strings.Join([]string{
printRequest(t, withHosts(&control.SystemStopReq{}, "foo-[0-100]", "bar9")),
printRequest(t,
withHosts(&control.SystemStopReq{Force: true},
"foo-[0-100]", "bar9")),
}, " "),
nil,
},
Expand Down
10 changes: 8 additions & 2 deletions src/control/server/mgmt_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -831,9 +831,12 @@ func (svc *mgmtSvc) SystemStop(ctx context.Context, req *mgmtpb.SystemStopReq) (
if err != nil {
return nil, err
}
svc.log.Debugf("system-stop fanout request: %+v", fReq)

// First phase: Prepare the ranks for shutdown, but only if the request
// is for an unforced full system stop.
// First phase: Prepare the ranks for shutdown, but only if the request is for an unforced
// full system stop.
// DAOS-16312: Note that if force is always specified in request, PrepShutdown will never
// be called.
if fReq.FullSystem && !fReq.Force {
fReq.Method = control.PrepShutdownRanks
fResp, _, err = svc.rpcFanout(ctx, fReq, fResp, true)
Expand Down Expand Up @@ -942,6 +945,7 @@ func (svc *mgmtSvc) SystemStart(ctx context.Context, req *mgmtpb.SystemStartReq)
if err != nil {
return nil, err
}
svc.log.Debugf("system-start fanout request: %+v", fReq)

fReq.CheckMode = req.CheckMode
fReq.Method = control.StartRanks
Expand All @@ -963,6 +967,7 @@ func (svc *mgmtSvc) SystemExclude(ctx context.Context, req *mgmtpb.SystemExclude
if err := svc.checkLeaderRequest(wrapCheckerReq(req)); err != nil {
return nil, err
}
svc.log.Debug("Received SystemExclude RPC")

if req.Hosts == "" && req.Ranks == "" {
return nil, errors.New("no hosts or ranks specified")
Expand All @@ -972,6 +977,7 @@ func (svc *mgmtSvc) SystemExclude(ctx context.Context, req *mgmtpb.SystemExclude
if err != nil {
return nil, err
}
svc.log.Debugf("system-exclude fanout request: %+v", fReq)

if fResp.AbsentHosts.Count() > 0 {
return nil, errors.Errorf("invalid host(s): %s", fResp.AbsentHosts.String())
Expand Down

0 comments on commit 6e9e271

Please sign in to comment.