OSingh commented on code in PR #1054:
URL: https://github.com/apache/yunikorn-k8shim/pull/1054#discussion_r3747305091
##########
pkg/cache/application.go:
##########
@@ -510,19 +513,55 @@ func (app *Application) onResuming() {
}
}
+// isPlaceholderTimeoutElapsed returns true when the configured placeholder
timeout has already
+// elapsed since the application creation time. Used on restart to avoid
creating placeholder
+// pods that would immediately time out.
+func (app *Application) isPlaceholderTimeoutElapsed() bool {
+ if app.placeholderTimeoutInSec <= 0 {
+ return false
+ }
+ creationTimeTag :=
app.tags[siCommon.DomainYuniKorn+siCommon.CreationTime]
+ if creationTimeTag == "" {
+ return false
+ }
+ createdAtSec, err := strconv.ParseInt(creationTimeTag, 10, 64)
+ if err != nil {
+ return false
+ }
+ elapsed := time.Since(time.Unix(createdAtSec, 0))
+ return elapsed >= time.Duration(app.placeholderTimeoutInSec)*time.Second
+}
+
// onReserving triggered when entering the reserving state.
// During normal operation this creates all the placeholders. During recovery
this call could cause the application
// in the shim and core to progress to the next state.
func (app *Application) onReserving() {
// if any placeholder already exist during recovery we might need to
send
// an event to trigger Application state change in the core
- if len(app.getPlaceHolderTasks()) > 0 {
+ switch {
+ case len(app.getPlaceHolderTasks()) > 0:
Review Comment:
Done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]