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

ENT-11838: Fixed perpetual warnings that a deleted host has checked in #5617

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

larsewi
Copy link
Contributor

@larsewi larsewi commented Oct 10, 2024

@larsewi larsewi added the WIP Work in Progress label Oct 10, 2024
@larsewi
Copy link
Contributor Author

larsewi commented Oct 11, 2024

Lastseen migration seems to work after upgrading from nightly package to this PR 🚀

# cf-check dump /var/cfengine/state/cf_lastseen.lmdb
{
	"a192.168.56.10": "SHA=b77ed17a94a734afb143610a28e4c81bcfe916866680390285f09c73dd7e7f9b",
	"kSHA=b77ed17a94a734afb143610a28e4c81bcfe916866680390285f09c73dd7e7f9b": "192.168.56.10",
	"qiSHA=b77ed17a94a734afb143610a28e4c81bcfe916866680390285f09c73dd7e7f9b": {"Q":{"dq":18.0000,"expect":-400760018451613696.0000,"q":159.0000,"var":2830478588096048211122947263693},"acknowledged":false,"lastseen":1728629014},
	"qoSHA=b77ed17a94a734afb143610a28e4c81bcfe916866680390285f09c73dd7e7f9b": {"Q":{"dq":18.0000,"expect":-400760018451613696.0000,"q":159.0000,"var":2830478588096048211122947263693},"acknowledged":false,"lastseen":1728629014},
}

@larsewi larsewi changed the title WIP: ENT-11838: Added acknowledge field to lastseen DB WIP: ENT-11838: Fixed perpetual warnings that a deleted host has checked in Oct 11, 2024
@larsewi larsewi force-pushed the lastseen branch 2 times, most recently from 6ab8894 to 80e9540 Compare October 14, 2024 08:08
@larsewi
Copy link
Contributor Author

larsewi commented Oct 14, 2024

New field seems to do the job when built together with https://github.com/cfengine/nova/pull/2339

# cf-check dump /var/cfengine/state/cf_lastseen.lmdb
{
	"a172.31.36.65": "SHA=a624c8d1ee1edb763b5a901c5140fe96e9a495c1e3532aaee923da5754578bdc",
	"a172.31.38.8": "SHA=aa5231a2b12a6511f97baf2313901bcc73bed4a2ac76d7d52201f128f2dd43f4",
	"kSHA=a624c8d1ee1edb763b5a901c5140fe96e9a495c1e3532aaee923da5754578bdc": "172.31.36.65",
	"kSHA=aa5231a2b12a6511f97baf2313901bcc73bed4a2ac76d7d52201f128f2dd43f4": "172.31.38.8",
	"qiSHA=a624c8d1ee1edb763b5a901c5140fe96e9a495c1e3532aaee923da5754578bdc": {"Q":{"dq":0.0000,"expect":0.0000,"q":0.0000,"var":0.0000},"acknowledged":true,"lastseen":1728899299},
	"qiSHA=aa5231a2b12a6511f97baf2313901bcc73bed4a2ac76d7d52201f128f2dd43f4": {"Q":{"dq":277.0000,"expect":181.8218,"q":289.0000,"var":30371.9887},"acknowledged":false,"lastseen":1728899721},
	"qoSHA=a624c8d1ee1edb763b5a901c5140fe96e9a495c1e3532aaee923da5754578bdc": {"Q":{"dq":60.0000,"expect":24.0000,"q":60.0000,"var":1440.0000},"acknowledged":false,"lastseen":1728899360},
	"qoSHA=aa5231a2b12a6511f97baf2313901bcc73bed4a2ac76d7d52201f128f2dd43f4": {"Q":{"dq":277.0000,"expect":182.2317,"q":289.0000,"var":30164.9899},"acknowledged":false,"lastseen":1728899721},
}

@larsewi larsewi removed the WIP Work in Progress label Oct 14, 2024
@larsewi larsewi changed the title WIP: ENT-11838: Fixed perpetual warnings that a deleted host has checked in ENT-11838: Fixed perpetual warnings that a deleted host has checked in Oct 14, 2024
Copy link
Contributor

@vpodzime vpodzime left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me otherwise. Good that we already an implementation for migration strategies 😁

libpromises/dbm_migration_lastseen.c Show resolved Hide resolved
libpromises/dbm_migration_lastseen.c Outdated Show resolved Hide resolved
libpromises/lastseen.c Show resolved Hide resolved
This field can be used to acknowledge an update to an incoming or
outgoing host entry in the lastseen DB. The field is set to `false` when
a key-value pair is updated. `cf-hub` may at any time acknowledge that
the update has been observed by setting the field to `true`.

Ticket: ENT-11838
Changelog: Title
Signed-off-by: Lars Erik Wik <[email protected]>
@larsewi larsewi force-pushed the lastseen branch 2 times, most recently from c323fd4 to 00aa149 Compare October 15, 2024 08:06
@larsewi larsewi marked this pull request as ready for review October 15, 2024 08:43
libpromises/lastseen.c Fixed Show fixed Hide fixed
libpromises/lastseen.c Fixed Show fixed Hide fixed
libpromises/lastseen.c Fixed Show fixed Hide fixed
libpromises/lastseen.c Fixed Show fixed Hide fixed
libpromises/lastseen.c Fixed Show fixed Hide fixed
libpromises/lastseen.c Fixed Show fixed Hide fixed
@larsewi larsewi force-pushed the lastseen branch 2 times, most recently from d979054 to 9d820d2 Compare October 15, 2024 11:02
Copy link
Contributor

@vpodzime vpodzime left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me otherwise.

libpromises/lastseen.c Show resolved Hide resolved
Added function to acknowledge the observation of a lastseen entry in DB.

Ticket: ENT-11838
Changelog: None
Signed-off-by: Lars Erik Wik <[email protected]>
Copy link
Contributor

@vpodzime vpodzime left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Copy link
Contributor

@craigcomstock craigcomstock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool.

if ((key[0] != 'k') && (key[0] != 'a'))
{
Log(LOG_LEVEL_WARNING,
"Found unexpected key '%s' during lastseen migration",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"Found unexpected key '%s' during lastseen migration",
"Found unexpected key '%s' during lastseen migration. Only expecting 'k' or 'a' prefixed keys.",


if (!WriteDB(db, "version", "2", sizeof("2")))
{
Log(LOG_LEVEL_ERR, "Failed to update version number durling lastseen migration");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Log(LOG_LEVEL_ERR, "Failed to update version number durling lastseen migration");
Log(LOG_LEVEL_ERR, "Failed to update version number during lastseen migration");

return false;
}

Log(LOG_LEVEL_INFO, "Migrated lastseen database from version 1 to 2");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With all the failure/return false cases above what state is the database left in?

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

Successfully merging this pull request may close these issues.

4 participants