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

[enhancement]: Show system updates less often (unable to clear packageUpdate notification) #2864

Closed
1 task done
klein0r opened this issue Aug 13, 2024 · 9 comments · Fixed by #2865
Closed
1 task done

Comments

@klein0r
Copy link
Contributor

klein0r commented Aug 13, 2024

No existing issues.

  • There is no existing issue for my request.

Description

At the moment, every getRepository or upgradeOsPackages host message leads to a new notification:

try {
await listUpdatableOsPackages();
} catch (e) {
logger.warn(`${hostLogPrefix} Could not check for new OS updates: ${e.message}`);
}

try {
await listUpdatableOsPackages();
} catch (e) {
logger.warn(`${hostLogPrefix} Could not check for new OS updates after upgrade: ${e.message}`);
}

const packages = await packManager.listUpgradeablePackages();
if (!packages.length) {
await notificationHandler.clearNotifications('system', 'packageUpdates', `system.host.${hostname}`);
return;
}
await notificationHandler.addMessage('system', 'packageUpdates', packages.join('\n'), `system.host.${hostname}`);
await states!.setState(`${hostObjectPrefix}.osPackageUpdates`, { val: JSON.stringify(packages), ack: true });

So there's a new notification every day (if the repo has changed) - even if the notification has been confirmed already.

Why?

I'm doing updates about once a week. So I cannot remove that notification for a few days. When using admin 7.0.23 it is not possible to remove those notifications:

asd

Looks like the notifications are cleared correctly (system.host.iobroker.notifications.system is {} afterwards) but a page reload re-generates the notification: {"packageUpdates":{"count":1}}

[3,70,"sendToHost",["system.host.iobroker","clearNotifications",{"category":"packageUpdates"}]]	1723533804.2533119

How?

No response

@klein0r klein0r changed the title [enhancement]: Show system updates less often [enhancement]: Show system updates less often (unable to clear packageUpdate notification) Aug 13, 2024
@klein0r
Copy link
Contributor Author

klein0r commented Aug 13, 2024

@foxriver76
Copy link
Collaborator

We could persist the current updates in a state or object and if nothing changed, do not re-generate + always re-generate on controller restart?

Or yes if written in state anyway we could use ts (if we only write when generating notification) to determine that last notification is (maybe) 7 days old or changed -> generate notification.

@klein0r
Copy link
Contributor Author

klein0r commented Aug 13, 2024

We could persist the current updates in a state or object and if nothing changed, do not re-generate + always re-generate on controller restart?

Sounds good, since that state already exists:

await states!.setState(`${hostObjectPrefix}.osPackageUpdates`, { val: JSON.stringify(packages), ack: true });

And there is also another bug, that the state is not set to an empty list when the system has been updated:

if (!packages.length) {
await notificationHandler.clearNotifications('system', 'packageUpdates', `system.host.${hostname}`);
return;
}

@klein0r
Copy link
Contributor Author

klein0r commented Aug 13, 2024

e.g.

/**
 * Check for updatable OS packages and register them as notification
 */
async function listUpdatableOsPackages(): Promise<void> {
    if (tools.isDocker()) {
        return;
    }

    const packManager = new PacketManager();
    await packManager.ready();

    const packages = await packManager.listUpgradeablePackages();
    const osPackageUpdatesId = `${hostObjectPrefix}.osPackageUpdates`;

    if (!packages.length) {
        await notificationHandler.clearNotifications('system', 'packageUpdates', `system.host.${hostname}`);
        await states!.setState(osPackageUpdatesId, { val: JSON.stringify([]), ack: true });
    } else {
        const osPackageUpdatesState = await states!.getState(osPackageUpdatesId);
        const packagesJson = JSON.stringify(packages);

        if (!osPackageUpdatesState || osPackageUpdatesState.val !== packagesJson) {
            await notificationHandler.addMessage('system', 'packageUpdates', packages.join('\n'), `system.host.${hostname}`);
            await states!.setState(osPackageUpdatesId, { val: packagesJson, ack: true });
        }
    }
}

@anton-hystrix
Copy link

Can we please also exclude system updates that were kept back? I'm annoyed to see the notification about debian version every time I open the page in browser. It also would be good if we could turn off these notifications completely. I update the server whenever I want to. Why do I need ioBroker to annoy me with this?

@foxriver76
Copy link
Collaborator

foxriver76 commented Aug 15, 2024

You can turn them off, simply use the notification manager adapter and no notifications will "annoy" you if configured.

@mcm1957
Copy link
Contributor

mcm1957 commented Aug 15, 2024

Can we please also exclude system updates that were kept back? I'm annoyed to see the notification about debian version every time I open the page in browser. It also would be good if we could turn off these notifications completely. I update the server whenever I want to. Why do I need ioBroker to annoy me with this?

take a look at adapter iobroker.notification-manager

@anton-hystrix
Copy link

take a look at adapter iobroker.notification-manager

I will, thanks. But anyway, it would be cool if "Aknowledge" button simply allowed to mark specific notification as read.

@foxriver76
Copy link
Collaborator

take a look at adapter iobroker.notification-manager

I will, thanks. But anyway, it would be cool if "Aknowledge" button simply allowed to mark specific notification as read.

That is what this issue is about, after PR is merged it will only be re-generated if new updates are available the user was not informed about eralier and likely this will relax the whole situation around people being annoyed on every admin reload by the notification + newest admin version should no longer auto open the notifications on reload if no warning is present.

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