sonic-buildimage/files/scripts
SuvarnaMeenakshi 2f66b4c545 [sonic-netns-exec]: use "$@" to reflects all positional parameters as they were set initially (#4375)
sonic-netns-exec fails to execute below command in swss.sh:

    sonic-netns-exec "$NET_NS" sonic-db-cli $1 EVAL "
    local tables = {$2}
    for i = 1, table.getn(tables) do
        local matches = redis.call('KEYS', tables[i])
        for j,name in ipairs(matches) do
            redis.call('DEL', name)
        end
    end" 0

This command fails with error " redis.exceptions.ResponseError: value is not an integer or out of range" .

Root cause:

When sonic-netns-exec executes the above function, argument passed to sonic-db-cli is NOT executed as a single script.

The argument is passed as separate keywords to sonic-db-cli, as below:

['EVAL', 'local', 'tables', '=', "{'PORT_TABLE*'}", 'for', 'i', '=', '1,', 'table.getn(tables)', 'do', 'local', 'matches', '=', "redis.call('KEYS',", 'tables[i])', 'for', 'j,name', 'in', 'ipairs(matches)', 'do', "redis.call('DEL',", 'name)', 'end', 'end', '0']

- How I did it
To make sure that the parameters are passed as they were set initially, fix sonic-netns-exec to use double quoted "$@", where "$@" is "$1" "$2" "$3" ... "${N}"

After fix, the argument passed to sonic-db-cli is as below:

Argument passed to sonic-db-cli:

['EVAL', "\n    local tables = {'PORT_TABLE*'}\n    for i = 1, table.getn(tables) do\n        local matches = redis.call('KEYS', tables[i])\n        for j,name in ipairs(matches) do\n            redis.call('DEL', name)\n        end\n    end", '0']

Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>
2020-04-15 13:13:31 -07:00
..
arp_update Sleep done before mismatch handler (#4165) 2020-02-24 10:25:56 -08:00
configdb-load.sh [sonic-cfggen] Loading the configuration from init_cfg.json and then from config_db.json (#4148) 2020-03-15 08:54:05 -07:00
core_cleanup.py [cron.d] Add cron job to periodically clean-up core files (#3449) 2019-09-13 10:50:31 -07:00
sonic-netns-exec [sonic-netns-exec]: use "$@" to reflects all positional parameters as they were set initially (#4375) 2020-04-15 13:13:31 -07:00
supervisor-proc-exit-listener [Services] Restart database service upon unexpected critical process exit. (#4138) 2020-02-13 16:20:38 -08:00
swss.sh Multi-ASIC implementation (#3888) 2020-04-15 13:08:34 -07:00
syncd.sh Multi-ASIC implementation (#3888) 2020-04-15 13:08:34 -07:00