mirror of
https://github.com/kubernetes/kubernetes.git
synced 2026-05-28 04:04:39 -04:00
Migrate internal references from v1alpha2 to v1alpha3 in scheduler and admission plugins
This commit is contained in:
parent
6404ddc2b7
commit
43ebd00b66
28 changed files with 147 additions and 147 deletions
|
|
@ -623,7 +623,7 @@ func addAllEventHandlers(
|
|||
handlers = append(handlers, handlerRegistration)
|
||||
case fwk.PodGroup:
|
||||
if utilfeature.DefaultFeatureGate.Enabled(features.GenericWorkload) {
|
||||
if handlerRegistration, err = informerFactory.Scheduling().V1alpha2().PodGroups().Informer().AddEventHandler(
|
||||
if handlerRegistration, err = informerFactory.Scheduling().V1alpha3().PodGroups().Informer().AddEventHandler(
|
||||
buildEvtResHandler(at, fwk.PodGroup),
|
||||
); err != nil {
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import (
|
|||
v1 "k8s.io/api/core/v1"
|
||||
resourceapi "k8s.io/api/resource/v1"
|
||||
resourcebetaapi "k8s.io/api/resource/v1beta2"
|
||||
schedulingapi "k8s.io/api/scheduling/v1alpha2"
|
||||
schedulingapi "k8s.io/api/scheduling/v1alpha3"
|
||||
storagev1 "k8s.io/api/storage/v1"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import (
|
|||
"time"
|
||||
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/api/scheduling/v1alpha2"
|
||||
"k8s.io/api/scheduling/v1alpha3"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
fwk "k8s.io/kube-scheduler/framework"
|
||||
"k8s.io/kubernetes/pkg/scheduler/apis/config"
|
||||
|
|
@ -172,7 +172,7 @@ type PodGroupPostFilterPlugin interface {
|
|||
fwk.Plugin
|
||||
|
||||
// PodGroupPostFilter is called after a PodGroup cannot be scheduled.
|
||||
PodGroupPostFilter(ctx context.Context, pg *v1alpha2.PodGroup, pods []*v1.Pod, pgSchedulingFunc PodGroupSchedulingFunc) *fwk.Status
|
||||
PodGroupPostFilter(ctx context.Context, pg *v1alpha3.PodGroup, pods []*v1.Pod, pgSchedulingFunc PodGroupSchedulingFunc) *fwk.Status
|
||||
}
|
||||
|
||||
// Framework manages the set of plugins in use by the scheduling framework.
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import (
|
|||
|
||||
v1 "k8s.io/api/core/v1"
|
||||
policy "k8s.io/api/policy/v1"
|
||||
schedulingapi "k8s.io/api/scheduling/v1alpha2"
|
||||
schedulingapi "k8s.io/api/scheduling/v1alpha3"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
|
|
@ -114,7 +114,7 @@ func New(_ context.Context, dpArgs runtime.Object, fh fwk.Handle, fts feature.Fe
|
|||
pl.Evaluator = preemption.NewEvaluator(Name, fh, &pl, pl.Executor)
|
||||
|
||||
if pl.fts.EnableWorkloadAwarePreemption || pl.fts.EnableTopologyAwareWorkloadScheduling {
|
||||
pl.pgLister = fh.SharedInformerFactory().Scheduling().V1alpha2().PodGroups().Lister()
|
||||
pl.pgLister = fh.SharedInformerFactory().Scheduling().V1alpha3().PodGroups().Lister()
|
||||
}
|
||||
if pl.fts.EnableWorkloadAwarePreemption {
|
||||
pl.podGroupEvaluator = preemption.NewPodGroupEvaluator(fh, pl.Executor)
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ import (
|
|||
|
||||
v1 "k8s.io/api/core/v1"
|
||||
policy "k8s.io/api/policy/v1"
|
||||
"k8s.io/api/scheduling/v1alpha2"
|
||||
"k8s.io/api/scheduling/v1alpha3"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
|
|
@ -529,7 +529,7 @@ func TestPostFilter(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
pgInformer := informerFactory.Scheduling().V1alpha2().PodGroups().Informer()
|
||||
pgInformer := informerFactory.Scheduling().V1alpha3().PodGroups().Informer()
|
||||
for i := range tt.podGroups {
|
||||
if err := pgInformer.GetStore().Add(tt.podGroups[i]); err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
@ -2578,7 +2578,7 @@ func TestPreEnqueue(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
pgInformer := informerFactory.Scheduling().V1alpha2().PodGroups().Informer()
|
||||
pgInformer := informerFactory.Scheduling().V1alpha3().PodGroups().Informer()
|
||||
for i := range tt.pgs {
|
||||
if err := pgInformer.GetStore().Add(tt.pgs[i]); err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
@ -2632,7 +2632,7 @@ func TestPreEnqueue(t *testing.T) {
|
|||
// Trigger preemption. Given custom PreemptPod implementation, the async preemption will not finish until
|
||||
// finishPreemption is closed.
|
||||
if tt.features.EnableWorkloadAwarePreemption && tt.podToTriggerPreemption.Spec.SchedulingGroup != nil {
|
||||
pg, err := informerFactory.Scheduling().V1alpha2().PodGroups().Lister().PodGroups(tt.podToTriggerPreemption.Namespace).Get(*tt.podToTriggerPreemption.Spec.SchedulingGroup.PodGroupName)
|
||||
pg, err := informerFactory.Scheduling().V1alpha3().PodGroups().Lister().PodGroups(tt.podToTriggerPreemption.Namespace).Get(*tt.podToTriggerPreemption.Spec.SchedulingGroup.PodGroupName)
|
||||
if err != nil {
|
||||
t.Fatalf("could not find pg: %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import (
|
|||
"github.com/go-logr/logr"
|
||||
|
||||
resourceapi "k8s.io/api/resource/v1"
|
||||
schedulingapi "k8s.io/api/scheduling/v1alpha2"
|
||||
schedulingapi "k8s.io/api/scheduling/v1alpha3"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
|
|
@ -78,7 +78,7 @@ func NewDRAManager(ctx context.Context, claimsCache *assumecache.AssumeCache, re
|
|||
|
||||
pgLister := &podGroupLister{}
|
||||
if utilfeature.DefaultFeatureGate.Enabled(features.DRAWorkloadResourceClaims) {
|
||||
pgLister.podGroupLister = informerFactory.Scheduling().V1alpha2().PodGroups().Lister()
|
||||
pgLister.podGroupLister = informerFactory.Scheduling().V1alpha3().PodGroups().Lister()
|
||||
}
|
||||
manager.podGroupLister = pgLister
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import (
|
|||
|
||||
v1 "k8s.io/api/core/v1"
|
||||
resourceapi "k8s.io/api/resource/v1"
|
||||
schedulingapi "k8s.io/api/scheduling/v1alpha2"
|
||||
schedulingapi "k8s.io/api/scheduling/v1alpha3"
|
||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
apimeta "k8s.io/apimachinery/pkg/api/meta"
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
resourceapi "k8s.io/api/resource/v1"
|
||||
schedulingapi "k8s.io/api/scheduling/v1alpha2"
|
||||
schedulingapi "k8s.io/api/scheduling/v1alpha3"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
apiresource "k8s.io/apimachinery/pkg/api/resource"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
|
@ -4030,7 +4030,7 @@ func setup(tCtx ktesting.TContext, args *config.DynamicResourcesArgs, nodes []*v
|
|||
tCtx.ExpectNoError(err, "create resource class")
|
||||
}
|
||||
for _, podGroup := range podGroups {
|
||||
_, err := tc.client.SchedulingV1alpha2().PodGroups(podGroup.Namespace).Create(tCtx, podGroup, metav1.CreateOptions{})
|
||||
_, err := tc.client.SchedulingV1alpha3().PodGroups(podGroup.Namespace).Create(tCtx, podGroup, metav1.CreateOptions{})
|
||||
tCtx.ExpectNoError(err, "create pod group")
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import (
|
|||
"time"
|
||||
|
||||
v1 "k8s.io/api/core/v1"
|
||||
schedulingapi "k8s.io/api/scheduling/v1alpha2"
|
||||
schedulingapi "k8s.io/api/scheduling/v1alpha3"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
schedulinglisters "k8s.io/client-go/listers/scheduling/v1alpha2"
|
||||
|
|
@ -59,7 +59,7 @@ var _ fwk.PermitPlugin = &GangScheduling{}
|
|||
func New(_ context.Context, _ runtime.Object, fh fwk.Handle, fts feature.Features) (fwk.Plugin, error) {
|
||||
return &GangScheduling{
|
||||
handle: fh,
|
||||
podGroupLister: fh.SharedInformerFactory().Scheduling().V1alpha2().PodGroups().Lister(),
|
||||
podGroupLister: fh.SharedInformerFactory().Scheduling().V1alpha3().PodGroups().Lister(),
|
||||
podGroupManager: fh.PodGroupManager(),
|
||||
snapshotLister: fh.SnapshotSharedLister(),
|
||||
}, nil
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import (
|
|||
"github.com/google/go-cmp/cmp"
|
||||
|
||||
v1 "k8s.io/api/core/v1"
|
||||
schedulingapi "k8s.io/api/scheduling/v1alpha2"
|
||||
schedulingapi "k8s.io/api/scheduling/v1alpha3"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||
"k8s.io/client-go/informers"
|
||||
|
|
@ -264,7 +264,7 @@ func TestGangSchedulingFlow(t *testing.T) {
|
|||
cache := internalcache.New(ctx, nil, true)
|
||||
|
||||
informerFactory := informers.NewSharedInformerFactory(fake.NewClientset(), 0)
|
||||
podGroupInformer := informerFactory.Scheduling().V1alpha2().PodGroups()
|
||||
podGroupInformer := informerFactory.Scheduling().V1alpha3().PodGroups()
|
||||
fakeActivator := &podActivatorMock{}
|
||||
snapshot := internalcache.NewEmptySnapshot()
|
||||
fh, err := frameworkruntime.NewFramework(ctx, nil, nil,
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ import (
|
|||
"fmt"
|
||||
|
||||
v1 "k8s.io/api/core/v1"
|
||||
schedulingapi "k8s.io/api/scheduling/v1alpha2"
|
||||
schedulingapi "k8s.io/api/scheduling/v1alpha3"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
schedulinglisters "k8s.io/client-go/listers/scheduling/v1alpha2"
|
||||
schedulinglisters "k8s.io/client-go/listers/scheduling/v1alpha3"
|
||||
"k8s.io/klog/v2"
|
||||
fwk "k8s.io/kube-scheduler/framework"
|
||||
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/feature"
|
||||
|
|
@ -47,7 +47,7 @@ var _ fwk.PlacementGeneratePlugin = &TopologyPlacement{}
|
|||
func New(_ context.Context, _ runtime.Object, fh fwk.Handle, fts feature.Features) (*TopologyPlacement, error) {
|
||||
return &TopologyPlacement{
|
||||
handle: fh,
|
||||
podGroupLister: fh.SharedInformerFactory().Scheduling().V1alpha2().PodGroups().Lister(),
|
||||
podGroupLister: fh.SharedInformerFactory().Scheduling().V1alpha3().PodGroups().Lister(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import (
|
|||
"testing"
|
||||
|
||||
v1 "k8s.io/api/core/v1"
|
||||
schedulingapi "k8s.io/api/scheduling/v1alpha2"
|
||||
schedulingapi "k8s.io/api/scheduling/v1alpha3"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||
"k8s.io/client-go/informers"
|
||||
|
|
@ -196,7 +196,7 @@ func TestGeneratePlacements(t *testing.T) {
|
|||
&v1.NodeList{Items: nodes},
|
||||
)
|
||||
informerFactory := informers.NewSharedInformerFactory(cs, 0)
|
||||
_ = informerFactory.Scheduling().V1alpha2().PodGroups().Informer()
|
||||
_ = informerFactory.Scheduling().V1alpha3().PodGroups().Informer()
|
||||
_ = informerFactory.Core().V1().Nodes().Informer()
|
||||
informerFactory.StartWithContext(tCtx)
|
||||
informerFactory.WaitForCacheSyncWithContext(tCtx)
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import (
|
|||
"time"
|
||||
|
||||
v1 "k8s.io/api/core/v1"
|
||||
schedulingapi "k8s.io/api/scheduling/v1alpha2"
|
||||
schedulingapi "k8s.io/api/scheduling/v1alpha3"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import (
|
|||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
schedulingapi "k8s.io/api/scheduling/v1alpha2"
|
||||
schedulingapi "k8s.io/api/scheduling/v1alpha3"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import (
|
|||
|
||||
v1 "k8s.io/api/core/v1"
|
||||
policy "k8s.io/api/policy/v1"
|
||||
schedulingapi "k8s.io/api/scheduling/v1alpha2"
|
||||
schedulingapi "k8s.io/api/scheduling/v1alpha3"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
policylisters "k8s.io/client-go/listers/policy/v1"
|
||||
schedulinglisters "k8s.io/client-go/listers/scheduling/v1alpha2"
|
||||
|
|
@ -53,7 +53,7 @@ func NewPodGroupEvaluator(fh fwk.Handle, executor *Executor) *PodGroupEvaluator
|
|||
return &PodGroupEvaluator{
|
||||
Handle: fh,
|
||||
pdbLister: fh.SharedInformerFactory().Policy().V1().PodDisruptionBudgets().Lister(),
|
||||
podGroupLister: fh.SharedInformerFactory().Scheduling().V1alpha2().PodGroups().Lister(),
|
||||
podGroupLister: fh.SharedInformerFactory().Scheduling().V1alpha3().PodGroups().Lister(),
|
||||
Executor: executor,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import (
|
|||
"github.com/google/go-cmp/cmp"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
policy "k8s.io/api/policy/v1"
|
||||
schedulingapi "k8s.io/api/scheduling/v1alpha2"
|
||||
schedulingapi "k8s.io/api/scheduling/v1alpha3"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
schedulinglisters "k8s.io/client-go/listers/scheduling/v1alpha2"
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import (
|
|||
"sync/atomic"
|
||||
|
||||
v1 "k8s.io/api/core/v1"
|
||||
schedulingapi "k8s.io/api/scheduling/v1alpha2"
|
||||
schedulingapi "k8s.io/api/scheduling/v1alpha3"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
schedulinglisters "k8s.io/client-go/listers/scheduling/v1alpha2"
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import (
|
|||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
schedulingapi "k8s.io/api/scheduling/v1alpha2"
|
||||
schedulingapi "k8s.io/api/scheduling/v1alpha3"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
fwk "k8s.io/kube-scheduler/framework"
|
||||
"k8s.io/kubernetes/pkg/scheduler/framework"
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import (
|
|||
"github.com/google/go-cmp/cmp/cmpopts"
|
||||
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/api/scheduling/v1alpha2"
|
||||
"k8s.io/api/scheduling/v1alpha3"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
|
|
|
|||
|
|
@ -266,7 +266,7 @@ func (sched *Scheduler) runWorkloadAwarePreemption(ctx context.Context, schedFwk
|
|||
return fwk.NewStatus(fwk.Unschedulable, "default preemption plugin is not registered, workload aware preemption is disabled")
|
||||
}
|
||||
|
||||
pg, err := schedFwk.SharedInformerFactory().Scheduling().V1alpha2().PodGroups().Lister().PodGroups(podGroupInfo.Namespace).Get(podGroupInfo.Name)
|
||||
pg, err := schedFwk.SharedInformerFactory().Scheduling().V1alpha3().PodGroups().Lister().PodGroups(podGroupInfo.Namespace).Get(podGroupInfo.Name)
|
||||
if err != nil {
|
||||
return fwk.AsStatus(fmt.Errorf("failed to get pod group object: %w", err))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import (
|
|||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/google/go-cmp/cmp/cmpopts"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
schedulingv1alpha2 "k8s.io/api/scheduling/v1alpha2"
|
||||
schedulingv1alpha3 "k8s.io/api/scheduling/v1alpha3"
|
||||
apimeta "k8s.io/apimachinery/pkg/api/meta"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
|
|
@ -100,7 +100,7 @@ func (mp *fakePodGroupPlugin) Permit(ctx context.Context, state fwk.CycleState,
|
|||
return fwk.NewStatus(fwk.Unschedulable, "default fake permit failure"), 0
|
||||
}
|
||||
|
||||
func (mp *fakePodGroupPlugin) PodGroupPostFilter(ctx context.Context, pg *schedulingv1alpha2.PodGroup, pods []*v1.Pod, pgSchedulingFunc framework.PodGroupSchedulingFunc) *fwk.Status {
|
||||
func (mp *fakePodGroupPlugin) PodGroupPostFilter(ctx context.Context, pg *schedulingv1alpha3.PodGroup, pods []*v1.Pod, pgSchedulingFunc framework.PodGroupSchedulingFunc) *fwk.Status {
|
||||
mp.podGroupPostFilterCalled = true
|
||||
if mp.podGroupPostFilterStatus != nil {
|
||||
return mp.podGroupPostFilterStatus
|
||||
|
|
@ -348,7 +348,7 @@ func TestPodGroupCycle_UpdateSnapshotError(t *testing.T) {
|
|||
qInfo1 := &framework.QueuedPodInfo{PodInfo: &framework.PodInfo{Pod: p1}}
|
||||
qInfo2 := &framework.QueuedPodInfo{PodInfo: &framework.PodInfo{Pod: p2}}
|
||||
|
||||
testPodGroup := &schedulingv1alpha2.PodGroup{
|
||||
testPodGroup := &schedulingv1alpha3.PodGroup{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "pg", Namespace: "default"},
|
||||
}
|
||||
|
||||
|
|
@ -398,7 +398,7 @@ func TestPodGroupCycle_UpdateSnapshotError(t *testing.T) {
|
|||
|
||||
client := clientsetfake.NewClientset(testPodGroup)
|
||||
informerFactory := informers.NewSharedInformerFactory(client, 0)
|
||||
podGroupLister := informerFactory.Scheduling().V1alpha2().PodGroups().Lister()
|
||||
podGroupLister := informerFactory.Scheduling().V1alpha3().PodGroups().Lister()
|
||||
informerFactory.Start(ctx.Done())
|
||||
informerFactory.WaitForCacheSync(ctx.Done())
|
||||
|
||||
|
|
@ -524,7 +524,7 @@ func TestPodGroupCycle_PodGroupPostFilter(t *testing.T) {
|
|||
|
||||
client := clientsetfake.NewSimpleClientset(testPodGroup, testNode)
|
||||
informerFactory := informers.NewSharedInformerFactory(client, 0)
|
||||
podGroupLister := informerFactory.Scheduling().V1alpha2().PodGroups().Lister()
|
||||
podGroupLister := informerFactory.Scheduling().V1alpha3().PodGroups().Lister()
|
||||
|
||||
informerFactory.Start(ctx.Done())
|
||||
informerFactory.WaitForCacheSync(ctx.Done())
|
||||
|
|
@ -1079,7 +1079,7 @@ func TestSubmitPodGroupAlgorithmResult(t *testing.T) {
|
|||
qInfo2 := &framework.QueuedPodInfo{PodInfo: &framework.PodInfo{Pod: p2}}
|
||||
qInfo3 := &framework.QueuedPodInfo{PodInfo: &framework.PodInfo{Pod: p3}}
|
||||
|
||||
testPodGroup := &schedulingv1alpha2.PodGroup{
|
||||
testPodGroup := &schedulingv1alpha3.PodGroup{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "pg", Namespace: "default"},
|
||||
}
|
||||
|
||||
|
|
@ -1094,7 +1094,7 @@ func TestSubmitPodGroupAlgorithmResult(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
name string
|
||||
existingPodGroup *schedulingv1alpha2.PodGroup
|
||||
existingPodGroup *schedulingv1alpha3.PodGroup
|
||||
algorithmResult podGroupAlgorithmResult
|
||||
expectBound sets.Set[string]
|
||||
expectPreempting sets.Set[string]
|
||||
|
|
@ -1453,9 +1453,9 @@ func TestSubmitPodGroupAlgorithmResult(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "Already Scheduled, successful cycle keeps condition",
|
||||
existingPodGroup: &schedulingv1alpha2.PodGroup{
|
||||
existingPodGroup: &schedulingv1alpha3.PodGroup{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "pg", Namespace: "default"},
|
||||
Status: schedulingv1alpha2.PodGroupStatus{
|
||||
Status: schedulingv1alpha3.PodGroupStatus{
|
||||
Conditions: []metav1.Condition{{
|
||||
Type: schedulingapi.PodGroupScheduled,
|
||||
Status: metav1.ConditionTrue,
|
||||
|
|
@ -1490,9 +1490,9 @@ func TestSubmitPodGroupAlgorithmResult(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "Already Scheduled, rejected cycle does not regress condition",
|
||||
existingPodGroup: &schedulingv1alpha2.PodGroup{
|
||||
existingPodGroup: &schedulingv1alpha3.PodGroup{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "pg", Namespace: "default"},
|
||||
Status: schedulingv1alpha2.PodGroupStatus{
|
||||
Status: schedulingv1alpha3.PodGroupStatus{
|
||||
Conditions: []metav1.Condition{{
|
||||
Type: schedulingapi.PodGroupScheduled,
|
||||
Status: metav1.ConditionTrue,
|
||||
|
|
@ -1525,9 +1525,9 @@ func TestSubmitPodGroupAlgorithmResult(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "Already Scheduled, error cycle does not regress condition",
|
||||
existingPodGroup: &schedulingv1alpha2.PodGroup{
|
||||
existingPodGroup: &schedulingv1alpha3.PodGroup{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "pg", Namespace: "default"},
|
||||
Status: schedulingv1alpha2.PodGroupStatus{
|
||||
Status: schedulingv1alpha3.PodGroupStatus{
|
||||
Conditions: []metav1.Condition{{
|
||||
Type: schedulingapi.PodGroupScheduled,
|
||||
Status: metav1.ConditionTrue,
|
||||
|
|
@ -1615,7 +1615,7 @@ func TestSubmitPodGroupAlgorithmResult(t *testing.T) {
|
|||
cache.AddNode(klog.FromContext(ctx), testNode)
|
||||
|
||||
informerFactory := informers.NewSharedInformerFactory(client, 0)
|
||||
podGroupLister := informerFactory.Scheduling().V1alpha2().PodGroups().Lister()
|
||||
podGroupLister := informerFactory.Scheduling().V1alpha3().PodGroups().Lister()
|
||||
informerFactory.Start(ctx.Done())
|
||||
informerFactory.WaitForCacheSync(ctx.Done())
|
||||
|
||||
|
|
@ -1664,7 +1664,7 @@ func TestSubmitPodGroupAlgorithmResult(t *testing.T) {
|
|||
t.Errorf("Expected failed pods: %v, but got: %v", tt.expectFailed, failedPods)
|
||||
}
|
||||
|
||||
updatedPodGroup, err := client.SchedulingV1alpha2().PodGroups("default").Get(ctx, "pg", metav1.GetOptions{})
|
||||
updatedPodGroup, err := client.SchedulingV1alpha3().PodGroups("default").Get(ctx, "pg", metav1.GetOptions{})
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to get PodGroup: %v", err)
|
||||
}
|
||||
|
|
@ -1679,7 +1679,7 @@ func TestSubmitPodGroupAlgorithmResult(t *testing.T) {
|
|||
func TestUpdatePodGroupCondition(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
existingPodGroup *schedulingv1alpha2.PodGroup
|
||||
existingPodGroup *schedulingv1alpha3.PodGroup
|
||||
namespace string
|
||||
podGroupName string
|
||||
condition *metav1.Condition
|
||||
|
|
@ -1690,7 +1690,7 @@ func TestUpdatePodGroupCondition(t *testing.T) {
|
|||
}{
|
||||
{
|
||||
name: "set Scheduled condition to True on empty status",
|
||||
existingPodGroup: &schedulingv1alpha2.PodGroup{
|
||||
existingPodGroup: &schedulingv1alpha3.PodGroup{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "pg1", Namespace: "ns1"},
|
||||
},
|
||||
namespace: "ns1",
|
||||
|
|
@ -1710,7 +1710,7 @@ func TestUpdatePodGroupCondition(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "set Scheduled condition to False with Unschedulable reason",
|
||||
existingPodGroup: &schedulingv1alpha2.PodGroup{
|
||||
existingPodGroup: &schedulingv1alpha3.PodGroup{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "pg2", Namespace: "ns1"},
|
||||
},
|
||||
namespace: "ns1",
|
||||
|
|
@ -1730,7 +1730,7 @@ func TestUpdatePodGroupCondition(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "set Scheduled condition to False with SchedulerError reason",
|
||||
existingPodGroup: &schedulingv1alpha2.PodGroup{
|
||||
existingPodGroup: &schedulingv1alpha3.PodGroup{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "pg3", Namespace: "ns1"},
|
||||
},
|
||||
namespace: "ns1",
|
||||
|
|
@ -1750,9 +1750,9 @@ func TestUpdatePodGroupCondition(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "transition from Unschedulable to Scheduled",
|
||||
existingPodGroup: &schedulingv1alpha2.PodGroup{
|
||||
existingPodGroup: &schedulingv1alpha3.PodGroup{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "pg4", Namespace: "ns1"},
|
||||
Status: schedulingv1alpha2.PodGroupStatus{
|
||||
Status: schedulingv1alpha3.PodGroupStatus{
|
||||
Conditions: []metav1.Condition{
|
||||
{
|
||||
Type: schedulingapi.PodGroupScheduled,
|
||||
|
|
@ -1781,9 +1781,9 @@ func TestUpdatePodGroupCondition(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "transition from SchedulerError to Scheduled",
|
||||
existingPodGroup: &schedulingv1alpha2.PodGroup{
|
||||
existingPodGroup: &schedulingv1alpha3.PodGroup{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "pg-se-to-true", Namespace: "ns1"},
|
||||
Status: schedulingv1alpha2.PodGroupStatus{
|
||||
Status: schedulingv1alpha3.PodGroupStatus{
|
||||
Conditions: []metav1.Condition{
|
||||
{
|
||||
Type: schedulingapi.PodGroupScheduled,
|
||||
|
|
@ -1812,9 +1812,9 @@ func TestUpdatePodGroupCondition(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "do not regress Scheduled to Unschedulable",
|
||||
existingPodGroup: &schedulingv1alpha2.PodGroup{
|
||||
existingPodGroup: &schedulingv1alpha3.PodGroup{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "pg-true-to-unsched", Namespace: "ns1"},
|
||||
Status: schedulingv1alpha2.PodGroupStatus{
|
||||
Status: schedulingv1alpha3.PodGroupStatus{
|
||||
Conditions: []metav1.Condition{
|
||||
{
|
||||
Type: schedulingapi.PodGroupScheduled,
|
||||
|
|
@ -1844,9 +1844,9 @@ func TestUpdatePodGroupCondition(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "do not regress Scheduled to SchedulerError",
|
||||
existingPodGroup: &schedulingv1alpha2.PodGroup{
|
||||
existingPodGroup: &schedulingv1alpha3.PodGroup{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "pg-true-to-se", Namespace: "ns1"},
|
||||
Status: schedulingv1alpha2.PodGroupStatus{
|
||||
Status: schedulingv1alpha3.PodGroupStatus{
|
||||
Conditions: []metav1.Condition{
|
||||
{
|
||||
Type: schedulingapi.PodGroupScheduled,
|
||||
|
|
@ -1876,9 +1876,9 @@ func TestUpdatePodGroupCondition(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "transition from Unschedulable to SchedulerError preserves LastTransitionTime",
|
||||
existingPodGroup: &schedulingv1alpha2.PodGroup{
|
||||
existingPodGroup: &schedulingv1alpha3.PodGroup{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "pg-unsched-to-se", Namespace: "ns1"},
|
||||
Status: schedulingv1alpha2.PodGroupStatus{
|
||||
Status: schedulingv1alpha3.PodGroupStatus{
|
||||
Conditions: []metav1.Condition{
|
||||
{
|
||||
Type: schedulingapi.PodGroupScheduled,
|
||||
|
|
@ -1908,9 +1908,9 @@ func TestUpdatePodGroupCondition(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "transition from SchedulerError to Unschedulable preserves LastTransitionTime",
|
||||
existingPodGroup: &schedulingv1alpha2.PodGroup{
|
||||
existingPodGroup: &schedulingv1alpha3.PodGroup{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "pg-se-to-unsched", Namespace: "ns1"},
|
||||
Status: schedulingv1alpha2.PodGroupStatus{
|
||||
Status: schedulingv1alpha3.PodGroupStatus{
|
||||
Conditions: []metav1.Condition{
|
||||
{
|
||||
Type: schedulingapi.PodGroupScheduled,
|
||||
|
|
@ -1940,9 +1940,9 @@ func TestUpdatePodGroupCondition(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "Scheduled to Scheduled preserves LastTransitionTime",
|
||||
existingPodGroup: &schedulingv1alpha2.PodGroup{
|
||||
existingPodGroup: &schedulingv1alpha3.PodGroup{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "pg-true-to-true", Namespace: "ns1"},
|
||||
Status: schedulingv1alpha2.PodGroupStatus{
|
||||
Status: schedulingv1alpha3.PodGroupStatus{
|
||||
Conditions: []metav1.Condition{
|
||||
{
|
||||
Type: schedulingapi.PodGroupScheduled,
|
||||
|
|
@ -1989,7 +1989,7 @@ func TestUpdatePodGroupCondition(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "ObservedGeneration is set from PodGroup generation",
|
||||
existingPodGroup: &schedulingv1alpha2.PodGroup{
|
||||
existingPodGroup: &schedulingv1alpha3.PodGroup{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "pg-gen", Namespace: "ns1", Generation: 7},
|
||||
},
|
||||
namespace: "ns1",
|
||||
|
|
@ -2020,7 +2020,7 @@ func TestUpdatePodGroupCondition(t *testing.T) {
|
|||
}
|
||||
client := clientsetfake.NewClientset(objects...)
|
||||
informerFactory := informers.NewSharedInformerFactory(client, 0)
|
||||
podGroupLister := informerFactory.Scheduling().V1alpha2().PodGroups().Lister()
|
||||
podGroupLister := informerFactory.Scheduling().V1alpha3().PodGroups().Lister()
|
||||
informerFactory.Start(ctx.Done())
|
||||
informerFactory.WaitForCacheSync(ctx.Done())
|
||||
sched := &Scheduler{client: client, podGroupLister: podGroupLister}
|
||||
|
|
@ -2040,7 +2040,7 @@ func TestUpdatePodGroupCondition(t *testing.T) {
|
|||
}
|
||||
sched.updatePodGroupCondition(ctx, podGroupInfo, tt.condition)
|
||||
|
||||
updatedPodGroup, err := client.SchedulingV1alpha2().PodGroups(tt.namespace).Get(ctx, tt.podGroupName, metav1.GetOptions{})
|
||||
updatedPodGroup, err := client.SchedulingV1alpha3().PodGroups(tt.namespace).Get(ctx, tt.podGroupName, metav1.GetOptions{})
|
||||
if tt.existingPodGroup == nil {
|
||||
if err == nil {
|
||||
t.Fatalf("Expected PodGroup to not be found, but got: %v", updatedPodGroup)
|
||||
|
|
@ -2527,7 +2527,7 @@ func TestRunWorkloadAwarePreemption(t *testing.T) {
|
|||
tests := []struct {
|
||||
name string
|
||||
podGroupInfo *framework.QueuedPodGroupInfo
|
||||
existingPodGroups []*schedulingv1alpha2.PodGroup
|
||||
existingPodGroups []*schedulingv1alpha3.PodGroup
|
||||
pluginsRegistered bool
|
||||
pluginReturnStatus *fwk.Status
|
||||
expectedStatus *fwk.Status
|
||||
|
|
@ -2559,12 +2559,12 @@ func TestRunWorkloadAwarePreemption(t *testing.T) {
|
|||
{PodInfo: &framework.PodInfo{Pod: st.MakePod().Name("p1").Namespace("default").Obj()}},
|
||||
},
|
||||
},
|
||||
existingPodGroups: []*schedulingv1alpha2.PodGroup{
|
||||
existingPodGroups: []*schedulingv1alpha3.PodGroup{
|
||||
{
|
||||
ObjectMeta: metav1.ObjectMeta{Namespace: "default", Name: "pg-with-constraints"},
|
||||
Spec: schedulingv1alpha2.PodGroupSpec{
|
||||
SchedulingConstraints: &schedulingv1alpha2.PodGroupSchedulingConstraints{
|
||||
Topology: []schedulingv1alpha2.TopologyConstraint{{}}, // non-empty
|
||||
Spec: schedulingv1alpha3.PodGroupSpec{
|
||||
SchedulingConstraints: &schedulingv1alpha3.PodGroupSchedulingConstraints{
|
||||
Topology: []schedulingv1alpha3.TopologyConstraint{{}}, // non-empty
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -2580,7 +2580,7 @@ func TestRunWorkloadAwarePreemption(t *testing.T) {
|
|||
{PodInfo: &framework.PodInfo{Pod: st.MakePod().Name("p1").Namespace("default").Obj()}},
|
||||
},
|
||||
},
|
||||
existingPodGroups: []*schedulingv1alpha2.PodGroup{
|
||||
existingPodGroups: []*schedulingv1alpha3.PodGroup{
|
||||
{
|
||||
ObjectMeta: metav1.ObjectMeta{Namespace: "default", Name: "pg-success"},
|
||||
},
|
||||
|
|
@ -2597,7 +2597,7 @@ func TestRunWorkloadAwarePreemption(t *testing.T) {
|
|||
{PodInfo: &framework.PodInfo{Pod: st.MakePod().Name("p1").Namespace("default").Obj()}},
|
||||
},
|
||||
},
|
||||
existingPodGroups: []*schedulingv1alpha2.PodGroup{
|
||||
existingPodGroups: []*schedulingv1alpha3.PodGroup{
|
||||
{
|
||||
ObjectMeta: metav1.ObjectMeta{Namespace: "default", Name: "pg-unschedulable"},
|
||||
},
|
||||
|
|
@ -2614,7 +2614,7 @@ func TestRunWorkloadAwarePreemption(t *testing.T) {
|
|||
{PodInfo: &framework.PodInfo{Pod: st.MakePod().Name("p1").Namespace("default").Obj()}},
|
||||
},
|
||||
},
|
||||
existingPodGroups: []*schedulingv1alpha2.PodGroup{},
|
||||
existingPodGroups: []*schedulingv1alpha3.PodGroup{},
|
||||
pluginsRegistered: true,
|
||||
pluginReturnStatus: fwk.NewStatus(fwk.Success),
|
||||
expectedStatus: fwk.AsStatus(fmt.Errorf("failed to get pod group object: %w", errors.New("podgroup.scheduling.k8s.io \"pg-unschedulable\" not found"))),
|
||||
|
|
@ -2682,7 +2682,7 @@ func TestRunWorkloadAwarePreemption(t *testing.T) {
|
|||
t.Fatalf("Failed to create framework: %v", err)
|
||||
}
|
||||
|
||||
podGroupLister := informerFactory.Scheduling().V1alpha2().PodGroups().Lister()
|
||||
podGroupLister := informerFactory.Scheduling().V1alpha3().PodGroups().Lister()
|
||||
|
||||
if tt.pluginsRegistered {
|
||||
informerFactory.Start(ctx.Done())
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ import (
|
|||
|
||||
v1 "k8s.io/api/core/v1"
|
||||
eventsv1 "k8s.io/api/events/v1"
|
||||
schedulingv1alpha2 "k8s.io/api/scheduling/v1alpha2"
|
||||
schedulingv1alpha3 "k8s.io/api/scheduling/v1alpha3"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
|
|
@ -1046,7 +1046,7 @@ func TestSchedulerScheduleOne(t *testing.T) {
|
|||
item.expectPodInUnschedulable = nil
|
||||
}
|
||||
|
||||
testPG := &schedulingv1alpha2.PodGroup{
|
||||
testPG := &schedulingv1alpha3.PodGroup{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "pg", Namespace: item.sendPod.Namespace},
|
||||
}
|
||||
clientObjs = []runtime.Object{item.sendPod, testPG}
|
||||
|
|
@ -1073,7 +1073,7 @@ func TestSchedulerScheduleOne(t *testing.T) {
|
|||
internalCache := internalcache.New(ctx, apiDispatcher, scheduleAsPodGroup)
|
||||
|
||||
if scheduleAsPodGroup {
|
||||
podGroupLister = informerFactory.Scheduling().V1alpha2().PodGroups().Lister()
|
||||
podGroupLister = informerFactory.Scheduling().V1alpha3().PodGroups().Lister()
|
||||
internalCache.AddPodGroupMember(item.sendPod)
|
||||
}
|
||||
cache := &fakecache.Cache{
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ import (
|
|||
"k8s.io/client-go/informers"
|
||||
coreinformers "k8s.io/client-go/informers/core/v1"
|
||||
clientset "k8s.io/client-go/kubernetes"
|
||||
schedulinglisters "k8s.io/client-go/listers/scheduling/v1alpha2"
|
||||
schedulinglisters "k8s.io/client-go/listers/scheduling/v1alpha3"
|
||||
restclient "k8s.io/client-go/rest"
|
||||
"k8s.io/client-go/tools/cache"
|
||||
resourceslicetracker "k8s.io/dynamic-resource-allocation/resourceslice/tracker"
|
||||
|
|
@ -315,7 +315,7 @@ func New(ctx context.Context,
|
|||
nodeLister := informerFactory.Core().V1().Nodes().Lister()
|
||||
var podGroupLister schedulinglisters.PodGroupLister
|
||||
if feature.DefaultFeatureGate.Enabled(features.GenericWorkload) {
|
||||
podGroupLister = informerFactory.Scheduling().V1alpha2().PodGroups().Lister()
|
||||
podGroupLister = informerFactory.Scheduling().V1alpha3().PodGroups().Lister()
|
||||
}
|
||||
|
||||
snapshot := internalcache.NewEmptySnapshot()
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import (
|
|||
v1 "k8s.io/api/core/v1"
|
||||
policy "k8s.io/api/policy/v1"
|
||||
resourceapi "k8s.io/api/resource/v1"
|
||||
schedulingapi "k8s.io/api/scheduling/v1alpha2"
|
||||
schedulingapi "k8s.io/api/scheduling/v1alpha3"
|
||||
storagev1 "k8s.io/api/storage/v1"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import (
|
|||
|
||||
v1 "k8s.io/api/core/v1"
|
||||
resourceapi "k8s.io/api/resource/v1"
|
||||
schedulingv1alpha2 "k8s.io/api/scheduling/v1alpha2"
|
||||
schedulingv1alpha3 "k8s.io/api/scheduling/v1alpha3"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
|
|
@ -155,26 +155,26 @@ func PatchPodStatus(ctx context.Context, cs kubernetes.Interface, name string, n
|
|||
// PatchPodGroupStatus calculates the delta bytes change from <old.Status> to <newStatus>,
|
||||
// and then submits a request to API server to patch the PodGroup status changes.
|
||||
func PatchPodGroupStatus(ctx context.Context, cs kubernetes.Interface, name string,
|
||||
namespace string, oldStatus *schedulingv1alpha2.PodGroupStatus,
|
||||
newStatus *schedulingv1alpha2.PodGroupStatus) error {
|
||||
namespace string, oldStatus *schedulingv1alpha3.PodGroupStatus,
|
||||
newStatus *schedulingv1alpha3.PodGroupStatus) error {
|
||||
if newStatus == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if oldStatus == nil {
|
||||
oldStatus = &schedulingv1alpha2.PodGroupStatus{}
|
||||
oldStatus = &schedulingv1alpha3.PodGroupStatus{}
|
||||
}
|
||||
|
||||
oldData, err := json.Marshal(schedulingv1alpha2.PodGroup{Status: *oldStatus})
|
||||
oldData, err := json.Marshal(schedulingv1alpha3.PodGroup{Status: *oldStatus})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
newData, err := json.Marshal(schedulingv1alpha2.PodGroup{Status: *newStatus})
|
||||
newData, err := json.Marshal(schedulingv1alpha3.PodGroup{Status: *newStatus})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
patchBytes, err := strategicpatch.CreateTwoWayMergePatch(oldData, newData, &schedulingv1alpha2.PodGroup{})
|
||||
patchBytes, err := strategicpatch.CreateTwoWayMergePatch(oldData, newData, &schedulingv1alpha3.PodGroup{})
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create merge patch for podgroup %q/%q: %w", namespace, name, err)
|
||||
}
|
||||
|
|
@ -184,7 +184,7 @@ func PatchPodGroupStatus(ctx context.Context, cs kubernetes.Interface, name stri
|
|||
}
|
||||
|
||||
patchFn := func() error {
|
||||
_, err := cs.SchedulingV1alpha2().PodGroups(namespace).Patch(ctx, name, types.StrategicMergePatchType, patchBytes, metav1.PatchOptions{}, "status")
|
||||
_, err := cs.SchedulingV1alpha3().PodGroups(namespace).Patch(ctx, name, types.StrategicMergePatchType, patchBytes, metav1.PatchOptions{}, "status")
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
@ -273,7 +273,7 @@ func GetHostPorts(pod *v1.Pod) []v1.ContainerPort {
|
|||
}
|
||||
|
||||
// PodGroupPriority returns priority of a given pod group.
|
||||
func PodGroupPriority(pg *schedulingv1alpha2.PodGroup) int32 {
|
||||
func PodGroupPriority(pg *schedulingv1alpha3.PodGroup) int32 {
|
||||
if pg.Spec.Priority != nil {
|
||||
return *pg.Spec.Priority
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import (
|
|||
"github.com/google/go-cmp/cmp"
|
||||
|
||||
v1 "k8s.io/api/core/v1"
|
||||
schedulingv1alpha2 "k8s.io/api/scheduling/v1alpha2"
|
||||
schedulingv1alpha3 "k8s.io/api/scheduling/v1alpha3"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
|
|
@ -368,24 +368,24 @@ func TestPatchPodGroupStatus(t *testing.T) {
|
|||
|
||||
tests := []struct {
|
||||
name string
|
||||
podGroup schedulingv1alpha2.PodGroup
|
||||
podGroup schedulingv1alpha3.PodGroup
|
||||
client *clientsetfake.Clientset
|
||||
// validateErr checks if error returned from PatchPodGroupStatus is expected one or not.
|
||||
// (true means error is expected one.)
|
||||
validateErr func(goterr error) bool
|
||||
statusToUpdate *schedulingv1alpha2.PodGroupStatus
|
||||
statusToUpdate *schedulingv1alpha3.PodGroupStatus
|
||||
nilOldStatus bool
|
||||
}{
|
||||
{
|
||||
name: "Should update podgroup conditions successfully",
|
||||
client: clientsetfake.NewClientset(),
|
||||
podGroup: schedulingv1alpha2.PodGroup{
|
||||
podGroup: schedulingv1alpha3.PodGroup{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Namespace: "ns",
|
||||
Name: "pg1",
|
||||
},
|
||||
},
|
||||
statusToUpdate: &schedulingv1alpha2.PodGroupStatus{
|
||||
statusToUpdate: &schedulingv1alpha3.PodGroupStatus{
|
||||
Conditions: []metav1.Condition{
|
||||
{
|
||||
Type: schedulingapi.PodGroupScheduled,
|
||||
|
|
@ -400,12 +400,12 @@ func TestPatchPodGroupStatus(t *testing.T) {
|
|||
{
|
||||
name: "no-op when status is unchanged",
|
||||
client: clientsetfake.NewClientset(),
|
||||
podGroup: schedulingv1alpha2.PodGroup{
|
||||
podGroup: schedulingv1alpha3.PodGroup{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Namespace: "ns",
|
||||
Name: "pg1",
|
||||
},
|
||||
Status: schedulingv1alpha2.PodGroupStatus{
|
||||
Status: schedulingv1alpha3.PodGroupStatus{
|
||||
Conditions: []metav1.Condition{
|
||||
{
|
||||
Type: schedulingapi.PodGroupScheduled,
|
||||
|
|
@ -417,7 +417,7 @@ func TestPatchPodGroupStatus(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
statusToUpdate: &schedulingv1alpha2.PodGroupStatus{
|
||||
statusToUpdate: &schedulingv1alpha3.PodGroupStatus{
|
||||
Conditions: []metav1.Condition{
|
||||
{
|
||||
Type: schedulingapi.PodGroupScheduled,
|
||||
|
|
@ -432,7 +432,7 @@ func TestPatchPodGroupStatus(t *testing.T) {
|
|||
{
|
||||
name: "nil newStatus returns nil",
|
||||
client: clientsetfake.NewClientset(),
|
||||
podGroup: schedulingv1alpha2.PodGroup{
|
||||
podGroup: schedulingv1alpha3.PodGroup{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Namespace: "ns",
|
||||
Name: "pg1",
|
||||
|
|
@ -449,23 +449,23 @@ func TestPatchPodGroupStatus(t *testing.T) {
|
|||
client.PrependReactor("patch", "podgroups", func(action clienttesting.Action) (bool, runtime.Object, error) {
|
||||
defer func() { reqcount++ }()
|
||||
if reqcount == 0 {
|
||||
return true, &schedulingv1alpha2.PodGroup{}, fmt.Errorf("connection refused: %w", syscall.ECONNREFUSED)
|
||||
return true, &schedulingv1alpha3.PodGroup{}, fmt.Errorf("connection refused: %w", syscall.ECONNREFUSED)
|
||||
}
|
||||
if reqcount == 1 {
|
||||
return false, &schedulingv1alpha2.PodGroup{}, nil
|
||||
return false, &schedulingv1alpha3.PodGroup{}, nil
|
||||
}
|
||||
return true, nil, errors.New("requests comes in more than three times.")
|
||||
})
|
||||
|
||||
return client
|
||||
}(),
|
||||
podGroup: schedulingv1alpha2.PodGroup{
|
||||
podGroup: schedulingv1alpha3.PodGroup{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Namespace: "ns",
|
||||
Name: "pg1",
|
||||
},
|
||||
},
|
||||
statusToUpdate: &schedulingv1alpha2.PodGroupStatus{
|
||||
statusToUpdate: &schedulingv1alpha3.PodGroupStatus{
|
||||
Conditions: []metav1.Condition{
|
||||
{
|
||||
Type: schedulingapi.PodGroupScheduled,
|
||||
|
|
@ -488,19 +488,19 @@ func TestPatchPodGroupStatus(t *testing.T) {
|
|||
if reqcount >= 4 {
|
||||
return true, nil, errors.New("requests comes in more than four times.")
|
||||
}
|
||||
return true, &schedulingv1alpha2.PodGroup{}, fmt.Errorf("connection refused: %w", syscall.ECONNREFUSED)
|
||||
return true, &schedulingv1alpha3.PodGroup{}, fmt.Errorf("connection refused: %w", syscall.ECONNREFUSED)
|
||||
})
|
||||
|
||||
return client
|
||||
}(),
|
||||
podGroup: schedulingv1alpha2.PodGroup{
|
||||
podGroup: schedulingv1alpha3.PodGroup{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Namespace: "ns",
|
||||
Name: "pg1",
|
||||
},
|
||||
},
|
||||
validateErr: net.IsConnectionRefused,
|
||||
statusToUpdate: &schedulingv1alpha2.PodGroupStatus{
|
||||
statusToUpdate: &schedulingv1alpha3.PodGroupStatus{
|
||||
Conditions: []metav1.Condition{
|
||||
{
|
||||
Type: schedulingapi.PodGroupScheduled,
|
||||
|
|
@ -521,26 +521,26 @@ func TestPatchPodGroupStatus(t *testing.T) {
|
|||
client.PrependReactor("patch", "podgroups", func(action clienttesting.Action) (bool, runtime.Object, error) {
|
||||
defer func() { reqcount++ }()
|
||||
if reqcount == 0 {
|
||||
return true, &schedulingv1alpha2.PodGroup{},
|
||||
return true, &schedulingv1alpha3.PodGroup{},
|
||||
apierrors.NewConflict(schema.GroupResource{
|
||||
Resource: "podgroups"}, "pg1",
|
||||
errors.New("the object has been modified"))
|
||||
}
|
||||
if reqcount == 1 {
|
||||
return false, &schedulingv1alpha2.PodGroup{}, nil
|
||||
return false, &schedulingv1alpha3.PodGroup{}, nil
|
||||
}
|
||||
return true, nil, errors.New("requests comes in more than three times.")
|
||||
})
|
||||
|
||||
return client
|
||||
}(),
|
||||
podGroup: schedulingv1alpha2.PodGroup{
|
||||
podGroup: schedulingv1alpha3.PodGroup{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Namespace: "ns",
|
||||
Name: "pg1",
|
||||
},
|
||||
},
|
||||
statusToUpdate: &schedulingv1alpha2.PodGroupStatus{
|
||||
statusToUpdate: &schedulingv1alpha3.PodGroupStatus{
|
||||
Conditions: []metav1.Condition{
|
||||
{
|
||||
Type: schedulingapi.PodGroupScheduled,
|
||||
|
|
@ -555,13 +555,13 @@ func TestPatchPodGroupStatus(t *testing.T) {
|
|||
{
|
||||
name: "nil oldStatus patches successfully",
|
||||
client: clientsetfake.NewClientset(),
|
||||
podGroup: schedulingv1alpha2.PodGroup{
|
||||
podGroup: schedulingv1alpha3.PodGroup{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Namespace: "ns",
|
||||
Name: "pg1",
|
||||
},
|
||||
},
|
||||
statusToUpdate: &schedulingv1alpha2.PodGroupStatus{
|
||||
statusToUpdate: &schedulingv1alpha3.PodGroupStatus{
|
||||
Conditions: []metav1.Condition{
|
||||
{
|
||||
Type: schedulingapi.PodGroupScheduled,
|
||||
|
|
@ -583,7 +583,7 @@ func TestPatchPodGroupStatus(t *testing.T) {
|
|||
defer cancel()
|
||||
|
||||
client := tc.client
|
||||
_, err := client.SchedulingV1alpha2().PodGroups(tc.podGroup.Namespace).Create(ctx, &tc.podGroup, metav1.CreateOptions{})
|
||||
_, err := client.SchedulingV1alpha3().PodGroups(tc.podGroup.Namespace).Create(ctx, &tc.podGroup, metav1.CreateOptions{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -603,7 +603,7 @@ func TestPatchPodGroupStatus(t *testing.T) {
|
|||
return
|
||||
}
|
||||
|
||||
retrievedPG, err := client.SchedulingV1alpha2().PodGroups(tc.podGroup.Namespace).Get(ctx, tc.podGroup.Name, metav1.GetOptions{})
|
||||
retrievedPG, err := client.SchedulingV1alpha3().PodGroups(tc.podGroup.Namespace).Get(ctx, tc.podGroup.Name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import (
|
|||
"k8s.io/apiserver/pkg/admission"
|
||||
genericadmissioninitializer "k8s.io/apiserver/pkg/admission/initializer"
|
||||
"k8s.io/client-go/informers"
|
||||
schedulingv1alpha2listers "k8s.io/client-go/listers/scheduling/v1alpha2"
|
||||
schedulingv1alpha3listers "k8s.io/client-go/listers/scheduling/v1alpha2"
|
||||
"k8s.io/component-base/featuregate"
|
||||
"k8s.io/kubernetes/pkg/apis/batch"
|
||||
"k8s.io/kubernetes/pkg/features"
|
||||
|
|
@ -57,7 +57,7 @@ type Plugin struct {
|
|||
genericWorkloadEnabled bool
|
||||
workloadWithJobEnabled bool
|
||||
inspectedFeatureGates bool
|
||||
pgLister schedulingv1alpha2listers.PodGroupLister
|
||||
pgLister schedulingv1alpha3listers.PodGroupLister
|
||||
}
|
||||
|
||||
// NewPlugin creates a new JobValidation admission plugin.
|
||||
|
|
@ -77,7 +77,7 @@ func (p *Plugin) SetExternalKubeInformerFactory(f informers.SharedInformerFactor
|
|||
if !p.genericWorkloadEnabled {
|
||||
return
|
||||
}
|
||||
pgInformer := f.Scheduling().V1alpha2().PodGroups()
|
||||
pgInformer := f.Scheduling().V1alpha3().PodGroups()
|
||||
p.pgLister = pgInformer.Lister()
|
||||
p.SetReadyFunc(pgInformer.Informer().HasSynced)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ package job
|
|||
import (
|
||||
"testing"
|
||||
|
||||
schedulingv1alpha2 "k8s.io/api/scheduling/v1alpha2"
|
||||
schedulingv1alpha3 "k8s.io/api/scheduling/v1alpha3"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
|
|
@ -38,26 +38,26 @@ import (
|
|||
func TestGangSchedulingParallelism(t *testing.T) {
|
||||
_, ctx := ktesting.NewTestContext(t)
|
||||
|
||||
gangPG := &schedulingv1alpha2.PodGroup{
|
||||
gangPG := &schedulingv1alpha3.PodGroup{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "gang-pg",
|
||||
Namespace: metav1.NamespaceDefault,
|
||||
},
|
||||
Spec: schedulingv1alpha2.PodGroupSpec{
|
||||
SchedulingPolicy: schedulingv1alpha2.PodGroupSchedulingPolicy{
|
||||
Gang: &schedulingv1alpha2.GangSchedulingPolicy{MinCount: 4},
|
||||
Spec: schedulingv1alpha3.PodGroupSpec{
|
||||
SchedulingPolicy: schedulingv1alpha3.PodGroupSchedulingPolicy{
|
||||
Gang: &schedulingv1alpha3.GangSchedulingPolicy{MinCount: 4},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
basicPG := &schedulingv1alpha2.PodGroup{
|
||||
basicPG := &schedulingv1alpha3.PodGroup{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "basic-pg",
|
||||
Namespace: metav1.NamespaceDefault,
|
||||
},
|
||||
Spec: schedulingv1alpha2.PodGroupSpec{
|
||||
SchedulingPolicy: schedulingv1alpha2.PodGroupSchedulingPolicy{
|
||||
Basic: &schedulingv1alpha2.BasicSchedulingPolicy{},
|
||||
Spec: schedulingv1alpha3.PodGroupSpec{
|
||||
SchedulingPolicy: schedulingv1alpha3.PodGroupSchedulingPolicy{
|
||||
Basic: &schedulingv1alpha3.BasicSchedulingPolicy{},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
@ -89,7 +89,7 @@ func TestGangSchedulingParallelism(t *testing.T) {
|
|||
enableFeatureGate bool
|
||||
oldJob *batch.Job
|
||||
newJob *batch.Job
|
||||
podGroups []*schedulingv1alpha2.PodGroup
|
||||
podGroups []*schedulingv1alpha3.PodGroup
|
||||
wantErr bool
|
||||
}{
|
||||
"feature gate disabled: allows parallelism change": {
|
||||
|
|
@ -99,7 +99,7 @@ func TestGangSchedulingParallelism(t *testing.T) {
|
|||
j.Spec.Parallelism = ptr.To[int32](2)
|
||||
return j
|
||||
}(),
|
||||
podGroups: []*schedulingv1alpha2.PodGroup{gangPG},
|
||||
podGroups: []*schedulingv1alpha3.PodGroup{gangPG},
|
||||
},
|
||||
"no schedulingGroup: skips check (handled by validation)": {
|
||||
enableFeatureGate: true,
|
||||
|
|
@ -114,7 +114,7 @@ func TestGangSchedulingParallelism(t *testing.T) {
|
|||
enableFeatureGate: true,
|
||||
oldJob: baseJob(ptr.To("gang-pg")),
|
||||
newJob: baseJob(ptr.To("gang-pg")),
|
||||
podGroups: []*schedulingv1alpha2.PodGroup{gangPG},
|
||||
podGroups: []*schedulingv1alpha3.PodGroup{gangPG},
|
||||
},
|
||||
"gang PodGroup: rejects parallelism change": {
|
||||
enableFeatureGate: true,
|
||||
|
|
@ -124,7 +124,7 @@ func TestGangSchedulingParallelism(t *testing.T) {
|
|||
j.Spec.Parallelism = ptr.To[int32](2)
|
||||
return j
|
||||
}(),
|
||||
podGroups: []*schedulingv1alpha2.PodGroup{gangPG},
|
||||
podGroups: []*schedulingv1alpha3.PodGroup{gangPG},
|
||||
wantErr: true,
|
||||
},
|
||||
"basic PodGroup: allows parallelism change": {
|
||||
|
|
@ -135,7 +135,7 @@ func TestGangSchedulingParallelism(t *testing.T) {
|
|||
j.Spec.Parallelism = ptr.To[int32](2)
|
||||
return j
|
||||
}(),
|
||||
podGroups: []*schedulingv1alpha2.PodGroup{basicPG},
|
||||
podGroups: []*schedulingv1alpha3.PodGroup{basicPG},
|
||||
},
|
||||
"PodGroup not found: allows parallelism change": {
|
||||
enableFeatureGate: true,
|
||||
|
|
@ -154,7 +154,7 @@ func TestGangSchedulingParallelism(t *testing.T) {
|
|||
j.Spec.Parallelism = ptr.To[int32](2)
|
||||
return j
|
||||
}(),
|
||||
podGroups: []*schedulingv1alpha2.PodGroup{
|
||||
podGroups: []*schedulingv1alpha3.PodGroup{
|
||||
{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "controller-created-pg",
|
||||
|
|
@ -169,9 +169,9 @@ func TestGangSchedulingParallelism(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
Spec: schedulingv1alpha2.PodGroupSpec{
|
||||
SchedulingPolicy: schedulingv1alpha2.PodGroupSchedulingPolicy{
|
||||
Gang: &schedulingv1alpha2.GangSchedulingPolicy{MinCount: 4},
|
||||
Spec: schedulingv1alpha3.PodGroupSpec{
|
||||
SchedulingPolicy: schedulingv1alpha3.PodGroupSchedulingPolicy{
|
||||
Gang: &schedulingv1alpha3.GangSchedulingPolicy{MinCount: 4},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -186,7 +186,7 @@ func TestGangSchedulingParallelism(t *testing.T) {
|
|||
j.Spec.Parallelism = ptr.To[int32](2)
|
||||
return j
|
||||
}(),
|
||||
podGroups: []*schedulingv1alpha2.PodGroup{
|
||||
podGroups: []*schedulingv1alpha3.PodGroup{
|
||||
{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "controller-created-pg",
|
||||
|
|
@ -201,9 +201,9 @@ func TestGangSchedulingParallelism(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
Spec: schedulingv1alpha2.PodGroupSpec{
|
||||
SchedulingPolicy: schedulingv1alpha2.PodGroupSchedulingPolicy{
|
||||
Basic: &schedulingv1alpha2.BasicSchedulingPolicy{},
|
||||
Spec: schedulingv1alpha3.PodGroupSpec{
|
||||
SchedulingPolicy: schedulingv1alpha3.PodGroupSchedulingPolicy{
|
||||
Basic: &schedulingv1alpha3.BasicSchedulingPolicy{},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -217,7 +217,7 @@ func TestGangSchedulingParallelism(t *testing.T) {
|
|||
j.Spec.Parallelism = ptr.To[int32](2)
|
||||
return j
|
||||
}(),
|
||||
podGroups: []*schedulingv1alpha2.PodGroup{
|
||||
podGroups: []*schedulingv1alpha3.PodGroup{
|
||||
{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "other-gang-pg",
|
||||
|
|
@ -232,9 +232,9 @@ func TestGangSchedulingParallelism(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
Spec: schedulingv1alpha2.PodGroupSpec{
|
||||
SchedulingPolicy: schedulingv1alpha2.PodGroupSchedulingPolicy{
|
||||
Gang: &schedulingv1alpha2.GangSchedulingPolicy{MinCount: 4},
|
||||
Spec: schedulingv1alpha3.PodGroupSpec{
|
||||
SchedulingPolicy: schedulingv1alpha3.PodGroupSchedulingPolicy{
|
||||
Gang: &schedulingv1alpha3.GangSchedulingPolicy{MinCount: 4},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -257,7 +257,7 @@ func TestGangSchedulingParallelism(t *testing.T) {
|
|||
p.SetExternalKubeInformerFactory(informerFactory)
|
||||
|
||||
for _, pg := range tc.podGroups {
|
||||
if err := informerFactory.Scheduling().V1alpha2().PodGroups().Informer().GetStore().Add(pg); err != nil {
|
||||
if err := informerFactory.Scheduling().V1alpha3().PodGroups().Informer().GetStore().Add(pg); err != nil {
|
||||
t.Fatalf("failed to add PodGroup: %v", err)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue