@@ -11,6 +11,7 @@ import (
1111 "github.com/minio/minio-go/v7/pkg/set"
1212 "k8s.io/apimachinery/pkg/api/meta"
1313
14+ "github.com/minio/operator/pkg/apis/job.min.io/v1alpha1"
1415 clientset "github.com/minio/operator/pkg/client/clientset/versioned"
1516 jobinformers "github.com/minio/operator/pkg/client/informers/externalversions/job.min.io/v1alpha1"
1617 joblisters "github.com/minio/operator/pkg/client/listers/job.min.io/v1alpha1"
@@ -22,6 +23,7 @@ import (
2223 "k8s.io/client-go/tools/record"
2324 "k8s.io/client-go/util/workqueue"
2425 "k8s.io/klog/v2"
26+ "sigs.k8s.io/controller-runtime/pkg/client"
2527)
2628
2729// JobController struct watches the Kubernetes API for changes to Tenant resources
@@ -34,6 +36,7 @@ type JobController struct {
3436 recorder record.EventRecorder
3537 workqueue workqueue.RateLimitingInterface
3638 minioClientSet clientset.Interface
39+ k8sClient client.Client
3740}
3841
3942// runWorker is a long-running function that will continually call the
@@ -144,6 +147,7 @@ func NewJobController(
144147 recorder record.EventRecorder ,
145148 workqueue workqueue.RateLimitingInterface ,
146149 minioClientSet clientset.Interface ,
150+ k8sClient client.Client ,
147151) * JobController {
148152 controller := & JobController {
149153 namespacesToWatch : namespacesToWatch ,
@@ -154,6 +158,7 @@ func NewJobController(
154158 recorder : recorder ,
155159 workqueue : workqueue ,
156160 minioClientSet : minioClientSet ,
161+ k8sClient : k8sClient ,
157162 }
158163
159164 // Set up an event handler for when resources change
@@ -203,7 +208,13 @@ func (c *JobController) SyncHandler(key string) (Result, error) {
203208 return WrapResult (Result {}, nil )
204209 }
205210 namespace , tenantName := key2NamespaceName (key )
206- jobCR , err := c .minioClientSet .JobV1alpha1 ().MinIOJobs (namespace ).Get (context .Background (), tenantName , metav1.GetOptions {})
211+ jobCR := v1alpha1.MinIOJob {
212+ ObjectMeta : metav1.ObjectMeta {
213+ Name : tenantName ,
214+ Namespace : namespace ,
215+ },
216+ }
217+ err := c .k8sClient .Get (context .Background (), client .ObjectKeyFromObject (& jobCR ), & jobCR )
207218 if err != nil {
208219 return WrapResult (Result {RequeueAfter : time .Second * 5 }, nil )
209220 }
0 commit comments