mirror of
https://github.com/arangodb/kube-arangodb.git
synced 2024-12-14 11:57:37 +00:00
FEATURE/fix-linter-issues (#529)
This commit is contained in:
parent
d21d0e2c18
commit
7c649303d0
102 changed files with 182 additions and 223 deletions
23
Makefile
23
Makefile
|
@ -123,7 +123,9 @@ ifdef VERBOSE
|
|||
TESTVERBOSEOPTIONS := -v
|
||||
endif
|
||||
|
||||
SOURCES := $(shell find $(SRCDIR) -name '*.go' -not -path './test/*')
|
||||
SOURCES_QUERY := find $(SRCDIR) -name '*.go' -type f -not -path '$(SRCDIR)/tests/*' -not -path '$(SRCDIR)/vendor/*' -not -path '$(SRCDIR)/.gobuild/*' -not -path '$(SRCDIR)/deps/*' -not -path '$(SRCDIR)/tools/*'
|
||||
SOURCES := $(shell $(SOURCES_QUERY))
|
||||
SOURCES_PACKAGES := $(shell $(SOURCES_QUERY) -exec dirname {} \; | sort | uniq)
|
||||
DASHBOARDSOURCES := $(shell find $(DASHBOARDDIR)/src -name '*.js' -not -path './test/*') $(DASHBOARDDIR)/package.json
|
||||
|
||||
ifndef ARANGOSYNCSRCDIR
|
||||
|
@ -157,13 +159,22 @@ allall: all
|
|||
# Tip: Run `eval $(minikube docker-env)` before calling make if you're developing on minikube.
|
||||
#
|
||||
|
||||
GOLANGCI_ENABLED=deadcode gocyclo golint varcheck structcheck maligned errcheck \
|
||||
ineffassign interfacer unconvert goconst \
|
||||
megacheck
|
||||
|
||||
#GOLANGCI_ENABLED+=dupl - disable dupl check
|
||||
|
||||
.PHONY: fmt
|
||||
fmt:
|
||||
golangci-lint run --no-config --issues-exit-code=1 --deadline=30m --disable-all --enable=deadcode --enable=gocyclo \
|
||||
--enable=golint --enable=varcheck --enable=structcheck --enable=maligned --enable=errcheck \
|
||||
--enable=dupl --enable=ineffassign --enable=interfacer --enable=unconvert --enable=goconst \
|
||||
--enable=gosec --enable=megacheck --exclude-use-default=false \
|
||||
$(ROOTDIR)/pkg/backup/...
|
||||
@goimports -w $(SOURCES)
|
||||
|
||||
.PHONY: linter
|
||||
linter: fmt
|
||||
@golangci-lint run --no-config --issues-exit-code=1 --deadline=30m --disable-all \
|
||||
$(foreach MODE,$(GOLANGCI_ENABLED),--enable $(MODE) ) \
|
||||
--exclude-use-default=false \
|
||||
$(SOURCES_PACKAGES)
|
||||
|
||||
.PHONY: build
|
||||
build: docker docker-ubi manifests
|
||||
|
|
4
main.go
4
main.go
|
@ -31,6 +31,8 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
utilsError "github.com/arangodb/kube-arangodb/pkg/util/errors"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/spf13/cobra"
|
||||
|
@ -232,7 +234,7 @@ func cmdMainRun(cmd *cobra.Command, args []string) {
|
|||
}); err != nil {
|
||||
cliLog.Fatal().Err(err).Msg("Failed to create HTTP server")
|
||||
} else {
|
||||
go svr.Run()
|
||||
go utilsError.LogError(cliLog, "error while starting service", svr.Run)
|
||||
}
|
||||
|
||||
// startChaos(context.Background(), cfg.KubeCli, cfg.Namespace, chaosLevel)
|
||||
|
|
|
@ -38,4 +38,4 @@ var (
|
|||
ArangoBackupShortNames = []string{"arangobackup"}
|
||||
|
||||
ArangoBackupPolicyShortNames = []string{"arangobackuppolicy"}
|
||||
)
|
||||
)
|
||||
|
|
|
@ -80,7 +80,7 @@ func (a *ArangoBackupDetails) Equal(b *ArangoBackupDetails) bool {
|
|||
compareBoolPointer(a.Imported, b.Imported)
|
||||
}
|
||||
|
||||
func compareBoolPointer(a, b * bool) bool {
|
||||
func compareBoolPointer(a, b *bool) bool {
|
||||
if a == nil && b != nil || a != nil && b == nil {
|
||||
return false
|
||||
}
|
||||
|
@ -94,4 +94,4 @@ func compareBoolPointer(a, b * bool) bool {
|
|||
}
|
||||
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,6 @@ var (
|
|||
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
|
||||
AddToScheme = SchemeBuilder.AddToScheme
|
||||
|
||||
|
||||
SchemeGroupVersion = schema.GroupVersion{Group: backup.ArangoBackupGroupName, Version: ArangoBackupVersion}
|
||||
)
|
||||
|
||||
|
|
|
@ -32,4 +32,4 @@ const (
|
|||
|
||||
var (
|
||||
ArangoDeploymentShortNames = []string{"arangodb", "arango"}
|
||||
)
|
||||
)
|
||||
|
|
|
@ -125,9 +125,7 @@ func (s *ServerGroupSpecSecurityContext) NewSecurityContext() *v1.SecurityContex
|
|||
if caps := s.GetAddCapabilities(); caps != nil {
|
||||
capabilities.Add = []v1.Capability{}
|
||||
|
||||
for _, capability := range caps {
|
||||
capabilities.Add = append(capabilities.Add, capability)
|
||||
}
|
||||
capabilities.Add = append(capabilities.Add, caps...)
|
||||
}
|
||||
|
||||
r.Capabilities = capabilities
|
||||
|
|
|
@ -25,10 +25,10 @@ package replication
|
|||
const (
|
||||
ArangoDeploymentReplicationResourceKind = "ArangoDeploymentReplication"
|
||||
ArangoDeploymentReplicationResourcePlural = "arangodeploymentreplications"
|
||||
ArangoDeploymentReplicationGroupName = "replication.database.arangodb.com"
|
||||
ArangoDeploymentReplicationGroupName = "replication.database.arangodb.com"
|
||||
)
|
||||
|
||||
var (
|
||||
ArangoDeploymentReplicationCRDName = ArangoDeploymentReplicationResourcePlural + "." + ArangoDeploymentReplicationGroupName
|
||||
ArangoDeploymentReplicationShortNames = []string{"arangorepl"}
|
||||
)
|
||||
)
|
||||
|
|
|
@ -23,9 +23,10 @@
|
|||
package backup
|
||||
|
||||
import (
|
||||
"github.com/arangodb/kube-arangodb/pkg/backup/utils"
|
||||
"net/http"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/backup/utils"
|
||||
|
||||
"github.com/arangodb/go-driver"
|
||||
backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1"
|
||||
database "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
|
||||
|
|
|
@ -98,9 +98,7 @@ func (m *mockArangoClientBackup) Abort(d driver.BackupTransferJobID) error {
|
|||
return m.state.errors.abortError
|
||||
}
|
||||
|
||||
if _, ok := m.state.progresses[d]; ok {
|
||||
delete(m.state.progresses, d)
|
||||
}
|
||||
delete(m.state.progresses, d)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -126,9 +124,7 @@ func (m *mockArangoClientBackup) Delete(id driver.BackupID) error {
|
|||
return m.state.errors.deleteError
|
||||
}
|
||||
|
||||
if _, ok := m.state.backups[id]; ok {
|
||||
delete(m.state.backups, id)
|
||||
}
|
||||
delete(m.state.backups, id)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -24,10 +24,11 @@ package backup
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/arangodb/go-driver"
|
||||
"github.com/arangodb/kube-arangodb/pkg/apis/backup"
|
||||
"github.com/arangodb/kube-arangodb/pkg/apis/deployment"
|
||||
"testing"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/backup/operator/event"
|
||||
"github.com/arangodb/kube-arangodb/pkg/backup/operator/operation"
|
||||
|
@ -81,15 +82,6 @@ func newObjectSet(state state.State) (*backupApi.ArangoBackup, *database.ArangoD
|
|||
return obj, deployment
|
||||
}
|
||||
|
||||
func compareTemporaryState(t *testing.T, err error, errorMsg string, handler *handler, obj *backupApi.ArangoBackup) {
|
||||
require.Error(t, err)
|
||||
require.True(t, isTemporaryError(err))
|
||||
require.EqualError(t, err, errorMsg)
|
||||
|
||||
newObj := refreshArangoBackup(t, handler, obj)
|
||||
require.Equal(t, obj.Status, newObj.Status)
|
||||
}
|
||||
|
||||
func newItem(o operation.Operation, namespace, name string) operation.Item {
|
||||
return operation.Item{
|
||||
Group: backupApi.SchemeGroupVersion.Group,
|
||||
|
|
|
@ -24,9 +24,10 @@ package backup
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/arangodb/go-driver"
|
||||
"github.com/arangodb/kube-arangodb/pkg/backup/utils"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func newTemporaryError(err error) error {
|
||||
|
|
|
@ -24,11 +24,12 @@ package backup
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/arangodb/kube-arangodb/pkg/apis/backup"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/apis/backup"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util"
|
||||
|
||||
"github.com/arangodb/go-driver"
|
||||
"github.com/arangodb/kube-arangodb/pkg/backup/utils"
|
||||
"k8s.io/apimachinery/pkg/util/uuid"
|
||||
|
|
|
@ -23,9 +23,10 @@
|
|||
package backup
|
||||
|
||||
import (
|
||||
"github.com/arangodb/kube-arangodb/pkg/apis/backup"
|
||||
"time"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/apis/backup"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/backup/operator"
|
||||
"github.com/rs/zerolog/log"
|
||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
|
|
@ -23,9 +23,10 @@
|
|||
package backup
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/arangodb/go-driver"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util"
|
||||
"testing"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/backup/operator/operation"
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ package backup
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/util"
|
||||
|
||||
"github.com/arangodb/go-driver"
|
||||
|
|
|
@ -24,18 +24,15 @@ package backup
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/arangodb/go-driver"
|
||||
"testing"
|
||||
|
||||
"github.com/arangodb/go-driver"
|
||||
|
||||
backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1"
|
||||
"github.com/arangodb/kube-arangodb/pkg/backup/operator/operation"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
const (
|
||||
progressError = "progress error"
|
||||
)
|
||||
|
||||
func Test_State_Downloading_Common(t *testing.T) {
|
||||
wrapperUndefinedDeployment(t, backupApi.ArangoBackupStateDownloading)
|
||||
wrapperConnectionIssues(t, backupApi.ArangoBackupStateDownloading)
|
||||
|
|
|
@ -24,10 +24,11 @@ package backup
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
deploymentType "github.com/arangodb/kube-arangodb/pkg/apis/deployment"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
deploymentType "github.com/arangodb/kube-arangodb/pkg/apis/deployment"
|
||||
|
||||
"k8s.io/apimachinery/pkg/util/uuid"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/backup/operator/operation"
|
||||
|
|
|
@ -23,11 +23,12 @@
|
|||
package backup
|
||||
|
||||
import (
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/arangodb/go-driver"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util"
|
||||
"k8s.io/apimachinery/pkg/util/uuid"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/backup/operator/operation"
|
||||
|
||||
|
|
|
@ -23,10 +23,11 @@
|
|||
package backup
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/arangodb/go-driver"
|
||||
"github.com/arangodb/kube-arangodb/pkg/backup/operator/operation"
|
||||
"github.com/stretchr/testify/require"
|
||||
"testing"
|
||||
|
||||
backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1"
|
||||
)
|
||||
|
|
|
@ -23,9 +23,10 @@
|
|||
package backup
|
||||
|
||||
import (
|
||||
"github.com/arangodb/go-driver"
|
||||
"testing"
|
||||
|
||||
"github.com/arangodb/go-driver"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/backup/operator/operation"
|
||||
|
||||
backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1"
|
||||
|
|
|
@ -23,10 +23,11 @@
|
|||
package backup
|
||||
|
||||
import (
|
||||
"github.com/arangodb/kube-arangodb/pkg/util"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/util"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/backup/operator/operation"
|
||||
|
||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
|
|
@ -24,6 +24,7 @@ package backup
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/util"
|
||||
|
||||
"github.com/arangodb/go-driver"
|
||||
|
|
|
@ -24,9 +24,10 @@ package backup
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/arangodb/go-driver"
|
||||
"testing"
|
||||
|
||||
"github.com/arangodb/go-driver"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/backup/operator/operation"
|
||||
|
||||
backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1"
|
||||
|
|
|
@ -24,6 +24,7 @@ package backup
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/arangodb/go-driver"
|
||||
backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1"
|
||||
"github.com/arangodb/kube-arangodb/pkg/backup/state"
|
||||
|
@ -118,14 +119,6 @@ func createStateMessage(from, to state.State, message string) string {
|
|||
return fmt.Sprintf("Transiting from %s to %s: %s", from, to, message)
|
||||
}
|
||||
|
||||
func switchTemporaryError(backup *backupApi.ArangoBackup, err error) (*backupApi.ArangoBackupStatus, error) {
|
||||
if _, ok := err.(temporaryError); ok {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return setFailedState(backup, err)
|
||||
}
|
||||
|
||||
func createBackupFromMeta(backupMeta driver.BackupMeta, old *backupApi.ArangoBackupDetails) *backupApi.ArangoBackupDetails {
|
||||
var obj *backupApi.ArangoBackupDetails
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ func isBackupRunning(backup *backupApi.ArangoBackup, client clientBackup.ArangoB
|
|||
(existingBackup.Status.State == backupApi.ArangoBackupStateUpload || existingBackup.Status.State == backupApi.ArangoBackupStateUploading) {
|
||||
if backupUpload := backup.Status.Backup; backupUpload != nil {
|
||||
if existingBackupUpload := existingBackup.Status.Backup; existingBackupUpload != nil {
|
||||
if strings.ToLower(backupUpload.ID) == strings.ToLower(existingBackupUpload.ID) {
|
||||
if strings.EqualFold(backupUpload.ID, existingBackupUpload.ID) {
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,10 +24,11 @@ package policy
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/arangodb/kube-arangodb/pkg/apis/backup"
|
||||
"reflect"
|
||||
"time"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/apis/backup"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/backup/operator"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/backup/operator/event"
|
||||
|
|
|
@ -24,9 +24,10 @@ package policy
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/apis/backup"
|
||||
"github.com/arangodb/kube-arangodb/pkg/apis/deployment"
|
||||
"testing"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/backup/operator/event"
|
||||
"github.com/arangodb/kube-arangodb/pkg/backup/operator/operation"
|
||||
|
|
|
@ -23,9 +23,10 @@
|
|||
package policy
|
||||
|
||||
import (
|
||||
"github.com/arangodb/kube-arangodb/pkg/apis/backup"
|
||||
"time"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/apis/backup"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/backup/operator"
|
||||
"github.com/rs/zerolog/log"
|
||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
|
|
@ -28,7 +28,7 @@ import (
|
|||
|
||||
certificates "github.com/arangodb-helper/go-certificates"
|
||||
"github.com/ghodss/yaml"
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/constants"
|
||||
|
|
|
@ -59,4 +59,4 @@ func (a ArangoPlanCollection) IsDBServerInShards(name string) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
type ArangoPlanShard map[string][]string
|
||||
type ArangoPlanShard map[string][]string
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
package agency
|
||||
|
||||
const (
|
||||
ArangoKey = "arango"
|
||||
PlanKey = "Plan"
|
||||
ArangoKey = "arango"
|
||||
PlanKey = "Plan"
|
||||
PlanCollectionsKey = "Collections"
|
||||
)
|
||||
|
|
|
@ -26,8 +26,8 @@ import (
|
|||
"context"
|
||||
|
||||
"github.com/arangodb/go-driver"
|
||||
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
|
||||
backupApi "github.com/arangodb/kube-arangodb/pkg/apis/backup/v1"
|
||||
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
|
||||
"github.com/rs/zerolog"
|
||||
)
|
||||
|
||||
|
|
|
@ -108,11 +108,11 @@ func (d *Deployment) bootstrapUserPassword(client driver.Client, secrets k8sutil
|
|||
}
|
||||
|
||||
// Obtain the user
|
||||
if user, err := client.User(nil, username); driver.IsNotFound(err) {
|
||||
_, err := client.CreateUser(nil, username, &driver.UserOptions{Password: password})
|
||||
if user, err := client.User(context.TODO(), username); driver.IsNotFound(err) {
|
||||
_, err := client.CreateUser(context.TODO(), username, &driver.UserOptions{Password: password})
|
||||
return maskAny(err)
|
||||
} else if err == nil {
|
||||
return maskAny(user.Update(nil, driver.UserOptions{
|
||||
return maskAny(user.Update(context.TODO(), driver.UserOptions{
|
||||
Password: password,
|
||||
}))
|
||||
} else {
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
package chaos
|
||||
|
||||
import (
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
|
||||
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
|
||||
)
|
||||
|
|
|
@ -25,10 +25,11 @@ package deployment
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
"net"
|
||||
"strconv"
|
||||
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
|
||||
"github.com/arangodb/arangosync-client/client"
|
||||
"github.com/arangodb/arangosync-client/tasks"
|
||||
driver "github.com/arangodb/go-driver"
|
||||
|
@ -454,7 +455,7 @@ func (d *Deployment) EnableScalingCluster() error {
|
|||
}
|
||||
|
||||
// GetAgencyPlan returns agency plan
|
||||
func (d *Deployment) GetAgencyData(ctx context.Context, i interface{}, keyParts ... string) error {
|
||||
func (d *Deployment) GetAgencyData(ctx context.Context, i interface{}, keyParts ...string) error {
|
||||
a, err := d.GetAgency(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -33,7 +33,6 @@ import (
|
|||
|
||||
"github.com/arangodb/arangosync-client/client"
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/rs/zerolog/log"
|
||||
apiextensionsclient "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
|
@ -48,7 +47,6 @@ import (
|
|||
"github.com/arangodb/kube-arangodb/pkg/generated/clientset/versioned"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/retry"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/trigger"
|
||||
)
|
||||
|
||||
|
@ -465,51 +463,6 @@ func (d *Deployment) updateCRSpec(newSpec api.DeploymentSpec, force ...bool) err
|
|||
}
|
||||
}
|
||||
|
||||
// failOnError reports the given error and sets the deployment status to failed.
|
||||
// Since there is no recovery from a failed deployment, use with care!
|
||||
func (d *Deployment) failOnError(err error, msg string) {
|
||||
log.Error().Err(err).Msg(msg)
|
||||
d.status.last.Reason = err.Error()
|
||||
d.reportFailedStatus()
|
||||
}
|
||||
|
||||
// reportFailedStatus sets the status of the deployment to Failed and keeps trying to forward
|
||||
// that to the API server.
|
||||
func (d *Deployment) reportFailedStatus() {
|
||||
log := d.deps.Log
|
||||
log.Info().Msg("deployment failed. Reporting failed reason...")
|
||||
|
||||
op := func() error {
|
||||
d.status.last.Phase = api.DeploymentPhaseFailed
|
||||
err := d.updateCRStatus()
|
||||
if err == nil || k8sutil.IsNotFound(err) {
|
||||
// Status has been updated
|
||||
return nil
|
||||
}
|
||||
|
||||
if !k8sutil.IsConflict(err) {
|
||||
log.Warn().Err(err).Msg("retry report status: fail to update")
|
||||
return maskAny(err)
|
||||
}
|
||||
|
||||
depl, err := d.deps.DatabaseCRCli.DatabaseV1().ArangoDeployments(d.apiObject.Namespace).Get(d.apiObject.Name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
// Update (PUT) will return conflict even if object is deleted since we have UID set in object.
|
||||
// Because it will check UID first and return something like:
|
||||
// "Precondition failed: UID in precondition: 0xc42712c0f0, UID in object meta: ".
|
||||
if k8sutil.IsNotFound(err) {
|
||||
return nil
|
||||
}
|
||||
log.Warn().Err(err).Msg("retry report status: fail to get latest version")
|
||||
return maskAny(err)
|
||||
}
|
||||
d.apiObject = depl
|
||||
return maskAny(fmt.Errorf("retry needed"))
|
||||
}
|
||||
|
||||
retry.Retry(op, time.Hour*24*365)
|
||||
}
|
||||
|
||||
// isOwnerOf returns true if the given object belong to this deployment.
|
||||
func (d *Deployment) isOwnerOf(obj metav1.Object) bool {
|
||||
ownerRefs := obj.GetOwnerReferences()
|
||||
|
@ -542,7 +495,6 @@ func (d *Deployment) lookForServiceMonitorCRD() {
|
|||
return
|
||||
}
|
||||
log.Warn().Err(err).Msgf("Error when looking for ServiceMonitor CRD")
|
||||
return
|
||||
}
|
||||
|
||||
// SetNumberOfServers adjust number of DBservers and coordinators in arangod
|
||||
|
|
|
@ -72,6 +72,8 @@ const (
|
|||
testImageLifecycle = "arangodb/kube-arangodb:0.3.16"
|
||||
testExporterImage = "arangodb/arangodb-exporter:0.1.6"
|
||||
testImageAlpine = "alpine:3.7"
|
||||
|
||||
testYes = "yes"
|
||||
)
|
||||
|
||||
type testCaseStruct struct {
|
||||
|
@ -984,7 +986,7 @@ func TestEnsurePods(t *testing.T) {
|
|||
}
|
||||
|
||||
testCase.createTestPodData(deployment, api.ServerGroupDBServers, firstDBServerStatus)
|
||||
testCase.ExpectedPod.ObjectMeta.Labels[k8sutil.LabelKeyArangoExporter] = "yes"
|
||||
testCase.ExpectedPod.ObjectMeta.Labels[k8sutil.LabelKeyArangoExporter] = testYes
|
||||
},
|
||||
ExpectedEvent: "member dbserver is created",
|
||||
ExpectedPod: v1.Pod{
|
||||
|
@ -1045,7 +1047,7 @@ func TestEnsurePods(t *testing.T) {
|
|||
}
|
||||
|
||||
testCase.createTestPodData(deployment, api.ServerGroupDBServers, firstDBServerStatus)
|
||||
testCase.ExpectedPod.ObjectMeta.Labels[k8sutil.LabelKeyArangoExporter] = "yes"
|
||||
testCase.ExpectedPod.ObjectMeta.Labels[k8sutil.LabelKeyArangoExporter] = testYes
|
||||
},
|
||||
ExpectedEvent: "member dbserver is created",
|
||||
ExpectedPod: v1.Pod{
|
||||
|
@ -1102,7 +1104,7 @@ func TestEnsurePods(t *testing.T) {
|
|||
}
|
||||
|
||||
testCase.createTestPodData(deployment, api.ServerGroupDBServers, firstDBServerStatus)
|
||||
testCase.ExpectedPod.ObjectMeta.Labels[k8sutil.LabelKeyArangoExporter] = "yes"
|
||||
testCase.ExpectedPod.ObjectMeta.Labels[k8sutil.LabelKeyArangoExporter] = testYes
|
||||
},
|
||||
config: Config{
|
||||
LifecycleImage: testImageLifecycle,
|
||||
|
@ -1171,7 +1173,7 @@ func TestEnsurePods(t *testing.T) {
|
|||
}
|
||||
|
||||
testCase.createTestPodData(deployment, api.ServerGroupDBServers, firstDBServerStatus)
|
||||
testCase.ExpectedPod.ObjectMeta.Labels[k8sutil.LabelKeyArangoExporter] = "yes"
|
||||
testCase.ExpectedPod.ObjectMeta.Labels[k8sutil.LabelKeyArangoExporter] = testYes
|
||||
},
|
||||
config: Config{
|
||||
LifecycleImage: testImageLifecycle,
|
||||
|
@ -1247,7 +1249,7 @@ func TestEnsurePods(t *testing.T) {
|
|||
}
|
||||
|
||||
testCase.createTestPodData(deployment, api.ServerGroupDBServers, firstDBServerStatus)
|
||||
testCase.ExpectedPod.ObjectMeta.Labels[k8sutil.LabelKeyArangoExporter] = "yes"
|
||||
testCase.ExpectedPod.ObjectMeta.Labels[k8sutil.LabelKeyArangoExporter] = testYes
|
||||
|
||||
secrets := deployment.GetKubeCli().CoreV1().Secrets(testNamespace)
|
||||
key := make([]byte, 32)
|
||||
|
|
|
@ -276,7 +276,6 @@ func (i *ImageUpdatePod) GetVolumes() ([]v1.Volume, []v1.VolumeMount) {
|
|||
}
|
||||
|
||||
func (i *ImageUpdatePod) GetSidecars(*v1.Pod) {
|
||||
return
|
||||
}
|
||||
|
||||
func (i *ImageUpdatePod) GetInitContainers() ([]v1.Container, error) {
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
package deployment
|
||||
|
||||
import (
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
|
||||
"k8s.io/client-go/tools/cache"
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ package reconcile
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/arangodb/go-driver/agency"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
|
@ -113,7 +114,7 @@ type ActionContext interface {
|
|||
// newActionContext creates a new ActionContext implementation.
|
||||
func newActionContext(log zerolog.Logger, context Context) ActionContext {
|
||||
return &actionContext{
|
||||
log: log,
|
||||
log: log,
|
||||
context: context,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,9 +25,10 @@ package reconcile
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
kubeErrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
"time"
|
||||
|
||||
kubeErrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
|
||||
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
|
||||
|
|
|
@ -24,6 +24,7 @@ package reconcile
|
|||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/arangodb/arangosync-client/client"
|
||||
driver "github.com/arangodb/go-driver"
|
||||
"github.com/arangodb/go-driver/agency"
|
||||
|
@ -110,7 +111,5 @@ type Context interface {
|
|||
// EnableScalingCluster enables scaling DBservers and coordinators
|
||||
EnableScalingCluster() error
|
||||
// GetAgencyData object for key path
|
||||
GetAgencyData(ctx context.Context, i interface{}, keyParts ... string) error
|
||||
GetAgencyData(ctx context.Context, i interface{}, keyParts ...string) error
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -25,9 +25,10 @@ package reconcile
|
|||
import (
|
||||
goContext "context"
|
||||
"fmt"
|
||||
"github.com/arangodb/kube-arangodb/pkg/deployment/agency"
|
||||
"time"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/deployment/agency"
|
||||
|
||||
driver "github.com/arangodb/go-driver"
|
||||
upgraderules "github.com/arangodb/go-upgrade-rules"
|
||||
"github.com/rs/zerolog"
|
||||
|
@ -85,7 +86,7 @@ func (d *Reconciler) CreatePlan() error {
|
|||
|
||||
func fetchAgency(log zerolog.Logger,
|
||||
spec api.DeploymentSpec, status api.DeploymentStatus,
|
||||
context PlanBuilderContext) (*agency.ArangoPlanDatabases, error) {
|
||||
context PlanBuilderContext) (*agency.ArangoPlanDatabases, error) {
|
||||
if spec.GetMode() != api.DeploymentModeCluster && spec.GetMode() != api.DeploymentModeActiveFailover {
|
||||
return nil, nil
|
||||
} else if status.Members.Agents.MembersReady() > 0 {
|
||||
|
|
|
@ -24,10 +24,11 @@ package reconcile
|
|||
|
||||
import (
|
||||
"context"
|
||||
|
||||
driver "github.com/arangodb/go-driver"
|
||||
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
|
@ -54,7 +55,7 @@ type PlanBuilderContext interface {
|
|||
// GetStatus returns the current status of the deployment
|
||||
GetStatus() (api.DeploymentStatus, int32)
|
||||
// GetAgencyData object for key path
|
||||
GetAgencyData(ctx context.Context, i interface{}, keyParts ... string) error
|
||||
GetAgencyData(ctx context.Context, i interface{}, keyParts ...string) error
|
||||
}
|
||||
|
||||
// newPlanBuilderContext creates a PlanBuilderContext from the given context
|
||||
|
|
|
@ -23,10 +23,11 @@
|
|||
package reconcile
|
||||
|
||||
import (
|
||||
"github.com/arangodb/kube-arangodb/pkg/deployment/pod"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/deployment/pod"
|
||||
|
||||
"github.com/arangodb/go-driver"
|
||||
upgraderules "github.com/arangodb/go-upgrade-rules"
|
||||
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
|
||||
|
|
|
@ -81,7 +81,7 @@ func getServerContainer(containers []core.Container) (core.Container, bool) {
|
|||
return core.Container{}, false
|
||||
}
|
||||
|
||||
func compareSC(a,b *core.SecurityContext) bool {
|
||||
func compareSC(a, b *core.SecurityContext) bool {
|
||||
if a == nil && b == nil {
|
||||
return true
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ func compareSC(a,b *core.SecurityContext) bool {
|
|||
return true
|
||||
}
|
||||
|
||||
func compareCapabilities(a,b *core.Capabilities) bool {
|
||||
func compareCapabilities(a, b *core.Capabilities) bool {
|
||||
if a == nil && b == nil {
|
||||
return true
|
||||
}
|
||||
|
@ -151,4 +151,4 @@ func compareCapabilityLists(a, b []core.Capability) bool {
|
|||
}
|
||||
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -198,9 +198,9 @@ func (c *testContext) GetStatus() (api.DeploymentStatus, int32) {
|
|||
func addAgentsToStatus(t *testing.T, status *api.DeploymentStatus, count int) {
|
||||
for i := 0; i < count; i++ {
|
||||
require.NoError(t, status.Members.Add(api.MemberStatus{
|
||||
ID: fmt.Sprintf("AGNT-%d", i),
|
||||
ID: fmt.Sprintf("AGNT-%d", i),
|
||||
PodName: fmt.Sprintf("agnt-depl-xxx-%d", i),
|
||||
Phase: api.MemberPhaseCreated,
|
||||
Phase: api.MemberPhaseCreated,
|
||||
Conditions: []api.Condition{
|
||||
{
|
||||
Type: api.ConditionTypeReady,
|
||||
|
|
|
@ -33,7 +33,7 @@ const (
|
|||
renewTLSCACertificateTimeout = time.Minute * 30
|
||||
rotateMemberTimeout = time.Minute * 15
|
||||
pvcResizeTimeout = time.Minute * 15
|
||||
pvcResizedTimeout = time.Minute * 15
|
||||
pvcResizedTimeout = time.Minute * 15
|
||||
shutdownMemberTimeout = time.Minute * 30
|
||||
upgradeMemberTimeout = time.Hour * 6
|
||||
waitForMemberUpTimeout = time.Minute * 15
|
||||
|
|
|
@ -30,7 +30,7 @@ import (
|
|||
certificates "github.com/arangodb-helper/go-certificates"
|
||||
"github.com/rs/zerolog"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/kubernetes/typed/core/v1"
|
||||
v1 "k8s.io/client-go/kubernetes/typed/core/v1"
|
||||
|
||||
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
|
||||
|
|
|
@ -30,7 +30,7 @@ import (
|
|||
certificates "github.com/arangodb-helper/go-certificates"
|
||||
"github.com/rs/zerolog"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/kubernetes/typed/core/v1"
|
||||
v1 "k8s.io/client-go/kubernetes/typed/core/v1"
|
||||
|
||||
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
|
||||
|
|
|
@ -21,11 +21,12 @@
|
|||
package resources
|
||||
|
||||
import (
|
||||
"github.com/arangodb/kube-arangodb/pkg/deployment/pod"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strconv"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/deployment/pod"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/constants"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
|
|
|
@ -26,7 +26,6 @@ import (
|
|||
"crypto/sha1"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/arangodb/kube-arangodb/pkg/deployment/pod"
|
||||
"net"
|
||||
"net/url"
|
||||
"path/filepath"
|
||||
|
@ -35,6 +34,8 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/deployment/pod"
|
||||
|
||||
driver "github.com/arangodb/go-driver"
|
||||
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/constants"
|
||||
|
|
|
@ -27,7 +27,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
|
||||
|
|
|
@ -28,7 +28,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
|
||||
|
|
|
@ -25,7 +25,7 @@ package deployment
|
|||
import (
|
||||
"sort"
|
||||
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
|
||||
|
|
|
@ -24,11 +24,12 @@ package operator
|
|||
|
||||
import (
|
||||
"context"
|
||||
"github.com/arangodb/kube-arangodb/pkg/backup/operator/event"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/constants"
|
||||
"math/rand"
|
||||
"time"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/backup/operator/event"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/constants"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
|
@ -212,7 +213,7 @@ func (o *Operator) onStartBackup(stop <-chan struct{}) {
|
|||
|
||||
eventRecorder := event.NewEventRecorder(operatorName, kubeClientSet)
|
||||
|
||||
arangoInformer := arangoInformer.NewSharedInformerFactoryWithOptions(arangoClientSet, 10 * time.Second, arangoInformer.WithNamespace(o.Namespace))
|
||||
arangoInformer := arangoInformer.NewSharedInformerFactoryWithOptions(arangoClientSet, 10*time.Second, arangoInformer.WithNamespace(o.Namespace))
|
||||
|
||||
if err = backup.RegisterInformer(operator, eventRecorder, arangoClientSet, kubeClientSet, arangoInformer); err != nil {
|
||||
panic(err)
|
||||
|
|
|
@ -24,6 +24,7 @@ package operator
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
deploymentType "github.com/arangodb/kube-arangodb/pkg/apis/deployment"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
|
|
@ -24,6 +24,7 @@ package operator
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
replication2 "github.com/arangodb/kube-arangodb/pkg/apis/replication"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
|
|
@ -26,7 +26,7 @@ import (
|
|||
"sort"
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/server"
|
||||
|
|
|
@ -362,12 +362,3 @@ func (dr *DeploymentReplication) reportFailedStatus() {
|
|||
|
||||
retry.Retry(op, time.Hour*24*365)
|
||||
}
|
||||
|
||||
// isOwnerOf returns true if the given object belong to this local storage.
|
||||
func (dr *DeploymentReplication) isOwnerOf(obj metav1.Object) bool {
|
||||
ownerRefs := obj.GetOwnerReferences()
|
||||
if len(ownerRefs) < 1 {
|
||||
return false
|
||||
}
|
||||
return ownerRefs[0].UID == dr.apiObject.UID
|
||||
}
|
||||
|
|
|
@ -90,9 +90,7 @@ func (dr *DeploymentReplication) inspectDeploymentReplication(lastInterval time.
|
|||
} else {
|
||||
if isIncomingEndpoint {
|
||||
// Destination is correctly configured
|
||||
if dr.status.Conditions.Update(api.ConditionTypeConfigured, true, "Active", "Destination syncmaster is configured correctly and active") {
|
||||
updateStatusNeeded = true
|
||||
}
|
||||
dr.status.Conditions.Update(api.ConditionTypeConfigured, true, "Active", "Destination syncmaster is configured correctly and active")
|
||||
// Fetch shard status
|
||||
dr.status.Destination = createEndpointStatus(destStatus, "")
|
||||
updateStatusNeeded = true
|
||||
|
@ -205,11 +203,6 @@ func (dr *DeploymentReplication) inspectDeploymentReplication(lastInterval time.
|
|||
return nextInterval
|
||||
}
|
||||
|
||||
// triggerInspection ensures that an inspection is run soon.
|
||||
func (dr *DeploymentReplication) triggerInspection() {
|
||||
dr.inspectTrigger.Trigger()
|
||||
}
|
||||
|
||||
// isIncomingEndpoint returns true when given sync status's endpoint
|
||||
// intersects with the given endpoint spec.
|
||||
func (dr *DeploymentReplication) isIncomingEndpoint(status client.SyncInfo, epSpec api.EndpointSpec) (bool, error) {
|
||||
|
|
|
@ -56,7 +56,7 @@ type Config struct {
|
|||
|
||||
type OperatorDependency struct {
|
||||
Enabled bool
|
||||
Probe *probe.ReadyProbe
|
||||
Probe *probe.ReadyProbe
|
||||
}
|
||||
|
||||
// Dependencies of the Server
|
||||
|
@ -228,9 +228,9 @@ func createTLSConfig(cert, key string) (*tls.Config, error) {
|
|||
return result, nil
|
||||
}
|
||||
|
||||
func ready(probes ... *probe.ReadyProbe) func(w http.ResponseWriter, r *http.Request) {
|
||||
func ready(probes ...*probe.ReadyProbe) func(w http.ResponseWriter, r *http.Request) {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
for _, probe := range probes {
|
||||
for _, probe := range probes {
|
||||
if !probe.IsReady() {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
|
@ -239,4 +239,4 @@ func ready(probes ... *probe.ReadyProbe) func(w http.ResponseWriter, r *http.Req
|
|||
|
||||
w.WriteHeader(http.StatusOK)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ import (
|
|||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"k8s.io/api/apps/v1"
|
||||
v1 "k8s.io/api/apps/v1"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
package storage
|
||||
|
||||
import (
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ import (
|
|||
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/rs/zerolog/log"
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
corev1 "k8s.io/client-go/kubernetes/typed/core/v1"
|
||||
|
|
|
@ -29,7 +29,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ import (
|
|||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
|
||||
"github.com/dchest/uniuri"
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
api "github.com/arangodb/kube-arangodb/pkg/apis/storage/v1alpha"
|
||||
|
|
|
@ -28,7 +28,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/storage/provisioner"
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
package storage
|
||||
|
||||
import (
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/client-go/tools/cache"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
|
||||
|
|
|
@ -25,7 +25,7 @@ package storage
|
|||
import (
|
||||
"time"
|
||||
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
package storage
|
||||
|
||||
import (
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/client-go/tools/cache"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
package storage
|
||||
|
||||
import (
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ package storage
|
|||
|
||||
import (
|
||||
"github.com/arangodb/kube-arangodb/pkg/server"
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
)
|
||||
|
||||
type serverVolume v1.PersistentVolume
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
package storage
|
||||
|
||||
import (
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
api "github.com/arangodb/kube-arangodb/pkg/apis/storage/v1alpha"
|
||||
|
|
|
@ -24,7 +24,7 @@ package storage
|
|||
|
||||
import (
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
"k8s.io/api/storage/v1"
|
||||
v1 "k8s.io/api/storage/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
api "github.com/arangodb/kube-arangodb/pkg/apis/storage/v1alpha"
|
||||
|
|
|
@ -52,9 +52,7 @@ var (
|
|||
// IsCriticalOption returns true if the given string is the key of
|
||||
// an option of arangod that cannot be overwritten.
|
||||
func IsCriticalOption(optionKey string) bool {
|
||||
if strings.HasPrefix(optionKey, "--") {
|
||||
optionKey = optionKey[2:]
|
||||
}
|
||||
optionKey = strings.TrimPrefix(optionKey, "--")
|
||||
_, found := criticalOptionKeys[optionKey]
|
||||
return found
|
||||
}
|
||||
|
|
|
@ -41,9 +41,7 @@ var (
|
|||
// IsCriticalOption returns true if the given string is the key of
|
||||
// an option of arangosync that cannot be overwritten.
|
||||
func IsCriticalOption(optionKey string) bool {
|
||||
if strings.HasPrefix(optionKey, "--") {
|
||||
optionKey = optionKey[2:]
|
||||
}
|
||||
optionKey = strings.TrimPrefix(optionKey, "--")
|
||||
_, found := criticalOptionKeys[optionKey]
|
||||
return found
|
||||
}
|
||||
|
|
|
@ -31,6 +31,8 @@ import (
|
|||
"os"
|
||||
"syscall"
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
|
||||
driver "github.com/arangodb/go-driver"
|
||||
errs "github.com/pkg/errors"
|
||||
)
|
||||
|
@ -201,3 +203,9 @@ func libCause(err error) (bool, error) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func LogError(logger zerolog.Logger, msg string, f func() error) {
|
||||
if err := f(); err != nil {
|
||||
logger.Error().Err(err).Msg(msg)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ func IsChildResource(kind, name, namespace string, resource meta.Object) bool {
|
|||
|
||||
ownerRef := resource.GetOwnerReferences()
|
||||
|
||||
if ownerRef == nil || len(ownerRef) == 0 {
|
||||
if len(ownerRef) == 0 {
|
||||
return false
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ import (
|
|||
|
||||
driver "github.com/arangodb/go-driver"
|
||||
upgraderules "github.com/arangodb/go-upgrade-rules"
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
|
|
@ -24,7 +24,7 @@ package k8sutil
|
|||
|
||||
import (
|
||||
"github.com/rs/zerolog"
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
)
|
||||
|
|
|
@ -2,7 +2,7 @@ package mocks
|
|||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/watch"
|
||||
"k8s.io/client-go/kubernetes/typed/core/v1"
|
||||
v1 "k8s.io/client-go/kubernetes/typed/core/v1"
|
||||
)
|
||||
|
||||
type coreV1 struct {
|
||||
|
|
|
@ -26,7 +26,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
)
|
||||
|
||||
// TestIsPodReady tests IsPodReady.
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
package k8sutil
|
||||
|
||||
import (
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/util/intstr"
|
||||
)
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
)
|
||||
|
||||
func TestCreate(t *testing.T) {
|
||||
|
|
|
@ -25,7 +25,7 @@ package k8sutil
|
|||
import (
|
||||
"strconv"
|
||||
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/constants"
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
package k8sutil
|
||||
|
||||
import (
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
|
|
|
@ -25,7 +25,7 @@ package k8sutil
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/constants"
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
package k8sutil
|
||||
|
||||
import (
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
|
|
|
@ -25,12 +25,12 @@ package k8sutil
|
|||
import (
|
||||
"testing"
|
||||
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/mock"
|
||||
"k8s.io/api/core/v1"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/mocks"
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
package k8sutil
|
||||
|
||||
import (
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
|
|
|
@ -28,7 +28,7 @@ import (
|
|||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
|
||||
|
|
|
@ -25,7 +25,7 @@ package k8sutil
|
|||
import (
|
||||
"time"
|
||||
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
|
@ -26,7 +26,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ package util
|
|||
import (
|
||||
"time"
|
||||
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
)
|
||||
|
||||
// NewString returns a reference to a string with given value.
|
||||
|
|
|
@ -278,7 +278,6 @@ func checkVolumeAvailable(kube kubernetes.Interface, vname string) (VolumeInfo,
|
|||
if _, err := kube.CoreV1().PersistentVolumes().Update(volume); err != nil {
|
||||
return VolumeInfo{}, errors.Wrapf(err, "failed to remove claim reference")
|
||||
}
|
||||
break
|
||||
default:
|
||||
return VolumeInfo{}, fmt.Errorf("Volume %s phase is %s, expected %s", vname, volume.Status.Phase, corev1.VolumeAvailable)
|
||||
}
|
||||
|
@ -455,7 +454,7 @@ func inspectDatabaseDirectory(dirname string) (*inspectResult, error) {
|
|||
// UUID
|
||||
|
||||
uuidfile := path.Join(dirname, "UUID")
|
||||
uuid, err := ioutil.ReadFile(uuidfile)
|
||||
uuid, err := ioutil.ReadFile(path.Clean(uuidfile))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ import (
|
|||
|
||||
"github.com/dchest/uniuri"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
|
||||
|
|
|
@ -350,7 +350,7 @@ func runSideCarTest(t *testing.T, spec SideCarTest) {
|
|||
if err != nil {
|
||||
t.Fatalf("Deployment not rotated in time: %s", err)
|
||||
}
|
||||
podCreationTimes := getPodCreationTimes(t, kubecli, d);
|
||||
podCreationTimes := getPodCreationTimes(t, kubecli, d)
|
||||
time.Sleep(2 * time.Minute)
|
||||
checkPodCreationTimes(t, kubecli, d, podCreationTimes)
|
||||
})
|
||||
|
|
|
@ -12,6 +12,10 @@ import (
|
|||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/apis/replication"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/apis/deployment"
|
||||
|
||||
sync "github.com/arangodb/arangosync-client/client"
|
||||
"github.com/arangodb/kube-arangodb/pkg/client"
|
||||
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
|
||||
|
@ -58,7 +62,7 @@ func newDeployment(ns, name string) *dapi.ArangoDeployment {
|
|||
return &dapi.ArangoDeployment{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
APIVersion: dapi.SchemeGroupVersion.String(),
|
||||
Kind: dapi.ArangoDeploymentResourceKind,
|
||||
Kind: deployment.ArangoDeploymentResourceKind,
|
||||
},
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: name,
|
||||
|
@ -105,7 +109,7 @@ func newReplication(ns, name string) *rapi.ArangoDeploymentReplication {
|
|||
return &rapi.ArangoDeploymentReplication{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
APIVersion: rapi.SchemeGroupVersion.String(),
|
||||
Kind: rapi.ArangoDeploymentReplicationResourceKind,
|
||||
Kind: replication.ArangoDeploymentReplicationResourceKind,
|
||||
},
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: name,
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue