-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add scheduler func for clearing batch scheduling on completed #1079
Changes from 4 commits
3c91cc3
6ed3470
2c4c7a4
4883f3c
c13b1c3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -160,6 +160,12 @@ func (v *VolcanoBatchScheduler) syncPodGroup(app *v1beta2.SparkApplication, size | |
return nil | ||
} | ||
|
||
func (v *VolcanoBatchScheduler) CleanupOnCompletion(app *v1beta2.SparkApplication) error { | ||
podGroupName := v.getAppPodGroupName(app) | ||
//Remove pod group for Spark Application | ||
return v.volcanoClient.SchedulingV1beta1().PodGroups(app.Namespace).Delete(podGroupName, &metav1.DeleteOptions{}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should ignore the error if it's NotFound. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I saw this comments at now, I will update code that ignores NotFound error here |
||
} | ||
|
||
func New(config *rest.Config) (schedulerinterface.BatchScheduler, error) { | ||
vkClient, err := volcanoclient.NewForConfig(config) | ||
if err != nil { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -597,6 +597,14 @@ func (c *Controller) syncSparkApplication(key string) error { | |
glog.Errorf("failed to update SparkApplication %s/%s: %v", app.Namespace, app.Name, err) | ||
return err | ||
} | ||
|
||
if state := appCopy.Status.AppState.State; state == v1beta2.CompletedState || | ||
state == v1beta2.FailedState { | ||
if err := c.cleanUpOnTermination(app, appCopy); err != nil { | ||
glog.Errorf("failed to clean up resources for SparkApplication %s/%s: %v", app.Namespace, app.Name, err) | ||
return err | ||
} | ||
} | ||
} | ||
|
||
return nil | ||
|
@@ -1001,3 +1009,16 @@ func (c *Controller) hasApplicationExpired(app *v1beta2.SparkApplication) bool { | |
|
||
return false | ||
} | ||
|
||
// Clean up when the spark application is terminated. | ||
func (c *Controller) cleanUpOnTermination(oldApp, newApp *v1beta2.SparkApplication) error { | ||
if needScheduling, scheduler := c.shouldDoBatchScheduling(newApp); needScheduling { | ||
// batch schduler is cleaned up only when state is changed to completion state | ||
if newApp.Status.AppState.State != oldApp.Status.AppState.State { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This check is not needed if deletion is idempotent, i.e., if we ignore NotFound error above. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. looks reasonable if needScheduling, scheduler := c.shouldDoBatchScheduling(newApp); needScheduling {
if err := scheduler.CleanupOnCompletion(newApp); err != nil && !errors.IsNotFound(err) {
return err
}
} |
||
if err := scheduler.CleanupOnCompletion(newApp); err != nil { | ||
return err | ||
} | ||
} | ||
} | ||
return nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is not needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove it