Skip to content
This repository was archived by the owner on Apr 3, 2018. It is now read-only.

One proxy per vm#483

Merged
sameo merged 4 commits into
containers:masterfrom
jodh-intel:one-proxy-per-vm
Nov 28, 2017
Merged

One proxy per vm#483
sameo merged 4 commits into
containers:masterfrom
jodh-intel:one-proxy-per-vm

Conversation

@jodh-intel
Copy link
Copy Markdown
Collaborator

proxy: Launch one proxy instance per pod

Create a proxy instance for each pod (virtual machine).

Since the proxy is now launched by virtcontainers, it is necessary to specify the path to the proxy binary
in the pod configuration.

Fixes #478.

@jodh-intel
Copy link
Copy Markdown
Collaborator Author

Blocked on clearcontainers/proxy#167.

Comment thread api.go Outdated
}

// Start the proxy
err = p.createProxyProcess()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

You should move that into p.startVM(netNsPath) function, so that we don't expand too much CreatePod() and RunPod().

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

()Funnily enough, it was there originally, but I moved it out for clarity since startVM wasn't just starting the VM so the name was confusing. Also, it matched more closely how we handle the shims (p.startShims()).

On the topic of CreatePod() and RunPod(), I've just raised #486 to remove the duplication so how about we land that first and I can then rebase this PR and there won't be any duplication.

Comment thread api.go Outdated
return nil, err
}

err = p.waitForProxy()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Similar to createProxyProcess(), I think this should be moved to stopVM().

Comment thread pod.go Outdated
// cannot fail on Linux
proc, _ := os.FindProcess(pid)

_, err := proc.Wait()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We should add a timeout here.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good call.

Looking at this again, the code actually won't work as we can't guarantee the calling process (now) owns the cc-proxy instance (it's likely to have been reparented to PID 1).

Do we already have BKM code somewhere for a (deep breath) pid or/proc/$pid-sniffing loop? I'm pretty sure we used to a long time ago but can't find it atm.

Comment thread pod.go Outdated

// waitForProxy waits for the proxy process to finish
func (p *Pod) waitForProxy() error {
pid := p.proxyProcess.Pid
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I don't see any place where you save this info about the proxy PID. When DeletePod() will be called, I think that p.proxyProcess is going to be empty.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good catch - fixing...

@sboeuf sboeuf requested review from amshinde and sameo November 13, 2017 19:43
@sboeuf
Copy link
Copy Markdown
Collaborator

sboeuf commented Nov 13, 2017

clearcontainers/proxy#167 has been merged, there is no blocker left for this PR.

Comment thread cc_proxy.go

// construct the socket path the proxy instance will use
socketPath := filepath.Join(runStoragePath, pod.id, "proxy.sock")
uri := fmt.Sprintf("unix://%s", socketPath)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I wonder if we have to ensure proxy's socket mode is 600

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is just constructing a path to give to the proxy. The proxy itself creates the socket (with perms 0660) here:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ohh I see, thanks @jodh-intel for the link

Comment thread api.go Outdated
}

// Start the proxy
err = p.createProxyProcess()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nit: Could we call that one startProxy() for consistency with the shim part?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good call - fixing...

Comment thread pod.go Outdated

p.proxyProcess = newProcess("", pid)

p.Logger().WithField("proxy-pid", pid).Debug("proxy started")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'd add the pod ID as part of the log here.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Actually, Logger() will already add that for us ;)

Comment thread cc_proxy.go
socketPath := filepath.Join(runStoragePath, pod.id, "proxy.sock")
uri := fmt.Sprintf("unix://%s", socketPath)

args := []string{config.Path, "-uri", uri}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe we could modify the process comm here by using something like "proxy-%s", pod.ID.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

We already have pod.id in the path as the socket is placed into the pod-specific directory. We could also add the pod ID to the socket name, but if we do, we'd be getting very close to the 107 byte socket name limit.

@jodh-intel
Copy link
Copy Markdown
Collaborator Author

Branch updated with some simplifications... and more tests! 😄

@jodh-intel
Copy link
Copy Markdown
Collaborator Author

CI is failing due to the API breakage introduced by this PR (CCProxyConfig has changed).

@sboeuf
Copy link
Copy Markdown
Collaborator

sboeuf commented Nov 16, 2017

@jodh-intel then you have to submit the PR on the runtime and point this PR in your commit message.

James O. D. Hunt added 3 commits November 27, 2017 11:00
Quote the url values in the error for maximum clarity if a url is blank.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
Change the log message in startShims() to avoid a confusing
"shim-count: 0" log entry.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
Change "defaultCCProxyURL" to use a Clear Containers 3.x path, rather
than a 2.x one.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
jodh-intel pushed a commit to jodh-intel/runtime that referenced this pull request Nov 27, 2017
Test re-vendor for
containers/virtcontainers#483.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
jodh-intel pushed a commit to jodh-intel/runtime that referenced this pull request Nov 27, 2017
Update the runtime based on
containers/virtcontainers#483, and accompanying
changes for the virtcontainers API changes.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
jodh-intel pushed a commit to jodh-intel/runtime that referenced this pull request Nov 27, 2017
Test re-vendor for
containers/virtcontainers#483.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
jodh-intel pushed a commit to jodh-intel/runtime that referenced this pull request Nov 27, 2017
Update the runtime based on
containers/virtcontainers#483, and accompanying
changes for the virtcontainers API changes.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
jodh-intel pushed a commit to jodh-intel/runtime that referenced this pull request Nov 27, 2017
Update the runtime based on
containers/virtcontainers#483, and accompanying
changes for the virtcontainers API changes.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
@jodh-intel
Copy link
Copy Markdown
Collaborator Author

Hi @sboeuf - please can you take another look?

@sboeuf
Copy link
Copy Markdown
Collaborator

sboeuf commented Nov 27, 2017

@jodh-intel yes sure, let me check that right now

Create a proxy instance for each pod (virtual machine).

Since the proxy is now launched by virtcontainers,
it is necessary to specify the path to the proxy binary
in the pod configuration.

Depends-on: github.com/clearcontainers/runtime#833

Fixes containers#478.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
jodh-intel pushed a commit to jodh-intel/runtime that referenced this pull request Nov 27, 2017
Update the runtime based on
containers/virtcontainers#483, and accompanying
changes for the virtcontainers API changes.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
@jodh-intel
Copy link
Copy Markdown
Collaborator Author

@sboeuf - branch updated again.

@sboeuf
Copy link
Copy Markdown
Collaborator

sboeuf commented Nov 27, 2017

@jodh-intel thx, let me take a look !

@sboeuf
Copy link
Copy Markdown
Collaborator

sboeuf commented Nov 27, 2017

LGTM

@sboeuf
Copy link
Copy Markdown
Collaborator

sboeuf commented Nov 27, 2017

Thanks for the PR @jodh-intel, everything looks good now.
@sameo could you please take a look before I merge this ?

@sameo
Copy link
Copy Markdown
Collaborator

sameo commented Nov 28, 2017

LGTM

Approved with PullApprove Approved with PullApprove

@sameo sameo merged commit 9294388 into containers:master Nov 28, 2017
@sameo sameo removed the in progress label Nov 28, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants