Skip to content
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

Add NetMode, UtsMode and IPCMode Namespaces support #64

Closed
wants to merge 1 commit into from

Conversation

rhatdan
Copy link
Member

@rhatdan rhatdan commented Nov 22, 2017

No description provided.

@rhatdan rhatdan force-pushed the namespaces branch 2 times, most recently from 6e7646e to 8740e19 Compare November 22, 2017 19:12
ip6Address string //ipv6
ipAddress string //ip
labels map[string]string //label
linkLocalIP []string // link-local-ip
Copy link
Member

Choose a reason for hiding this comment

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

nit of a nit, gotta space after // in the comment for these 3, but not in the others. Yes my OCD is kicking in.

Copy link
Member Author

Choose a reason for hiding this comment

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

I actually think we should just remove these comments, since they were just a helper to @baude to remember the link between the CLI option and the internal storage

return nil
}

func addUTSNS(config *createConfig, g *generate.Generator) error {
Copy link
Member

Choose a reason for hiding this comment

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

will you be adding "IsContainer" functionality to this function too? If not, should this be renamed to remove rather than add?

Copy link
Member Author

Choose a reason for hiding this comment

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

IsContainer is not valid for UTS, it only has host and Private (Default). UTS almost always follows with --net.

@TomSweeneyRedHat
Copy link
Member

lots of unhappy tests atm.

@rhatdan
Copy link
Member Author

rhatdan commented Nov 22, 2017

Yup, I have to make shm work properly. Taking all day to get close.

@rhatdan rhatdan force-pushed the namespaces branch 7 times, most recently from a5d4ab3 to f14145d Compare November 28, 2017 14:06
@rhatdan
Copy link
Member Author

rhatdan commented Nov 28, 2017

@TomSweeneyRedHat @baude @mheon @umohnani8 Tests finally pass, Please review this. I can break this up into a series of PRs if that is easier.

@@ -384,7 +403,7 @@ func (c *Container) Init() (err error) {

c.state.State = ContainerStateCreated

if err := c.runtime.state.SaveContainer(c); err != nil {
if err := c.Save(); err != nil {
return errors.Wrapf(err, "error saving container %s state", c.ID())
Copy link
Member

Choose a reason for hiding this comment

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

Just return err, the same error message here is being returned in Save() as well. This will just print out the same error message twice.

@@ -416,7 +435,7 @@ func (c *Container) Start() error {
return err
}

if err := c.runtime.state.SaveContainer(c); err != nil {
if err := c.Save(); err != nil {
return errors.Wrapf(err, "error saving container %s state", c.ID())
Copy link
Member

Choose a reason for hiding this comment

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

Just return err

@@ -501,7 +520,7 @@ func (c *Container) Mount(label string) (string, error) {
c.state.Mounted = true
c.config.MountLabel = mountLabel

if err := c.runtime.state.SaveContainer(c); err != nil {
if err := c.Save(); err != nil {
return "", errors.Wrapf(err, "error saving container %s state", c.ID())
Copy link
Member

Choose a reason for hiding this comment

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

just return err

@rh-atomic-bot
Copy link
Collaborator

☔ The latest upstream changes (presumably ab62fe1) made this pull request unmergeable. Please resolve the merge conflicts.

@@ -672,3 +691,11 @@ func (c *Container) isStopped() (bool, error) {
}
return c.state.State == ContainerStateStopped, nil
}

// Save container state to the database
func (c *Container) Save() error {
Copy link
Member

Choose a reason for hiding this comment

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

Don't think this needs to be exposed. We should never need to call this from outside libpod.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

@rhatdan rhatdan force-pushed the namespaces branch 3 times, most recently from ccc22a5 to 9d0b0ac Compare November 28, 2017 15:23
@@ -53,6 +60,27 @@ func (r *Runtime) NewContainer(spec *spec.Spec, options ...CtrCreateOption) (c *
}
}()

shmdir := ctr.ShmDir()
if shmdir == "" {
Copy link
Member

Choose a reason for hiding this comment

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

Can you set ctr.config.ShmDir here to the new SHM you create? That way we preserve the path in the DB

Copy link
Member Author

Choose a reason for hiding this comment

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

I am setting it about 5 rows below. ctr.config.ShmDir() return ctr.config.ShmDir,

}
g := generate.NewFromSpec(spec)
g.AddBindMount(shmdir, "/dev/shm", []string{"rw"})
ctr.replaceSpec(g.Spec())
Copy link
Member

Choose a reason for hiding this comment

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

Instead of using replaceSpec, can you do this in https://github.com/projectatomic/libpod/blob/master/libpod/container.go#L426-L431 - when we generate the runtime spec we're going to use? That will remove the need for replaceSpec and ensure that ctr.config.Spec is always the spec the user gave to us

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

if config.pidMode.IsHost() {
labelOpts = append(labelOpts, label.DisableSecOpt()...)
}
if config.pidMode.IsContainer() {
Copy link
Member

Choose a reason for hiding this comment

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

Can this be else-if? I think pid=host and pid= are exclusive

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

if config.ipcMode.IsHost() {
labelOpts = append(labelOpts, label.DisableSecOpt()...)
}
if config.ipcMode.IsContainer() {
Copy link
Member

Choose a reason for hiding this comment

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

Can this be else-if? I think host and container are exclusive

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

if ipcMode.IsHost() {
return "/dev/shm", nil
}
if ipcMode.IsContainer() {
Copy link
Member

Choose a reason for hiding this comment

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

Can this be else-if

Copy link
Member Author

Choose a reason for hiding this comment

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

No need other calls are returning.

if netMode.IsNone() {
return libpod.ErrNotImplemented
}
if netMode.IsBridge() {
Copy link
Member

Choose a reason for hiding this comment

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

Can this be else-if

Copy link
Member Author

Choose a reason for hiding this comment

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

no need other calls are returning.

if netMode.IsBridge() {
return libpod.ErrNotImplemented
}
if netMode.IsContainer() {
Copy link
Member

Choose a reason for hiding this comment

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

Can this be else-if

Copy link
Member Author

Choose a reason for hiding this comment

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

No need since others are returning.

@rh-atomic-bot
Copy link
Collaborator

☔ The latest upstream changes (presumably 1f9c894) made this pull request unmergeable. Please resolve the merge conflicts.

@rhatdan rhatdan force-pushed the namespaces branch 2 times, most recently from caaae06 to ce64196 Compare November 30, 2017 14:38
@TomSweeneyRedHat
Copy link
Member

@rhatdan, Travis isn't happy due to some unwanted whitespace.

@rhatdan
Copy link
Member Author

rhatdan commented Dec 1, 2017

@mheon Now storing the list of mounts in the DB. So code less hacky and it seems to work, PTAL.

}
}
}
c.config.Mounts = []string{}
Copy link
Member

Choose a reason for hiding this comment

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

Since this is in c.config, it won't be saved

@@ -471,6 +484,19 @@ func (c *Container) Start() error {
return err
}

mounted, err := mount.Mounted(c.config.ShmDir)
Copy link
Member

Choose a reason for hiding this comment

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

I feel like we ought to make a generic Mount() function that ensures the container, SHM, and everything else are mounted and ready to go. But that can wait for another PR.

@mheon
Copy link
Member

mheon commented Dec 1, 2017

@rhatdan There's a DB schema version in sql_state.go since my DB versioning patch hit. Can you increment that from 1 to 2, to indicate a change has been made in database arrangement?

@mheon
Copy link
Member

mheon commented Dec 1, 2017

Otherwise, LGTM. I don't know if Mounts should be in Config or State yet, but for now I think we're fine.

@rhatdan
Copy link
Member Author

rhatdan commented Dec 1, 2017

Well mounts should not change after the container has been created.

@rhatdan
Copy link
Member Author

rhatdan commented Dec 2, 2017

@bot retest please

@rhatdan
Copy link
Member Author

rhatdan commented Dec 2, 2017

@mheon updated the schema version.

Allow kpod create/run to create contianers in different network namespaces, uts namespaces and
IPC Namespaces.

This patch just handles the simple join the host, or another containers namespaces.

Lots more work needed to full integrate  --net

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
@mheon
Copy link
Member

mheon commented Dec 2, 2017

bot, retest this please

@mheon
Copy link
Member

mheon commented Dec 2, 2017

LGTM
@rh-atomic-bot r+

@rh-atomic-bot
Copy link
Collaborator

📌 Commit 403d5da has been approved by mheon

@rh-atomic-bot
Copy link
Collaborator

⌛ Testing commit 403d5da with merge e810bf5...

@rh-atomic-bot
Copy link
Collaborator

💔 Test failed - status-papr

@mheon
Copy link
Member

mheon commented Dec 2, 2017

@rh-atomic-bot retry

@rh-atomic-bot
Copy link
Collaborator

⌛ Testing commit 403d5da with merge adf8809...

@rh-atomic-bot
Copy link
Collaborator

☀️ Test successful - status-papr
Approved by: mheon
Pushing adf8809 to master...

baude pushed a commit to baude/podman that referenced this pull request Aug 31, 2019
travis: run with ginkgo -p instead of go test
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 28, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants