Skip to content

Replacing -d/--daemon with daemon command. Implementation of 'docker daemon' command#10535

Closed
shishir-a412ed wants to merge 1 commit intomoby:masterfrom
shishir-a412ed:docker_daemon_cmd
Closed

Replacing -d/--daemon with daemon command. Implementation of 'docker daemon' command#10535
shishir-a412ed wants to merge 1 commit intomoby:masterfrom
shishir-a412ed:docker_daemon_cmd

Conversation

@shishir-a412ed
Copy link
Copy Markdown
Contributor

Signed-off-by: Shishir Mahajan <shishir.mahajan@redhat.com

docker/docker.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't backwards compatible. Consider sudo docker -g ./graph -p ./d.pid -d.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you elaborate ? All we are doing is replacing '-d/--daemon' with 'daemon' keyword. So that docker daemon is started using sudo docker daemon rather than sudo docker -d

@shishir-a412ed
Copy link
Copy Markdown
Contributor Author

@aidanhs
We are trying to register docker daemon as a command. Like any other docker command, we should pass options after the command (daemon). So this should work sudo docker daemon -g ./graph -p ./d.pid

@rhatdan
Copy link
Copy Markdown
Contributor

rhatdan commented Feb 3, 2015

@aidanhs The problem we have now, is users specifying commands that are only appropriate for the --daemon on other commands, and the tool silently allowing it. Users expect something to happen, and have no idea why it did not. -d needs to die.

@aidanhs
Copy link
Copy Markdown
Contributor

aidanhs commented Feb 3, 2015

I absolutely agree that -d needs to die. I was planning on making a PR to warn users about the bad arguments you mention @rhatdan since this PR got stalled somewhat last time.

However, it's pretty easy to retain full backwards compat for a few releases - in the loop I've commented on, if you see a -d then remove it and insert daemon at position 1 in os.Args list. That would support the example I gave.

Alternatively, drop support for -d entirely. Please don't leave it the current state where it may or may not work (and possibly will fail in a cryptic way because the -d -> daemon transform is silent), depending on whether you had the foresight to give the -d arguments before anything else.

@shishir-a412ed
Copy link
Copy Markdown
Contributor Author

@aidanhs It works as long as we pass the arguments at the right place.
If you pass the argument before the daemon keyword. It takes it as a flag, and since it is not a flag (it fails), but an argument to the command daemon. it should be passed after the command, not before it.

We are not completely removing -d / --daemon to give users some head ups, as this command is deprecated and will be removed in near future. I have seen this before with other docker commands.

@thaJeztah
Copy link
Copy Markdown
Member

Jenkins failed on docker rmi .... docker rmi requires a minimum of 1 argument. Don't think it's related to the PR

@rhatdan
Copy link
Copy Markdown
Contributor

rhatdan commented Feb 3, 2015

@shishir-a412ed Change the patch to put the daemin to the front and @aidanhs will be happy and we will be backwards compatible.

@rhatdan
Copy link
Copy Markdown
Contributor

rhatdan commented Feb 3, 2015

@thaJeztah Yes that is strange, possible jenkens is a little hosed up.

docker/docker.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be backwards compatible, daemon should always become the first argument, even if -d was passed as the x-th argument. The other arguments should be re-ordered to come after daemon

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, realisation that this suggestion isn't sufficient - see #10535 (comment) below.

i.e. you make it impossible to pass global-level arguments if you shuffle the daemon command to the front.

If #10453 was merged, then this PR was rebased on top of it, we'd have a reliable way of actually filtering os.Args into two lists: global args and daemon args. Without it we're still treating api-enable-cors as a global arg when this PR gets merged, which is wrong.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure; should the older API docs also be updated? It's a bit of a difficult case; newer docker versions support the older API, whereas older docker versions won't support the new daemon command.

If the -d backwards compatibility stays in (for the time being), I think the older API docs should not be updated, or should mention both forms (-d / daemon).

Probably best to get some feedback from a doc maintainers for this.

@jessfraz
Copy link
Copy Markdown
Contributor

jessfraz commented Feb 3, 2015

I think you need a rebase it is failing on context errors https://jenkins.dockerproject.com/job/Docker-PRs2/4/console

@shishir-a412ed
Copy link
Copy Markdown
Contributor Author

@jfrazelle I just rebased 2 mins ago.

@jessfraz
Copy link
Copy Markdown
Contributor

jessfraz commented Feb 3, 2015

you can see the logs that are failing in the link

@thaJeztah
Copy link
Copy Markdown
Member

I think what's missing in the PR is updates to the completion scripts.

According to this: #10416 (comment), updating the fish completions can be updated almost automatically.

The bash completions (found here) need to be updated manually. You could ask @albers if he's willing to assist, but I think it's best to first see if the maintainers are willing to approve the PR first.

Not sure about the zsh completions, I think those have been neglected a bit.

@albers
Copy link
Copy Markdown
Member

albers commented Feb 3, 2015

If this is going to be accepted, I'd like to take over the bash completion part. @thaJeztah Thanks for pointing me to this.

@tiborvass
Copy link
Copy Markdown
Contributor

@shishir-a412ed Thanks for your contribution!

I also prefer having docker daemon instead of docker -d, however we cannot simply remove docker -d overnight. docker -d will have to live for a while. I'm okay to have a deprecation warning message for docker -d. Please don't make changes to your PR until we have decided, we wouldn't want to waste your time if we were to decide otherwise.

@thaJeztah
Copy link
Copy Markdown
Member

@tiborvass should this be labeled as "proposal"?

WRT backwards compatibility (also see the discussion above) I think that's almost in place, but help/usage probably changes, yes.

@tiborvass
Copy link
Copy Markdown
Contributor

@shishir-a412ed @thaJeztah Oh my bad, I tested with -d -D and saw:

INFO[0000] -d is deprecated. Please use daemon command
flag provided but not defined: -D

I assumed there was no backwards compat. Seems like it's just a bug in how the PR handles flags the old way. Also almost all the tests are failing, docker run -d is not working.

Anyway, I'll mark this as UX and it needs design approval.

@tiborvass tiborvass added the UX label Feb 4, 2015
@shishir-a412ed
Copy link
Copy Markdown
Contributor Author

@tiborvass I can take a look at those errors, and also work on backward compatibility issue.
However as you suggested, the first step is for you guys to make a decision on whether this is something docker wants as part of their product line ??

A quick decision on this would be really helpful as this is pending for a long time. PR 9255.

@shishir-a412ed
Copy link
Copy Markdown
Contributor Author

@tiborvass

  1. The reason why docker -d -D was not working, because -D (debug flag) was never part of Daemon Config struct. I have fixed this, you can test now.
  2. I have fixed the docker run -d issue.
  3. I have also fixed the backward compatibility issue. So now we can pass -d/--daemon at any position.

These were small changes, I don't mind fixing it. However we would really appreciate if we can get this change upstream. Let me know what you guys think ?

Shishir

@shishir-a412ed shishir-a412ed force-pushed the docker_daemon_cmd branch 2 times, most recently from 47943e3 to e1b875c Compare February 4, 2015 17:41
docker/docker.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just return false here instead of this loop?
If it's not a command it's probably a misspelling of a command, so there's no point in shuffling (which we risk doing if we continue round the outer loop and hit a -d somewhere).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need the loop to check if we have hit a command, so that we can return and go no further.
to make sure -d is not an argument to a command and is a daemon start (-d/--daemon) which requires shuffling.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, let me explain by giving a concrete example: docker rnu myimage cmd -a -b -c -d.
Clearly this is a misspelling of the run command. Unfortunately, because you only check for real subcommands, this will be (incorrectly) identified as a command to shuffle into a daemon command.
My proposal is: as soon as you find any argument which isn't a daemon or global argument we should assume that this is not a daemon subcommand. This correctly handles a) valid subcommands b) misspelled subcommands.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable to me.

@shishir-a412ed
Copy link
Copy Markdown
Contributor Author

@aidanhs @rhatdan I have made the requested changes.

@shishir-a412ed
Copy link
Copy Markdown
Contributor Author

@rhatdan
adding some testing code to validate the behaviour now.

docker/docker.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor style note that you don't need the else, you can just remove it and unindent the block.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

@aidanhs
Copy link
Copy Markdown
Contributor

aidanhs commented Apr 28, 2015

Will look closer tomorrow, but looks generally good to me (at least shuffle and checkDaemon do, which are what I'm mainly interested in).

…daemon' command

Signed-off-by: Shishir Mahajan <shishir.mahajan@redhat.com>
@shishir-a412ed
Copy link
Copy Markdown
Contributor Author

@tiborvass any updates on this? I have added the test cases as well.

@tiborvass
Copy link
Copy Markdown
Contributor

Thanks @shishir-a412ed I'll carry this PR and #11418 to get it in asap.

@aidanhs
Copy link
Copy Markdown
Contributor

aidanhs commented May 4, 2015

@tiborvass can you clarify? Are you going to make this a PR as part of something else? Is there anywhere to track progress?

Just not quite sure what's happened to this PR...

@icecrime
Copy link
Copy Markdown
Contributor

icecrime commented May 5, 2015

@aidanhs What is means is that we want the feature, but not in its current form: @tiborvass will take on @shishir-a412ed and make the required changes to get it merged.

@shishir-a412ed
Copy link
Copy Markdown
Contributor Author

@icecrime Can you please elaborate a little bit ?
Would you be using this PR's code as part of another PR ?
Are you going to use the same strategy (shuffling for maintaining the backward compatibility, segregating daemon and global flags into two different flagsets {I assume segregation is something we all want} ) ? or you plan on solving this with a completely different approach ?

@aidanhs
Copy link
Copy Markdown
Contributor

aidanhs commented May 6, 2015

I'm mainly interested in how I can follow progress, given @tiborvass probably has quite a few other things on his plate as well.

@rhatdan
Copy link
Copy Markdown
Contributor

rhatdan commented May 12, 2015

@tiborvass @crosbymichael @jfrazelle Has this patch been moved somewhere in a new pull request that we can view? Usually when you guys do this you refer to a new pull request where we can comment and continue to contribute.

We have been working on this pull request for over a year and just having it dissapear is not supporting the community.

@duglin
Copy link
Copy Markdown
Contributor

duglin commented May 12, 2015

I think @tiborvass is working on a new PR but its not been submitted yet.

@thaJeztah
Copy link
Copy Markdown
Member

@duglin I agree it's a bit confusing though to "carry" without opening a new PR; it makes people nervous. Perhaps just opening a placeholder "WIP" PR would have kept people at ease :)

@aidanhs
Copy link
Copy Markdown
Contributor

aidanhs commented May 29, 2015

Any update? Two week silence?

@shishir-a412ed
Copy link
Copy Markdown
Contributor Author

@tiborvass
Any updates on this? It's been a month since you closed this and #11418.
I have put in a lot of effort on this one, and it is a little demotivating and demoralizing to see all my effort go in vain.
how can I be sure that the next PR I spend my time and effort on would not become like this one?

/cc @crosbymichael @rhatdan

@rhatdan
Copy link
Copy Markdown
Contributor

rhatdan commented Jun 3, 2015

I agree, this is VERY contributor unfriendly. To say you are taking over a patch set and then going radio silent...

@tiborvass
Copy link
Copy Markdown
Contributor

I sincerely apologize to @shishir-a412ed and everyone on this thread, this was 100% my fault. I'll make sure not to do this again.

Here's the PR #13771 I just opened, it was dependent on #13636 that just got merged. I welcome your feedback there on #13771. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.