Skip to content

Commit

Permalink
OAS-9904 Introduce ArangoDeployment Gateway Group
Browse files Browse the repository at this point in the history
  • Loading branch information
jwierzbo committed Aug 20, 2024
1 parent a257c4f commit d9737e4
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
1 change: 0 additions & 1 deletion pkg/apis/shared/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ const (
ArangoPort = 8529
ArangoSyncMasterPort = 8629
ArangoSyncWorkerPort = 8729
ArangoGatewayPort = 10000
ArangoExporterPort = 9101

ArangoExporterStatusEndpoint = "/_api/version"
Expand Down
6 changes: 4 additions & 2 deletions pkg/deployment/pod/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func GenerateMemberEndpoint(services service.Inspector, apiObject meta.Object, s
}

func GenerateMemberEndpointFromService(svc *core.Service, apiObject meta.Object, spec api.DeploymentSpec, group api.ServerGroup, member api.MemberStatus) (string, error) {
if group.IsArangod() {
if group.IsArangod() || group.IsGateway() {
switch method := spec.CommunicationMethod.Get(); method {
case api.DeploymentCommunicationMethodDNS, api.DeploymentCommunicationMethodHeadlessDNS:
return k8sutil.CreateServiceDNSNameWithDomain(svc, spec.ClusterDomain), nil
Expand All @@ -60,7 +60,9 @@ func GenerateMemberEndpointFromService(svc *core.Service, apiObject meta.Object,
default:
return k8sutil.CreatePodDNSNameWithDomain(apiObject, spec.ClusterDomain, group.AsRole(), member.ID), nil
}
} else {
} else if group.IsArangosync() {
return k8sutil.CreateSyncMasterClientServiceDNSNameWithDomain(apiObject, spec.ClusterDomain), nil
} else {
return "", errors.Errorf("Unknown group %s", group.AsRole())
}
}
2 changes: 1 addition & 1 deletion pkg/deployment/resources/pod_creator_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (a *ArangoGatewayContainer) GetName() string {
}

func (a *ArangoGatewayContainer) GetPorts() []core.ContainerPort {
port := shared.ArangoGatewayPort
port := shared.ArangoPort

return []core.ContainerPort{
{
Expand Down
12 changes: 5 additions & 7 deletions pkg/deployment/resources/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ func (r *Resources) EnsureServices(ctx context.Context, cachedStatus inspectorIn
defer metrics.SetDuration(inspectServicesDurationGauges.WithLabelValues(deploymentName), start)
counterMetric := inspectedServicesCounters.WithLabelValues(deploymentName)

if spec.IsGatewayEnabled() {
role = api.ServerGroupGateways.AsRole()
}

// Fetch existing services
svcs := cachedStatus.ServicesModInterface().V1()
amInspector := cachedStatus.ArangoMember().V1()
Expand Down Expand Up @@ -130,7 +134,7 @@ func (r *Resources) EnsureServices(ctx context.Context, cachedStatus inspectorIn

// Group Services
for _, group := range api.AllServerGroups {
if !group.Enabled(spec.GetMode()) {
if !group.Enabled(spec.GetMode()) && !group.IsGateway() {
continue
}

Expand Down Expand Up @@ -189,11 +193,6 @@ func (r *Resources) EnsureServices(ctx context.Context, cachedStatus inspectorIn
counterMetric.Inc()
headlessPorts, headlessSelector := k8sutil.HeadlessServiceDetails(deploymentName)

// todo
/* if spec.IsGatewayEnabled() {
// set headlessSelector to point to gateway
}*/

if s, exists := cachedStatus.Service().V1().GetSimple(k8sutil.CreateHeadlessServiceName(deploymentName)); !exists {
ctxChild, cancel := globals.GetGlobalTimeouts().Kubernetes().WithTimeout(ctx)
defer cancel()
Expand Down Expand Up @@ -261,7 +260,6 @@ func (r *Resources) EnsureServices(ctx context.Context, cachedStatus inspectorIn
return errors.WithStack(err)
}

//todo
if r.context.IsSyncEnabled() {
// External (and internal) Sync master service
counterMetric.Inc()
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/k8sutil/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const (
LabelKeyArangoScheduled = "deployment.arangodb.com/scheduled"
// LabelKeyArangoTopology is the key of the label used to store the ArangoDeployment topology ID in
LabelKeyArangoTopology = "deployment.arangodb.com/topology"
// LabelKeyArangoLeader is the key of the label used to store the current leader of a group instances.
// LabelKeyArangoLeader is the key of the label used to store the current leader of a group instances. AF only.
LabelKeyArangoLeader = "deployment.arangodb.com/leader"
// LabelKeyArangoActive is the key of the label used to mark members as active.
LabelKeyArangoActive = "deployment.arangodb.com/active"
Expand Down

0 comments on commit d9737e4

Please sign in to comment.