mirror of
https://github.com/arangodb/kube-arangodb.git
synced 2024-12-14 11:57:37 +00:00
[Bugfix] Fix ArangoSync Port (#954)
This commit is contained in:
parent
30ea984f9d
commit
ea2dc2ae3b
4 changed files with 99 additions and 33 deletions
|
@ -4,6 +4,7 @@
|
|||
- (Feature) Allow configuration for securityContext.runAsUser value
|
||||
- (Bugfix) Fix Satellite collections in Agency
|
||||
- (Bugfix) Fix backup creation timeout
|
||||
- (Bugfix) ArangoSync port fix
|
||||
|
||||
## [1.2.9](https://github.com/arangodb/kube-arangodb/tree/1.2.9) (2022-03-30)
|
||||
- (Feature) Improve Kubernetes clientsets management
|
||||
|
|
|
@ -34,7 +34,7 @@ import (
|
|||
inspectorInterface "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector"
|
||||
|
||||
core "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
|
||||
"github.com/arangodb/kube-arangodb/pkg/apis/shared"
|
||||
|
@ -68,6 +68,15 @@ func (r *Resources) EnsureServices(ctx context.Context, cachedStatus inspectorIn
|
|||
|
||||
// Ensure member services
|
||||
if err := status.Members.ForeachServerGroup(func(group api.ServerGroup, list api.MemberStatusList) error {
|
||||
var targetPort int32 = shared.ArangoPort
|
||||
|
||||
switch group {
|
||||
case api.ServerGroupSyncMasters:
|
||||
targetPort = shared.ArangoSyncMasterPort
|
||||
case api.ServerGroupSyncWorkers:
|
||||
targetPort = shared.ArangoSyncWorkerPort
|
||||
}
|
||||
|
||||
for _, m := range list {
|
||||
memberName := m.ArangoMemberName(r.context.GetAPIObject().GetName(), group)
|
||||
|
||||
|
@ -78,10 +87,10 @@ func (r *Resources) EnsureServices(ctx context.Context, cachedStatus inspectorIn
|
|||
|
||||
if s, ok := cachedStatus.Service().V1().GetSimple(member.GetName()); !ok {
|
||||
s = &core.Service{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
ObjectMeta: meta.ObjectMeta{
|
||||
Name: member.GetName(),
|
||||
Namespace: member.GetNamespace(),
|
||||
OwnerReferences: []metav1.OwnerReference{
|
||||
OwnerReferences: []meta.OwnerReference{
|
||||
member.AsOwner(),
|
||||
},
|
||||
},
|
||||
|
@ -92,7 +101,7 @@ func (r *Resources) EnsureServices(ctx context.Context, cachedStatus inspectorIn
|
|||
Name: "server",
|
||||
Protocol: "TCP",
|
||||
Port: shared.ArangoPort,
|
||||
TargetPort: intstr.IntOrString{IntVal: shared.ArangoPort},
|
||||
TargetPort: intstr.IntOrString{IntVal: targetPort},
|
||||
},
|
||||
},
|
||||
PublishNotReadyAddresses: true,
|
||||
|
@ -101,7 +110,7 @@ func (r *Resources) EnsureServices(ctx context.Context, cachedStatus inspectorIn
|
|||
}
|
||||
|
||||
err := globals.GetGlobalTimeouts().Kubernetes().RunWithTimeout(ctx, func(ctxChild context.Context) error {
|
||||
_, err := svcs.Create(ctxChild, s, metav1.CreateOptions{})
|
||||
_, err := svcs.Create(ctxChild, s, meta.CreateOptions{})
|
||||
return err
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -121,7 +130,7 @@ func (r *Resources) EnsureServices(ctx context.Context, cachedStatus inspectorIn
|
|||
Name: "server",
|
||||
Protocol: "TCP",
|
||||
Port: shared.ArangoPort,
|
||||
TargetPort: intstr.IntOrString{IntVal: shared.ArangoPort},
|
||||
TargetPort: intstr.IntOrString{IntVal: targetPort},
|
||||
},
|
||||
}
|
||||
spec.PublishNotReadyAddresses = true
|
||||
|
@ -131,7 +140,7 @@ func (r *Resources) EnsureServices(ctx context.Context, cachedStatus inspectorIn
|
|||
s.Spec = *spec
|
||||
|
||||
err := globals.GetGlobalTimeouts().Kubernetes().RunWithTimeout(ctx, func(ctxChild context.Context) error {
|
||||
_, err := svcs.Update(ctxChild, s, metav1.UpdateOptions{})
|
||||
_, err := svcs.Update(ctxChild, s, meta.UpdateOptions{})
|
||||
return err
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -296,7 +305,7 @@ func (r *Resources) ensureExternalAccessServices(ctx context.Context, cachedStat
|
|||
}
|
||||
if updateExternalAccessService && !createExternalAccessService && !deleteExternalAccessService {
|
||||
err := globals.GetGlobalTimeouts().Kubernetes().RunWithTimeout(ctx, func(ctxChild context.Context) error {
|
||||
_, err := svcs.Update(ctxChild, existing, metav1.UpdateOptions{})
|
||||
_, err := svcs.Update(ctxChild, existing, meta.UpdateOptions{})
|
||||
return err
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -314,7 +323,7 @@ func (r *Resources) ensureExternalAccessServices(ctx context.Context, cachedStat
|
|||
if deleteExternalAccessService {
|
||||
log.Info().Str("service", eaServiceName).Msgf("Removing obsolete %s external access service", title)
|
||||
err := globals.GetGlobalTimeouts().Kubernetes().RunWithTimeout(ctx, func(ctxChild context.Context) error {
|
||||
return svcs.Delete(ctxChild, eaServiceName, metav1.DeleteOptions{})
|
||||
return svcs.Delete(ctxChild, eaServiceName, meta.DeleteOptions{})
|
||||
})
|
||||
if err != nil {
|
||||
log.Debug().Err(err).Msgf("Failed to remove %s external access service", title)
|
||||
|
|
|
@ -69,6 +69,11 @@ func containersCompare(_ api.DeploymentSpec, _ api.ServerGroup, spec, status *co
|
|||
}
|
||||
}
|
||||
|
||||
if !equality.Semantic.DeepEqual(ac.Ports, bc.Ports) {
|
||||
bc.Ports = ac.Ports
|
||||
mode = mode.And(SilentRotation)
|
||||
}
|
||||
|
||||
if !areProbesEqual(ac.StartupProbe, bc.StartupProbe) {
|
||||
bc.StartupProbe = ac.StartupProbe
|
||||
mode = mode.And(SilentRotation)
|
||||
|
|
|
@ -24,7 +24,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
core "k8s.io/api/core/v1"
|
||||
|
||||
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
|
||||
"github.com/arangodb/kube-arangodb/pkg/apis/shared"
|
||||
|
@ -63,10 +63,10 @@ func Test_InitContainers(t *testing.T) {
|
|||
testCases := []TestCase{
|
||||
{
|
||||
name: "Same containers",
|
||||
spec: buildPodSpec(addInitContainer(api.ServerGroupReservedInitContainerNameUUID, nil), addInitContainer("sidecar", func(c *v1.Container) {
|
||||
spec: buildPodSpec(addInitContainer(api.ServerGroupReservedInitContainerNameUUID, nil), addInitContainer("sidecar", func(c *core.Container) {
|
||||
c.Image = "local:1.0"
|
||||
})),
|
||||
status: buildPodSpec(addInitContainer(api.ServerGroupReservedInitContainerNameUUID, nil), addInitContainer("sidecar", func(c *v1.Container) {
|
||||
status: buildPodSpec(addInitContainer(api.ServerGroupReservedInitContainerNameUUID, nil), addInitContainer("sidecar", func(c *core.Container) {
|
||||
c.Image = "local:1.0"
|
||||
})),
|
||||
|
||||
|
@ -80,10 +80,10 @@ func Test_InitContainers(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "Containers with different image",
|
||||
spec: buildPodSpec(addInitContainer(api.ServerGroupReservedInitContainerNameUUID, nil), addInitContainer("sidecar", func(c *v1.Container) {
|
||||
spec: buildPodSpec(addInitContainer(api.ServerGroupReservedInitContainerNameUUID, nil), addInitContainer("sidecar", func(c *core.Container) {
|
||||
c.Image = "local:1.0"
|
||||
})),
|
||||
status: buildPodSpec(addInitContainer(api.ServerGroupReservedInitContainerNameUUID, nil), addInitContainer("sidecar", func(c *v1.Container) {
|
||||
status: buildPodSpec(addInitContainer(api.ServerGroupReservedInitContainerNameUUID, nil), addInitContainer("sidecar", func(c *core.Container) {
|
||||
c.Image = "local:2.0"
|
||||
})),
|
||||
|
||||
|
@ -104,10 +104,10 @@ func Test_InitContainers(t *testing.T) {
|
|||
testCases := []TestCase{
|
||||
{
|
||||
name: "Containers with different image but init rotation enforced",
|
||||
spec: buildPodSpec(addInitContainer(api.ServerGroupReservedInitContainerNameUUID, nil), addInitContainer("sidecar", func(c *v1.Container) {
|
||||
spec: buildPodSpec(addInitContainer(api.ServerGroupReservedInitContainerNameUUID, nil), addInitContainer("sidecar", func(c *core.Container) {
|
||||
c.Image = "local:1.0"
|
||||
})),
|
||||
status: buildPodSpec(addInitContainer(api.ServerGroupReservedInitContainerNameUUID, nil), addInitContainer("sidecar", func(c *v1.Container) {
|
||||
status: buildPodSpec(addInitContainer(api.ServerGroupReservedInitContainerNameUUID, nil), addInitContainer("sidecar", func(c *core.Container) {
|
||||
c.Image = "local:2.0"
|
||||
})),
|
||||
|
||||
|
@ -121,14 +121,14 @@ func Test_InitContainers(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "Core Containers with different image but init rotation enforced",
|
||||
spec: buildPodSpec(addInitContainer(api.ServerGroupReservedInitContainerNameUUID, func(c *v1.Container) {
|
||||
spec: buildPodSpec(addInitContainer(api.ServerGroupReservedInitContainerNameUUID, func(c *core.Container) {
|
||||
c.Image = "local:1.0"
|
||||
}), addInitContainer("sidecar", func(c *v1.Container) {
|
||||
}), addInitContainer("sidecar", func(c *core.Container) {
|
||||
c.Image = "local:1.0"
|
||||
})),
|
||||
status: buildPodSpec(addInitContainer(api.ServerGroupReservedInitContainerNameUUID, func(c *v1.Container) {
|
||||
status: buildPodSpec(addInitContainer(api.ServerGroupReservedInitContainerNameUUID, func(c *core.Container) {
|
||||
c.Image = "local:2.0"
|
||||
}), addInitContainer("sidecar", func(c *v1.Container) {
|
||||
}), addInitContainer("sidecar", func(c *core.Container) {
|
||||
c.Image = "local:1.0"
|
||||
})),
|
||||
|
||||
|
@ -142,12 +142,12 @@ func Test_InitContainers(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "Only core container change",
|
||||
spec: buildPodSpec(addInitContainer(api.ServerGroupReservedInitContainerNameUUID, func(c *v1.Container) {
|
||||
spec: buildPodSpec(addInitContainer(api.ServerGroupReservedInitContainerNameUUID, func(c *core.Container) {
|
||||
c.Image = "local:1.0"
|
||||
}), addInitContainer(api.ServerGroupReservedInitContainerNameUpgrade, func(c *v1.Container) {
|
||||
}), addInitContainer(api.ServerGroupReservedInitContainerNameUpgrade, func(c *core.Container) {
|
||||
c.Image = "local:1.0"
|
||||
})),
|
||||
status: buildPodSpec(addInitContainer(api.ServerGroupReservedInitContainerNameUUID, func(c *v1.Container) {
|
||||
status: buildPodSpec(addInitContainer(api.ServerGroupReservedInitContainerNameUUID, func(c *core.Container) {
|
||||
c.Image = "local:2.0"
|
||||
})),
|
||||
|
||||
|
@ -161,16 +161,16 @@ func Test_InitContainers(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "Only core container change with sidecar",
|
||||
spec: buildPodSpec(addInitContainer(api.ServerGroupReservedInitContainerNameUUID, func(c *v1.Container) {
|
||||
spec: buildPodSpec(addInitContainer(api.ServerGroupReservedInitContainerNameUUID, func(c *core.Container) {
|
||||
c.Image = "local:1.0"
|
||||
}), addInitContainer(api.ServerGroupReservedInitContainerNameUpgrade, func(c *v1.Container) {
|
||||
}), addInitContainer(api.ServerGroupReservedInitContainerNameUpgrade, func(c *core.Container) {
|
||||
c.Image = "local:1.0"
|
||||
}), addInitContainer("sidecar", func(c *v1.Container) {
|
||||
}), addInitContainer("sidecar", func(c *core.Container) {
|
||||
c.Image = "local:1.0"
|
||||
})),
|
||||
status: buildPodSpec(addInitContainer(api.ServerGroupReservedInitContainerNameUUID, func(c *v1.Container) {
|
||||
status: buildPodSpec(addInitContainer(api.ServerGroupReservedInitContainerNameUUID, func(c *core.Container) {
|
||||
c.Image = "local:2.0"
|
||||
}), addInitContainer("sidecar", func(c *v1.Container) {
|
||||
}), addInitContainer("sidecar", func(c *core.Container) {
|
||||
c.Image = "local:1.0"
|
||||
})),
|
||||
|
||||
|
@ -184,16 +184,16 @@ func Test_InitContainers(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "Only core container change with sidecar change",
|
||||
spec: buildPodSpec(addInitContainer(api.ServerGroupReservedInitContainerNameUUID, func(c *v1.Container) {
|
||||
spec: buildPodSpec(addInitContainer(api.ServerGroupReservedInitContainerNameUUID, func(c *core.Container) {
|
||||
c.Image = "local:1.0"
|
||||
}), addInitContainer(api.ServerGroupReservedInitContainerNameUpgrade, func(c *v1.Container) {
|
||||
}), addInitContainer(api.ServerGroupReservedInitContainerNameUpgrade, func(c *core.Container) {
|
||||
c.Image = "local:1.0"
|
||||
}), addInitContainer("sidecar", func(c *v1.Container) {
|
||||
}), addInitContainer("sidecar", func(c *core.Container) {
|
||||
c.Image = "local:1.0"
|
||||
})),
|
||||
status: buildPodSpec(addInitContainer(api.ServerGroupReservedInitContainerNameUUID, func(c *v1.Container) {
|
||||
status: buildPodSpec(addInitContainer(api.ServerGroupReservedInitContainerNameUUID, func(c *core.Container) {
|
||||
c.Image = "local:2.0"
|
||||
}), addInitContainer("sidecar", func(c *v1.Container) {
|
||||
}), addInitContainer("sidecar", func(c *core.Container) {
|
||||
c.Image = "local:2.0"
|
||||
})),
|
||||
|
||||
|
@ -271,6 +271,57 @@ func Test_Container_Args(t *testing.T) {
|
|||
runTestCases(t)(testCases...)
|
||||
}
|
||||
|
||||
func Test_Container_Ports(t *testing.T) {
|
||||
testCases := []TestCase{
|
||||
{
|
||||
name: "Ports of server pod changed",
|
||||
spec: buildPodSpec(addContainer("server", func(c *core.Container) {
|
||||
c.Ports = []core.ContainerPort{
|
||||
{
|
||||
Name: "server",
|
||||
ContainerPort: 8526,
|
||||
Protocol: "tcp",
|
||||
},
|
||||
}
|
||||
})),
|
||||
status: buildPodSpec(addContainer("server", func(c *core.Container) {
|
||||
c.Ports = []core.ContainerPort{
|
||||
{
|
||||
Name: "server",
|
||||
ContainerPort: 8626,
|
||||
Protocol: "tcp",
|
||||
},
|
||||
}
|
||||
})),
|
||||
expectedMode: SilentRotation,
|
||||
},
|
||||
{
|
||||
name: "Ports of sidecar pod changed",
|
||||
spec: buildPodSpec(addContainer("sidecar", func(c *core.Container) {
|
||||
c.Ports = []core.ContainerPort{
|
||||
{
|
||||
Name: "server",
|
||||
ContainerPort: 8526,
|
||||
Protocol: "tcp",
|
||||
},
|
||||
}
|
||||
})),
|
||||
status: buildPodSpec(addContainer("sidecar", func(c *core.Container) {
|
||||
c.Ports = []core.ContainerPort{
|
||||
{
|
||||
Name: "server",
|
||||
ContainerPort: 8626,
|
||||
Protocol: "tcp",
|
||||
},
|
||||
}
|
||||
})),
|
||||
expectedMode: GracefulRotation,
|
||||
},
|
||||
}
|
||||
|
||||
runTestCases(t)(testCases...)
|
||||
}
|
||||
|
||||
func TestIsOnlyLogLevelChanged(t *testing.T) {
|
||||
type args struct {
|
||||
specArgs []string
|
||||
|
|
Loading…
Reference in a new issue