Skip to content

Commit

Permalink
Merge pull request #285 from arangodb/feature/disable-ipv6
Browse files Browse the repository at this point in the history
IPv6 revisited
  • Loading branch information
neunhoef authored Oct 31, 2018
2 parents 94d7ae8 + 41e15a4 commit 3fab871
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 19 deletions.
2 changes: 1 addition & 1 deletion docs/Manual/Deployment/Kubernetes/DeploymentResource.md
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ servers.
When not specified, no monitoring token is used.
The default value is empty.

### `spec.disableIPV6: bool`
### `spec.disableIPv6: bool`

This setting prevents the use of IPv6 addresses by ArangoDB servers.
The default is `false`.
Expand Down
22 changes: 11 additions & 11 deletions pkg/apis/deployment/v1alpha/deployment_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ type DeploymentSpec struct {
Image *string `json:"image,omitempty"`
ImagePullPolicy *v1.PullPolicy `json:"imagePullPolicy,omitempty"`
DowntimeAllowed *bool `json:"downtimeAllowed,omitempty"`
DisableIPV6 *bool `json:"disableIPV6,omitempty"`
DisableIPv6 *bool `json:"disableIPv6,omitempty"`

ExternalAccess ExternalAccessSpec `json:"externalAccess"`
RocksDB RocksDBSpec `json:"rocksdb"`
Expand Down Expand Up @@ -99,14 +99,14 @@ func (s DeploymentSpec) IsDowntimeAllowed() bool {
return util.BoolOrDefault(s.DowntimeAllowed)
}

// IsDisableIPV6 returns the value of disableIPV6.
func (s DeploymentSpec) IsDisableIPV6() bool {
return util.BoolOrDefault(s.DisableIPV6)
// IsDisableIPv6 returns the value of disableIPv6.
func (s DeploymentSpec) IsDisableIPv6() bool {
return util.BoolOrDefault(s.DisableIPv6)
}

// GetListenAddr returns "[::]" or "0.0.0.0" depending on IsDisableIPV6
// GetListenAddr returns "[::]" or "0.0.0.0" depending on IsDisableIPv6
func (s DeploymentSpec) GetListenAddr() string {
if s.IsDisableIPV6() {
if s.IsDisableIPv6() {
return "0.0.0.0"
}
return "[::]"
Expand Down Expand Up @@ -194,8 +194,8 @@ func (s *DeploymentSpec) SetDefaultsFrom(source DeploymentSpec) {
if s.DowntimeAllowed == nil {
s.DowntimeAllowed = util.NewBoolOrNil(source.DowntimeAllowed)
}
if s.DisableIPV6 == nil {
s.DisableIPV6 = util.NewBoolOrNil(source.DisableIPV6)
if s.DisableIPv6 == nil {
s.DisableIPv6 = util.NewBoolOrNil(source.DisableIPv6)
}
s.ExternalAccess.SetDefaultsFrom(source.ExternalAccess)
s.RocksDB.SetDefaultsFrom(source.RocksDB)
Expand Down Expand Up @@ -286,9 +286,9 @@ func (s DeploymentSpec) ResetImmutableFields(target *DeploymentSpec) []string {
target.StorageEngine = NewStorageEngineOrNil(s.StorageEngine)
resetFields = append(resetFields, "storageEngine")
}
if s.IsDisableIPV6() != target.IsDisableIPV6() {
target.DisableIPV6 = util.NewBoolOrNil(s.DisableIPV6)
resetFields = append(resetFields, "disableIPV6")
if s.IsDisableIPv6() != target.IsDisableIPv6() {
target.DisableIPv6 = util.NewBoolOrNil(s.DisableIPv6)
resetFields = append(resetFields, "disableIPv6")
}
if l := s.ExternalAccess.ResetImmutableFields("externalAccess", &target.ExternalAccess); l != nil {
resetFields = append(resetFields, l...)
Expand Down
8 changes: 4 additions & 4 deletions pkg/apis/deployment/v1alpha/deployment_spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ func TestDeploymentSpecResetImmutableFields(t *testing.T) {
[]string{"mode", "agents.count"},
},
{
DeploymentSpec{DisableIPV6: util.NewBool(false)},
DeploymentSpec{DisableIPV6: util.NewBool(true)},
DeploymentSpec{DisableIPV6: util.NewBool(false)},
DeploymentSpec{DisableIPv6: util.NewBool(false)},
DeploymentSpec{DisableIPv6: util.NewBool(true)},
DeploymentSpec{DisableIPv6: util.NewBool(false)},
false,
[]string{"disableIPV6"},
[]string{"disableIPv6"},
},
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/deployment/v1alpha/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions scripts/kube_run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ kubectl --namespace ${DEPLOYMENTNAMESPACE} \
--env="ARANGODIMAGE=${ARANGODIMAGE}" \
--env="TEST_NAMESPACE=${DEPLOYMENTNAMESPACE}" \
--env="CLEANDEPLOYMENTS=${CLEANDEPLOYMENTS}" \
--env="TESTDISABLEIPV6=${TESTDISABLEIPV6}" \
-- \
-test.v -test.timeout $TESTTIMEOUT $TESTLENGTHOPTIONS $TESTOPTIONS
7 changes: 6 additions & 1 deletion tests/test_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ import (

api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha"
"github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned"
"github.com/arangodb/kube-arangodb/pkg/util"
"github.com/arangodb/kube-arangodb/pkg/util/arangod"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
"github.com/arangodb/kube-arangodb/pkg/util/retry"
"github.com/arangodb/kube-arangodb/pkg/util"
)

const (
Expand Down Expand Up @@ -271,6 +271,11 @@ func newDeployment(name string) *api.ArangoDeployment {
depl.Spec.Image = util.NewString(image)
}

disableIPv6 := strings.TrimSpace(os.Getenv("TESTDISABLEIPV6"))
if disableIPv6 != "" && disableIPv6 != "0" {
depl.Spec.DisableIPv6 = util.NewBool(true)
}

return depl
}

Expand Down

0 comments on commit 3fab871

Please sign in to comment.