-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cleanup(pkg/driver): use unix where available. #353
Conversation
Signed-off-by: Federico Di Pierro <[email protected]>
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: FedeDP The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
kmodName := strings.ReplaceAll(driverName, "-", "_") | ||
printer.Logger.Info("Check if kernel module is still loaded.") | ||
lsmodCmdArgs := fmt.Sprintf(`lsmod | cut -d' ' -f1 | grep -qx %q`, kmodName) | ||
_, err = exec.Command("bash", "-c", lsmodCmdArgs).Output() //nolint:gosec // false positive | ||
f, err := os.Open("/proc/modules") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using lsmod
, manually scan /proc/modules
.
for i := 0; i < maxRmmodWait; i++ { | ||
printer.Logger.Info("Kernel module is still loaded.") | ||
printer.Logger.Info("Trying to unload it with 'rmmod'.") | ||
if err = unix.DeleteModule(kmodName, 0); err == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of calling rmmod
directly, just use unit.DeleteModule
.
/close This is not worth the trouble IMHO. |
@FedeDP: Closed this PR. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
What type of PR is this?
/kind cleanup
Any specific area of the project related to this PR?
/area library
What this PR does / why we need it:
Small cleanups on top of #343 : use
unix
golang library where available.NOTE: reimplementing
insmod
ormodprobe
in go, instead of executing it through anexec.Command
is pretty convoluted since they do quite lot of things.See for example how is that implemented in this library: https://github.com/pmorjan/kmod/tree/master
Also, that library itself does not help us much since the job is still pretty complex.
I'd avoid the risk of introducing bugs reimplementing ourselves 2 of the most widely used bash utilities.
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer: