Skip to content

Commit

Permalink
Merge pull request #467 from tangming1996/bugfix/federal-learning
Browse files Browse the repository at this point in the history
fix FederatedLearningJob delete error
  • Loading branch information
kubeedge-bot authored Feb 20, 2025
2 parents d234200 + bff8fd4 commit 150cc1a
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,17 @@ func (c *Controller) deletePod(obj interface{}) {
return
}

_, err := c.jobLister.FederatedLearningJobs(pod.Namespace).Get(controllerRef.Name)
if err != nil {
if errors.IsNotFound(err) {
// The FederatedLearningJob has been deleted, and the Pod should not be rebuilt.
klog.Infof("FederatedLearningJob %s/%s not found, skipping pod recreation", pod.Namespace, controllerRef.Name)
return
}
klog.Errorf("Error getting FederatedLearningJob %s/%s: %v", pod.Namespace, controllerRef.Name, err)
return
}

// then check if the pod is already in the map
if _, exists := c.recreatedPods.Load(pod.Name); exists {
return
Expand All @@ -232,7 +243,7 @@ func (c *Controller) deletePod(obj interface{}) {
newPod.DeletionTimestamp = nil
// Remove the deletion grace period seconds
newPod.DeletionGracePeriodSeconds = nil
_, err := c.kubeClient.CoreV1().Pods(pod.Namespace).Create(context.TODO(), newPod, metav1.CreateOptions{})
_, err = c.kubeClient.CoreV1().Pods(pod.Namespace).Create(context.TODO(), newPod, metav1.CreateOptions{})
if err != nil {
return
}
Expand Down Expand Up @@ -713,7 +724,10 @@ func New(cc *runtime.ControllerContext) (runtime.FeatureControllerI, error) {
kubeClient: cc.KubeClient,
client: cc.SednaClient.SednaV1alpha1(),

queue: workqueue.NewNamedRateLimitingQueue(workqueue.NewItemExponentialFailureRateLimiter(runtime.DefaultBackOff, runtime.MaxBackOff), Name),
queue: workqueue.NewRateLimitingQueueWithConfig(
workqueue.NewItemExponentialFailureRateLimiter(runtime.DefaultBackOff, runtime.MaxBackOff),
workqueue.RateLimitingQueueConfig{Name: Name},
),
recorder: eventBroadcaster.NewRecorder(scheme.Scheme, v1.EventSource{Component: Name + "-controller"}),
cfg: cfg,
}
Expand Down

0 comments on commit 150cc1a

Please sign in to comment.