This is an automated email from the ASF dual-hosted git repository.
brandboat pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/yunikorn-core.git
The following commit(s) were added to refs/heads/master by this push:
new 0e8a2907 [YUNIKORN-2793] Clean up the user and group check. (#939)
0e8a2907 is described below
commit 0e8a29078145e71fdab4c33f6f9ad554f9ca8fc0
Author: ryankert <[email protected]>
AuthorDate: Fri Aug 9 21:03:04 2024 +0800
[YUNIKORN-2793] Clean up the user and group check. (#939)
Closes: #939
Signed-off-by: Kuan-Po Tseng <[email protected]>
---
pkg/webservice/handlers.go | 10 ----------
pkg/webservice/handlers_test.go | 35 ++---------------------------------
2 files changed, 2 insertions(+), 43 deletions(-)
diff --git a/pkg/webservice/handlers.go b/pkg/webservice/handlers.go
index 2d7d5081..83003551 100644
--- a/pkg/webservice/handlers.go
+++ b/pkg/webservice/handlers.go
@@ -60,8 +60,6 @@ const (
InvalidGroupName = "Invalid group name"
UserDoesNotExists = "User not found"
GroupDoesNotExists = "Group not found"
- UserNameMissing = "User name is missing"
- GroupNameMissing = "Group name is missing"
ApplicationDoesNotExists = "Application not found"
NodeDoesNotExists = "Node not found"
)
@@ -1103,10 +1101,6 @@ func getUserResourceUsage(w http.ResponseWriter, r
*http.Request) {
return
}
user := vars.ByName("user")
- if user == "" {
- buildJSONErrorResponse(w, UserNameMissing,
http.StatusBadRequest)
- return
- }
unescapedUser, err := url.QueryUnescape(user)
if err != nil {
buildJSONErrorResponse(w, err.Error(), http.StatusBadRequest)
@@ -1148,10 +1142,6 @@ func getGroupResourceUsage(w http.ResponseWriter, r
*http.Request) {
return
}
group := vars.ByName("group")
- if group == "" {
- buildJSONErrorResponse(w, GroupNameMissing,
http.StatusBadRequest)
- return
- }
unescapedGroupName, err := url.QueryUnescape(group)
if err != nil {
buildJSONErrorResponse(w, err.Error(), http.StatusBadRequest)
diff --git a/pkg/webservice/handlers_test.go b/pkg/webservice/handlers_test.go
index 7cf045df..8c9aaf06 100644
--- a/pkg/webservice/handlers_test.go
+++ b/pkg/webservice/handlers_test.go
@@ -1798,15 +1798,6 @@ func assertUserNotExists(t *testing.T, resp
*MockResponseWriter) {
assert.Equal(t, errInfo.StatusCode, http.StatusNotFound)
}
-func assertUserNameMissing(t *testing.T, resp *MockResponseWriter) {
- var errInfo dao.YAPIError
- err := json.Unmarshal(resp.outputBytes, &errInfo)
- assert.NilError(t, err, unmarshalError)
- assert.Equal(t, http.StatusBadRequest, resp.statusCode, statusCodeError)
- assert.Equal(t, errInfo.Message, UserNameMissing, jsonMessageError)
- assert.Equal(t, errInfo.StatusCode, http.StatusBadRequest)
-}
-
func assertGroupExists(t *testing.T, resp *MockResponseWriter, expected
*dao.GroupResourceUsageDAOInfo) {
var actual *dao.GroupResourceUsageDAOInfo
err := json.Unmarshal(resp.outputBytes, &actual)
@@ -1832,15 +1823,6 @@ func assertInvalidGroupName(t *testing.T, resp
*MockResponseWriter) {
assert.Equal(t, errInfo.StatusCode, http.StatusBadRequest)
}
-func assertGroupNameMissing(t *testing.T, resp *MockResponseWriter) {
- var errInfo dao.YAPIError
- err := json.Unmarshal(resp.outputBytes, &errInfo)
- assert.NilError(t, err, unmarshalError)
- assert.Equal(t, http.StatusBadRequest, resp.statusCode, statusCodeError)
- assert.Equal(t, errInfo.Message, GroupNameMissing, jsonMessageError)
- assert.Equal(t, errInfo.StatusCode, http.StatusBadRequest)
-}
-
func assertNodeIDNotExists(t *testing.T, resp *MockResponseWriter) {
var errInfo dao.YAPIError
err := json.Unmarshal(resp.outputBytes, &errInfo)
@@ -1918,24 +1900,11 @@ func TestFullStateDumpPath(t *testing.T) {
func TestSpecificUserResourceUsage(t *testing.T) {
prepareUserAndGroupContext(t, groupsLimitsConfig)
- // Test user name is missing
- req, err := createRequest(t, "/ws/v1/partition/default/usage/user/",
map[string]string{"group": "testgroup"})
- assert.NilError(t, err)
- resp := &MockResponseWriter{}
- getUserResourceUsage(resp, req)
- assertUserNameMissing(t, resp)
-
- // Test group name is missing
- req, err = createRequest(t, "/ws/v1/partition/default/usage/group/",
map[string]string{"user": "testuser"})
- assert.NilError(t, err)
- resp = &MockResponseWriter{}
- getGroupResourceUsage(resp, req)
- assertGroupNameMissing(t, resp)
// Test existed user query
- req, err = createRequest(t, "/ws/v1/partition/default/usage/user/",
map[string]string{"user": "testuser", "group": "testgroup"})
+ req, err := createRequest(t, "/ws/v1/partition/default/usage/user/",
map[string]string{"user": "testuser", "group": "testgroup"})
assert.NilError(t, err)
- resp = &MockResponseWriter{}
+ resp := &MockResponseWriter{}
getUserResourceUsage(resp, req)
assertUserExists(t, resp,
&dao.UserResourceUsageDAOInfo{
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]