-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Allow retrieving owner of lock * Add command to stop running agent instance * Pass context to command execution * Cleanup cancelled disruption Signed-off-by: Pablo Chacin <[email protected]>
- Loading branch information
1 parent
ad6272b
commit 1cfe9cf
Showing
16 changed files
with
355 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package commands | ||
|
||
import ( | ||
"syscall" | ||
|
||
"github.com/grafana/xk6-disruptor/pkg/runtime" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// BuiltCleanupCmd returns a cobra command with the specification of the kill command | ||
func BuiltCleanupCmd(env runtime.Environment) *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "cleanup", | ||
Short: "stops any ongoing fault injection and cleans resources", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
runningProcess := env.Lock().Owner() | ||
// no instance is currently running | ||
if runningProcess == -1 { | ||
return nil | ||
} | ||
|
||
return syscall.Kill(runningProcess, syscall.SIGTERM) | ||
|
||
// TODO: cleanup resources (e.g iptables) | ||
}, | ||
} | ||
|
||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.