Skip to content
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
2 changes: 1 addition & 1 deletion cmd/webhook/app/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func handle() {
}

// register admission handlers
handler.Register(mgr, mgr.GetClient(), setupLog)
handler.Register(mgr, setupLog)

// register pod mutating handlers
err = plugins.RegisterMutatingHandlers(mgr.GetClient())
Expand Down
6 changes: 3 additions & 3 deletions pkg/application/inject/fuse/injector_runtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ func TestInjectList(t *testing.T) {
if err != nil {
t.Errorf("testcase %s failed due to error %v", testcase.name, err)
}
runtimeInfo.SetClient(fakeClient)
runtimeInfo.SetAPIReader(fakeClient)
runtimeInfos[pvc] = runtimeInfo
}

Expand Down Expand Up @@ -261,7 +261,7 @@ func TestInjectUnstructured(t *testing.T) {
if err != nil {
t.Errorf("testcase %s failed due to error %v", name, err)
}
runtimeInfo.SetClient(fakeClient)
runtimeInfo.SetAPIReader(fakeClient)
runtimeInfos[name] = runtimeInfo
pod := corev1.Pod{
TypeMeta: metav1.TypeMeta{
Expand Down Expand Up @@ -330,7 +330,7 @@ func TestInjectObject(t *testing.T) {
if err != nil {
t.Errorf("testcase %s failed due to error %v", name, err)
}
runtimeInfo.SetClient(fakeClient)
runtimeInfo.SetAPIReader(fakeClient)
runtimeInfos[name] = runtimeInfo

deploy := appsv1.Deployment{
Expand Down
14 changes: 7 additions & 7 deletions pkg/application/inject/fuse/injector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1158,7 +1158,7 @@ func TestInjectPod(t *testing.T) {
if err != nil {
t.Errorf("testcase %s failed due to error %v", testcase.name, err)
}
runtimeInfo.SetClient(fakeClient)
runtimeInfo.SetAPIReader(fakeClient)
runtimeInfos[pvc] = runtimeInfo
}

Expand Down Expand Up @@ -1448,7 +1448,7 @@ func TestSkipInjectPod(t *testing.T) {
if err != nil {
t.Errorf("testcase %s failed due to error %v", testcase.name, err)
}
runtimeInfo.SetClient(fakeClient)
runtimeInfo.SetAPIReader(fakeClient)
runtimeInfos[pvc] = runtimeInfo
}

Expand Down Expand Up @@ -2375,7 +2375,7 @@ func TestInjectPodWithMultiplePVC(t *testing.T) {
if err != nil {
t.Errorf("testcase %s failed due to error %v", testcase.name, err)
}
runtimeInfo.SetClient(fakeClient)
runtimeInfo.SetAPIReader(fakeClient)
runtimeInfos[pvc] = runtimeInfo
}

Expand Down Expand Up @@ -2839,7 +2839,7 @@ func TestInjectPodWithDatasetSubPath(t *testing.T) {
if err != nil {
t.Errorf("testcase %s failed due to error %v", testcase.name, err)
}
runtimeInfo.SetClient(fakeClient)
runtimeInfo.SetAPIReader(fakeClient)
runtimeInfos[pvc] = runtimeInfo
}

Expand Down Expand Up @@ -4120,7 +4120,7 @@ func TestInjectPodUnprivileged(t *testing.T) {
if err != nil {
t.Errorf("testcase %s failed due to error %v", testcase.name, err)
}
runtimeInfo.SetClient(fakeClient)
runtimeInfo.SetAPIReader(fakeClient)
runtimeInfos[pvc] = runtimeInfo
}

Expand Down Expand Up @@ -5227,7 +5227,7 @@ func TestInjectPodWithInitContainer(t *testing.T) {
if err != nil {
t.Errorf("testcase %s failed due to error %v", testcase.name, err)
}
runtimeInfo.SetClient(fakeClient)
runtimeInfo.SetAPIReader(fakeClient)
runtimeInfos[pvc] = runtimeInfo
}

Expand Down Expand Up @@ -6205,7 +6205,7 @@ func TestInjectPodWithEnabledFUSEMetrics(t *testing.T) {
if err != nil {
t.Errorf("testcase %s failed due to error %v", testcase.name, err)
}
runtimeInfo.SetClient(fakeClient)
runtimeInfo.SetAPIReader(fakeClient)
runtimeInfos[pvc] = runtimeInfo
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/common/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ const (
type AdmissionHandler interface {
admission.Handler

Setup(client client.Client, decoder *admission.Decoder)
Setup(client client.Client, reader client.Reader, decoder *admission.Decoder)
}
6 changes: 3 additions & 3 deletions pkg/ddc/alluxio/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestQueryCacheStatus(t *testing.T) {
defer patch1.Reset()

patch2 := ApplyFunc(utils.GetDataset,
func(_ client.Client, _ string, _ string) (*datav1alpha1.Dataset, error) {
func(_ client.Reader, _ string, _ string) (*datav1alpha1.Dataset, error) {
d := &datav1alpha1.Dataset{
Status: datav1alpha1.DatasetStatus{
UfsTotal: "52.18MiB",
Expand Down Expand Up @@ -95,7 +95,7 @@ func TestQueryCacheStatus(t *testing.T) {
defer patch1.Reset()

patch2 := ApplyFunc(utils.GetDataset,
func(_ client.Client, _ string, _ string) (*datav1alpha1.Dataset, error) {
func(_ client.Reader, _ string, _ string) (*datav1alpha1.Dataset, error) {
d := &datav1alpha1.Dataset{
Status: datav1alpha1.DatasetStatus{
UfsTotal: "[Calculating]",
Expand Down Expand Up @@ -132,7 +132,7 @@ func TestQueryCacheStatus(t *testing.T) {
defer patch1.Reset()

patch2 := ApplyFunc(utils.GetDataset,
func(_ client.Client, _ string, _ string) (*datav1alpha1.Dataset, error) {
func(_ client.Reader, _ string, _ string) (*datav1alpha1.Dataset, error) {
d := &datav1alpha1.Dataset{
Status: datav1alpha1.DatasetStatus{
UfsTotal: "",
Expand Down
2 changes: 1 addition & 1 deletion pkg/ddc/alluxio/shutdown_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ func TestAlluxioEngineCleanupCache(t *testing.T) {
defer patch1.Reset()

patch2 := ApplyFunc(utils.GetDataset,
func(_ client.Client, _ string, _ string) (*datav1alpha1.Dataset, error) {
func(_ client.Reader, _ string, _ string) (*datav1alpha1.Dataset, error) {
d := &datav1alpha1.Dataset{
Status: datav1alpha1.DatasetStatus{
UfsTotal: "19.07MiB",
Expand Down
2 changes: 1 addition & 1 deletion pkg/ddc/alluxio/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func TestCheckAndUpdateRuntimeStatus(t *testing.T) {
defer patch1.Reset()

patch2 := ApplyFunc(utils.GetDataset,
func(_ client.Client, _ string, _ string) (*datav1alpha1.Dataset, error) {
func(_ client.Reader, _ string, _ string) (*datav1alpha1.Dataset, error) {
d := &datav1alpha1.Dataset{
Status: datav1alpha1.DatasetStatus{
UfsTotal: "19.07MiB",
Expand Down
28 changes: 14 additions & 14 deletions pkg/ddc/base/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ type RuntimeInfoInterface interface {

GetFuseContainerTemplate() (template *common.FuseInjectionTemplate, err error)

SetClient(client client.Client)
SetAPIReader(apiReader client.Reader)

GetMetadataList() []datav1alpha1.Metadata

Expand Down Expand Up @@ -138,7 +138,7 @@ type RuntimeInfo struct {
// Check if the deprecated PV naming style is used
deprecatedPVName bool

client client.Client
apiReader client.Reader

annotations map[string]string

Expand Down Expand Up @@ -367,8 +367,8 @@ func (info *RuntimeInfo) IsDeprecatedPVName() bool {
return info.deprecatedPVName
}

func (info *RuntimeInfo) SetClient(client client.Client) {
info.client = client
func (info *RuntimeInfo) SetAPIReader(apiReader client.Reader) {
info.apiReader = apiReader
}

func convertToTieredstoreInfo(tieredstore datav1alpha1.TieredStore) (TieredStoreInfo, error) {
Expand Down Expand Up @@ -432,8 +432,8 @@ func convertToTieredstoreInfo(tieredstore datav1alpha1.TieredStore) (TieredStore
}

// GetRuntimeInfo gets the RuntimeInfo according to name and namespace of it
func GetRuntimeInfo(client client.Client, name, namespace string) (runtimeInfo RuntimeInfoInterface, err error) {
dataset, err := utils.GetDataset(client, name, namespace)
func GetRuntimeInfo(reader client.Reader, name, namespace string) (runtimeInfo RuntimeInfoInterface, err error) {
dataset, err := utils.GetDataset(reader, name, namespace)
if err != nil {
return runtimeInfo, err
}
Expand All @@ -444,7 +444,7 @@ func GetRuntimeInfo(client client.Client, name, namespace string) (runtimeInfo R
}
switch runtimeType {
case common.AlluxioRuntime:
alluxioRuntime, err := utils.GetAlluxioRuntime(client, name, namespace)
alluxioRuntime, err := utils.GetAlluxioRuntime(reader, name, namespace)
if err != nil {
return runtimeInfo, err
}
Expand All @@ -460,7 +460,7 @@ func GetRuntimeInfo(client client.Client, name, namespace string) (runtimeInfo R
runtimeInfo.SetFuseNodeSelector(alluxioRuntime.Spec.Fuse.NodeSelector)
runtimeInfo.SetupFuseCleanPolicy(alluxioRuntime.Spec.Fuse.CleanPolicy)
case common.JindoRuntime:
jindoRuntime, err := utils.GetJindoRuntime(client, name, namespace)
jindoRuntime, err := utils.GetJindoRuntime(reader, name, namespace)
if err != nil {
return runtimeInfo, err
}
Expand All @@ -477,7 +477,7 @@ func GetRuntimeInfo(client client.Client, name, namespace string) (runtimeInfo R
runtimeInfo.SetFuseNodeSelector(jindoRuntime.Spec.Fuse.NodeSelector)
runtimeInfo.SetupFuseCleanPolicy(jindoRuntime.Spec.Fuse.CleanPolicy)
case common.GooseFSRuntime:
goosefsRuntime, err := utils.GetGooseFSRuntime(client, name, namespace)
goosefsRuntime, err := utils.GetGooseFSRuntime(reader, name, namespace)
if err != nil {
return runtimeInfo, err
}
Expand All @@ -493,7 +493,7 @@ func GetRuntimeInfo(client client.Client, name, namespace string) (runtimeInfo R
runtimeInfo.SetFuseNodeSelector(goosefsRuntime.Spec.Fuse.NodeSelector)
runtimeInfo.SetupFuseCleanPolicy(goosefsRuntime.Spec.Fuse.CleanPolicy)
case common.JuiceFSRuntime:
juicefsRuntime, err := utils.GetJuiceFSRuntime(client, name, namespace)
juicefsRuntime, err := utils.GetJuiceFSRuntime(reader, name, namespace)
if err != nil {
return runtimeInfo, err
}
Expand All @@ -509,7 +509,7 @@ func GetRuntimeInfo(client client.Client, name, namespace string) (runtimeInfo R
runtimeInfo.SetFuseNodeSelector(juicefsRuntime.Spec.Fuse.NodeSelector)
runtimeInfo.SetupFuseCleanPolicy(juicefsRuntime.Spec.Fuse.CleanPolicy)
case common.ThinRuntime:
thinRuntime, err := utils.GetThinRuntime(client, name, namespace)
thinRuntime, err := utils.GetThinRuntime(reader, name, namespace)
if err != nil {
return runtimeInfo, err
}
Expand All @@ -525,7 +525,7 @@ func GetRuntimeInfo(client client.Client, name, namespace string) (runtimeInfo R
runtimeInfo.SetFuseNodeSelector(thinRuntime.Spec.Fuse.NodeSelector)
runtimeInfo.SetupFuseCleanPolicy(thinRuntime.Spec.Fuse.CleanPolicy)
case common.EFCRuntime:
efcRuntime, err := utils.GetEFCRuntime(client, name, namespace)
efcRuntime, err := utils.GetEFCRuntime(reader, name, namespace)
if err != nil {
return runtimeInfo, err
}
Expand All @@ -541,7 +541,7 @@ func GetRuntimeInfo(client client.Client, name, namespace string) (runtimeInfo R
runtimeInfo.SetFuseNodeSelector(efcRuntime.Spec.Fuse.NodeSelector)
runtimeInfo.SetupFuseCleanPolicy(efcRuntime.Spec.Fuse.CleanPolicy)
case common.VineyardRuntime:
vineyardRuntime, err := utils.GetVineyardRuntime(client, name, namespace)
vineyardRuntime, err := utils.GetVineyardRuntime(reader, name, namespace)
if err != nil {
return runtimeInfo, err
}
Expand All @@ -562,7 +562,7 @@ func GetRuntimeInfo(client client.Client, name, namespace string) (runtimeInfo R
}

if runtimeInfo != nil {
runtimeInfo.SetClient(client)
runtimeInfo.SetAPIReader(reader)
runtimeInfo.SetOwnerDatasetUID(dataset.UID)
}
return runtimeInfo, err
Expand Down
6 changes: 3 additions & 3 deletions pkg/ddc/base/runtime_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (info *RuntimeInfo) GetFuseContainerTemplate() (template *common.FuseInject
}

func (info *RuntimeInfo) getFuseDaemonset() (ds *appsv1.DaemonSet, err error) {
if info.client == nil {
if info.apiReader == nil {
err = fmt.Errorf("client is not set")
return
}
Expand All @@ -84,11 +84,11 @@ func (info *RuntimeInfo) getFuseDaemonset() (ds *appsv1.DaemonSet, err error) {
default:
fuseName = info.name + "-fuse"
}
return kubeclient.GetDaemonset(info.client, fuseName, info.GetNamespace())
return kubeclient.GetDaemonset(info.apiReader, fuseName, info.GetNamespace())
}

func (info *RuntimeInfo) getMountInfo() (path, mountType, subpath string, err error) {
pv, err := kubeclient.GetPersistentVolume(info.client, info.GetPersistentVolumeName())
pv, err := kubeclient.GetPersistentVolume(info.apiReader, info.GetPersistentVolumeName())
if err != nil {
err = errors.Wrapf(err, "cannot find pvc \"%s/%s\"'s bounded PV", info.namespace, info.name)
return
Expand Down
10 changes: 5 additions & 5 deletions pkg/ddc/base/runtime_helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ import (
// if err != nil {
// t.Errorf("testcase %s failed due to error %v", testcase.name, err)
// }
// runtimeInfo.SetClient(fakeClient)
// runtimeInfo.SetAPIReader(fakeClient)
// _, err = runtimeInfo.GetTemplateToInjectForFuse(testcase.pvcName, testcase.pvc.Namespace, options)
// if (err == nil) == testcase.expectErr {
// t.Errorf("testcase %s failed due to expecting want error: %v error %v", testcase.name, testcase.expectErr, err)
Expand Down Expand Up @@ -866,7 +866,7 @@ import (
// if err != nil {
// t.Errorf("testcase %s failed due to error %v", testcase.name, err)
// }
// runtimeInfo.SetClient(fakeClient)
// runtimeInfo.SetAPIReader(fakeClient)
// _, err = runtimeInfo.GetTemplateToInjectForFuse(testcase.pvcName, testcase.pvc.Namespace, options)
// if (err == nil) == testcase.expectErr {
// t.Errorf("testcase %s failed due to expecting want error: %v error %v", testcase.name, testcase.expectErr, err)
Expand Down Expand Up @@ -1075,7 +1075,7 @@ import (
// if err != nil {
// t.Errorf("testcase %s failed due to error %v", testcase.name, err)
// }
// runtimeInfo.SetClient(fakeClient)
// runtimeInfo.SetAPIReader(fakeClient)
// template, err := runtimeInfo.GetTemplateToInjectForFuse(testcase.pvcName, testcase.pvc.Namespace, options)
// if (err == nil) == testcase.expectErr {
// t.Errorf("testcase %s failed due to expecting want error: %v error %v", testcase.name, testcase.expectErr, err)
Expand Down Expand Up @@ -1158,7 +1158,7 @@ func TestGetFuseDaemonset(t *testing.T) {
}

if fakeClient != nil {
runtimeInfo.SetClient(fakeClient)
runtimeInfo.SetAPIReader(fakeClient)
}

_, err := runtimeInfo.getFuseDaemonset()
Expand Down Expand Up @@ -1302,7 +1302,7 @@ func TestGetMountInfoFromVolumeClaim(t *testing.T) {
name: tt.args.name,
namespace: tt.args.namespace,
runtimeType: common.JindoRuntime,
client: fake.NewFakeClientWithScheme(testScheme, objs...),
apiReader: fake.NewFakeClientWithScheme(testScheme, objs...),
}

path, mountType, subpath, err := runtimeInfo.getMountInfo()
Expand Down
4 changes: 2 additions & 2 deletions pkg/ddc/base/runtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1149,11 +1149,11 @@ func TestGetRuntimeInfo(t *testing.T) {
return
}
if got != nil {
got.SetClient(nil)
got.SetAPIReader(nil)
}

if tt.want != nil {
tt.want.SetClient(nil)
tt.want.SetAPIReader(nil)
}

if !tt.wantErr && !reflect.DeepEqual(got, tt.want) {
Expand Down
6 changes: 3 additions & 3 deletions pkg/ddc/goosefs/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestQueryCacheStatus(t *testing.T) {
defer patch1.Reset()

patch2 := ApplyFunc(utils.GetDataset,
func(_ client.Client, _ string, _ string) (*datav1alpha1.Dataset, error) {
func(_ client.Reader, _ string, _ string) (*datav1alpha1.Dataset, error) {
d := &datav1alpha1.Dataset{
Status: datav1alpha1.DatasetStatus{
UfsTotal: "52.18MiB",
Expand Down Expand Up @@ -89,7 +89,7 @@ func TestQueryCacheStatus(t *testing.T) {
defer patch1.Reset()

patch2 := ApplyFunc(utils.GetDataset,
func(_ client.Client, _ string, _ string) (*datav1alpha1.Dataset, error) {
func(_ client.Reader, _ string, _ string) (*datav1alpha1.Dataset, error) {
d := &datav1alpha1.Dataset{
Status: datav1alpha1.DatasetStatus{
UfsTotal: "[Calculating]",
Expand Down Expand Up @@ -126,7 +126,7 @@ func TestQueryCacheStatus(t *testing.T) {
defer patch1.Reset()

patch2 := ApplyFunc(utils.GetDataset,
func(_ client.Client, _ string, _ string) (*datav1alpha1.Dataset, error) {
func(_ client.Reader, _ string, _ string) (*datav1alpha1.Dataset, error) {
d := &datav1alpha1.Dataset{
Status: datav1alpha1.DatasetStatus{
UfsTotal: "",
Expand Down
2 changes: 1 addition & 1 deletion pkg/ddc/goosefs/shutdown_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ func TestGooseFSEngineCleanupCache(t *testing.T) {
defer patch1.Reset()

patch2 := ApplyFunc(utils.GetDataset,
func(_ client.Client, _ string, _ string) (*datav1alpha1.Dataset, error) {
func(_ client.Reader, _ string, _ string) (*datav1alpha1.Dataset, error) {
d := &datav1alpha1.Dataset{
Status: datav1alpha1.DatasetStatus{
UfsTotal: "19.07MiB",
Expand Down
2 changes: 1 addition & 1 deletion pkg/ddc/goosefs/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func TestCheckAndUpdateRuntimeStatus(t *testing.T) {
defer patch1.Reset()

patch2 := ApplyFunc(utils.GetDataset,
func(_ client.Client, _ string, _ string) (*datav1alpha1.Dataset, error) {
func(_ client.Reader, _ string, _ string) (*datav1alpha1.Dataset, error) {
d := &datav1alpha1.Dataset{
Status: datav1alpha1.DatasetStatus{
UfsTotal: "19.07MiB",
Expand Down
Loading
Loading