chenyulin0719 commented on code in PR #871:
URL: https://github.com/apache/yunikorn-k8shim/pull/871#discussion_r1667081374
##########
pkg/common/utils/utils.go:
##########
@@ -104,12 +104,21 @@ func IsAssignedPod(pod *v1.Pod) bool {
}
func GetQueueNameFromPod(pod *v1.Pod) string {
+ // Queue name can be defined in multiple places
+ // The queue name is determined by the following order
+ // 1. Label: constants.CanonicalLabelQueueName
+ // 2. Annotation: constants.AnnotationQueueName
+ // 3. Label: constants.LabelQueueName
+ // 4. Default: constants.ApplicationDefaultQueue
Review Comment:
Note: the order to fetch queue name from pod is:
Before this PR,
1. Label: constants.LabelQueueName
2. Annotation: constants.AnnotationQueueName
3. Default: constants.ApplicationDefaultQueue
After this PR
1. **Label: constants.CanonicalLabelQueueName (New)**
2. Annotation: constants.AnnotationQueueName
3. Label: constants.LabelQueueName (**Previous: constants.LabelQueueName >
constants.AnnotationQueueName**)
4. Default: constants.ApplicationDefaultQueue
##########
pkg/cache/application.go:
##########
@@ -568,22 +586,6 @@ func (app *Application) handleCompleteApplicationEvent() {
}()
}
-func failTaskPodWithReasonAndMsg(task *Task, reason string, msg string) {
- podCopy := task.GetTaskPod().DeepCopy()
- podCopy.Status = v1.PodStatus{
- Phase: v1.PodFailed,
- Reason: reason,
- Message: msg,
- }
- log.Log(log.ShimCacheApplication).Info("setting pod to failed",
zap.String("podName", task.GetTaskPod().Name))
- pod, err := task.UpdateTaskPodStatus(podCopy)
- if err != nil {
- log.Log(log.ShimCacheApplication).Error("failed to update task
pod status", zap.Error(err))
- } else {
- log.Log(log.ShimCacheApplication).Info("new pod status",
zap.String("status", string(pod.Status.Phase)))
- }
-}
-
Review Comment:
Note: Moved failTaskPodWithReasonAndMsg() to task.go
Also change
- podCopy := task.GetTaskPod().DeepCopy()
to
- podCopy := task.pod.DeepCopy()
to prevent deadlock when task state machine is handling TaskRejected event.
(WLock)
##########
pkg/common/utils/utils.go:
##########
@@ -154,15 +163,30 @@ func GetApplicationIDFromPod(pod *v1.Pod) string {
}
}
- // Application ID can be defined in annotation
- appID := GetPodAnnotationValue(pod, constants.AnnotationApplicationID)
+ // Application ID can be defined in multiple places
+ // The application ID is determined by the following order.
+ // 1. Label: constants.CanonicalLabelApplicationID
+ // 2. Annotation: constants.AnnotationApplicationID
+ // 3. Label: constants.LabelApplicationID
+ // 4. Label: constants.SparkLabelAppID
Review Comment:
Note: The order to get 'app-id' from pod:
Before this PR:
1. Annotation: constants.AnnotationApplicationID
2. Label: constants.LabelApplicationID
3. Label: constants.SparkLabelAppID
After this PR
1. **Label: constants.CanonicalLabelApplicationID (New)**
2. Annotation: constants.AnnotationApplicationID
3. Label: constants.LabelApplicationID
4. Label: constants.SparkLabelAppID
##########
pkg/cache/placeholder.go:
##########
@@ -90,8 +90,8 @@ func newPlaceholder(placeholderName string, app *Application,
taskGroup TaskGrou
Name: placeholderName,
Namespace: app.tags[constants.AppTagNamespace],
Labels: utils.MergeMaps(taskGroup.Labels,
map[string]string{
- constants.LabelApplicationID:
app.GetApplicationID(),
- constants.LabelQueueName: app.GetQueue(),
+ constants.CanonicalLabelApplicationID:
app.GetApplicationID(),
+ constants.CanonicalLabelQueueName:
app.GetQueue(),
Review Comment:
Note:
- Directly use canonical representation for placeholder. The newer version
shim allows legacy and canonical representation metadata coexists. So there is
no backward compatibility issue here.
--
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]