perf: remove lc dependency
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
package crd
|
||||
|
||||
import (
|
||||
"gitea.com/logicamp/lc"
|
||||
"flink-kube-operator/pkg"
|
||||
|
||||
"github.com/reactivex/rxgo/v2"
|
||||
"go.uber.org/zap"
|
||||
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
|
||||
@@ -10,7 +11,7 @@ import (
|
||||
func (crd Crd) manageFinalizer(jobEventObservable rxgo.Observable) {
|
||||
for j := range jobEventObservable.Observe() {
|
||||
jobEvent := j.V.(*FlinkJobCrdEvent)
|
||||
lc.Logger.Debug("[crd] [manage-finalizer] adding finalizer for", zap.String("name", jobEvent.Job.GetName()))
|
||||
pkg.Logger.Debug("[crd] [manage-finalizer] adding finalizer for", zap.String("name", jobEvent.Job.GetName()))
|
||||
controllerutil.AddFinalizer(jobEvent.Job, "")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,8 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"gitea.com/logicamp/lc"
|
||||
"flink-kube-operator/pkg"
|
||||
|
||||
"go.uber.org/zap"
|
||||
metaV1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
@@ -30,7 +31,7 @@ func (crd *Crd) Patch(jobUid types.UID, patchData map[string]interface{}) error
|
||||
metaV1.PatchOptions{},
|
||||
)
|
||||
if err != nil {
|
||||
lc.Logger.Error(
|
||||
pkg.Logger.Error(
|
||||
"[crd] [status] error patching custom resource status",
|
||||
zap.String("namespace", job.GetNamespace()),
|
||||
zap.Error(err),
|
||||
@@ -39,13 +40,13 @@ func (crd *Crd) Patch(jobUid types.UID, patchData map[string]interface{}) error
|
||||
}
|
||||
newJob, err := convertFromUnstructured(unstructuredJob)
|
||||
if err != nil {
|
||||
lc.Logger.Error("[crd] [status] error in structure unstructured patched", zap.Error(err))
|
||||
pkg.Logger.Error("[crd] [status] error in structure unstructured patched", zap.Error(err))
|
||||
} else {
|
||||
lc.Logger.Debug("[crd] [status] patched")
|
||||
pkg.Logger.Debug("[crd] [status] patched")
|
||||
}
|
||||
jobs[jobUid] = newJob
|
||||
if err != nil {
|
||||
lc.Logger.Error("[crd] [status] ", zap.Error(err))
|
||||
pkg.Logger.Error("[crd] [status] ", zap.Error(err))
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -5,7 +5,8 @@ import (
|
||||
"flink-kube-operator/internal/crd/v1alpha1"
|
||||
"fmt"
|
||||
|
||||
"gitea.com/logicamp/lc"
|
||||
"flink-kube-operator/pkg"
|
||||
|
||||
"github.com/reactivex/rxgo/v2"
|
||||
"go.uber.org/zap"
|
||||
metaV1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
@@ -19,25 +20,25 @@ func (crd Crd) watchFlinkJobs() rxgo.Observable {
|
||||
ch := make(chan rxgo.Item)
|
||||
|
||||
go func() {
|
||||
lc.Logger.Debug("[crd] starting watch")
|
||||
pkg.Logger.Debug("[crd] starting watch")
|
||||
watcher, err := crd.client.Watch(context.Background(), metaV1.ListOptions{})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer watcher.Stop()
|
||||
for event := range watcher.ResultChan() {
|
||||
lc.Logger.Debug("[crd] event received", zap.Any("type", event.Type))
|
||||
pkg.Logger.Debug("[crd] event received", zap.Any("type", event.Type))
|
||||
unstructuredJob := event.Object.(*unstructured.Unstructured)
|
||||
unstructuredMap, _, err := unstructured.NestedMap(unstructuredJob.Object)
|
||||
if err != nil {
|
||||
lc.Logger.Error("cannot create unstructured map", zap.Error(err))
|
||||
pkg.Logger.Error("cannot create unstructured map", zap.Error(err))
|
||||
continue
|
||||
}
|
||||
job := &v1alpha1.FlinkJob{}
|
||||
|
||||
err = runtime.DefaultUnstructuredConverter.FromUnstructured(unstructuredMap, job)
|
||||
if err != nil {
|
||||
lc.Logger.Error("cannot convert unstructured to structured", zap.Error(err))
|
||||
pkg.Logger.Error("cannot convert unstructured to structured", zap.Error(err))
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -50,11 +51,11 @@ func (crd Crd) watchFlinkJobs() rxgo.Observable {
|
||||
switch event.Type {
|
||||
case watch.Bookmark:
|
||||
case watch.Modified:
|
||||
lc.Logger.Info("[crd] [watch] flink job updated")
|
||||
pkg.Logger.Info("[crd] [watch] flink job updated")
|
||||
fmt.Printf("FlinkJob updated: %s\n", job.GetName())
|
||||
crd.repsert(job)
|
||||
case watch.Added:
|
||||
lc.Logger.Info("[crd] [watch] new flink job created")
|
||||
pkg.Logger.Info("[crd] [watch] new flink job created")
|
||||
crd.repsert(job)
|
||||
case watch.Deleted:
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user