Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Several NAV scripts run twice on every invocation #2877

Closed
lunkwill42 opened this issue Mar 20, 2024 · 1 comment · Fixed by #2878
Closed

[BUG] Several NAV scripts run twice on every invocation #2877

lunkwill42 opened this issue Mar 20, 2024 · 1 comment · Fixed by #2878
Assignees
Labels

Comments

@lunkwill42
Copy link
Member

lunkwill42 commented Mar 20, 2024

Describe the bug

Due to the changed method of script installation in NAV 5.9, the navsyncdb, navpgdump and navtopology commands now run twice on every invocation. This isn't normally a big problem, but it can result in strange output and errors during an invocation, for example if using the command to create the initial NAV database (as the second run will typically fail because the database was already created and populated by the first run).

The principal problem is because nav/bin/navsyncdb.py and the other mentioned scripts are implemented to import main() from somewhere else, but do not implement a if __name__ == '__main__' guard to avoid running main() as a side effect of an import operation, like so:

from nav.pgsync import main
main()

To Reproduce

Steps to reproduce the behavior (WARNING: This is a destructive command, never run it in a production environment):

  1. Run navsyncdb from the command line.
  2. See double output:
$ navsyncdb
No outstanding schema changes.
No outstanding schema changes.

Expected behavior

navsyncdb, navpgdump and navtopology should only run once per invocation.

Environment (please complete the following information):

  • NAV version installed: 5.9.1
@lunkwill42 lunkwill42 added the bug label Mar 20, 2024
@lunkwill42 lunkwill42 self-assigned this Mar 20, 2024
@lunkwill42 lunkwill42 changed the title [BUG] navsyncdb command runs twice on every invocation [BUG] Several NAV scripts run twice on every invocation Mar 20, 2024
lunkwill42 added a commit to Uninett/nav-debian that referenced this issue Mar 20, 2024
@lunkwill42
Copy link
Member Author

Fixed by #2878

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant