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

ccondit 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 c63a21ff [YUNIKORN-1948] Introduce a command to validate the content 
of a given queue config file (#634)
c63a21ff is described below

commit c63a21ffb59b9dc21817375344faa2b0b924c05b
Author: Yongjun Zhang <[email protected]>
AuthorDate: Thu Sep 7 10:40:48 2023 -0500

    [YUNIKORN-1948] Introduce a command to validate the content of a given 
queue config file (#634)
    
    Closes: #634
    
    Signed-off-by: Craig Condit <[email protected]>
---
 Makefile                                     |  7 ++++-
 cmd/queueconfigchecker/queueconfigchecker.go | 47 ++++++++++++++++++++++++++++
 pkg/common/configs/config.go                 |  1 -
 3 files changed, 53 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 4431e060..02d26cad 100644
--- a/Makefile
+++ b/Makefile
@@ -177,7 +177,7 @@ pseudo:
 
 # Build the example binaries for dev and test
 .PHONY: commands
-commands: build/simplescheduler build/schedulerclient
+commands: build/simplescheduler build/schedulerclient build/queueconfigchecker
 
 build/simplescheduler: go.mod go.sum cmd
        @echo "building example scheduler"
@@ -189,6 +189,11 @@ build/schedulerclient:
        @mkdir -p build
        "$(GO)" build $(RACE) -a -ldflags '-extldflags "-static"' -o 
build/schedulerclient ./cmd/schedulerclient
 
+build/queueconfigchecker:
+       @echo "building queueconfigchecker"
+       @mkdir -p build
+       "$(GO)" build $(RACE) -a -ldflags '-extldflags "-static"' -o 
build/queueconfigchecker ./cmd/queueconfigchecker
+
 # Build binaries for dev and test
 .PHONY: build
 build: commands
diff --git a/cmd/queueconfigchecker/queueconfigchecker.go 
b/cmd/queueconfigchecker/queueconfigchecker.go
new file mode 100644
index 00000000..dead2ef5
--- /dev/null
+++ b/cmd/queueconfigchecker/queueconfigchecker.go
@@ -0,0 +1,47 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+package main
+
+import (
+       "log"
+       "os"
+
+       "github.com/apache/yunikorn-core/pkg/common/configs"
+)
+
+/*
+A utility command to load queue configuration file and check its validity
+*/
+func main() {
+       if len(os.Args) != 2 {
+               log.Println("Usage: " + os.Args[0] + " <queue-config-file>")
+               os.Exit(1)
+       }
+       queueFile := os.Args[1]
+       conf, err := os.ReadFile(queueFile)
+       if err != nil {
+               log.Printf("Could not read file: %v", err)
+               os.Exit(2)
+       }
+       _, err = configs.LoadSchedulerConfigFromByteArray(conf)
+       if err != nil {
+               log.Printf("Config validation failed: %v", err)
+               os.Exit(3)
+       }
+}
diff --git a/pkg/common/configs/config.go b/pkg/common/configs/config.go
index bb6c3129..8f34a044 100644
--- a/pkg/common/configs/config.go
+++ b/pkg/common/configs/config.go
@@ -149,7 +149,6 @@ type NodeSortingPolicy struct {
        ResourceWeights map[string]float64 `yaml:",omitempty" json:",omitempty"`
 }
 
-// Visible by tests
 func LoadSchedulerConfigFromByteArray(content []byte) (*SchedulerConfig, 
error) {
        conf, err := ParseAndValidateConfig(content)
        if err != nil {


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

Reply via email to