sonic-buildimage/files
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
..
Aboot [Arista] Update drivers submodules (#4353) 2020-04-01 23:26:42 -07:00
apt [apt] Instruct apt-get to NOT check the "Valid Until" date in Release files (#3973) 2020-01-21 10:43:51 -08:00
build_scripts [build_debian] Include checksum of ASIC config files in SONiC filesystem (#3384) 2019-09-05 19:41:35 -07:00
build_templates Multi-ASIC implementation (#3888) 2020-04-15 13:08:34 -07:00
dhcp ZTP infrastructure changes to support DHCP discovery provisioning data (#3298) 2020-03-03 22:23:59 -08:00
docker [docker-engine]: upgrade docker engine to 18.09 (#2417) 2019-01-04 20:47:43 -08:00
image_config Multi-ASIC implementation (#3888) 2020-04-15 13:08:34 -07:00
initramfs-tools [Arista] Update drivers submodules (#4353) 2020-04-01 23:26:42 -07:00
scripts [sonic-netns-exec]: use "$@" to reflects all positional parameters as they were set initially (#4375) 2020-04-15 13:13:31 -07:00
sshd [security] Do not generate ssh server keys for non RSA protocols (#2718) 2019-03-29 15:27:33 -07:00