Page MenuHomePhabricator

Unable to change configuration after changing it from script (vbash + script-template)
Open, HighPublicBUG

Description

Hi all!
If we change some configuration from script, then we can't do after this any changes manually until reboot system.
Example:

Startup configuration:

[edit]
vyos@vyos# show interfaces ethernet eth2 
 address 192.168.202.1/24
 disable
 duplex auto
 hw-id 08:00:27:2d:07:cb
 policy {
     route google
 }
 smp-affinity auto
 speed auto
[edit]
vyos@vyos# show system task-scheduler 
 task testtask01 {
     crontab-spec @reboot
     executable {
         path /config/scripts/testscript01.script
     }
 }
[edit]
vyos@vyos#

Script content:

root@vyos:/home/vyos# cat /config/scripts/testscript01.script 
#!/bin/vbash
source /opt/vyatta/etc/functions/script-template

sleep 30s
configure
delete interfaces ethernet eth2 disable
commit
exit

Reboot, wait 30 seconds and check for configuration changes:

[edit]
vyos@vyos# show interfaces ethernet eth2 
 address 192.168.202.1/24
 duplex auto
 hw-id 08:00:27:2d:07:cb
 policy {
     route google
 }
 smp-affinity auto
 speed auto
[edit]
vyos@vyos# 
vyos@vyos# exit
exit
vyos@vyos:~$ show interfaces 
Codes: S - State, L - Link, u - Up, D - Down, A - Admin Down
Interface        IP Address                        S/L  Description
---------        ----------                        ---  -----------
eth0             10.0.2.5/24                       u/u  
eth1             192.168.20.60/24                  u/u  
eth2             192.168.202.1/24                  u/u  
lo               127.0.0.1/8                       u/u  
                 ::1/128
vyos@vyos:~$

So, script is working. But, now if we try to change configuration:

[edit]
vyos@vyos# set system host-name test01

  Set failed

[edit]
vyos@vyos# set interfaces ethernet eth1 speed 100

  Set failed

[edit]
vyos@vyos# set firewall name test1 default-action drop 

  Set failed

[edit]
vyos@vyos#

... and so on. Configuration management become completely broken until we disable script and reboot.

Details

Difficulty level
Unknown (require assessment)
Version
VyOS 1.2.0-rolling+201810280337
Why the issue appeared?
Will be filled on close

Event Timeline

zsdc created this task.Oct 28 2018, 7:13 PM
syncer triaged this task as Normal priority.Oct 28 2018, 7:28 PM
syncer added a subscriber: syncer.

the script must be run from vyatta group
sg vyattacfg /path/to/script

@dmbaturin should we run all our scripts with such wrapper? (e.g. add it to all places where scripts can be used)

@zsdc Which version are you using? It should be fixed in rc1 already. If you are using rc1 or newer, that means the fix is incomplete.

If you are using 1.1.8, please use sg as @syncer suggests.

@zsdc Ah, sorry, rolling-1028. I'll take a look.

zsdc added a comment.Oct 28 2018, 7:43 PM

@syncer, thanks for hint. Works with:

[edit]
vyos@vyos# show system task-scheduler 
 task testtask01 {
     crontab-spec @reboot
     executable {
         arguments "vyattacfg /config/scripts/testscript01.script"
         path /usr/bin/sg
     }
 }
[edit]
vyos@vyos#

But this workaround is ugly a little bit (if we want to use arguments for example).
Maybe, better will be if VyOS will do this under the hood, without end-user engagement?

@zsdc Yes, that's the idea. We even have a task about it: T462

The code looks right to me. Could you create a task without the workaround and post relevant crontab line?

zsdc added a comment.Oct 28 2018, 8:02 PM

@dmbaturin after some thinking about this problem I think that doing sg for all script is not a very good idea. There can be a situations, when we wan't to run it from other groups.
By now, I see two ways:

  • add additional parameter to executable option, that will define using script vbash with template or not;
  • move setting up right group to /opt/vyatta/etc/functions/script-template.

Second way seems more practical and easy for configuration migrations.

pasik added a subscriber: pasik.Dec 16 2018, 11:23 AM
syncer assigned this task to dmbaturin.
syncer raised the priority of this task from Normal to High.
syncer moved this task from Needs Triage to Backlog on the VyOS 1.2 Crux (VyOS 1.2.1) board.