8000 [Feature] Extract GRPC Server (#1590) · arangodb/kube-arangodb@61cdd68 · GitHub
[go: up one dir, main page]

Skip to content

Commit 61cdd68

Browse files
authored
[Feature] Extract GRPC Server (#1590)
1 parent e67f5a0 commit 61cdd68

File tree

194 files changed

+1289
-739
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

194 files changed

+1289
-739
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Change Log
22

33
## [master](https://github.com/arangodb/kube-arangodb/tree/master) (N/A)
4+
- (Feature) Extract GRPC Server
45

56
## [1.2.37](https://github.com/arangodb/kube-arangodb/tree/1.2.37) (2024-01-22)
67
- (Documentation) Improve documentation rendering for GitHub Pages

cmd/admin.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -192,7 +192,7 @@ func getDeploymentAndCredentials(ctx context.Context,
192192

193193
client, ok := kclient.GetDefaultFactory().Client()
194194
if !ok {
195-
err = errors.Newf("Client not initialised")
195+
err = errors.Errorf("Client not initialised")
196196
return
197197
}
198198

@@ -337,7 +337,7 @@ func getCACertificate(ctx context.Context, secrets secretv1.ReadInterface, name
337337
func getDeployment(ctx context.Context, namespace, deplName string) (api.ArangoDeployment, error) {
338338
client, ok := kclient.GetDefaultFactory().Client()
339339
if !ok {
340-
return api.ArangoDeployment{}, errors.Newf("Client not initialised")
340+
return api.ArangoDeployment{}, errors.Errorf("Client not initialised")
341341
}
342342

343343
extCli := client.Arango()

cmd/cmd.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import (
3333
"time"
3434

3535
"github.com/gin-gonic/gin"
36-
"github.com/pkg/errors"
3736
"github.com/rs/zerolog"
3837
"github.com/spf13/cobra"
3938
flag "github.com/spf13/pflag"
@@ -59,7 +58,7 @@ import (
5958
"github.com/arangodb/kube-arangodb/pkg/server"
6059
"github.com/arangodb/kube-arangodb/pkg/util"
6160
"github.com/arangodb/kube-arangodb/pkg/util/constants"
62-< 48DA div class="diff-text-inner"> utilsError "github.com/arangodb/kube-arangodb/pkg/util/errors"
61+
"github.com/arangodb/kube-arangodb/pkg/util/errors"
6362
"github.com/arangodb/kube-arangodb/pkg/util/globals"
6463
operatorHTTP "github.com/arangodb/kube-arangodb/pkg/util/http"
6564
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
@@ -437,7 +436,7 @@ func executeMain(cmd *cobra.Command, args []string) {
437436
if err != nil {
438437
logger.Err(err).Fatal("Failed to create API server")
439438
}
440-
go utilsError.LogError(logger, "while running API server", apiServer.Run)
439+
go errors.LogError(logger, "while running API server", apiServer.Run)
441440
}
442441

443442
listenAddr := net.JoinHostPort(serverOptions.host, strconv.Itoa(serverOptions.port))
@@ -486,7 +485,7 @@ func executeMain(cmd *cobra.Command, args []string) {
486485
}); err != nil {
487486
logger.Err(err).Fatal("Failed to create HTTP server")
488487
} else {
489-
go utilsError.LogError(logger, "error while starting server", svr.Run)
488+
go errors.LogError(logger, "error while starting server", svr.Run)
490489
}
491490

492491
// startChaos(context.Background(), cfg.KubeCli, cfg.Namespace, chaosLevel)

cmd/crd.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -28,11 +28,11 @@ import (
2828
"strings"
2929
"time"
3030

31-
"github.com/pkg/errors"
3231
"github.com/spf13/cobra"
3332

3433
"github.com/arangodb/kube-arangodb/pkg/crd"
3534
"github.com/arangodb/kube-arangodb/pkg/crd/crds"
35+
"github.com/arangodb/kube-arangodb/pkg/util/errors"
3636
"github.com/arangodb/kube-arangodb/pkg/util/kclient"
3737
)
3838

cmd/init_container_version_check.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -24,9 +24,10 @@ import (
2424
"encoding/json"
2525
"os"
2626

27-
"github.com/pkg/errors"
2827
"github.com/rs/zerolog/log"
2928
"github.com/spf13/cobra"
29+
30+
"github.com/arangodb/kube-arangodb/pkg/util/errors"
3031
)
3132

3233
const cmdVersionCheckInitContainersInvalidVersionExitCode = 11

cmd/lifecycle_probes.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -30,7 +30,6 @@ import (
3030
"path"
3131
"strconv"
3232

33-
"github.com/pkg/errors"
3433
"github.com/rs/zerolog/log"
3534
"github.com/spf13/cobra"
3635

@@ -45,6 +44,7 @@ import (
4544
"github.com/arangodb/kube-arangodb/pkg/deployment/resources"
4645
"github.com/arangodb/kube-arangodb/pkg/util"
4746
"github.com/arangodb/kube-arangodb/pkg/util/constants"
47+
"github.com/arangodb/kube-arangodb/pkg/util/errors"
4848
)
4949

5050
const (

cmd/lifecycle_startup.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -21,14 +21,14 @@
2121
package cmd
2222

2323
import (
24-
"errors"
2524
"fmt"
2625
"net/http"
2726
"time"
2827

2928
"github.com/spf13/cobra"
3029

3130
shared "github.com/arangodb/kube-arangodb/pkg/apis/shared"
31+
"github.com/arangodb/kube-arangodb/pkg/util/errors"
3232
)
3333

3434
var cmdLifecycleStartup = &cobra.Command{

cmd/ml_storage.go

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,8 @@ import (
2525

2626
"github.com/rs/zerolog/log"
2727
"github.com/spf13/cobra"
28-
"google.golang.org/grpc"
2928

30-
pbShutdown "github.com/arangodb/kube-arangodb/pkg/api/shutdown/v1"
3129
"github.com/arangodb/kube-arangodb/pkg/ml/storage"
32-
"github.com/arangodb/kube-arangodb/pkg/util/probe"
3330
"github.com/arangodb/kube-arangodb/pkg/util/shutdown"
3431
"github.com/arangodb/kube-arangodb/pkg/util/svc"
3532
)
@@ -53,7 +50,7 @@ var (
5350
}
5451

5552
cmdMLStorageControllerOptions struct {
56-
svc.GRPCConfig
53+
Configuration svc.Configuration
5754
}
5855
)
5956

@@ -62,8 +59,8 @@ func init() {
6259
cmdMLStorage.AddCommand(cmdMLStorageS3)
6360

6461
f := cmdMLStorageS3.PersistentFlags()
65-
f.StringVar(&cmdMLStorageControllerOptions.ListenAddress, "controller.address", "", "Address the GRPC controller service will listen on (IP:port)")
66-
f.StringVar(&cmdMLStorageS3Options.ListenAddress, "server.address", "", "Address the GRPC service will listen on (IP:port)")
62+
f.StringVar(&cmdMLStorageControllerOptions.Configuration.Address, "controller.address", "", "Address the GRPC controller service will listen on (IP:port)")
63+
f.StringVar(&cmdMLStorageS3Options.Configuration.Address, "server.address", "", "Address the GRPC service will listen on (IP:port)")
6764

6865
f.StringVar(&cmdMLStorageS3Options.S3.Endpoint, "s3.endpoint", "", "Endpoint of S3 API implementation")
6966
f.StringVar(&cmdMLStorageS3Options.S3.CACrtFile, "s3.ca-crt", "", "Path to file containing CA certificate to validate endpoint connection")
@@ -84,16 +81,18 @@ func cmdMLStorageS3Run(cmd *cobra.Command, _ []string) {
8481
}
8582

8683
func cmdMLStorageS3RunE(_ *cobra.Command) error {
84+
health := svc.NewHealthService(cmdMLStorageControllerOptions.Configuration, svc.Readiness, shutdown.NewGlobalShutdownServer())
85+
86+
health.Start(shutdown.Context())
87+
8788
storageService, err := storage.NewService(shutdown.Context(), storage.StorageTypeS3Proxy, cmdMLStorageS3Options.ServiceConfig)
8889
if err != nil {
8990
return err
9091
}
9192

92-
healthService := probe.NewHealthService()
93+
svc := svc.NewService(cmdMLStorageS3Options.Configuration, storageService)
94+
95+
svcRun := svc.StartWithHealth(shutdown.Context(), health)
9396

94-
controllerService := svc.NewGRPC(cmdMLStorageControllerOptions.GRPCConfig, func(server *grpc.Server) {
95-
pbShutdown.RegisterShutdownServer(server, shutdown.NewShutdownableShutdownServer())
96-
healthService.Register(server)
97-
})
98-
return svc.RunServices(shutdown.Context(), healthService, storageService, controllerService)
97+
return svcRun.Wait()
9998
}

cmd/uuid.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -25,9 +25,10 @@ import (
2525
"os"
2626
"strings"
2727

28-
"github.com/pkg/errors"
2928
"github.com/rs/zerolog/log"
3029
"github.com/spf13/cobra"
30+
31+
"github.com/arangodb/kube-arangodb/pkg/util/errors"
3132
)
3233

3334
type cmdUUIDInputStruct struct {

internal/md/sections.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2023 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2023-2024 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -78,7 +78,7 @@ func ReplaceSection(in, replace, section string) (string, error) {
7878

7979
endID := strings.Index(in, end)
8080
if endID == -1 {
81-
return "", errors.Newf("END_INJECT sections is missing for section %s. Note that newline is required at the end and before tag", section)
81+
return "", errors.Errorf("END_INJECT sections is missing for section %s. Note that newline is required at the end and before tag", section)
8282
}
8383

8484
if strings.HasSuffix(replace, "\n\n") {

internal/md/table.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -53,7 +53,7 @@ func (t *table) AddRow(in map[Column]string) error {
5353

5454
for k, v := range in {
5555
if _, ok := t.columns.Get(k.ID()); !ok {
56-
return errors.Newf("Column not found")
56+
return errors.Errorf("Column not found")
5757
}
5858

5959
r[k.ID()] = v

pkg/api/tls.go

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/apps/v1/job_validate.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -32,11 +32,11 @@ func (a *ArangoJob) Validate() error {
3232

3333
func (a *ArangoJobSpec) Validate() error {
3434
if a.ArangoDeploymentName == "" {
35-
return errors.Newf("deployment name can not be empty")
35+
return errors.Errorf("deployment name can not be empty")
3636
}
3737

3838
if a.JobTemplate == nil {
39-
return errors.Newf("jobTemplate name can not be empty")
39+
return errors.Errorf("jobTemplate name can not be empty")
4040
}
4141

4242
return nil

pkg/apis/backup/v1/backup_policy_validate.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -38,9 +38,9 @@ func (a *ArangoBackupPolicy) Validate() error {
3838

3939
func (a *ArangoBackupPolicySpec) Validate() error {
4040
if expr, err := cron.ParseStandard(a.Schedule); err != nil {
41-
return errors.Newf("error while parsing expr: %s", err.Error())
41+
return errors.Errorf("error while parsing expr: %s", err.Error())
4242
} else if expr.Next(time.Now()).IsZero() {
43-
return errors.Newf("invalid schedule format")
43+
return errors.Errorf("invalid schedule format")
4444
}
4545

4646
return nil

pkg/apis/backup/v1/backup_validate.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// DISCLAIMER
33
//
4-
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
4+
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
55
//
66
// Licensed under the Apache License, Version 2.0 (the "License");
77
// you may not use this file except in compliance with the License.
@@ -38,7 +38,7 @@ func (a *ArangoBackup) Validate() error {
3838

3939
func (a *ArangoBackupSpec) Validate() error {
4040
if a.Deployment.Name == "" {
41-
return errors.Newf("deployment name can not be empty")
41+
return errors.Errorf("deployment name can not be empty")
4242
}
4343

4444
if a.Download != nil {
@@ -58,15 +58,15 @@ func (a *ArangoBackupSpec) Validate() error {
5858

5959
func (a *ArangoBackupSpecOperation) Validate() error {
6060
if a.RepositoryURL == "" {
61-
return errors.Newf("RepositoryURL can not be empty")
61+
return errors.Errorf("RepositoryURL can not be empty")
6262
}
6363

6464
return nil
6565
}
6666

6767
func (a *ArangoBackupSpecDownload) Validate() error {
6868
if a.ID == "" {
69-
return errors.Newf("ID can not be empty")
69+
return errors.Errorf("ID can not be empty")
7070
}
7171

7272
return a.ArangoBackupSpecOperation.Validate()

0 commit comments

Comments
 (0)
0