Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport PR #2305 to release/v1.7 for Add rotate-all option to rotator #2393

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions internal/errors/rotator.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// Copyright (C) 2019-2024 vdaas.org vald team <vald@vdaas.org>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// You may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

// Package errors provides error types and function
package errors

// ErrReadReplicaIDEmpty represents error when trying to rotate agents with empty replicaID.
var ErrReadReplicaIDEmpty = New("readreplica id is empty. it should be set via MY_TARGET_REPLICA_ID env var")
6 changes: 6 additions & 0 deletions internal/k8s/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (

snapshotv1 "github.com/kubernetes-csi/external-snapshotter/client/v6/apis/volumesnapshot/v1"
"github.com/vdaas/vald/internal/errors"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/equality"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -52,17 +53,22 @@ type (
MatchingLabels = cli.MatchingLabels
InNamespace = cli.InNamespace
VolumeSnapshot = snapshotv1.VolumeSnapshot
Deployment = appsv1.Deployment
DeploymentList = appsv1.DeploymentList
ObjectMeta = metav1.ObjectMeta
)

const (
DeletePropagationBackground = metav1.DeletePropagationBackground
WatchDeletedEvent = watch.Deleted
SelectionOpEquals = selection.Equals
SelectionOpExists = selection.Exists
)

var (
ServerSideApply = cli.Apply
MergePatch = cli.Merge
NewSelector = labels.NewSelector
)

type Client interface {
Expand Down
71 changes: 71 additions & 0 deletions internal/test/mock/k8s/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// Copyright (C) 2019-2024 vdaas.org vald team <vald@vdaas.org>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// You may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package k8s

import (
"context"

"github.com/stretchr/testify/mock"
"github.com/vdaas/vald/internal/k8s/client"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/selection"
"k8s.io/apimachinery/pkg/watch"
crclient "sigs.k8s.io/controller-runtime/pkg/client"
)

type ValdK8sClientMock struct {
mock.Mock
}

var _ client.Client = (*ValdK8sClientMock)(nil)

func (m *ValdK8sClientMock) Get(ctx context.Context, name string, namespace string, obj client.Object, opts ...crclient.GetOption) error {
args := m.Called(ctx, name, namespace, obj, opts)
return args.Error(0)

Check warning on line 35 in internal/test/mock/k8s/client.go

View check run for this annotation

Codecov / codecov/patch

internal/test/mock/k8s/client.go#L33-L35

Added lines #L33 - L35 were not covered by tests
}

func (m *ValdK8sClientMock) List(ctx context.Context, list crclient.ObjectList, opts ...client.ListOption) error {
args := m.Called(ctx, list, opts)
return args.Error(0)
}

func (m *ValdK8sClientMock) Create(ctx context.Context, obj client.Object, opts ...client.CreateOption) error {
args := m.Called(ctx, obj, opts)
return args.Error(0)

Check warning on line 45 in internal/test/mock/k8s/client.go

View check run for this annotation

Codecov / codecov/patch

internal/test/mock/k8s/client.go#L43-L45

Added lines #L43 - L45 were not covered by tests
}

func (m *ValdK8sClientMock) Delete(ctx context.Context, obj client.Object, opts ...crclient.DeleteOption) error {
args := m.Called(ctx, obj, opts)
return args.Error(0)

Check warning on line 50 in internal/test/mock/k8s/client.go

View check run for this annotation

Codecov / codecov/patch

internal/test/mock/k8s/client.go#L48-L50

Added lines #L48 - L50 were not covered by tests
}

func (m *ValdK8sClientMock) Update(ctx context.Context, obj client.Object, opts ...crclient.UpdateOption) error {
args := m.Called(ctx, obj, opts)
return args.Error(0)

Check warning on line 55 in internal/test/mock/k8s/client.go

View check run for this annotation

Codecov / codecov/patch

internal/test/mock/k8s/client.go#L53-L55

Added lines #L53 - L55 were not covered by tests
}

func (m *ValdK8sClientMock) Patch(ctx context.Context, obj client.Object, patch crclient.Patch, opts ...crclient.PatchOption) error {
args := m.Called(ctx, obj, patch, opts)
return args.Error(0)

Check warning on line 60 in internal/test/mock/k8s/client.go

View check run for this annotation

Codecov / codecov/patch

internal/test/mock/k8s/client.go#L58-L60

Added lines #L58 - L60 were not covered by tests
}

func (m *ValdK8sClientMock) Watch(ctx context.Context, obj crclient.ObjectList, opts ...client.ListOption) (watch.Interface, error) {
args := m.Called(ctx, obj, opts)
return args.Get(0).(watch.Interface), args.Error(1)

Check warning on line 65 in internal/test/mock/k8s/client.go

View check run for this annotation

Codecov / codecov/patch

internal/test/mock/k8s/client.go#L63-L65

Added lines #L63 - L65 were not covered by tests
}

func (m *ValdK8sClientMock) LabelSelector(key string, op selection.Operator, vals []string) (labels.Selector, error) {
args := m.Called(key, op, vals)
return args.Get(0).(labels.Selector), args.Error(1)
}
26 changes: 26 additions & 0 deletions internal/test/testify/testify.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (C) 2019-2024 vdaas.org vald team <vald@vdaas.org>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// You may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package testify

import (
"github.com/stretchr/testify/mock"
)

type (
Arguments = mock.Arguments
)

const (
Anything = mock.Anything
)
2 changes: 1 addition & 1 deletion pkg/agent/core/faiss/service/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/vdaas/vald/internal/timeutil"
)

// Option represent the functional option for faiss
// Option represent the functional option for faiss.
type Option func(f *faiss) error

var defaultOptions = []Option{
Expand Down
Loading
Loading