Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Conversation

@ZhaoXuqiang
Copy link
Contributor

@ZhaoXuqiang ZhaoXuqiang commented Aug 24, 2017

share a pod with existing container, with --net container:xxx
get shared container by compare pid with exist running container's Pid which found from container's state file

Signed-off-by: Zhang Wei [email protected]
Signed-off-by: ZhaoXuqiang [email protected]

@ZhaoXuqiang ZhaoXuqiang changed the title Enable pod support [WRP] Enable pod support Aug 24, 2017
@ZhaoXuqiang ZhaoXuqiang changed the title [WRP] Enable pod support [WIP] Enable pod support Aug 24, 2017
@ZhaoXuqiang ZhaoXuqiang force-pushed the enable-pod-support branch 2 times, most recently from 6121774 to fc950c4 Compare August 24, 2017 12:09
@ZhaoXuqiang ZhaoXuqiang changed the title [WIP] Enable pod support Enable pod support Aug 25, 2017
@ZhaoXuqiang ZhaoXuqiang force-pushed the enable-pod-support branch 2 times, most recently from cf04158 to cee61ca Compare August 25, 2017 06:54
@WeiZhang555
Copy link
Contributor

Please modify your commit message to describe more about this modifcations, also remove "cherry-pick from cfd4695 and 81d42e4", 81d42e4 isn't included in these codes and is outdated so you don't need to mention it. @ZhaoXuqiang

share a pod with existing container, with `--net container:xxx`

get shared container by compare pid with exist running container's Pid which found from container's state file

Signed-off-by: Zhang Wei <[email protected]>
Signed-off-by: ZhaoXuqiang <[email protected]>
if err != nil {
return fmt.Errorf("The container %q is not ready", sharedContainer)
if sharedContainer, err = findSharedContainer(context.GlobalString("root"), ns.Path); err != nil {
return fmt.Errorf("failed to find shared container: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you keep

-				_, err = os.Stat(filepath.Join(root, sharedContainer, stateJSON))
 -				if err != nil {
 -					return fmt.Errorf("The container %q is not existing or not ready", sharedContainer)
 -				}
 -				_, err = os.Stat(filepath.Join(root, sharedContainer, "namespace"))
 -				if err != nil {
 -					return fmt.Errorf("The container %q is not ready", sharedContainer)

This piece of code is used for validation, I think it's still useful.

Copy link
Contributor Author

@ZhaoXuqiang ZhaoXuqiang Aug 26, 2017

Choose a reason for hiding this comment

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

I think it's not useful.

 	if sharedContainer != "" {
 		scState, err = loadStateFile(root, sharedContainer)
 		if err != nil {
 			return err
 		}
 		vm, lockFile, err = getSandbox(filepath.Join(context.GlobalString("root"), sharedContainer, "sandbox"))
 		if err != nil {
 			return err
 		}
 	}
func loadStateFile(root, container string) (*State, error) {
	stateFile := filepath.Join(root, container, stateJSON)
	file, err := os.Open(stateFile)
	if err != nil {
		return nil, err
	}
	defer file.Close()

	var state State
	if err = json.NewDecoder(file).Decode(&state); err != nil {
		return nil, fmt.Errorf("Decode state file %s error: %s", stateFile, err.Error())
	}
	return &state, nil
}

loadStateFile will confirm the state file exist.
namespace file is not used.

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like it's OK then.

ping @laijs

@laijs
Copy link
Contributor

laijs commented Aug 27, 2017

LGTM

@laijs laijs merged commit 8ad7e33 into hyperhq:master Aug 27, 2017
jimoosciuc pushed a commit to jimoosciuc/runv that referenced this pull request May 26, 2020
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.

3 participants