1
0
Fork 0
mirror of https://github.com/arangodb/kube-arangodb.git synced 2024-12-14 11:57:37 +00:00

[Feature] Extract GRPC Server (#1590)

This commit is contained in:
Adam Janikowski 2024-02-08 15:25:48 +01:00 committed by GitHub
parent e67f5a0f58
commit 61cdd68e89
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
194 changed files with 1295 additions and 745 deletions

View file

@ -1,6 +1,7 @@
# Change Log
## [master](https://github.com/arangodb/kube-arangodb/tree/master) (N/A)
- (Feature) Extract GRPC Server
## [1.2.37](https://github.com/arangodb/kube-arangodb/tree/1.2.37) (2024-01-22)
- (Documentation) Improve documentation rendering for GitHub Pages

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -192,7 +192,7 @@ func getDeploymentAndCredentials(ctx context.Context,
client, ok := kclient.GetDefaultFactory().Client()
if !ok {
err = errors.Newf("Client not initialised")
err = errors.Errorf("Client not initialised")
return
}
@ -337,7 +337,7 @@ func getCACertificate(ctx context.Context, secrets secretv1.ReadInterface, name
func getDeployment(ctx context.Context, namespace, deplName string) (api.ArangoDeployment, error) {
client, ok := kclient.GetDefaultFactory().Client()
if !ok {
return api.ArangoDeployment{}, errors.Newf("Client not initialised")
return api.ArangoDeployment{}, errors.Errorf("Client not initialised")
}
extCli := client.Arango()

View file

@ -33,7 +33,6 @@ import (
"time"
"github.com/gin-gonic/gin"
"github.com/pkg/errors"
"github.com/rs/zerolog"
"github.com/spf13/cobra"
flag "github.com/spf13/pflag"
@ -59,7 +58,7 @@ import (
"github.com/arangodb/kube-arangodb/pkg/server"
"github.com/arangodb/kube-arangodb/pkg/util"
"github.com/arangodb/kube-arangodb/pkg/util/constants"
utilsError "github.com/arangodb/kube-arangodb/pkg/util/errors"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
"github.com/arangodb/kube-arangodb/pkg/util/globals"
operatorHTTP "github.com/arangodb/kube-arangodb/pkg/util/http"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
@ -437,7 +436,7 @@ func executeMain(cmd *cobra.Command, args []string) {
if err != nil {
logger.Err(err).Fatal("Failed to create API server")
}
go utilsError.LogError(logger, "while running API server", apiServer.Run)
go errors.LogError(logger, "while running API server", apiServer.Run)
}
listenAddr := net.JoinHostPort(serverOptions.host, strconv.Itoa(serverOptions.port))
@ -486,7 +485,7 @@ func executeMain(cmd *cobra.Command, args []string) {
}); err != nil {
logger.Err(err).Fatal("Failed to create HTTP server")
} else {
go utilsError.LogError(logger, "error while starting server", svr.Run)
go errors.LogError(logger, "error while starting server", svr.Run)
}
// startChaos(context.Background(), cfg.KubeCli, cfg.Namespace, chaosLevel)

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -28,11 +28,11 @@ import (
"strings"
"time"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/arangodb/kube-arangodb/pkg/crd"
"github.com/arangodb/kube-arangodb/pkg/crd/crds"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
"github.com/arangodb/kube-arangodb/pkg/util/kclient"
)

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -24,9 +24,10 @@ import (
"encoding/json"
"os"
"github.com/pkg/errors"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
)
const cmdVersionCheckInitContainersInvalidVersionExitCode = 11

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -30,7 +30,6 @@ import (
"path"
"strconv"
"github.com/pkg/errors"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
@ -45,6 +44,7 @@ import (
"github.com/arangodb/kube-arangodb/pkg/deployment/resources"
"github.com/arangodb/kube-arangodb/pkg/util"
"github.com/arangodb/kube-arangodb/pkg/util/constants"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
)
const (

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -21,7 +21,6 @@
package cmd
import (
"errors"
"fmt"
"net/http"
"time"
@ -29,6 +28,7 @@ import (
"github.com/spf13/cobra"
shared "github.com/arangodb/kube-arangodb/pkg/apis/shared"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
)
var cmdLifecycleStartup = &cobra.Command{

View file

@ -25,11 +25,8 @@ import (
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"google.golang.org/grpc"
pbShutdown "github.com/arangodb/kube-arangodb/pkg/api/shutdown/v1"
"github.com/arangodb/kube-arangodb/pkg/ml/storage"
"github.com/arangodb/kube-arangodb/pkg/util/probe"
"github.com/arangodb/kube-arangodb/pkg/util/shutdown"
"github.com/arangodb/kube-arangodb/pkg/util/svc"
)
@ -53,7 +50,7 @@ var (
}
cmdMLStorageControllerOptions struct {
svc.GRPCConfig
Configuration svc.Configuration
}
)
@ -62,8 +59,8 @@ func init() {
cmdMLStorage.AddCommand(cmdMLStorageS3)
f := cmdMLStorageS3.PersistentFlags()
f.StringVar(&cmdMLStorageControllerOptions.ListenAddress, "controller.address", "", "Address the GRPC controller service will listen on (IP:port)")
f.StringVar(&cmdMLStorageS3Options.ListenAddress, "server.address", "", "Address the GRPC service will listen on (IP:port)")
f.StringVar(&cmdMLStorageControllerOptions.Configuration.Address, "controller.address", "", "Address the GRPC controller service will listen on (IP:port)")
f.StringVar(&cmdMLStorageS3Options.Configuration.Address, "server.address", "", "Address the GRPC service will listen on (IP:port)")
f.StringVar(&cmdMLStorageS3Options.S3.Endpoint, "s3.endpoint", "", "Endpoint of S3 API implementation")
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) {
}
func cmdMLStorageS3RunE(_ *cobra.Command) error {
health := svc.NewHealthService(cmdMLStorageControllerOptions.Configuration, svc.Readiness, shutdown.NewGlobalShutdownServer())
health.Start(shutdown.Context())
storageService, err := storage.NewService(shutdown.Context(), storage.StorageTypeS3Proxy, cmdMLStorageS3Options.ServiceConfig)
if err != nil {
return err
}
healthService := probe.NewHealthService()
svc := svc.NewService(cmdMLStorageS3Options.Configuration, storageService)
controllerService := svc.NewGRPC(cmdMLStorageControllerOptions.GRPCConfig, func(server *grpc.Server) {
pbShutdown.RegisterShutdownServer(server, shutdown.NewShutdownableShutdownServer())
healthService.Register(server)
})
return svc.RunServices(shutdown.Context(), healthService, storageService, controllerService)
svcRun := svc.StartWithHealth(shutdown.Context(), health)
return svcRun.Wait()
}

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -25,9 +25,10 @@ import (
"os"
"strings"
"github.com/pkg/errors"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
)
type cmdUUIDInputStruct struct {

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2023-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -78,7 +78,7 @@ func ReplaceSection(in, replace, section string) (string, error) {
endID := strings.Index(in, end)
if endID == -1 {
return "", errors.Newf("END_INJECT sections is missing for section %s. Note that newline is required at the end and before tag", section)
return "", errors.Errorf("END_INJECT sections is missing for section %s. Note that newline is required at the end and before tag", section)
}
if strings.HasSuffix(replace, "\n\n") {

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// 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 {
for k, v := range in {
if _, ok := t.columns.Get(k.ID()); !ok {
return errors.Newf("Column not found")
return errors.Errorf("Column not found")
}
r[k.ID()] = v

6
pkg/api/tls.go generated
View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -56,11 +56,11 @@ func loadOrSelfSignCertificate(cli typedCore.CoreV1Interface, cfg ServerConfig)
}
certBytes, found := s.Data[core.TLSCertKey]
if !found {
return "", "", errors.Newf("No %s found in secret %s", core.TLSCertKey, cfg.TLSSecretName)
return "", "", errors.Errorf("No %s found in secret %s", core.TLSCertKey, cfg.TLSSecretName)
}
keyBytes, found := s.Data[core.TLSPrivateKeyKey]
if !found {
return "", "", errors.Newf("No %s found in secret %s", core.TLSPrivateKeyKey, cfg.TLSSecretName)
return "", "", errors.Errorf("No %s found in secret %s", core.TLSPrivateKeyKey, cfg.TLSSecretName)
}
return string(certBytes), string(keyBytes), nil
}

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -32,11 +32,11 @@ func (a *ArangoJob) Validate() error {
func (a *ArangoJobSpec) Validate() error {
if a.ArangoDeploymentName == "" {
return errors.Newf("deployment name can not be empty")
return errors.Errorf("deployment name can not be empty")
}
if a.JobTemplate == nil {
return errors.Newf("jobTemplate name can not be empty")
return errors.Errorf("jobTemplate name can not be empty")
}
return nil

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -38,9 +38,9 @@ func (a *ArangoBackupPolicy) Validate() error {
func (a *ArangoBackupPolicySpec) Validate() error {
if expr, err := cron.ParseStandard(a.Schedule); err != nil {
return errors.Newf("error while parsing expr: %s", err.Error())
return errors.Errorf("error while parsing expr: %s", err.Error())
} else if expr.Next(time.Now()).IsZero() {
return errors.Newf("invalid schedule format")
return errors.Errorf("invalid schedule format")
}
return nil

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -38,7 +38,7 @@ func (a *ArangoBackup) Validate() error {
func (a *ArangoBackupSpec) Validate() error {
if a.Deployment.Name == "" {
return errors.Newf("deployment name can not be empty")
return errors.Errorf("deployment name can not be empty")
}
if a.Download != nil {
@ -58,7 +58,7 @@ func (a *ArangoBackupSpec) Validate() error {
func (a *ArangoBackupSpecOperation) Validate() error {
if a.RepositoryURL == "" {
return errors.Newf("RepositoryURL can not be empty")
return errors.Errorf("RepositoryURL can not be empty")
}
return nil
@ -66,7 +66,7 @@ func (a *ArangoBackupSpecOperation) Validate() error {
func (a *ArangoBackupSpecDownload) Validate() error {
if a.ID == "" {
return errors.Newf("ID can not be empty")
return errors.Errorf("ID can not be empty")
}
return a.ArangoBackupSpecOperation.Validate()

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -23,10 +23,10 @@ package v1
import (
"runtime"
"github.com/pkg/errors"
core "k8s.io/api/core/v1"
shared "github.com/arangodb/kube-arangodb/pkg/apis/shared"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
)
// ArangoDeploymentArchitecture defines the list of supported architectures.

View file

@ -92,12 +92,12 @@ func (b *BootstrapSpec) Validate() error {
for username, secretname := range b.PasswordSecretNames {
// Remove this restriction as soon as we can bootstrap databases
if username != UserNameRoot {
return errors.Newf("only username `root` allowed in passwordSecretNames")
return errors.Errorf("only username `root` allowed in passwordSecretNames")
}
if secretname.IsNone() {
if username != UserNameRoot {
return errors.Newf("magic value None not allowed for %s", username)
return errors.Errorf("magic value None not allowed for %s", username)
}
} else {
if err := shared.ValidateResourceName(string(secretname)); err != nil {

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -21,9 +21,8 @@
package v1
import (
"github.com/pkg/errors"
shared "github.com/arangodb/kube-arangodb/pkg/apis/shared"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
)
type ArangoClusterSynchronizationSpec struct {

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -23,8 +23,9 @@ package v1
import (
"testing"
"github.com/pkg/errors"
"github.com/stretchr/testify/require"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
)
func Test_ACS_KubeConfigSpec(t *testing.T) {

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -40,7 +40,7 @@ func (d DeploymentImageDiscoveryModeSpec) Validate() error {
case DeploymentImageDiscoveryDirectMode:
return nil
default:
return errors.Newf("mode %s is not supported", d)
return errors.Errorf("mode %s is not supported", d)
}
}

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -100,12 +100,12 @@ func (s ExternalAccessSpec) Validate() error {
if s.AdvertisedEndpoint != nil {
ep := s.GetAdvertisedEndpoint()
if _, err := url.Parse(ep); err != nil {
return errors.WithStack(errors.Newf("Failed to parse advertised endpoint '%s': %s", ep, err))
return errors.WithStack(errors.Errorf("Failed to parse advertised endpoint '%s': %s", ep, err))
}
}
for _, x := range s.LoadBalancerSourceRanges {
if _, _, err := net.ParseCIDR(x); err != nil {
return errors.WithStack(errors.Newf("Failed to parse loadbalancer source range '%s': %s", x, err))
return errors.WithStack(errors.Errorf("Failed to parse loadbalancer source range '%s': %s", x, err))
}
}
return nil

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -183,7 +183,7 @@ func (l MemberStatusList) SelectMemberToRemove(selectors ...MemberToRemoveSelect
if member, ok := l.ElementByID(m); ok {
return member, nil
} else {
return MemberStatus{}, errors.Newf("Unable to find member with id %s", m)
return MemberStatus{}, errors.Errorf("Unable to find member with id %s", m)
}
}
}

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -47,7 +47,7 @@ func (s *ServerGroupIndexMethod) Validate() error {
case ServerGroupIndexMethodRandom, ServerGroupIndexMethodOrdered:
return nil
default:
return errors.Newf("Unknown IndexMethod %s", v)
return errors.Errorf("Unknown IndexMethod %s", v)
}
}

View file

@ -48,7 +48,7 @@ func IsReservedServerGroupInitContainerName(name string) bool {
func ValidateServerGroupInitContainerName(name string) error {
if IsReservedServerGroupInitContainerName(name) {
return errors.Newf("InitContainer name %s is restricted", name)
return errors.Errorf("InitContainer name %s is restricted", name)
}
return sharedApi.AsKubernetesResourceName(&name).Validate()
@ -73,7 +73,7 @@ func (s *ServerGroupInitContainerMode) Validate() error {
case ServerGroupInitContainerIgnoreMode, ServerGroupInitContainerUpdateMode:
return nil
default:
return errors.Newf("Unknown serverGroupInitContainerMode %s", v)
return errors.Errorf("Unknown serverGroupInitContainerMode %s", v)
}
}

View file

@ -563,14 +563,14 @@ func (s *ServerGroupSpec) validateVolumes() error {
for _, mount := range s.VolumeMounts {
if _, ok := volumes[mount.Name]; !ok {
return errors.Newf("Volume %s is not defined, but required by mount", mount.Name)
return errors.Errorf("Volume %s is not defined, but required by mount", mount.Name)
}
}
for _, container := range s.InitContainers.GetContainers() {
for _, mount := range container.VolumeMounts {
if _, ok := volumes[mount.Name]; !ok {
return errors.Newf("Volume %s is not defined, but required by mount in init container %s", mount.Name, container.Name)
return errors.Errorf("Volume %s is not defined, but required by mount in init container %s", mount.Name, container.Name)
}
}
}
@ -578,7 +578,7 @@ func (s *ServerGroupSpec) validateVolumes() error {
for _, container := range s.Sidecars {
for _, mount := range s.VolumeMounts {
if _, ok := volumes[mount.Name]; !ok {
return errors.Newf("Volume %s is not defined, but required by mount in sidecar %s", mount.Name, container.Name)
return errors.Errorf("Volume %s is not defined, but required by mount in sidecar %s", mount.Name, container.Name)
}
}
}

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -20,7 +20,7 @@
package v1
import "github.com/pkg/errors"
import "github.com/arangodb/kube-arangodb/pkg/util/errors"
// ServerGroupPortProtocol define supported protocols of listeners
type ServerGroupPortProtocol string

View file

@ -87,14 +87,14 @@ func (s ServerGroupSpecVolumes) Validate() error {
for volumeName, count := range mappedVolumes {
if IsRestrictedVolumeName(volumeName) {
validationErrors = append(validationErrors, errors.Newf("volume with name %s is restricted", volumeName))
validationErrors = append(validationErrors, errors.Errorf("volume with name %s is restricted", volumeName))
}
if count == 1 {
continue
}
validationErrors = append(validationErrors, errors.Newf("volume with name %s defined more than once: %d", volumeName, count))
validationErrors = append(validationErrors, errors.Errorf("volume with name %s defined more than once: %d", volumeName, count))
}
return shared.WithErrors(validationErrors...)
@ -202,11 +202,11 @@ func (s *ServerGroupSpecVolume) validate() error {
count := s.notNilFields()
if count == 0 {
return errors.Newf("at least one option need to be defined: secret, configMap or emptyDir")
return errors.Errorf("at least one option need to be defined: secret, configMap or emptyDir")
}
if count > 1 {
return errors.Newf("only one option can be defined: secret, configMap or emptyDir")
return errors.Errorf("only one option can be defined: secret, configMap or emptyDir")
}
return nil

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -77,19 +77,19 @@ func (s SyncExternalAccessSpec) Validate() error {
}
for _, ep := range s.MasterEndpoint {
if u, err := url.Parse(ep); err != nil {
return errors.WithStack(errors.Newf("Failed to parse master endpoint '%s': %s", ep, err))
return errors.WithStack(errors.Errorf("Failed to parse master endpoint '%s': %s", ep, err))
} else {
if u.Scheme != "http" && u.Scheme != "https" {
return errors.WithStack(errors.Newf("Invalid scheme '%s' in master endpoint '%s'", u.Scheme, ep))
return errors.WithStack(errors.Errorf("Invalid scheme '%s' in master endpoint '%s'", u.Scheme, ep))
}
if u.Host == "" {
return errors.WithStack(errors.Newf("Missing host in master endpoint '%s'", ep))
return errors.WithStack(errors.Errorf("Missing host in master endpoint '%s'", ep))
}
}
}
for _, name := range s.AccessPackageSecretNames {
if err := shared.ValidateResourceName(name); err != nil {
return errors.WithStack(errors.Newf("Invalid name '%s' in accessPackageSecretNames: %s", name, err))
return errors.WithStack(errors.Errorf("Invalid name '%s' in accessPackageSecretNames: %s", name, err))
}
}
return nil

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -40,7 +40,7 @@ func (s TLSSNISpec) Validate() error {
for _, value := range values {
if _, exists := mapped[value]; exists {
return errors.Newf("sni for host %s is already defined", value)
return errors.Errorf("sni for host %s is already defined", value)
}
// Mark value as existing

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -125,7 +125,7 @@ func (s TLSSpec) GetParsedAltNames() (dnsNames, ipAddresses, emailAddresses []st
} else if validation.IsValidEmailAddress(name) {
emailAddresses = append(emailAddresses, name)
} else {
return nil, nil, nil, errors.WithStack(errors.Newf("'%s' is not a valid alternate name", name))
return nil, nil, nil, errors.WithStack(errors.Errorf("'%s' is not a valid alternate name", name))
}
}
return dnsNames, ipAddresses, emailAddresses, nil

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -26,7 +26,7 @@ import (
"strconv"
"strings"
"github.com/pkg/errors"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
)
var _ json.Marshaler = Version{}

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -23,10 +23,10 @@ package v2alpha1
import (
"runtime"
"github.com/pkg/errors"
core "k8s.io/api/core/v1"
shared "github.com/arangodb/kube-arangodb/pkg/apis/shared"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
)
// ArangoDeploymentArchitecture defines the list of supported architectures.

View file

@ -92,12 +92,12 @@ func (b *BootstrapSpec) Validate() error {
for username, secretname := range b.PasswordSecretNames {
// Remove this restriction as soon as we can bootstrap databases
if username != UserNameRoot {
return errors.Newf("only username `root` allowed in passwordSecretNames")
return errors.Errorf("only username `root` allowed in passwordSecretNames")
}
if secretname.IsNone() {
if username != UserNameRoot {
return errors.Newf("magic value None not allowed for %s", username)
return errors.Errorf("magic value None not allowed for %s", username)
}
} else {
if err := shared.ValidateResourceName(string(secretname)); err != nil {

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -21,9 +21,8 @@
package v2alpha1
import (
"github.com/pkg/errors"
shared "github.com/arangodb/kube-arangodb/pkg/apis/shared"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
)
type ArangoClusterSynchronizationSpec struct {

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -23,8 +23,9 @@ package v2alpha1
import (
"testing"
"github.com/pkg/errors"
"github.com/stretchr/testify/require"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
)
func Test_ACS_KubeConfigSpec(t *testing.T) {

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -40,7 +40,7 @@ func (d DeploymentImageDiscoveryModeSpec) Validate() error {
case DeploymentImageDiscoveryDirectMode:
return nil
default:
return errors.Newf("mode %s is not supported", d)
return errors.Errorf("mode %s is not supported", d)
}
}

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -100,12 +100,12 @@ func (s ExternalAccessSpec) Validate() error {
if s.AdvertisedEndpoint != nil {
ep := s.GetAdvertisedEndpoint()
if _, err := url.Parse(ep); err != nil {
return errors.WithStack(errors.Newf("Failed to parse advertised endpoint '%s': %s", ep, err))
return errors.WithStack(errors.Errorf("Failed to parse advertised endpoint '%s': %s", ep, err))
}
}
for _, x := range s.LoadBalancerSourceRanges {
if _, _, err := net.ParseCIDR(x); err != nil {
return errors.WithStack(errors.Newf("Failed to parse loadbalancer source range '%s': %s", x, err))
return errors.WithStack(errors.Errorf("Failed to parse loadbalancer source range '%s': %s", x, err))
}
}
return nil

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -183,7 +183,7 @@ func (l MemberStatusList) SelectMemberToRemove(selectors ...MemberToRemoveSelect
if member, ok := l.ElementByID(m); ok {
return member, nil
} else {
return MemberStatus{}, errors.Newf("Unable to find member with id %s", m)
return MemberStatus{}, errors.Errorf("Unable to find member with id %s", m)
}
}
}

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -47,7 +47,7 @@ func (s *ServerGroupIndexMethod) Validate() error {
case ServerGroupIndexMethodRandom, ServerGroupIndexMethodOrdered:
return nil
default:
return errors.Newf("Unknown IndexMethod %s", v)
return errors.Errorf("Unknown IndexMethod %s", v)
}
}

View file

@ -48,7 +48,7 @@ func IsReservedServerGroupInitContainerName(name string) bool {
func ValidateServerGroupInitContainerName(name string) error {
if IsReservedServerGroupInitContainerName(name) {
return errors.Newf("InitContainer name %s is restricted", name)
return errors.Errorf("InitContainer name %s is restricted", name)
}
return sharedApi.AsKubernetesResourceName(&name).Validate()
@ -73,7 +73,7 @@ func (s *ServerGroupInitContainerMode) Validate() error {
case ServerGroupInitContainerIgnoreMode, ServerGroupInitContainerUpdateMode:
return nil
default:
return errors.Newf("Unknown serverGroupInitContainerMode %s", v)
return errors.Errorf("Unknown serverGroupInitContainerMode %s", v)
}
}

View file

@ -563,14 +563,14 @@ func (s *ServerGroupSpec) validateVolumes() error {
for _, mount := range s.VolumeMounts {
if _, ok := volumes[mount.Name]; !ok {
return errors.Newf("Volume %s is not defined, but required by mount", mount.Name)
return errors.Errorf("Volume %s is not defined, but required by mount", mount.Name)
}
}
for _, container := range s.InitContainers.GetContainers() {
for _, mount := range container.VolumeMounts {
if _, ok := volumes[mount.Name]; !ok {
return errors.Newf("Volume %s is not defined, but required by mount in init container %s", mount.Name, container.Name)
return errors.Errorf("Volume %s is not defined, but required by mount in init container %s", mount.Name, container.Name)
}
}
}
@ -578,7 +578,7 @@ func (s *ServerGroupSpec) validateVolumes() error {
for _, container := range s.Sidecars {
for _, mount := range s.VolumeMounts {
if _, ok := volumes[mount.Name]; !ok {
return errors.Newf("Volume %s is not defined, but required by mount in sidecar %s", mount.Name, container.Name)
return errors.Errorf("Volume %s is not defined, but required by mount in sidecar %s", mount.Name, container.Name)
}
}
}

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -20,7 +20,7 @@
package v2alpha1
import "github.com/pkg/errors"
import "github.com/arangodb/kube-arangodb/pkg/util/errors"
// ServerGroupPortProtocol define supported protocols of listeners
type ServerGroupPortProtocol string

View file

@ -87,14 +87,14 @@ func (s ServerGroupSpecVolumes) Validate() error {
for volumeName, count := range mappedVolumes {
if IsRestrictedVolumeName(volumeName) {
validationErrors = append(validationErrors, errors.Newf("volume with name %s is restricted", volumeName))
validationErrors = append(validationErrors, errors.Errorf("volume with name %s is restricted", volumeName))
}
if count == 1 {
continue
}
validationErrors = append(validationErrors, errors.Newf("volume with name %s defined more than once: %d", volumeName, count))
validationErrors = append(validationErrors, errors.Errorf("volume with name %s defined more than once: %d", volumeName, count))
}
return shared.WithErrors(validationErrors...)
@ -202,11 +202,11 @@ func (s *ServerGroupSpecVolume) validate() error {
count := s.notNilFields()
if count == 0 {
return errors.Newf("at least one option need to be defined: secret, configMap or emptyDir")
return errors.Errorf("at least one option need to be defined: secret, configMap or emptyDir")
}
if count > 1 {
return errors.Newf("only one option can be defined: secret, configMap or emptyDir")
return errors.Errorf("only one option can be defined: secret, configMap or emptyDir")
}
return nil

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -77,19 +77,19 @@ func (s SyncExternalAccessSpec) Validate() error {
}
for _, ep := range s.MasterEndpoint {
if u, err := url.Parse(ep); err != nil {
return errors.WithStack(errors.Newf("Failed to parse master endpoint '%s': %s", ep, err))
return errors.WithStack(errors.Errorf("Failed to parse master endpoint '%s': %s", ep, err))
} else {
if u.Scheme != "http" && u.Scheme != "https" {
return errors.WithStack(errors.Newf("Invalid scheme '%s' in master endpoint '%s'", u.Scheme, ep))
return errors.WithStack(errors.Errorf("Invalid scheme '%s' in master endpoint '%s'", u.Scheme, ep))
}
if u.Host == "" {
return errors.WithStack(errors.Newf("Missing host in master endpoint '%s'", ep))
return errors.WithStack(errors.Errorf("Missing host in master endpoint '%s'", ep))
}
}
}
for _, name := range s.AccessPackageSecretNames {
if err := shared.ValidateResourceName(name); err != nil {
return errors.WithStack(errors.Newf("Invalid name '%s' in accessPackageSecretNames: %s", name, err))
return errors.WithStack(errors.Errorf("Invalid name '%s' in accessPackageSecretNames: %s", name, err))
}
}
return nil

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -40,7 +40,7 @@ func (s TLSSNISpec) Validate() error {
for _, value := range values {
if _, exists := mapped[value]; exists {
return errors.Newf("sni for host %s is already defined", value)
return errors.Errorf("sni for host %s is already defined", value)
}
// Mark value as existing

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -125,7 +125,7 @@ func (s TLSSpec) GetParsedAltNames() (dnsNames, ipAddresses, emailAddresses []st
} else if validation.IsValidEmailAddress(name) {
emailAddresses = append(emailAddresses, name)
} else {
return nil, nil, nil, errors.WithStack(errors.Newf("'%s' is not a valid alternate name", name))
return nil, nil, nil, errors.WithStack(errors.Errorf("'%s' is not a valid alternate name", name))
}
}
return dnsNames, ipAddresses, emailAddresses, nil

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -26,7 +26,7 @@ import (
"strconv"
"strings"
"github.com/pkg/errors"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
)
var _ json.Marshaler = Version{}

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2023-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -35,16 +35,16 @@ type ArangoMLBatchJobSpec struct {
func (a *ArangoMLBatchJobSpec) Validate() error {
if a == nil {
return errors.Newf("Spec is not defined")
return errors.Errorf("Spec is not defined")
}
var err []error
if a.JobSpec == nil {
return shared.PrefixResourceErrors("spec", errors.Newf("JobSpec is not defined"))
return shared.PrefixResourceErrors("spec", errors.Errorf("JobSpec is not defined"))
}
if len(a.JobSpec.Template.Spec.Containers) != 1 {
err = append(err, shared.PrefixResourceErrors("spec.template.spec.containers", errors.Newf("Exactly one container is required")))
err = append(err, shared.PrefixResourceErrors("spec.template.spec.containers", errors.Errorf("Exactly one container is required")))
}
return shared.WithErrors(err...)

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2023-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -35,17 +35,17 @@ type ArangoMLCronJobSpec struct {
func (a *ArangoMLCronJobSpec) Validate() error {
if a == nil {
return errors.Newf("Spec is not defined")
return errors.Errorf("Spec is not defined")
}
var err []error
if a.CronJobSpec == nil {
return shared.PrefixResourceErrors("spec", errors.Newf("CronJobSpec is not defined"))
return shared.PrefixResourceErrors("spec", errors.Errorf("CronJobSpec is not defined"))
}
if len(a.CronJobSpec.JobTemplate.Spec.Template.Spec.Containers) != 1 {
err = append(err, shared.PrefixResourceErrors("spec.jobTemplate.spec.template.spec.containers",
errors.Newf("Exactly one container is required")))
errors.Errorf("Exactly one container is required")))
}
return shared.WithErrors(err...)

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2023-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -147,7 +147,7 @@ func (s *ArangoMLExtensionSpecDeployment) Validate() error {
}
if s.GetReplicas() < 0 || s.GetReplicas() > 10 {
errs = append(errs, shared.PrefixResourceErrors("replicas", errors.Newf("out of range [0, 10]")))
errs = append(errs, shared.PrefixResourceErrors("replicas", errors.Errorf("out of range [0, 10]")))
}
var usedPorts util.List[int32]
@ -161,7 +161,7 @@ func (s *ArangoMLExtensionSpecDeployment) Validate() error {
port := component.GetPort(GetArangoMLExtensionSpecDeploymentComponentDefaultPort(prefix))
if port == 0 {
errs = append(errs, shared.PrefixResourceErrors(prefix, errors.Newf("port not defined")))
errs = append(errs, shared.PrefixResourceErrors(prefix, errors.Errorf("port not defined")))
continue
}
@ -169,7 +169,7 @@ func (s *ArangoMLExtensionSpecDeployment) Validate() error {
return i == port
})
if duplicateCount > 0 {
errs = append(errs, shared.PrefixResourceErrors(prefix, errors.Newf("port %d already specified for other component", port)))
errs = append(errs, shared.PrefixResourceErrors(prefix, errors.Errorf("port %d already specified for other component", port)))
} else {
usedPorts.Append(port)
}

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2023-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -93,7 +93,7 @@ func (a *ArangoMLExtensionSpecMetadataServiceLocal) Validate() error {
// If Nil then we use default
return shared.WithErrors(
shared.PrefixResourceErrors("arangoPipeDatabase", util.BoolSwitch(a.GetArangoPipeDatabase() != ArangoMLExtensionSpecMetadataServiceLocalDefaultArangoPipeDatabase, errors.Newf("Database name is hardcoded"), nil)),
shared.PrefixResourceErrors("arangoMLFeatureStore", util.BoolSwitch(a.GetArangoMLFeatureStoreDatabase() != ArangoMLExtensionSpecMetadataServiceLocalDefaultArangoMLFeatureStoreDatabase, errors.Newf("Database name is hardcoded"), nil)),
shared.PrefixResourceErrors("arangoPipeDatabase", util.BoolSwitch(a.GetArangoPipeDatabase() != ArangoMLExtensionSpecMetadataServiceLocalDefaultArangoPipeDatabase, errors.Errorf("Database name is hardcoded"), nil)),
shared.PrefixResourceErrors("arangoMLFeatureStore", util.BoolSwitch(a.GetArangoMLFeatureStoreDatabase() != ArangoMLExtensionSpecMetadataServiceLocalDefaultArangoMLFeatureStoreDatabase, errors.Errorf("Database name is hardcoded"), nil)),
)
}

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2023-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -39,11 +39,11 @@ func (s *ArangoMLStorageSpecBackend) GetS3() *ArangoMLStorageSpecBackendS3 {
func (s *ArangoMLStorageSpecBackend) Validate() error {
if s == nil {
return errors.Newf("Backend is not specified")
return errors.Errorf("Backend is not specified")
}
if s.S3 == nil {
return errors.Newf("At least one backend needs to be defined")
return errors.Errorf("At least one backend needs to be defined")
}
return shared.WithErrors(shared.PrefixResourceError("s3", s.S3.Validate()))

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2023-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -61,7 +61,7 @@ func (s *ArangoMLStorageSpecBackendS3) Validate() error {
}
if _, err := url.Parse(s.GetEndpoint()); err != nil {
errs = append(errs, shared.PrefixResourceErrors("endpoint", errors.Newf("invalid URL: %s", err.Error())))
errs = append(errs, shared.PrefixResourceErrors("endpoint", errors.Errorf("invalid URL: %s", err.Error())))
}
errs = append(errs, shared.PrefixResourceErrors("credentialsSecret", s.GetCredentialsSecret().Validate()))

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2023-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -39,7 +39,7 @@ func (s *ArangoMLStorageSpecMode) GetSidecar() *ArangoMLStorageSpecModeSidecar {
func (s *ArangoMLStorageSpecMode) Validate() error {
if s == nil {
return errors.Newf("Mode is not defined")
return errors.Errorf("Mode is not defined")
}
return shared.WithErrors(shared.PrefixResourceError("sidecar", s.Sidecar.Validate()))
}

View file

@ -55,11 +55,11 @@ func (s *ArangoMLStorageSpecModeSidecar) Validate() error {
var err []error
if s.GetListenPort() < 1 {
err = append(err, shared.PrefixResourceErrors("listenPort", errors.Newf("must be positive")))
err = append(err, shared.PrefixResourceErrors("listenPort", errors.Errorf("must be positive")))
}
if s.GetControllerListenPort() < 1 {
err = append(err, shared.PrefixResourceErrors("controllerListenPort", errors.Newf("must be positive")))
err = append(err, shared.PrefixResourceErrors("controllerListenPort", errors.Errorf("must be positive")))
}
err = append(err, s.GetContainerTemplate().Validate())

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -67,13 +67,13 @@ func (n *KubernetesResourceName) String() string {
// Validate validate if name is valid kubernetes DNS_LABEL
func (n *KubernetesResourceName) Validate() error {
if n == nil {
return errors.Newf("cannot be undefined")
return errors.Errorf("cannot be undefined")
}
name := *n
if name == "" {
return errors.Newf("cannot be empty")
return errors.Errorf("cannot be empty")
}
if err := IsValidName(name.String()); err != nil {
@ -90,11 +90,11 @@ func (n *KubernetesResourceName) Immutable(o *KubernetesResourceName) error {
}
if o == nil || n == nil {
return errors.Newf("field is immutable")
return errors.Errorf("field is immutable")
}
if *o != *n {
return errors.Newf("field is immutable")
return errors.Errorf("field is immutable")
}
return nil
@ -104,7 +104,7 @@ func (n *KubernetesResourceName) Immutable(o *KubernetesResourceName) error {
// More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
func IsValidName(name string) error {
if res := validation.IsDNS1123Label(name); len(res) > 0 {
return errors.Newf("Validation of label failed: %s", strings.Join(res, ", "))
return errors.Errorf("Validation of label failed: %s", strings.Join(res, ", "))
}
return nil
@ -112,7 +112,7 @@ func IsValidName(name string) error {
func IsValidDomain(name string) error {
if res := validation.IsDNS1123Subdomain(name); len(res) > 0 {
return errors.Newf("validation of domain failed: %s", strings.Join(res, ", "))
return errors.Errorf("validation of domain failed: %s", strings.Join(res, ", "))
}
return nil

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -40,12 +40,12 @@ var (
// See https://kubernetes.io/docs/concepts/overview/working-with-objects/names/
func ValidateResourceName(name string) error {
if len(name) > 253 {
return errors.WithStack(errors.Newf("Name '%s' is too long", name))
return errors.WithStack(errors.Errorf("Name '%s' is too long", name))
}
if resourceNameRE.MatchString(name) {
return nil
}
return errors.WithStack(errors.Newf("Name '%s' is not a valid resource name", name))
return errors.WithStack(errors.Errorf("Name '%s' is not a valid resource name", name))
}
// ValidateOptionalResourceName validates a kubernetes resource name.
@ -73,7 +73,7 @@ func ValidatePullPolicy(in core.PullPolicy) error {
return nil
}
return errors.Newf("Unknown pull policy: '%s'", string(in))
return errors.Errorf("Unknown pull policy: '%s'", string(in))
}
type ValidateInterface interface {
@ -106,7 +106,7 @@ func ValidateRequired[T interface{}](in *T, validator func(T) error) error {
return validator(*in)
}
return errors.Newf("should be not nil")
return errors.Errorf("should be not nil")
}
// ValidateList validates all elements on the list
@ -123,7 +123,7 @@ func ValidateList[T interface{}](in []T, validator func(T) error) error {
// ValidateImage Validates if provided image is valid
func ValidateImage(image string) error {
if image == "" {
return errors.Newf("Image should be not empty")
return errors.Errorf("Image should be not empty")
}
return nil
@ -137,7 +137,7 @@ func ValidateAnyNotNil[T any](msg string, obj ...*T) error {
}
}
return errors.Newf(msg)
return errors.Errorf(msg)
}
// ValidateServiceType checks that service type is supported
@ -149,5 +149,5 @@ func ValidateServiceType(st core.ServiceType) error {
core.ServiceTypeExternalName:
return nil
}
return errors.Newf("Unsupported service type %s", st)
return errors.Errorf("Unsupported service type %s", st)
}

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -56,7 +56,7 @@ func (s StorageClassSpec) Validate() error {
switch r := s.GetReclaimPolicy(); r {
case core.PersistentVolumeReclaimRetain, core.PersistentVolumeReclaimDelete:
default:
return errors.Newf("Unsupported ReclaimPolicy: %s", r)
return errors.Errorf("Unsupported ReclaimPolicy: %s", r)
}
return nil

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -57,7 +57,7 @@ func registerCRD(getter crdDefinitionGetter, defaultOpts crds.CRDOptions) error
def := getter(nil)
if _, ok := registeredCRDs[def.CRD.GetName()]; ok {
return errors.Newf("CRD %s already exists", def.CRD.GetName())
return errors.Errorf("CRD %s already exists", def.CRD.GetName())
}
registeredCRDs[def.CRD.GetName()] = crdRegistration{
getter: getter,

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -167,7 +167,7 @@ func Generate(cmd *cobra.Command, out io.Writer, factories ...shared.Factory) er
}
if len(fileErrors) > 0 || len(factoryErrors) > 0 {
return errors.Newf("Error while receiving data")
return errors.Errorf("Error while receiving data")
}
return nil

View file

@ -49,7 +49,7 @@ func agencyDump(logger zerolog.Logger, files chan<- shared.File) error {
k, ok := kclient.GetDefaultFactory().Client()
if !ok {
return errors.Newf("Client is not initialised")
return errors.Errorf("Client is not initialised")
}
deployments, err := listArangoDeployments(k.Arango())()
@ -100,7 +100,7 @@ func discoverExecFunc() (ArangoOperatorExecFunc, error) {
k, ok := kclient.GetDefaultFactory().Client()
if !ok {
return nil, errors.Newf("Client is not initialised")
return nil, errors.Errorf("Client is not initialised")
}
pods, err := listPods(k.Kubernetes())()
@ -131,7 +131,7 @@ func discoverExecFunc() (ArangoOperatorExecFunc, error) {
}
if id == "" {
return nil, errors.Newf("Unable to find Operator pod")
return nil, errors.Errorf("Unable to find Operator pod")
}
return func(args ...string) ([]byte, []byte, error) {

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2023-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -56,7 +56,7 @@ func listArangoDeployments(client arangoClient.Interface) func() ([]*api.ArangoD
func deployments(logger zerolog.Logger, files chan<- shared.File) error {
k, ok := kclient.GetDefaultFactory().Client()
if !ok {
return errors.Newf("Client is not initialised")
return errors.Errorf("Client is not initialised")
}
deploymentList, err := listArangoDeployments(k.Arango())()

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2023-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -35,7 +35,7 @@ func ML() shared.Factory {
func ml(logger zerolog.Logger, files chan<- shared.File) error {
k, ok := kclient.GetDefaultFactory().Client()
if !ok {
return errors.Newf("Client is not initialised")
return errors.Errorf("Client is not initialised")
}
if err := mlExtensions(logger, files, k); err != nil {

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -54,7 +54,7 @@ func listEvents(client kubernetes.Interface) func() ([]*core.Event, error) {
func events(logger zerolog.Logger, files chan<- shared.File) error {
k, ok := kclient.GetDefaultFactory().Client()
if !ok {
return errors.Newf("Client is not initialised")
return errors.Errorf("Client is not initialised")
}
files <- shared.NewYAMLFile("kubernetes/events.yaml", listEvents(k.Kubernetes()))

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -56,7 +56,7 @@ func listPods(client kubernetes.Interface) func() ([]*core.Pod, error) {
func pods(logger zerolog.Logger, files chan<- shared.File) error {
k, ok := kclient.GetDefaultFactory().Client()
if !ok {
return errors.Newf("Client is not initialised")
return errors.Errorf("Client is not initialised")
}
pods, err := listPods(k.Kubernetes())()

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -54,7 +54,7 @@ func listSecrets(client kubernetes.Interface) func() ([]*core.Secret, error) {
func secrets(logger zerolog.Logger, files chan<- shared.File) error {
k, ok := kclient.GetDefaultFactory().Client()
if !ok {
return errors.Newf("Client is not initialised")
return errors.Errorf("Client is not initialised")
}
files <- shared.NewYAMLFile("kubernetes/secrets.yaml", listSecrets(k.Kubernetes()))

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2023-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -56,7 +56,7 @@ func listServices(client kubernetes.Interface) func() ([]*core.Service, error) {
func services(logger zerolog.Logger, files chan<- shared.File) error {
k, ok := kclient.GetDefaultFactory().Client()
if !ok {
return errors.Newf("Client is not initialised")
return errors.Errorf("Client is not initialised")
}
services, err := listServices(k.Kubernetes())()

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -93,17 +93,17 @@ func (h health) Healthy() error {
}
if h.election[h.leaderID] != h.agencySize {
return errors.Newf("Not all agents are in quorum")
return errors.Errorf("Not all agents are in quorum")
}
index := h.commitIndexes[h.leaderID]
if index == 0 {
return errors.Newf("Agency CommitIndex is zero")
return errors.Errorf("Agency CommitIndex is zero")
}
for k, v := range h.commitIndexes {
if v != index {
return errors.Newf("Agent %s is behind in CommitIndex", k)
return errors.Errorf("Agent %s is behind in CommitIndex", k)
}
}
@ -112,17 +112,17 @@ func (h health) Healthy() error {
func (h health) Serving() error {
if h.agencySize == 0 {
return errors.Newf("Empty agents list")
return errors.Errorf("Empty agents list")
}
if len(h.election) == 0 {
return errors.Newf("No Leader")
return errors.Errorf("No Leader")
} else if len(h.election) > 1 {
return errors.Newf("Multiple leaders")
return errors.Errorf("Multiple leaders")
}
if len(h.leaders) <= h.agencySize/2 {
return errors.Newf("Quorum is not present")
return errors.Errorf("Quorum is not present")
}
return nil
@ -342,7 +342,7 @@ func (c *cache) reload(ctx context.Context, size int, clients Connections) (*sta
data, index, ok := c.loader.State()
if !ok {
return nil, 0, errors.Newf("State is invalid after reload")
return nil, 0, errors.Errorf("State is invalid after reload")
}
return data, index, nil
@ -441,5 +441,5 @@ func (c *cache) getLeader(ctx context.Context, size int, clients Connections) (c
}
}
return nil, h, errors.Newf("Unable to find agent")
return nil, h, errors.Errorf("Unable to find agent")
}

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -36,7 +36,7 @@ func GetAgencyConfig(ctx context.Context, connection conn.Connection) (*Config,
}
if code != http.StatusOK {
return nil, errors.Newf("Unknown response code %d", code)
return nil, errors.Errorf("Unknown response code %d", code)
}
return resp, nil

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2023-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -38,15 +38,15 @@ func GetAgencyState[T interface{}](ctx context.Context, connection conn.Connecti
}
if code != http.StatusOK {
return def, errors.Newf("Unknown response code %d", code)
return def, errors.Errorf("Unknown response code %d", code)
}
if resp == nil {
return def, errors.Newf("Missing response body")
return def, errors.Errorf("Missing response body")
}
if len(*resp) != 1 {
return def, errors.Newf("Invalid response size")
return def, errors.Errorf("Invalid response size")
}
return (*resp)[0], nil

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -23,8 +23,9 @@ package state
import (
"encoding/json"
"github.com/pkg/errors"
"k8s.io/apimachinery/pkg/util/intstr"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
)
const (

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -66,7 +66,7 @@ func (s *Timestamp) Time() (time.Time, bool) {
func (s *Timestamp) UnmarshalJSON(bytes []byte) error {
if s == nil {
return errors.Newf("Object is nil")
return errors.Errorf("Object is nil")
}
var t string

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -184,7 +184,7 @@ func (cc *cache) GetAgency(_ context.Context, agencyIDs ...string) (agency.Agenc
}
if len(dnsNames) == 0 {
return nil, errors.Newf("There is no DNS Name")
return nil, errors.Errorf("There is no DNS Name")
}
c, err := cc.factory.Agency(dnsNames...)

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -146,7 +146,7 @@ func (d *Deployment) UpdateMember(ctx context.Context, member api.MemberStatus)
status := d.GetStatus()
_, group, found := status.Members.ElementByID(member.ID)
if !found {
return errors.WithStack(errors.Newf("Member %s not found", member.ID))
return errors.WithStack(errors.Errorf("Member %s not found", member.ID))
}
if err := status.Members.Update(member, group); err != nil {
return errors.WithStack(err)
@ -252,7 +252,7 @@ func (d *Deployment) getAuth() (driver.Authentication, error) {
}
if !d.GetCachedStatus().Initialised() {
return nil, errors.Newf("Cache is not yet started")
return nil, errors.Errorf("Cache is not yet started")
}
var secret string
@ -269,7 +269,7 @@ func (d *Deployment) getAuth() (driver.Authentication, error) {
}
if !found {
return nil, errors.Newf("JWT Secret is invalid")
return nil, errors.Errorf("JWT Secret is invalid")
}
jwt, err := jwt.CreateArangodJwtAuthorizationHeader(secret, "kube-arangodb")
@ -676,11 +676,11 @@ func (d *Deployment) WithMemberStatusUpdateErr(ctx context.Context, id string, g
return d.WithStatusUpdateErr(ctx, func(s *api.DeploymentStatus) (bool, error) {
m, g, ok := s.Members.ElementByID(id)
if !ok {
return false, errors.Newf("Member %s not found", id)
return false, errors.Errorf("Member %s not found", id)
}
if g != group {
return false, errors.Newf("Invalid group for %s. Wanted %s, found %s", id, group.AsRole(), g.AsRole())
return false, errors.Errorf("Invalid group for %s. Wanted %s, found %s", id, group.AsRole(), g.AsRole())
}
changed, err := action(&m)

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -204,7 +204,7 @@ func (d *Deployment) RefreshAgencyCache(ctx context.Context) (uint64, error) {
}
}
return 0, errors.Newf("Agency not yet established")
return 0, errors.Errorf("Agency not yet established")
}
func (d *Deployment) SetAgencyMaintenanceMode(ctx context.Context, enabled bool) error {
@ -484,7 +484,7 @@ func (d *Deployment) acceptNewSpec(ctx context.Context, depl *api.ArangoDeployme
}
// We have immutable fields, throw an error and proceed
return true, false, errors.Newf("Immutable fields cannot be changed: %s", strings.Join(fields, ", "))
return true, false, errors.Errorf("Immutable fields cannot be changed: %s", strings.Join(fields, ", "))
}
// Update accepted spec
@ -632,7 +632,7 @@ func (d *Deployment) applyPatch(ctx context.Context, p ...patch.Item) error {
}
if err != nil {
d.log.Err(err).Debug("failed to patch ArangoDeployment")
return errors.WithStack(errors.Newf("failed to patch ArangoDeployment: %v", err))
return errors.WithStack(errors.Errorf("failed to patch ArangoDeployment: %v", err))
}
}
}

View file

@ -279,7 +279,7 @@ func (d *Deployment) inspectDeploymentWithError(ctx context.Context, lastInterva
// Is the deployment in a good state?
if status.Conditions.IsTrue(api.ConditionTypeSecretsChanged) {
return minInspectionInterval, errors.Newf("Secrets changed")
return minInspectionInterval, errors.Errorf("Secrets changed")
}
// Ensure we have image info

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -258,7 +258,7 @@ func (s *stateInspector) GetMemberClient(id string) (driver.Client, error) {
}
}
return nil, errors.Newf("failed to get ArangoDB member client: %s", id)
return nil, errors.Errorf("failed to get ArangoDB member client: %s", id)
}
// GetMemberSyncClient returns member client to a server.
@ -274,7 +274,7 @@ func (s *stateInspector) GetMemberSyncClient(id string) (client.API, error) {
}
}
return nil, errors.Newf("failed to get ArangoSync member client: %s", id)
return nil, errors.Errorf("failed to get ArangoSync member client: %s", id)
}
func (s *stateInspector) MemberState(id string) (State, bool) {
@ -325,7 +325,7 @@ func (s State) GetDatabaseClient() (driver.Client, error) {
return nil, s.NotReachableErr
}
return nil, errors.Newf("ArangoDB is not reachable")
return nil, errors.Errorf("ArangoDB is not reachable")
}
func (s State) IsReachable() bool {

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -54,7 +54,7 @@ func (d *Deployment) createAgencyMapping(ctx context.Context) error {
agents := status.Members.Agents
if len(agents) > *spec.Agents.Count {
return errors.Newf("Agency size is bigger than requested size")
return errors.Errorf("Agency size is bigger than requested size")
}
c := api.DeploymentStatusAgencySize(*spec.Agents.Count)
@ -211,6 +211,6 @@ func (d *Deployment) renderMember(spec api.DeploymentSpec, status *api.Deploymen
Architecture: &arch,
}, nil
default:
return nil, errors.WithStack(errors.Newf("Unknown server group %d", group))
return nil, errors.WithStack(errors.Errorf("Unknown server group %d", group))
}
}

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -85,16 +85,16 @@ func GetEncryptionKey(ctx context.Context, secrets secretv1.ReadInterface, name
func GetEncryptionKeyFromSecret(keyfile *core.Secret) (string, []byte, error) {
if len(keyfile.Data) == 0 {
return "", nil, errors.Newf("Current encryption key is not valid - missing data section")
return "", nil, errors.Errorf("Current encryption key is not valid - missing data section")
}
d, ok := keyfile.Data[constants.SecretEncryptionKey]
if !ok {
return "", nil, errors.Newf("Current encryption key is not valid - missing field")
return "", nil, errors.Errorf("Current encryption key is not valid - missing field")
}
if len(d) != 32 {
return "", nil, errors.Newf("Current encryption key is not valid")
return "", nil, errors.Errorf("Current encryption key is not valid")
}
sha := fmt.Sprintf("%0x", sha256.Sum256(d))
@ -170,7 +170,7 @@ func (e encryption) Verify(i Input, cachedStatus interfaces.Inspector) error {
secret, exists := cachedStatus.Secret().V1().GetSimple(i.Deployment.RocksDB.Encryption.GetKeySecretName())
if !exists {
return errors.Newf("Encryption key secret does not exist %s", i.Deployment.RocksDB.Encryption.GetKeySecretName())
return errors.Errorf("Encryption key secret does not exist %s", i.Deployment.RocksDB.Encryption.GetKeySecretName())
}
if err := k8sutil.ValidateEncryptionKeyFromSecret(secret); err != nil {

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -102,7 +102,7 @@ func (e jwt) Verify(i Input, cachedStatus interfaces.Inspector) error {
if !VersionHasJWTSecretKeyfolder(i.Version, i.Enterprise) {
secret, exists := cachedStatus.Secret().V1().GetSimple(i.Deployment.Authentication.GetJWTSecretName())
if !exists {
return errors.Newf("Secret for JWT token is missing %s", i.Deployment.Authentication.GetJWTSecretName())
return errors.Errorf("Secret for JWT token is missing %s", i.Deployment.Authentication.GetJWTSecretName())
}
if err := k8sutil.ValidateTokenFromSecret(secret); err != nil {

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -81,12 +81,12 @@ func (s sni) Verify(i Input, cachedStatus interfaces.Inspector) error {
for _, secret := range util.SortKeys(i.Deployment.TLS.GetSNI().Mapping) {
kubeSecret, exists := cachedStatus.Secret().V1().GetSimple(secret)
if !exists {
return errors.Newf("SNI Secret not found %s", secret)
return errors.Errorf("SNI Secret not found %s", secret)
}
_, ok := kubeSecret.Data[constants.SecretTLSKeyfile]
if !ok {
return errors.Newf("Unable to find secret key %s/%s for SNI", secret, constants.SecretTLSKeyfile)
return errors.Errorf("Unable to find secret key %s/%s for SNI", secret, constants.SecretTLSKeyfile)
}
}
return nil

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -34,7 +34,7 @@ func GenerateMemberEndpoint(services service.Inspector, apiObject meta.Object, s
memberName := member.ArangoMemberName(apiObject.GetName(), group)
svc, ok := services.Service().V1().GetSimple(memberName)
if !ok {
return "", errors.Newf("Service %s not found", memberName)
return "", errors.Errorf("Service %s not found", memberName)
}
return GenerateMemberEndpointFromService(svc, apiObject, spec, group, member)
@ -47,7 +47,7 @@ func GenerateMemberEndpointFromService(svc *core.Service, apiObject meta.Object,
return k8sutil.CreateServiceDNSNameWithDomain(svc, spec.ClusterDomain), nil
case api.DeploymentCommunicationMethodIP:
if svc.Spec.ClusterIP == "" {
return "", errors.Newf("ClusterIP of service %s is empty", svc.GetName())
return "", errors.Errorf("ClusterIP of service %s is empty", svc.GetName())
}
if svc.Spec.ClusterIP == core.ClusterIPNone {

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -68,7 +68,7 @@ func (a *actionArangoMemberUpdatePodSpec) Start(ctx context.Context) (bool, erro
_, ok := cache.ArangoMember().V1().GetSimple(name)
if !ok {
err := errors.Newf("ArangoMember not found")
err := errors.Errorf("ArangoMember not found")
a.log.Err(err).Error("ArangoMember not found")
return false, err
}

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -65,7 +65,7 @@ func (a *actionArangoMemberUpdatePodStatus) Start(ctx context.Context) (bool, er
member, ok := cache.ArangoMember().V1().GetSimple(name)
if !ok {
err := errors.Newf("ArangoMember not found")
err := errors.Errorf("ArangoMember not found")
a.log.Err(err).Error("ArangoMember not found")
return false, err
}

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -96,7 +96,7 @@ func (a actionBackupRestore) Start(ctx context.Context) (bool, error) {
case api.DeploymentModeCluster:
return a.restoreAsync(ctx, backupResource)
default:
return false, errors.Newf("Unknown mode %s", mode)
return false, errors.Errorf("Unknown mode %s", mode)
}
}
@ -124,7 +124,7 @@ func (a actionBackupRestore) restoreAsync(ctx context.Context, backup *backupApi
}
}
return false, errors.Newf("Async response not received")
return false, errors.Errorf("Async response not received")
}
func (a actionBackupRestore) restoreSync(ctx context.Context, backup *backupApi.ArangoBackup) (bool, error) {
@ -166,12 +166,12 @@ func (a actionBackupRestore) restoreSync(ctx context.Context, backup *backupApi.
func (a actionBackupRestore) CheckProgress(ctx context.Context) (bool, bool, error) {
backup, ok := a.actionCtx.Get(a.action, actionBackupRestoreLocalBackupName)
if !ok {
return false, false, errors.Newf("Local Key is missing in action: %s", actionBackupRestoreLocalBackupName)
return false, false, errors.Errorf("Local Key is missing in action: %s", actionBackupRestoreLocalBackupName)
}
job, ok := a.actionCtx.Get(a.action, actionBackupRestoreLocalJobID)
if !ok {
return false, false, errors.Newf("Local Key is missing in action: %s", actionBackupRestoreLocalJobID)
return false, false, errors.Errorf("Local Key is missing in action: %s", actionBackupRestoreLocalJobID)
}
ctxChild, cancel := globals.GetGlobalTimeouts().ArangoD().WithTimeout(ctx)

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -149,6 +149,6 @@ func (a actionBootstrapSetPassword) ensureUserPasswordSecret(ctx context.Context
if err == nil {
return pass, nil
}
return "", errors.Newf("invalid secret format in secret %s", secret)
return "", errors.Errorf("invalid secret format in secret %s", secret)
}
}

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -365,7 +365,7 @@ func (ac *actionContext) UpdateMember(ctx context.Context, member api.MemberStat
status := ac.context.GetStatus()
_, group, found := status.Members.ElementByID(member.ID)
if !found {
return errors.WithStack(errors.Newf("Member %s not found", member.ID))
return errors.WithStack(errors.Errorf("Member %s not found", member.ID))
}
if err := status.Members.Update(member, group); err != nil {
return errors.WithStack(err)

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -37,14 +37,14 @@ import (
func ensureEncryptionSupport(actionCtx ActionContext) error {
if !actionCtx.GetSpec().RocksDB.IsEncrypted() {
return errors.Newf("Encryption is disabled")
return errors.Errorf("Encryption is disabled")
}
if image, ok := actionCtx.GetCurrentImageInfo(); !ok {
return errors.Newf("Missing image info")
return errors.Errorf("Missing image info")
} else {
if !features.EncryptionRotation().Supported(image.ArangoDBVersion, image.Enterprise) {
return errors.Newf("Supported only in Enterprise Edition 3.7.0+")
return errors.Errorf("Supported only in Enterprise Edition 3.7.0+")
}
}
return nil

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -48,11 +48,11 @@ func ensureJWTFolderSupportFromAction(actionCtx ActionContext) (bool, error) {
func ensureJWTFolderSupport(spec api.DeploymentSpec, status api.DeploymentStatus) (bool, error) {
if !spec.IsAuthenticated() {
return false, errors.Newf("Authentication is disabled")
return false, errors.Errorf("Authentication is disabled")
}
if image := status.CurrentImage; image == nil {
return false, errors.Newf("Missing image info")
return false, errors.Errorf("Missing image info")
} else {
if !features.JWTRotation().Supported(image.ArangoDBVersion, image.Enterprise) {
return false, nil

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -64,7 +64,7 @@ func (a *actionKillMemberPod) Start(ctx context.Context) (bool, error) {
cache, ok := a.actionCtx.ACS().ClusterCache(m.ClusterID)
if !ok {
return true, errors.Newf("Client is not ready")
return true, errors.Errorf("Client is not ready")
}
if ifPodUIDMismatch(m, a.action, cache) {
@ -94,7 +94,7 @@ func (a *actionKillMemberPod) CheckProgress(ctx context.Context) (bool, bool, er
cache, ok := a.actionCtx.ACS().ClusterCache(m.ClusterID)
if !ok {
return false, false, errors.Newf("Client is not ready")
return false, false, errors.Errorf("Client is not ready")
}
p, ok := cache.Pod().V1().GetSimple(m.Pod.GetName())

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -76,7 +76,7 @@ func (a *actionPVCResize) Start(ctx context.Context) (bool, error) {
cache, ok := a.actionCtx.ACS().ClusterCache(m.ClusterID)
if !ok {
return true, errors.Newf("Cluster is not ready")
return true, errors.Errorf("Cluster is not ready")
}
if m.PersistentVolumeClaim.GetName() == "" {

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2023-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -119,22 +119,22 @@ func (a *actionRebuildOutSyncedShards) CheckProgress(ctx context.Context) (bool,
jobID, ok := a.actionCtx.Get(a.action, actionRebuildOutSyncedShardsLocalJobID)
if !ok {
return false, true, errors.Newf("Local Key is missing in action: %s", actionRebuildOutSyncedShardsLocalJobID)
return false, true, errors.Errorf("Local Key is missing in action: %s", actionRebuildOutSyncedShardsLocalJobID)
}
batchID, ok := a.actionCtx.Get(a.action, actionRebuildOutSyncedShardsBatchID)
if !ok {
return false, true, errors.Newf("Local Key is missing in action: %s", actionRebuildOutSyncedShardsBatchID)
return false, true, errors.Errorf("Local Key is missing in action: %s", actionRebuildOutSyncedShardsBatchID)
}
database, ok := a.actionCtx.Get(a.action, actionRebuildOutSyncedShardsLocalDatabase)
if !ok {
return false, true, errors.Newf("Local Key is missing in action: %s", actionRebuildOutSyncedShardsLocalDatabase)
return false, true, errors.Errorf("Local Key is missing in action: %s", actionRebuildOutSyncedShardsLocalDatabase)
}
shardID, ok := a.actionCtx.Get(a.action, actionRebuildOutSyncedShardsLocalShard)
if !ok {
return false, true, errors.Newf("Local Key is missing in action: %s", actionRebuildOutSyncedShardsLocalShard)
return false, true, errors.Errorf("Local Key is missing in action: %s", actionRebuildOutSyncedShardsLocalShard)
}
// check first if there is rebuild job running

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -52,19 +52,19 @@ type actionRecreateMember struct {
func (a *actionRecreateMember) Start(ctx context.Context) (bool, error) {
m, g, ok := a.actionCtx.GetMemberStatusAndGroupByID(a.action.MemberID)
if !ok {
return false, errors.Newf("expecting member to be present in list, but it is not")
return false, errors.Errorf("expecting member to be present in list, but it is not")
}
cache, ok := a.actionCtx.ACS().ClusterCache(m.ClusterID)
if !ok {
return true, errors.Newf("Cluster is not ready")
return true, errors.Errorf("Cluster is not ready")
}
switch g {
case api.ServerGroupDBServers, api.ServerGroupAgents: // Only DBServers and Agents use persistent data
_, ok := cache.PersistentVolumeClaim().V1().GetSimple(m.PersistentVolumeClaim.GetName())
if !ok {
return false, errors.Newf("PVC is missing %s. Members won't be recreated without old PV", m.PersistentVolumeClaim.GetName())
return false, errors.Errorf("PVC is missing %s. Members won't be recreated without old PV", m.PersistentVolumeClaim.GetName())
}
}

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -65,7 +65,7 @@ func (a *actionRemoveMember) Start(ctx context.Context) (bool, error) {
cache, ok := a.actionCtx.ACS().ClusterCache(m.ClusterID)
if !ok {
return true, errors.Newf("Cluster is not ready")
return true, errors.Errorf("Cluster is not ready")
}
// For safety, remove from cluster
@ -93,7 +93,7 @@ func (a *actionRemoveMember) Start(ctx context.Context) (bool, error) {
if m.Conditions.IsTrue(api.ConditionTypeTerminating) {
if record.Status != driver.ServerStatusFailed {
return false, errors.WithStack(errors.Newf("can not remove server from cluster. Not yet terminated. Retry later"))
return false, errors.WithStack(errors.Errorf("can not remove server from cluster. Not yet terminated. Retry later"))
}
a.log.Debug("dbserver has shut down")
@ -131,7 +131,7 @@ func (a *actionRemoveMember) Start(ctx context.Context) (bool, error) {
}
// Check that member has been removed
if _, found := a.actionCtx.GetMemberStatusByID(a.action.MemberID); found {
return false, errors.WithStack(errors.Newf("Member %s still exists", a.action.MemberID))
return false, errors.WithStack(errors.Errorf("Member %s still exists", a.action.MemberID))
}
return true, nil
}

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2023-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -62,21 +62,21 @@ func (a *actionRemoveMemberPVC) Start(ctx context.Context) (bool, error) {
pvcUID, ok := a.action.GetParam("pvc")
if !ok {
return true, errors.Newf("PVC UID Parameter is missing")
return true, errors.Errorf("PVC UID Parameter is missing")
}
cache, ok := a.actionCtx.ACS().ClusterCache(m.ClusterID)
if !ok {
return true, errors.Newf("Cluster is not ready")
return true, errors.Errorf("Cluster is not ready")
}
agencyCache, ok := a.actionCtx.GetAgencyCache()
if !ok {
return true, errors.Newf("Agency is not ready")
return true, errors.Errorf("Agency is not ready")
}
if agencyCache.PlanLeaderServers().Contains(state.Server(m.ID)) {
return true, errors.Newf("Server is still used in cluster")
return true, errors.Errorf("Server is still used in cluster")
}
// We are safe to remove PVC

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -25,11 +25,11 @@ import (
"fmt"
"strings"
"github.com/pkg/errors"
core "k8s.io/api/core/v1"
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
"github.com/arangodb/kube-arangodb/pkg/deployment/rotation"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
"github.com/arangodb/kube-arangodb/pkg/util/globals"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/definitions"

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -115,7 +115,7 @@ func (a actionRuntimeContainerImageUpdate) Post(ctx context.Context) error {
_, ok = cache.ArangoMember().V1().GetSimple(name)
if !ok {
err := errors.Newf("ArangoMember not found")
err := errors.Errorf("ArangoMember not found")
a.log.Err(err).Error("ArangoMember not found")
return err
}
@ -179,7 +179,7 @@ func (a actionRuntimeContainerImageUpdate) Start(ctx context.Context) (bool, err
cache, ok := a.actionCtx.ACS().ClusterCache(m.ClusterID)
if !ok {
return true, errors.Newf("Client is not ready")
return true, errors.Errorf("Client is not ready")
}
name, image, ok := a.getContainerDetails()
@ -195,7 +195,7 @@ func (a actionRuntimeContainerImageUpdate) Start(ctx context.Context) (bool, err
member, ok := a.actionCtx.ACS().CurrentClusterCache().ArangoMember().V1().GetSimple(m.ArangoMemberName(a.actionCtx.GetName(), a.action.Group))
if !ok {
err := errors.Newf("ArangoMember not found")
err := errors.Errorf("ArangoMember not found")
a.log.Err(err).Error("ArangoMember not found")
return false, err
}
@ -250,7 +250,7 @@ func (a actionRuntimeContainerImageUpdate) Start(ctx context.Context) (bool, err
a.log.Str("container", name).Str("pod", pod.GetName()).Warn("Container not found")
return false, errors.Newf("Container %s not found in Pod %s", name, pod.GetName())
return false, errors.Errorf("Container %s not found in Pod %s", name, pod.GetName())
}
func (a actionRuntimeContainerImageUpdate) CheckProgress(ctx context.Context) (bool, bool, error) {
@ -311,14 +311,14 @@ func (a actionRuntimeContainerImageUpdate) CheckProgress(ctx context.Context) (b
}
// Pod won't get up and running
return true, false, errors.Newf("Container %s failed during image replacement: (%d) %s: %s", name, s.ExitCode, s.Reason, s.Message)
return true, false, errors.Errorf("Container %s failed during image replacement: (%d) %s: %s", name, s.ExitCode, s.Reason, s.Message)
} else if s := cstatus.State.Waiting; s != nil {
if pod.Spec.RestartPolicy == core.RestartPolicyAlways {
lastTermination := cstatus.LastTerminationState.Terminated
if lastTermination != nil {
allowedRestartPeriod := time.Now().Add(time.Second * -20)
if lastTermination.FinishedAt.Time.Before(allowedRestartPeriod) {
return true, false, errors.Newf("Container %s continuously failing during image replacement: (%d) %s: %s", name, lastTermination.ExitCode, lastTermination.Reason, lastTermination.Message)
return true, false, errors.Errorf("Container %s continuously failing during image replacement: (%d) %s: %s", name, lastTermination.ExitCode, lastTermination.Reason, lastTermination.Message)
} else {
a.log.Str("pod-name", pod.GetName()).Debug("pod is restarting - we are not marking it as terminated yet..")
}

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -24,12 +24,12 @@ import (
"context"
"reflect"
"github.com/pkg/errors"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
"github.com/arangodb/kube-arangodb/pkg/deployment/patch"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
"github.com/arangodb/kube-arangodb/pkg/util/globals"
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/tolerations"
)

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -139,7 +139,7 @@ func (s shutdownHelperAPI) Start(ctx context.Context) (bool, error) {
cache, ok := s.actionCtx.ACS().ClusterCache(s.memberStatus.ClusterID)
if !ok {
return true, errors.Newf("Cluster is not ready")
return true, errors.Errorf("Cluster is not ready")
}
// Remove finalizers, so Kubernetes will quickly terminate the pod
@ -228,7 +228,7 @@ func (s shutdownHelperDelete) Start(ctx context.Context) (bool, error) {
cache, ok := s.actionCtx.ACS().ClusterCache(s.memberStatus.ClusterID)
if !ok {
return true, errors.Newf("Cluster is not ready")
return true, errors.Errorf("Cluster is not ready")
}
// Terminate pod

View file

@ -1,7 +1,7 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -46,19 +46,19 @@ func mapTLSSNIConfig(sni api.TLSSNISpec, cachedStatus inspectorInterface.Inspect
for name, servers := range mapping {
secret, exists := cachedStatus.Secret().V1().GetSimple(name)
if !exists {
return nil, errors.Newf("Secret %s does not exist", name)
return nil, errors.Errorf("Secret %s does not exist", name)
}
tlsKey, ok := secret.Data[constants.SecretTLSKeyfile]
if !ok {
return nil, errors.Newf("Not found tls keyfile key in SNI secret")
return nil, errors.Errorf("Not found tls keyfile key in SNI secret")
}
tlsKeyChecksum := fmt.Sprintf("%0x", sha256.Sum256(tlsKey))
for _, server := range servers {
if _, ok := fetchedSecrets[server]; ok {
return nil, errors.Newf("Not found tls key in SNI secret")
return nil, errors.Errorf("Not found tls key in SNI secret")
}
fetchedSecrets[server] = tlsKeyChecksum
}
@ -81,13 +81,13 @@ func compareTLSSNIConfig(ctx context.Context, log logging.Logger, c driver.Conne
}
if len(m) != len(tlsDetails.Result.SNI) {
return false, errors.Newf("Count of SNI mounted secrets does not match")
return false, errors.Errorf("Count of SNI mounted secrets does not match")
}
for key, value := range tlsDetails.Result.SNI {
currentValue, ok := m[key]
if !ok {
return false, errors.Newf("Unable to fetch TLS SNI state")
return false, errors.Errorf("Unable to fetch TLS SNI state")
}
if value.GetSHA().Checksum() != currentValue {

Some files were not shown because too many files have changed in this diff Show more