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

Question: modification time for /usr and /etc #1415

Closed
peterbaouoft opened this issue Jun 15, 2018 · 6 comments
Closed

Question: modification time for /usr and /etc #1415

peterbaouoft opened this issue Jun 15, 2018 · 6 comments

Comments

@peterbaouoft
Copy link
Contributor

Hi,
It seems like for /usr on Atomic host, the modification time is canonicalized to epoch (1970), and this makes /usr always older than /etc.

However, to have system-sysusers to trigger automatically during boot time, /usr needs to be newer than /etc due to ConditionNeedsUpdate=/etc in the service file:

[rbao@unused-10-15-17-147 ~]$ cat /usr/lib/systemd/system/systemd-sysusers.service 
[Unit]
Description=Create System Users
Documentation=man:sysusers.d(5) man:systemd-sysusers.service(8)
DefaultDependencies=no
Conflicts=shutdown.target
After=systemd-remount-fs.service
Before=sysinit.target shutdown.target systemd-update-done.service
ConditionNeedsUpdate=/etc

 ................................................

Reading a bit from systemd code base, it seems like ConditionNeedsUpdate needs /usr to be strictly newer (i.e only > and not >=). See code and documentation. So I think canonicalize /etc to 1970 unfortunately would not be an option.

Any suggestions for changing modification time of /usr to be newer than /etc/ for systemd-sysusers to trigger? Or, we can have a conditional during rebase/deploy transactions that manually calls systemd-sysusers command if that also works... Thanks for your time =D.

NOTE: Related to #1376

@cgwalters
Copy link
Member

Yeah, ConditionNeedsUpdate was designed for a dual-partition system, I'm not sure it was ever made to work for either classic or ostree systems. Perhaps the simplest is to have ostree write out /etc/.updated in the new deployment if it's built with systemd support.

@cgwalters
Copy link
Member

To rephrase, this is ConditionNeedsUpdate not being compatible with OSTree. And now that I look it's based on timestamps of /etc/.updated and /usr/.updated, not timestamps of the directories. Hmm. So what we could do is teach ostree to write out /usr/.updated with the current timestamp (non-epoch), and then things should work?

@peterbaouoft
Copy link
Contributor Author

peterbaouoft commented Jun 15, 2018

And now that I look it's based on timestamps of /etc/.updated and /usr/.updated

Thanks for the response =D. For this part (/usr/.updated section), which part of the codebase were you looking at? I might miss the part for /usr/.updated section.. Were we looking at the same thing?

I was reading https://github.com/systemd/systemd/blob/master/src/shared/condition.c#L440-L447

if (lstat("/usr/", &usr) < 0)
                return true;

        /*
         * First, compare seconds as they are always accurate...
         */
if (usr.st_mtim.tv_sec != other.st_mtim.tv_sec)
        return usr.st_mtim.tv_sec > other.st_mtim.tv_sec;

@cgwalters
Copy link
Member

You're right. OK if you don't mind let's refile this against ostree and discuss details there? I think Endless did some work here in the past...ah yep I found this endlessm/ostree@9ef61fd

@peterbaouoft
Copy link
Contributor Author

You're right. OK if you don't mind let's refile this against ostree and discuss details there?

Sure :D.

ah yep I found this endlessm/ostree@9ef61fd

\o/

@peterbaouoft
Copy link
Contributor Author

Close this in favor of ostreedev/ostree#1628

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

2 participants