-
Notifications
You must be signed in to change notification settings - Fork 2
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
Variable naming error #2
Open
lifubang
wants to merge
3
commits into
kolyshkin:fix-top
Choose a base branch
from
acmcodercom:fix-top-more
base: fix-top
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
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
In case a user specifies arguments such as -C or f, optimization introduced by commit a076bad can't be used, so the code falls back to listing all the processing and filtering those with PIDs of the container specified. In case a user also specifies -o with some fields that may contain spaces, and those fields are before the PID field (such as -o comm,pid), PID filtering is broken. In the worst case scenario, command can contain numeric arguments which are then parsed as PIDs, leading to showing some processes not belonging to the container specified. To fix, we need to 1. Check if ps arguments contain -o. If true: 2.1. Add pid, to the beginning of -o argument (so the first field is PID). 2.2. Use the first field to obtain PID for filtering purposes. 2.3. Remove the first field from the output. This fixes two bugs: - inability to use -o if it does not contain pid; - wrongly listing processes not belonging to a container. In addition, now, since we are adding our own PID column, any tricks that a malicious user might do with column naming (such as adding `-ouid=PID`) won't work anymore, so we can drop the option validation entirely, as well as its test case! Big thanks to https://github.com/lifubang for analysis and preliminary patches (see moby#37748). To test: ``` ID=$(docker run -d busybox top) docker top -ocmd $ID docker top -o cmd $ID docker top -C top -o cmd $ID docker rm -f $ID ``` [v2: don't add pid if it's the first field already, add pid field even for the first ps (with q) run] [v3: add o and --format handling, remove validatePSArgs] [v4: make sure PID is the first column if we added it] [v5: improve error return] Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Signed-off-by: Lifubang <lifubang@acmcoder.com>
kolyshkin
force-pushed
the
fix-top
branch
11 times, most recently
from
September 19, 2018 05:03
182834e
to
6d43175
Compare
kolyshkin
force-pushed
the
fix-top
branch
4 times, most recently
from
September 20, 2018 20:14
27a3505
to
b4bb386
Compare
kolyshkin
added a commit
that referenced
this pull request
Nov 28, 2018
When go-1.11beta1 is used for building, the following error is reported: > 14:56:20 daemon\graphdriver\lcow\lcow.go:236: Debugf format %s reads > arg #2, but call has 1 arg While fixing this, let's also fix a few other things in this very function (startServiceVMIfNotRunning): 1. Do not use fmt.Printf when not required. 2. Use `title` whenever possible. 3. Don't add `id` to messages as `title` already has it. 4. Remove duplicated colons. 5. Try to unify style of messages. 6. s/startservicevmifnotrunning/startServiceVMIfNotRunning/ ... In general, logging/debugging here is a mess and requires much more love than I can give it at the moment. Areas for improvement: 1. Add a global var logger = logrus.WithField("storage-driver", "lcow") and use it everywhere else in the code. 2. Use logger.WithField("id", id) whenever possible (same for "context" and other similar fields). 3. Revise all the errors returned to be uniform. 4. Make use of errors.Wrap[f] whenever possible. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
errorNoPID -> errorNoPid