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

We do not verify the presence of opkg cache files for update #55

Open
Hurricos opened this issue Dec 11, 2022 · 2 comments
Open

We do not verify the presence of opkg cache files for update #55

Hurricos opened this issue Dec 11, 2022 · 2 comments

Comments

@Hurricos
Copy link

When openwrt_remote_opkg_lists_dir is placed at /tmp/opkg-lists (the
default), it is recreated on each boot. However, when any opkg command
is run -- including e.g. opkg list-installed -- that directory is
created and left empty.

On such a router, the first time an opkg command is run, the
openwrt_remote_opkg_lists_dir is given mtime <= 86400 (at least for
the next 24h), suggesting to the default ansible-openwrt's tasks that
an opkg update has been issued recently when one has not. This seems
to happen when an Ansible check-mode run is performed right after a
router is booted.

Hurricos added a commit to Hurricos/ansible-openwrt that referenced this issue Dec 11, 2022
When openwrt_remote_opkg_lists_dir is placed at /tmp/opkg-lists (the
default), it is recreated on each boot. However, when any opkg command
is run -- including e.g. `opkg list-installed` -- that directory is
created and left empty.

On such a router, the first time an `opkg` command is run, the
openwrt_remote_opkg_lists_dir is given mtime <= 86400 (at least for
the next 24h), suggesting to the default ansible-openwrt's tasks that
an `opkg update` has been issued recently when one has not. This seems
to happen when an Ansible check-mode run is performed right after a
router is booted.

Correct this problem by verifying that there are actual opkg cache
files. We assume (perhaps incorrectly) that all of the opkg cache
files were created at the same time during the most recent successful
`opkg update` run, if there are any, meaning they all have dates
roughly matching that of their openwrt_remote_opkg_lists_dir. As a
result, we do not need to check the age of those files.

This commit fixes issue gekmihesg#55:
gekmihesg#55

Signed-off-by: Martin Kennedy <hurricos@gmail.com>
@Hurricos
Copy link
Author

@gekmihesg Could you review my fix for this broken opkg module behavior soon after first boot?

Hurricos added a commit to Hurricos/ansible-openwrt that referenced this issue Dec 21, 2022
When openwrt_remote_opkg_lists_dir is placed at /tmp/opkg-lists (the
default), it is recreated on each boot. However, when any opkg command
is run -- including e.g. `opkg list-installed` -- that directory is
created and left empty.

On such a router, the first time an `opkg` command is run, the
openwrt_remote_opkg_lists_dir is given mtime <= 86400 (at least for
the next 24h), suggesting to the default ansible-openwrt's tasks that
an `opkg update` has been issued recently when one has not. This seems
to happen when an Ansible check-mode run is performed right after a
router is booted.

Correct this problem by verifying that there are actual opkg cache
files. We assume (perhaps incorrectly) that all of the opkg cache
files were created at the same time during the most recent successful
`opkg update` run, if there are any, meaning they all have dates
roughly matching that of their openwrt_remote_opkg_lists_dir. As a
result, we do not need to check the age of those files.

This commit fixes issue gekmihesg#55:
gekmihesg#55

Signed-off-by: Martin Kennedy <hurricos@gmail.com>
@Hurricos
Copy link
Author

Commit 16f590e fixes this commit's behavior in check-mode. Unfortunately, in order to find the number of files in e.g. /tmp/opkg-lists, I need to use the find command, which does not support check mode; to avoid breakage when running in check-mode, safen the check for find output with an is defined.

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

No branches or pull requests

1 participant