diff --git a/executor/runtime/docker/docker.go b/executor/runtime/docker/docker.go index 2bf5be6cd..e94c40cf6 100644 --- a/executor/runtime/docker/docker.go +++ b/executor/runtime/docker/docker.go @@ -652,6 +652,14 @@ func prepareNetworkDriver(parentCtx context.Context, cfg Config, c *runtimeTypes "--batch-size", strconv.Itoa(cfg.batchSize), } + assignIPv6Address, err := c.AssignIPv6Address() + if err != nil { + return err + } + if assignIPv6Address { + args = append(args, "--allocate-ipv6-address=true") + } + // This blocks, and ignores kills. if !c.TitusInfo.GetIgnoreLaunchGuard() { args = append(args, "--wait-for-sg-lock-timeout", cfg.waitForSecurityGroupLockTimeout.String()) diff --git a/executor/runtime/types/types.go b/executor/runtime/types/types.go index a5401d314..77fa8cae8 100644 --- a/executor/runtime/types/types.go +++ b/executor/runtime/types/types.go @@ -24,7 +24,8 @@ import ( const ( hostnameStyleParam = "titusParameter.agent.hostnameStyle" // FuseEnabledParam is a container atttribute set to enable FUSE - FuseEnabledParam = "titusParameter.agent.fuseEnabled" + FuseEnabledParam = "titusParameter.agent.fuseEnabled" + assignIPv6AddressParam = "titusParameter.agent.assignIPv6Address" ) // ErrMissingIAMRole indicates that the Titus job was submitted without an IAM role @@ -263,6 +264,20 @@ func (c *Container) GetFuseEnabled() (bool, error) { return val, nil } +// AssignIPv6Address determines whether the container should be assigned an IPv6 address +func (c *Container) AssignIPv6Address() (bool, error) { + assignIPv6AddressStr, ok := c.TitusInfo.GetPassthroughAttributes()[assignIPv6AddressParam] + if !ok { + return false, nil + } + val, err := strconv.ParseBool(assignIPv6AddressStr) + if err != nil { + return false, err + } + + return val, nil +} + // Resources specify constraints to be applied to a Container type Resources struct { Mem int64 // in MiB diff --git a/executor/runtime/types/types_test.go b/executor/runtime/types/types_test.go index e52d31b2d..606a516f5 100644 --- a/executor/runtime/types/types_test.go +++ b/executor/runtime/types/types_test.go @@ -134,3 +134,23 @@ func TestInvalidHostnameStyle(t *testing.T) { assert.NotNil(t, err) assert.IsType(t, &InvalidConfigurationError{}, err) } + +func TestDefaultIPv6AddressAssignment(t *testing.T) { + c := Container{ + TitusInfo: &titus.ContainerInfo{}, + } + assignIPv6Address, err := c.AssignIPv6Address() + assert.NoError(t, err) + assert.False(t, assignIPv6Address) +} + +func TestIPv6AddressAssignment(t *testing.T) { + c := Container{ + TitusInfo: &titus.ContainerInfo{ + PassthroughAttributes: map[string]string{assignIPv6AddressParam: "true"}, + }, + } + assignIPv6Address, err := c.AssignIPv6Address() + assert.NoError(t, err) + assert.True(t, assignIPv6Address) +}