@@ -33,7 +33,6 @@ import (
33
33
"k8s.io/apimachinery/pkg/api/errors"
34
34
"k8s.io/apimachinery/pkg/api/resource"
35
35
"k8s.io/apimachinery/pkg/runtime"
36
- "k8s.io/apimachinery/pkg/types"
37
36
ctrl "sigs.k8s.io/controller-runtime"
38
37
"sigs.k8s.io/controller-runtime/pkg/builder"
39
38
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -980,10 +979,6 @@ func (r *RayClusterReconciler) createHeadPod(ctx context.Context, instance rayv1
980
979
981
980
// build the pod then create it
982
981
pod := r .buildHeadPod (ctx , instance )
983
- podIdentifier := types.NamespacedName {
984
- Name : pod .Name ,
985
- Namespace : pod .Namespace ,
986
- }
987
982
if EnableBatchScheduler {
988
983
if scheduler , err := r .BatchSchedulerMgr .GetSchedulerForCluster (& instance ); err == nil {
989
984
scheduler .AddMetadataToPod (& instance , utils .RayNodeHeadGroupLabelValue , & pod )
@@ -994,19 +989,7 @@ func (r *RayClusterReconciler) createHeadPod(ctx context.Context, instance rayv1
994
989
995
990
logger .Info ("createHeadPod" , "head pod with name" , pod .GenerateName )
996
991
if err := r .Create (ctx , & pod ); err != nil {
997
- if errors .IsAlreadyExists (err ) {
998
- fetchedPod := corev1.Pod {}
999
- // the pod might be in terminating state, we need to check
1000
- if errPod := r .Get (ctx , podIdentifier , & fetchedPod ); errPod == nil {
1001
- if fetchedPod .DeletionTimestamp != nil {
1002
- logger .Error (errPod , "create pod error!" , "pod is in a terminating state, we will wait until it is cleaned up" , podIdentifier )
1003
- return err
1004
- }
1005
- }
1006
- logger .Info ("Creating pod" , "Pod already exists" , pod .Name )
1007
- } else {
1008
- return err
1009
- }
992
+ return err
1010
993
}
1011
994
r .Recorder .Eventf (& instance , corev1 .EventTypeNormal , "Created" , "Created head pod %s" , pod .Name )
1012
995
return nil
@@ -1017,10 +1000,6 @@ func (r *RayClusterReconciler) createWorkerPod(ctx context.Context, instance ray
1017
1000
1018
1001
// build the pod then create it
1019
1002
pod := r .buildWorkerPod (ctx , instance , worker )
1020
- podIdentifier := types.NamespacedName {
1021
- Name : pod .Name ,
1022
- Namespace : pod .Namespace ,
1023
- }
1024
1003
if EnableBatchScheduler {
1025
1004
if scheduler , err := r .BatchSchedulerMgr .GetSchedulerForCluster (& instance ); err == nil {
1026
1005
scheduler .AddMetadataToPod (& instance , worker .GroupName , & pod )
@@ -1031,20 +1010,7 @@ func (r *RayClusterReconciler) createWorkerPod(ctx context.Context, instance ray
1031
1010
1032
1011
replica := pod
1033
1012
if err := r .Create (ctx , & replica ); err != nil {
1034
- if errors .IsAlreadyExists (err ) {
1035
- fetchedPod := corev1.Pod {}
1036
- // the pod might be in terminating state, we need to check
1037
- if errPod := r .Get (ctx , podIdentifier , & fetchedPod ); errPod == nil {
1038
- if fetchedPod .DeletionTimestamp != nil {
1039
- logger .Error (errPod , "create pod error!" , "pod is in a terminating state, we will wait until it is cleaned up" , podIdentifier )
1040
- return err
1041
- }
1042
- }
1043
- logger .Info ("Creating pod" , "Pod already exists" , pod .Name )
1044
- } else {
1045
- logger .Error (fmt .Errorf ("createWorkerPod error" ), "error creating pod" , "pod" , pod , "err = " , err )
1046
- return err
1047
- }
1013
+ return err
1048
1014
}
1049
1015
logger .Info ("Created pod" , "Pod " , pod .GenerateName )
1050
1016
r .Recorder .Eventf (& instance , corev1 .EventTypeNormal , "Created" , "Created worker pod %s" , pod .Name )
0 commit comments