Use batch/v1 instead of batch/v1beta1 (#5562)

This commit is contained in:
hongming
2023-03-03 10:37:38 +08:00
committed by GitHub
parent 24e7f11489
commit f7d0addf9e
4 changed files with 12 additions and 14 deletions

View File

@@ -104,7 +104,7 @@ var SupportedGroupVersionResources = map[ClientType][]schema.GroupVersionResourc
{Group: "storage.k8s.io", Version: "v1", Resource: "storageclasses"},
{Group: "batch", Version: "v1", Resource: "jobs"},
{Group: "batch", Version: "v1beta1", Resource: "cronjobs"},
{Group: "batch", Version: "v1", Resource: "cronjobs"},
{Group: "networking.k8s.io", Version: "v1", Resource: "ingresses"},

View File

@@ -27,7 +27,6 @@ import (
"time"
"github.com/emicklei/go-restful"
"k8s.io/apimachinery/pkg/api/errors"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
@@ -472,7 +471,7 @@ func (s *APIServer) waitForResourceSync(ctx context.Context) error {
{Group: "batch", Version: "v1"}: {
"jobs",
},
{Group: "batch", Version: "v1beta1"}: {
{Group: "batch", Version: "v1"}: {
"cronjobs",
},
{Group: "networking.k8s.io", Version: "v1"}: {

View File

@@ -49,7 +49,7 @@ var supportedResources = map[string]schema.GroupVersionResource{
persistentvolumeclaimsKey: {Group: "", Version: "v1", Resource: "persistentvolumeclaims"},
ingressKey: {Group: "networking.k8s.io", Version: "v1", Resource: "ingresses"},
jobsKey: {Group: "batch", Version: "v1", Resource: "jobs"},
cronJobsKey: {Group: "batch", Version: "v1beta1", Resource: "cronjobs"},
cronJobsKey: {Group: "batch", Version: "v1", Resource: "cronjobs"},
s2iBuilders: {Group: "devops.kubesphere.io", Version: "v1alpha1", Resource: "s2ibuilders"},
}

View File

@@ -19,13 +19,12 @@ package cronjob
import (
"sort"
"k8s.io/api/batch/v1beta1"
v1 "k8s.io/api/batch/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/informers"
"kubesphere.io/kubesphere/pkg/models/resources/v1alpha2"
"kubesphere.io/kubesphere/pkg/server/params"
"k8s.io/apimachinery/pkg/labels"
)
type cronJobSearcher struct {
@@ -37,17 +36,17 @@ func NewCronJobSearcher(informer informers.SharedInformerFactory) v1alpha2.Inter
}
func (c *cronJobSearcher) Get(namespace, name string) (interface{}, error) {
return c.informer.Batch().V1beta1().CronJobs().Lister().CronJobs(namespace).Get(name)
return c.informer.Batch().V1().CronJobs().Lister().CronJobs(namespace).Get(name)
}
func cronJobStatus(item *v1beta1.CronJob) string {
func cronJobStatus(item *v1.CronJob) string {
if item.Spec.Suspend != nil && *item.Spec.Suspend {
return v1alpha2.StatusPaused
}
return v1alpha2.StatusRunning
}
func (*cronJobSearcher) match(match map[string]string, item *v1beta1.CronJob) bool {
func (*cronJobSearcher) match(match map[string]string, item *v1.CronJob) bool {
for k, v := range match {
switch k {
case v1alpha2.Status:
@@ -63,7 +62,7 @@ func (*cronJobSearcher) match(match map[string]string, item *v1beta1.CronJob) bo
return true
}
func (*cronJobSearcher) fuzzy(fuzzy map[string]string, item *v1beta1.CronJob) bool {
func (*cronJobSearcher) fuzzy(fuzzy map[string]string, item *v1.CronJob) bool {
for k, v := range fuzzy {
if !v1alpha2.ObjectMetaFuzzyMath(k, v, item.ObjectMeta) {
@@ -74,7 +73,7 @@ func (*cronJobSearcher) fuzzy(fuzzy map[string]string, item *v1beta1.CronJob) bo
return true
}
func (*cronJobSearcher) compare(left, right *v1beta1.CronJob, orderBy string) bool {
func (*cronJobSearcher) compare(left, right *v1.CronJob, orderBy string) bool {
switch orderBy {
case v1alpha2.LastScheduleTime:
if left.Status.LastScheduleTime == nil {
@@ -90,13 +89,13 @@ func (*cronJobSearcher) compare(left, right *v1beta1.CronJob, orderBy string) bo
}
func (c *cronJobSearcher) Search(namespace string, conditions *params.Conditions, orderBy string, reverse bool) ([]interface{}, error) {
cronJobs, err := c.informer.Batch().V1beta1().CronJobs().Lister().CronJobs(namespace).List(labels.Everything())
cronJobs, err := c.informer.Batch().V1().CronJobs().Lister().CronJobs(namespace).List(labels.Everything())
if err != nil {
return nil, err
}
result := make([]*v1beta1.CronJob, 0)
result := make([]*v1.CronJob, 0)
if len(conditions.Match) == 0 && len(conditions.Fuzzy) == 0 {
result = cronJobs