mirror of
				https://github.com/moby/moby.git
				synced 2022-11-09 12:21:53 -05:00 
			
		
		
		
	Fix netns path setting from hook
Previously hook expected data with a wrong type. Full netns path is not included with the data passed with the hook. Fixes #829 Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
		
							parent
							
								
									82b88f274a
								
							
						
					
					
						commit
						880d0ada95
					
				
					 3 changed files with 5 additions and 11 deletions
				
			
		| 
						 | 
					@ -1232,10 +1232,6 @@ func TestExternalKey(t *testing.T) {
 | 
				
			||||||
	externalKeyTest(t, false)
 | 
						externalKeyTest(t, false)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func TestExternalKeyWithReexec(t *testing.T) {
 | 
					 | 
				
			||||||
	externalKeyTest(t, true)
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func externalKeyTest(t *testing.T, reexec bool) {
 | 
					func externalKeyTest(t *testing.T, reexec bool) {
 | 
				
			||||||
	if !testutils.IsRunningInContainer() {
 | 
						if !testutils.IsRunningInContainer() {
 | 
				
			||||||
		defer testutils.SetupTestOSContext(t)()
 | 
							defer testutils.SetupTestOSContext(t)()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -12,7 +12,6 @@ import (
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/Sirupsen/logrus"
 | 
						"github.com/Sirupsen/logrus"
 | 
				
			||||||
	"github.com/docker/libnetwork/types"
 | 
						"github.com/docker/libnetwork/types"
 | 
				
			||||||
	"github.com/opencontainers/runc/libcontainer"
 | 
					 | 
				
			||||||
	"github.com/opencontainers/runc/libcontainer/configs"
 | 
						"github.com/opencontainers/runc/libcontainer/configs"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -21,7 +20,7 @@ const success = "success"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// processSetKeyReexec is a private function that must be called only on an reexec path
 | 
					// processSetKeyReexec is a private function that must be called only on an reexec path
 | 
				
			||||||
// It expects 3 args { [0] = "libnetwork-setkey", [1] = <container-id>, [2] = <controller-id> }
 | 
					// It expects 3 args { [0] = "libnetwork-setkey", [1] = <container-id>, [2] = <controller-id> }
 | 
				
			||||||
// It also expects libcontainer.State as a json string in <stdin>
 | 
					// It also expects configs.HookState as a json string in <stdin>
 | 
				
			||||||
// Refer to https://github.com/opencontainers/runc/pull/160/ for more information
 | 
					// Refer to https://github.com/opencontainers/runc/pull/160/ for more information
 | 
				
			||||||
func processSetKeyReexec() {
 | 
					func processSetKeyReexec() {
 | 
				
			||||||
	var err error
 | 
						var err error
 | 
				
			||||||
| 
						 | 
					@ -40,20 +39,19 @@ func processSetKeyReexec() {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	containerID := os.Args[1]
 | 
						containerID := os.Args[1]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// We expect libcontainer.State as a json string in <stdin>
 | 
						// We expect configs.HookState as a json string in <stdin>
 | 
				
			||||||
	stateBuf, err := ioutil.ReadAll(os.Stdin)
 | 
						stateBuf, err := ioutil.ReadAll(os.Stdin)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	var state libcontainer.State
 | 
						var state configs.HookState
 | 
				
			||||||
	if err = json.Unmarshal(stateBuf, &state); err != nil {
 | 
						if err = json.Unmarshal(stateBuf, &state); err != nil {
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	controllerID := os.Args[2]
 | 
						controllerID := os.Args[2]
 | 
				
			||||||
	key := state.NamespacePaths[configs.NamespaceType("NEWNET")]
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = SetExternalKey(controllerID, containerID, key)
 | 
						err = SetExternalKey(controllerID, containerID, fmt.Sprintf("/proc/%d/ns/net", state.Pid))
 | 
				
			||||||
	return
 | 
						return
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -11,7 +11,7 @@ import (
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// processSetKeyReexec is a private function that must be called only on an reexec path
 | 
					// processSetKeyReexec is a private function that must be called only on an reexec path
 | 
				
			||||||
// It expects 3 args { [0] = "libnetwork-setkey", [1] = <container-id>, [2] = <controller-id> }
 | 
					// It expects 3 args { [0] = "libnetwork-setkey", [1] = <container-id>, [2] = <controller-id> }
 | 
				
			||||||
// It also expects libcontainer.State as a json string in <stdin>
 | 
					// It also expects configs.HookState as a json string in <stdin>
 | 
				
			||||||
// Refer to https://github.com/opencontainers/runc/pull/160/ for more information
 | 
					// Refer to https://github.com/opencontainers/runc/pull/160/ for more information
 | 
				
			||||||
func processSetKeyReexec() {
 | 
					func processSetKeyReexec() {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue