Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Commit

Permalink
Add IPv6 assignment parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
sargun committed Aug 17, 2018
1 parent 7df7e22 commit 09ace36
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
8 changes: 8 additions & 0 deletions executor/runtime/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
17 changes: 16 additions & 1 deletion executor/runtime/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions executor/runtime/types/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit 09ace36

Please sign in to comment.