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

pbacsko 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 3ac7b485 [YUNIKORN-2518] Allow recovery queue in REST requests (#864)
3ac7b485 is described below

commit 3ac7b4856dc88cf02e35ab0b113d949aa0d7438a
Author: steinsgateted <[email protected]>
AuthorDate: Thu May 2 13:13:55 2024 +0200

    [YUNIKORN-2518] Allow recovery queue in REST requests (#864)
    
    Closes: #864
    
    Signed-off-by: Peter Bacsko <[email protected]>
---
 pkg/webservice/handlers.go      |  4 ++--
 pkg/webservice/handlers_test.go | 11 +++++++----
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/pkg/webservice/handlers.go b/pkg/webservice/handlers.go
index 17d09566..04c70c50 100644
--- a/pkg/webservice/handlers.go
+++ b/pkg/webservice/handlers.go
@@ -117,10 +117,10 @@ func validateQueue(queuePath string) error {
        if queuePath != "" {
                queueNameArr := strings.Split(queuePath, ".")
                for _, name := range queueNameArr {
-                       if !configs.QueueNameRegExp.MatchString(name) {
+                       if !configs.QueueNameRegExp.MatchString(name) && name 
!= common.RecoveryQueue {
                                return fmt.Errorf("problem in queue query 
parameter parsing as queue param "+
                                        "%s contains invalid queue name %s. 
Queue name must only have "+
-                                       "alphanumeric characters, - or _, and 
be no longer than 64 characters", queuePath, name)
+                                       "alphanumeric characters, - or _, and 
be no longer than 64 characters except the recovery queue root.@recovery@", 
queuePath, name)
                        }
                }
        }
diff --git a/pkg/webservice/handlers_test.go b/pkg/webservice/handlers_test.go
index bb6e38df..1d7ffd90 100644
--- a/pkg/webservice/handlers_test.go
+++ b/pkg/webservice/handlers_test.go
@@ -1694,7 +1694,7 @@ func assertQueueInvalid(t *testing.T, resp 
*MockResponseWriter, invalidQueuePath
        err := json.Unmarshal(resp.outputBytes, &errInfo)
        assert.NilError(t, err, unmarshalError)
        assert.Equal(t, http.StatusBadRequest, resp.statusCode, statusCodeError)
-       assert.Equal(t, errInfo.Message, "problem in queue query parameter 
parsing as queue param "+invalidQueuePath+" contains invalid queue name 
"+invalidQueueName+". Queue name must only have alphanumeric characters, - or 
_, and be no longer than 64 characters", jsonMessageError)
+       assert.Equal(t, errInfo.Message, "problem in queue query parameter 
parsing as queue param "+invalidQueuePath+" contains invalid queue name 
"+invalidQueueName+". Queue name must only have alphanumeric characters, - or 
_, and be no longer than 64 characters except the recovery queue 
root.@recovery@", jsonMessageError)
        assert.Equal(t, errInfo.StatusCode, http.StatusBadRequest)
 }
 
@@ -1786,15 +1786,18 @@ func assertActiveStateNotAllow(t *testing.T, resp 
*MockResponseWriter) {
 
 func TestValidateQueue(t *testing.T) {
        err := validateQueue("root.test.test123")
-       assert.NilError(t, err, "Queue path is correct but stil throwing 
error.")
+       assert.NilError(t, err, "Queue path is correct but still throwing 
error.")
 
        invalidQueuePath := "root.test.test123@"
        invalidQueueName := "test123@"
        err1 := validateQueue(invalidQueuePath)
-       assert.Error(t, err1, "problem in queue query parameter parsing as 
queue param "+invalidQueuePath+" contains invalid queue name 
"+invalidQueueName+". Queue name must only have alphanumeric characters, - or 
_, and be no longer than 64 characters")
+       assert.Error(t, err1, "problem in queue query parameter parsing as 
queue param "+invalidQueuePath+" contains invalid queue name 
"+invalidQueueName+". Queue name must only have alphanumeric characters, - or 
_, and be no longer than 64 characters except the recovery queue 
root.@recovery@")
 
        err2 := validateQueue("root")
-       assert.NilError(t, err2, "Queue path is correct but stil throwing 
error.")
+       assert.NilError(t, err2, "Queue path is correct but still throwing 
error.")
+
+       err3 := validateQueue("root.@recovery@")
+       assert.NilError(t, err3, "Queue path is correct but still throwing 
error.")
 }
 
 func TestFullStateDumpPath(t *testing.T) {


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

Reply via email to