This is an automated email from the ASF dual-hosted git repository.

manirajv06 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/yunikorn-k8shim.git


The following commit(s) were added to refs/heads/master by this push:
     new e1de0032 [YUNIKORN-3311] Remove user label processing code (#1059)
e1de0032 is described below

commit e1de0032f6bbcb60eb8f46e89cfa6bdd0df1eb9d
Author: kaijaytu <[email protected]>
AuthorDate: Mon Aug 3 14:51:08 2026 +0530

    [YUNIKORN-3311] Remove user label processing code (#1059)
    
    Closes: #1059
    
    Signed-off-by: Manikandan R <[email protected]>
---
 pkg/cache/metadata.go             |  2 +-
 pkg/common/constants/constants.go |  1 -
 pkg/common/utils/utils.go         | 25 ++-----------------
 pkg/common/utils/utils_test.go    | 52 +--------------------------------------
 pkg/conf/schedulerconf.go         |  3 ---
 pkg/conf/schedulerconf_test.go    |  1 -
 6 files changed, 4 insertions(+), 80 deletions(-)

diff --git a/pkg/cache/metadata.go b/pkg/cache/metadata.go
index 68ba9deb..c64a4970 100644
--- a/pkg/cache/metadata.go
+++ b/pkg/cache/metadata.go
@@ -102,7 +102,7 @@ func getAppMetadata(pod *v1.Pod) (ApplicationMetadata, 
bool) {
                tags[constants.AppTagImagePullSecrets] = strings.Join(arr, ",")
        }
 
-       // get the user from Pod Labels
+       // get the user from pod annotation
        user, groups := utils.GetUserFromPod(pod)
 
        var taskGroups []TaskGroup = nil
diff --git a/pkg/common/constants/constants.go 
b/pkg/common/constants/constants.go
index ca338f85..742f9dc7 100644
--- a/pkg/common/constants/constants.go
+++ b/pkg/common/constants/constants.go
@@ -57,7 +57,6 @@ const AppTagNamespace = "namespace"
 const AppTagNamespaceParentQueue = "namespace.parentqueue"
 const AppTagImagePullSecrets = "imagePullSecrets"
 const DefaultAppNamespace = "default"
-const DefaultUserLabel = DomainYuniKorn + "username"
 const DefaultUser = "nobody"
 
 // Spark
diff --git a/pkg/common/utils/utils.go b/pkg/common/utils/utils.go
index 3eecedac..e42bfbce 100644
--- a/pkg/common/utils/utils.go
+++ b/pkg/common/utils/utils.go
@@ -318,7 +318,7 @@ func MergeMaps(first, second map[string]string) 
map[string]string {
        return result
 }
 
-// GetUserFromPod find username from pod annotation or label
+// GetUserFromPod find username from pod annotation
 func GetUserFromPod(pod *v1.Pod) (string, []string) {
        if pod.Annotations[userInfoKey] != "" {
                userInfoJSON := pod.Annotations[userInfoKey]
@@ -339,28 +339,7 @@ func GetUserFromPod(pod *v1.Pod) (string, []string) {
                return user, groups
        }
 
-       // Label is processed for backwards compatibility
-       userLabelKey := conf.GetSchedulerConf().UserLabelKey
-       if userLabelKey != "" {
-               log.Log(log.Deprecation).Warn("'userLabelKey' config is 
deprecated, use 'user.info' annotation")
-       }
-       // UserLabelKey should not be empty
-       if userLabelKey == "" {
-               userLabelKey = constants.DefaultUserLabel
-       }
-       // Username to be defined in labels
-       if username := GetPodLabelValue(pod, userLabelKey); username != "" && 
len(username) > 0 {
-               log.Log(log.Deprecation).Warn("Found user name from pod label",
-                       zap.String("userLabel", userLabelKey),
-                       zap.String("user", username))
-               return username, nil
-       }
-       value := constants.DefaultUser
-
-       log.Log(log.ShimUtils).Debug("Unable to retrieve user name from pod 
labels. Empty user label",
-               zap.String("userLabel", userLabelKey))
-
-       return value, nil
+       return constants.DefaultUser, nil
 }
 
 // GetCoreSchedulerConfigFromConfigMap resolves a yunikorn configmap into a 
core scheduler config.
diff --git a/pkg/common/utils/utils_test.go b/pkg/common/utils/utils_test.go
index 895d0836..e226102e 100644
--- a/pkg/common/utils/utils_test.go
+++ b/pkg/common/utils/utils_test.go
@@ -875,57 +875,6 @@ func TestMergeMaps(t *testing.T) {
        }
 }
 
-func TestGetUserFromPodLabel(t *testing.T) {
-       userInLabel := "testuser"
-       userNotInLabel := constants.DefaultUser
-       customUserKeyLabel := "test"
-       testCases := []struct {
-               name         string
-               userLabelKey string
-               pod          *v1.Pod
-               expectedUser string
-       }{
-               {"User defined in label with default key", 
constants.DefaultUserLabel, &v1.Pod{
-                       ObjectMeta: metav1.ObjectMeta{
-                               Labels: 
map[string]string{constants.DefaultUserLabel: userInLabel},
-                       },
-               }, userInLabel},
-               {"The length of UserKeyLabel value is 0", 
constants.DefaultUserLabel, &v1.Pod{
-                       ObjectMeta: metav1.ObjectMeta{
-                               Labels: map[string]string{customUserKeyLabel: 
""},
-                       },
-               }, userNotInLabel},
-               {"User not defined in label", constants.DefaultUserLabel, 
&v1.Pod{}, userNotInLabel},
-               {"UserKeyLabel is empty and the user definded in the pod labels 
with default key", "", &v1.Pod{
-                       ObjectMeta: metav1.ObjectMeta{
-                               Labels: 
map[string]string{constants.DefaultUserLabel: userInLabel},
-                       },
-               }, userInLabel},
-               {"UserKeyLabel is empty and the user isn't defined in the pod 
labels", "", &v1.Pod{}, userNotInLabel},
-               {"UserKeyLabel is changed and the user definded in the pod 
labels", customUserKeyLabel, &v1.Pod{
-                       ObjectMeta: metav1.ObjectMeta{
-                               Labels: map[string]string{customUserKeyLabel: 
userInLabel},
-                       },
-               }, userInLabel},
-               {"UserKeyLabel is changed and the user isn't defined in the pod 
labels", customUserKeyLabel, &v1.Pod{}, userNotInLabel},
-       }
-
-       for _, tc := range testCases {
-               t.Run(tc.name, func(t *testing.T) {
-                       conf := conf.GetSchedulerConf()
-                       // The default UserLabelKey could be set with the 
custom UserLabelKey.
-                       if tc.userLabelKey != constants.DefaultUserLabel {
-                               conf.UserLabelKey = tc.userLabelKey
-                       }
-
-                       userID, _ := GetUserFromPod(tc.pod)
-                       assert.Equal(t, userID, tc.expectedUser)
-                       // The order of test cases is allowed to impact other 
test case.
-                       conf.UserLabelKey = constants.DefaultUserLabel
-               })
-       }
-}
-
 func TestGetUserFromPodAnnotation(t *testing.T) {
        const userAndGroups = 
"{\"user\":\"test\",\"groups\":[\"devops\",\"test\"]}"
        const emptyUserAndGroups = 
"{\"user\":\"\",\"groups\":[\"devops\",\"test\"]}"
@@ -954,6 +903,7 @@ func TestGetUserFromPodAnnotation(t *testing.T) {
                                        userInfoKey: "xyzxyz"},
                        },
                }, "nobody", nil},
+               {"No annotation", &v1.Pod{}, "nobody", nil},
        }
 
        for _, tc := range testCases {
diff --git a/pkg/conf/schedulerconf.go b/pkg/conf/schedulerconf.go
index df0640da..72b3f3df 100644
--- a/pkg/conf/schedulerconf.go
+++ b/pkg/conf/schedulerconf.go
@@ -125,7 +125,6 @@ type SchedulerConf struct {
        KubeBurst                int                `json:"kubeBurst"`
        EnableConfigHotRefresh   bool               
`json:"enableConfigHotRefresh"`
        DisableGangScheduling    bool               
`json:"disableGangScheduling"`
-       UserLabelKey             string             `json:"userLabelKey"`
        PlaceHolderConfig        *PlaceHolderConfig `json:"placeHolderConfig"`
        InstanceTypeNodeLabelKey string             
`json:"instanceTypeNodeLabelKey"`
        Namespace                string             `json:"namespace"`
@@ -159,7 +158,6 @@ func (conf *SchedulerConf) Clone() *SchedulerConf {
                KubeBurst:                conf.KubeBurst,
                EnableConfigHotRefresh:   conf.EnableConfigHotRefresh,
                DisableGangScheduling:    conf.DisableGangScheduling,
-               UserLabelKey:             conf.UserLabelKey,
                PlaceHolderConfig:        conf.PlaceHolderConfig,
                InstanceTypeNodeLabelKey: conf.InstanceTypeNodeLabelKey,
                Namespace:                conf.Namespace,
@@ -332,7 +330,6 @@ func CreateDefaultConfig() *SchedulerConf {
                KubeBurst:                DefaultKubeBurst,
                EnableConfigHotRefresh:   DefaultEnableConfigHotRefresh,
                DisableGangScheduling:    DefaultDisableGangScheduling,
-               UserLabelKey:             constants.DefaultUserLabel,
                InstanceTypeNodeLabelKey: 
constants.DefaultNodeInstanceTypeNodeLabelKey,
                GenerateUniqueAppIds:     
DefaultAMFilteringGenerateUniqueAppIds,
                PlaceHolderConfig: &PlaceHolderConfig{
diff --git a/pkg/conf/schedulerconf_test.go b/pkg/conf/schedulerconf_test.go
index cf56c898..4518599e 100644
--- a/pkg/conf/schedulerconf_test.go
+++ b/pkg/conf/schedulerconf_test.go
@@ -74,7 +74,6 @@ func assertDefaults(t *testing.T, conf *SchedulerConf) {
        assert.Equal(t, conf.DispatchTimeout, DefaultDispatchTimeout)
        assert.Equal(t, conf.KubeQPS, DefaultKubeQPS)
        assert.Equal(t, conf.KubeBurst, DefaultKubeBurst)
-       assert.Equal(t, conf.UserLabelKey, constants.DefaultUserLabel)
 }
 
 func TestDecompress(t *testing.T) {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to