debug: add env var flag K3D_DEBUG_DISABLE_DOCKER_INIT to test k3s as pid 1
This commit is contained in:
parent
d21882a01c
commit
81a41bdab1
@ -25,6 +25,8 @@ package docker
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/containerd/containerd/log"
|
"github.com/containerd/containerd/log"
|
||||||
@ -44,10 +46,16 @@ import (
|
|||||||
|
|
||||||
// TranslateNodeToContainer translates a k3d node specification to a docker container representation
|
// TranslateNodeToContainer translates a k3d node specification to a docker container representation
|
||||||
func TranslateNodeToContainer(node *k3d.Node) (*NodeInDocker, error) {
|
func TranslateNodeToContainer(node *k3d.Node) (*NodeInDocker, error) {
|
||||||
|
init := true
|
||||||
|
if disableInit, err := strconv.ParseBool(os.Getenv("K3D_DEBUG_DISABLE_DOCKER_INIT")); err == nil && disableInit {
|
||||||
|
l.Log().Traceln("docker-init disabled for all containers")
|
||||||
|
init = false
|
||||||
|
}
|
||||||
|
|
||||||
/* initialize everything that we need */
|
/* initialize everything that we need */
|
||||||
containerConfig := docker.Config{}
|
containerConfig := docker.Config{}
|
||||||
hostConfig := docker.HostConfig{
|
hostConfig := docker.HostConfig{
|
||||||
Init: &[]bool{true}[0],
|
Init: &init,
|
||||||
ExtraHosts: node.ExtraHosts,
|
ExtraHosts: node.ExtraHosts,
|
||||||
}
|
}
|
||||||
networkingConfig := network.NetworkingConfig{}
|
networkingConfig := network.NetworkingConfig{}
|
||||||
|
@ -23,6 +23,8 @@ THE SOFTWARE.
|
|||||||
package docker
|
package docker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
|
"strconv"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/go-test/deep"
|
"github.com/go-test/deep"
|
||||||
@ -58,6 +60,9 @@ func TestTranslateNodeToContainer(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
init := true
|
init := true
|
||||||
|
if disableInit, err := strconv.ParseBool(os.Getenv("K3D_DEBUG_DISABLE_DOCKER_INIT")); err == nil && disableInit {
|
||||||
|
init = false
|
||||||
|
}
|
||||||
|
|
||||||
expectedRepresentation := &NodeInDocker{
|
expectedRepresentation := &NodeInDocker{
|
||||||
ContainerConfig: container.Config{
|
ContainerConfig: container.Config{
|
||||||
|
Loading…
Reference in New Issue
Block a user