Skip to content

Commit

Permalink
configd: T6747: use one long-lived instance of FRRender
Browse files Browse the repository at this point in the history
Previously there was one FRRender() instance per config session. This resulted
in re-rendering the FRR configuration every time a new config session was
created.

Example:

  vyos@vyos:~$ configure
  vyos@vyos# set interfaces dummy dum0 description foo
  vyos@vyos# commit
  vyos@vyos# exit

  vyos@vyos:~$ configure
  vyos@vyos# set interfaces dummy dum0 description bar
  vyos@vyos# commit
  vyos@vyos# exit

In the past this caused a re-render of the FRR configuration as the delta check
added in commit ec80c75 ("frrender: T6746: only re-render FRR config if
config_dict did change") evaluated to false, as it operated on a new instance
of the FRRender class.

With this change there is no FRR re-render, as there is nothing to update
in FRR.
  • Loading branch information
c-po committed Jan 4, 2025
1 parent fb87278 commit 4f17dd1
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/services/vyos-configd
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,6 @@ def initialization(socket):
scripts_called = []
setattr(config, 'scripts_called', scripts_called)

if not hasattr(config, 'frrender_cls'):
setattr(config, 'frrender_cls', FRRender())

return config


Expand Down Expand Up @@ -312,8 +309,10 @@ if __name__ == '__main__':
remove_if_file(configd_env_file)
os.symlink(configd_env_set_file, configd_env_file)

config = None
# We only need one long-lived instance of FRRender
frr = FRRender()

config = None
while True:
# Wait for next request from client
msg = socket.recv().decode()
Expand All @@ -332,10 +331,11 @@ if __name__ == '__main__':
scripts_called = getattr(config, 'scripts_called', [])
logger.debug(f'scripts_called: {scripts_called}')

if hasattr(config, 'frrender_cls') and res == R_SUCCESS:
frrender_cls = getattr(config, 'frrender_cls')
if res == R_SUCCESS:
tmp = get_frrender_dict(config)
if frrender_cls.generate(tmp):
frrender_cls.apply()
if frr.generate(tmp):
# only apply a new FRR configuration if anything changed
# in comparison to the previous applied configuration
frr.apply()
else:
logger.critical(f'Unexpected message: {message}')

0 comments on commit 4f17dd1

Please sign in to comment.