perfsonar / psconfig

Configures perfSONAR tests from a central source in an extensible way.
Apache License 2.0
4 stars 2 forks source link

Badly-Structured Config Causes Validator Crash #99

Open mfeit-internet2 opened 1 year ago

mfeit-internet2 commented 1 year ago

This config file...

{
    "_meta":{
        "display-name": "Example Measurements"
    },

    "archives": {
        "example_esmond_archive": {
            "archiver": "esmond",
            "data": {
                "measurement-agent": "{% scheduled_by_address %}",
                "url": "https://10.224.16.80/esmond/perfsonar/archive/"
            }
        }
    },

    "addresses": {
        "neo-comp-devperf1": { "address": "10.224.21.11" },
        "neo-comp-devperf2": { "address": "10.224.21.12" }
    },

    "groups": {
        "example_group_mesh": {
            "type": "mesh",
            "addresses": [
        {"neo-comp-devperf1": "10.224.21.11" },
        {"neo-comp-devperf2": "10.224.21.12" }
            ]
        }

    },

    "tests": {
        "example_test_throughput": {
            "type": "throughput",
            "spec": {
                "source": "{% address[0] %}",
                "dest": "{% address[1] %}",
                "duration": "PT30S"
            }
        },
        "example_test_latencybg": {
            "type": "latencybg",
            "spec": {
                "source": "{% address[0] %}",
                "dest": "{% address[1] %}",
                "flip": "{% flip %}"
            }
        },
        "example_test_trace": {
            "type": "trace",
            "spec": {
                "source": "{% address[0] %}",
                "dest": "{% address[1] %}"
            }
        }
    },

    "schedules": {
        "example_schedule_PT4H": {
            "repeat": "PT4H",
            "sliprand": true,
            "slip": "PT4H"
        },
        "example_schedule_PT10M": {
            "repeat": "PT10M",
            "sliprand": true,
            "slip": "PT10M"
        }
    },

    "tasks": {
        "example_task_throughput": {
            "group": "example_group_mesh",
            "test": "example_test_throughput",
            "schedule": "example_schedule_PT4H",
            "archives": [ "example_esmond_archive" ],
            "_meta": {
                "display-name": "Example Throughput Tests"
            }
        },
        "example_task_latencybg": {
            "group": "example_group_mesh",
            "test": "example_test_latencybg",
            "archives": [ "example_esmond_archive" ],
            "_meta": {
                "display-name": "Example Loss Tests"
            }
        },
        "example_task_trace": {
            "group": "example_group_mesh",
            "test": "example_test_trace",
            "schedule": "example_schedule_PT10M",
            "archives": [ "example_esmond_archive" ],
            "_meta": {
                "display-name": "Example Traceroute Tests"
            }
        }
    }
}

...causes the validator to crash:

[root@xxx tmp]# psconfig validate skeleton.json
Loading template ...... OK
Validating JSON schema ...... OK
Can't call method "can" on an undefined value at /usr/lib/perfsonar/bin/psconfig_commands/../../lib/perfSONAR_PS/Client/PSConfig/Config.pm line 528.
Verifying object references ...... [root@xxx tmp]#

The cause is a badly-structured groups section:

    "groups": {
        "example_group_mesh": {
            "type": "mesh",
            "addresses": [
        {"neo-comp-devperf1": "10.224.21.11" },    <-- Wrong format
        {"neo-comp-devperf2": "10.224.21.12" }     <-- Wrong format
            ]
        }  
    },

Discussion on perfsonar-user: