Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 291894 - sys-apps/openrc-0.5.2-r1 - new swclock init script executed at boot time even if not in any runlevel
Summary: sys-apps/openrc-0.5.2-r1 - new swclock init script executed at boot time even...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] baselayout (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 293139 293126
  Show dependency tree
 
Reported: 2009-11-04 19:09 UTC by Daniel Pielmeier
Modified: 2009-11-14 06:54 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
openrc log file (rc.log,358 bytes, text/plain)
2009-11-04 19:10 UTC, Daniel Pielmeier
Details
rc-status --all (rc-status_a,3.58 KB, text/plain)
2009-11-04 19:11 UTC, Daniel Pielmeier
Details
rc-status --servicelist (rc-status_s,5.62 KB, text/plain)
2009-11-04 19:11 UTC, Daniel Pielmeier
Details
openrc-migration.diff (openrc-migration.diff,897 bytes, text/plain)
2009-11-11 22:39 UTC, Daniel Pielmeier
Details
openrc-migration.diff (openrc-migration.diff,925 bytes, text/plain)
2009-11-12 00:16 UTC, William Hubbs
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Pielmeier gentoo-dev 2009-11-04 19:09:39 UTC
I always get the following errors at boot time:
swclock: `/lib/rc/init.d/shutdowntime': No such file or directory

swclock is not activated but it looks like openrc tries to run the init script in any case, this fails because /lib/rc/init.d/shutdowntime is missing.
Comment 1 Daniel Pielmeier gentoo-dev 2009-11-04 19:10:04 UTC
Created attachment 209254 [details]
openrc log file
Comment 2 Daniel Pielmeier gentoo-dev 2009-11-04 19:11:05 UTC
Created attachment 209259 [details]
rc-status --all
Comment 3 Daniel Pielmeier gentoo-dev 2009-11-04 19:11:43 UTC
Created attachment 209260 [details]
rc-status --servicelist
Comment 4 Michael Park 2009-11-10 09:00:06 UTC
I get the same thing with openrc-0.5.2-r2. rc-update shows that swclock is not defined for any runlevel, yet openrc-0.5.2-r2 wants to run it and wants to run a non-existant /etc/init.d/shutdowntime file. Also, rc-update delete hwclock [runlevel] has no effect, openrc still wants to run hwclock. even though I specified that it should run at shutdown, but openrc won't even run it at shutdown too. 
Comment 5 Roy Marples 2009-11-10 20:54:39 UTC
Try adding hwclock to the boot runlevel.
Comment 6 Nick White 2009-11-11 01:28:07 UTC
I ran into this too, with 0.5.2-r2. Adding swclock to the boot runlevel suprisingly didn't fix things for me (even after several experimental shutdown/startup runthroughs), but after manually restarting it with rc-config restart swclock things have gone swimmingly.
Comment 7 Daniel Pielmeier gentoo-dev 2009-11-11 08:58:26 UTC
(In reply to comment #5)
> Try adding hwclock to the boot runlevel.

Setting hwclock to the boot reunlevel fixed it.
Comment 8 William Hubbs gentoo-dev 2009-11-11 15:39:59 UTC
I am closing this since it looks like it has been resolved.  Please re-open
if this is still an issue.
Comment 9 SpanKY gentoo-dev 2009-11-11 16:31:35 UTC
i dont think so.  the swclock init.d shouldnt have been stopped if it wasnt started, and ignoring that, there shouldnt have been an error in the first place.
Comment 10 Roy Marples 2009-11-11 20:54:36 UTC
(In reply to comment #9)
> i dont think so.  the swclock init.d shouldnt have been stopped if it wasnt
> started

No-one said that.

> and ignoring that, there shouldnt have been an error in the first
> place.

There isn't with the default config.

The reporter has removed hwclock from the boot runlevel and one of his scripts "needs clock". As there are now two scripts that provide clock (hwclock and swclock), OpenRC doesn't know which one to start, so it starts them both. swclock correctly errors as the required file does not exist.
Comment 11 SpanKY gentoo-dev 2009-11-11 21:47:05 UTC
the log file shows that 'hwclock' was started implicitly via 'needs clock'.  which init.d that is exactly is unknown, but it should get fixed.
Daniel: can you run `grep -r 'need.*clock' /etc/init.d/` and post the output ?

i dont think the logic of "no preference selected means start *all* providers" makes any sense, but ignoring that, an implicitly starrted swclock should not result in an error during shutdown.  i dont see any explanation here as to why the error is being observed.
Comment 12 William Hubbs gentoo-dev 2009-11-11 21:52:02 UTC
In response to comment #6:

swclock was added for bug #272073 to support systems that do not have a
working real-time clock.
If your system's hardware clock works, you should be using hwclock, not
swclock.  Please make sure that you have the correct script added to
your boot runlevel.

In response to comment #9:

The issue reported initially was because the reporter did not have a
clock script in his boot runlevel.  See comment #5 and the
attachment in comment #2 for this.

This is a documented step  in the openrc migration guide, just below
code listing 2.11.  Once the reporter followed Roy's suggestion in
comment #5, he said the issue was fixed (comment #7).

When a clock script is added to the boot runlevel, things work as
expected.  That is why I closed this bug.

This does generate a question about dependencies.  I don't know if this
belongs on this bug or if we should open another one, but here is the
issue this bug illustrates.

hwclock and swclock both provide clock and are both installed.  If
neither service is added to any runlevel but something needs clock, what
should openrc do?

Comment 13 Daniel Pielmeier gentoo-dev 2009-11-11 22:04:19 UTC
(In reply to comment #12)

> In response to comment #9:
> 
> The issue reported initially was because the reporter did not have a
> clock script in his boot runlevel.  See comment #5 and the
> attachment in comment #2 for this.

The Clock section from the openrc migration guide states:
The initscript in /etc/init.d/ has also been renamed accordingly, so make sure it's in the appropriate runlevel.


So the guide needs an update in this section and should inform about the two different clock init scripts. Also it should advise the user to add the choosen init script to the boot runlevel instead of the "appropiate".


> This is a documented step  in the openrc migration guide, just below
> code listing 2.11.  Once the reporter followed Roy's suggestion in
> comment #5, he said the issue was fixed (comment #7).
> 
> When a clock script is added to the boot runlevel, things work as
> expected.  That is why I closed this bug.
Comment 14 Daniel Pielmeier gentoo-dev 2009-11-11 22:39:15 UTC
Created attachment 209963 [details]
openrc-migration.diff

Attached is a small patch for the openrc migration guide. I can open a documentation bug if it is okay. Thoughts? Recommendations?
Comment 15 William Hubbs gentoo-dev 2009-11-12 00:16:06 UTC
Created attachment 209972 [details]
openrc-migration.diff

A slight wording change for the patch.

Billy, let me know what you think about this.
Comment 16 Daniel Pielmeier gentoo-dev 2009-11-12 08:26:31 UTC
(In reply to comment #15)
> Created an attachment (id=209972) [details]
> openrc-migration.diff
> A slight wording change for the patch.
> Billy, let me know what you think about this.

I am fine with the changes, looks a bit clearer now.

This is now bug #292886, so add further improvements there.
Comment 17 William Hubbs gentoo-dev 2009-11-12 22:06:38 UTC
The documentation is up to date.

Pybugz wouldn't close for some reason, so I am trying again with the web interface.
Comment 18 SpanKY gentoo-dev 2009-11-13 03:52:23 UTC
summarizing the bug and updating documentation still doesnt address any of my questions in comment #11
Comment 19 Roy Marples 2009-11-13 09:01:16 UTC
(In reply to comment #11)
> i dont think the logic of "no preference selected means start *all* providers"
> makes any sense

So open a bug about changing it then.

> but ignoring that, an implicitly starrted swclock should not
> result in an error during shutdown.  i dont see any explanation here as to why
> the error is being observed.

Re-read the above - no-one said this happened. I think you're mis-reading it as the file referenced has the word shutdown in it.
Comment 20 SpanKY gentoo-dev 2009-11-13 15:22:23 UTC
shutdown or boot, there is still no explanation/fix for why an error was observed.  if swclock is started for the first time, it shouldnt throw up on a missing file.  this is the most common code path:
 - user upgrades to new openrc
 - user wants to use swclock
 - user removes all clock provides
 - user adds swclock
 - user reboots
 - swclock is not stopped because it was never started
 - user sees error during boot
 - user files bug report
Comment 21 Nick White 2009-11-13 15:50:15 UTC
To clarify, my path was:

- removed hwclock from boot runlevel before switching to openrc (due to ignorance)
- switched to openrc 0.4.8
- updated to openrc 0.5.2-r2
- rebooted
- got the error at bootup: swclock: `/lib/rc/init.d/shutdowntime': No such file or directory
- swclock stop was never triggered on shutdown, so the error appeared each bootup
- manually restarting swclock created /lib/rc/init.d/shutdowntime, and from then on things worked

(from this I learned that I really should be using hwclock anyway, which I've now switched to).
Comment 22 William Hubbs gentoo-dev 2009-11-13 18:40:29 UTC
The only issue remaining is that swclock fails to start if it hasn't
ever been stopped.  /lib/rc/init.d/shutdowntime doesn't exist in this
situation, and that is what causes swclock to fail to start.

This can be verified by running rc-service swclock start on a system
that doesn't use swclock.

Should this generate a failure or should swclock go ahead and start
successfully?  If it doesn't start successfully, should we update the
documentation and tell users to run rc-service swclock stop before they
reboot if they are using swclock?

Comment 24 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2009-11-13 21:37:00 UTC
As a secondary item to this, it would be nice to have a way to flag a init script as not to be chosen automatically as a provider, and require that it be explicitly configured instead.
Comment 25 Roy Marples 2009-11-13 22:31:09 UTC
Just remove the provide directive from the init script?
Comment 26 SpanKY gentoo-dev 2009-11-13 22:32:12 UTC
thanks Roy, that should do it.  i'll address the providers in a diff bug.

Daniel: can you please run the grep i posted in comment #11 ?
Comment 27 Roy Marples 2009-11-13 22:36:09 UTC
(In reply to comment #26)
> thanks Roy, that should do it.

http://roy.marples.name/projects/openrc/changeset/0de1d18d41950dc36a0c38ff5bf0ef0fc5c73801

I tested this time :)
Comment 28 Daniel Pielmeier gentoo-dev 2009-11-13 22:48:00 UTC
(In reply to comment #26)
> thanks Roy, that should do it.  i'll address the providers in a diff bug.
> 
> Daniel: can you please run the grep i posted in comment #11 ?
> 

Sorry Mike, I somehow missed this. Here is the output of the grep as requested:

grep -r 'need.*clock' /etc/init.d/
/etc/init.d/syslog-ng:	need clock hostname localmount
Comment 29 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2009-11-14 00:29:51 UTC
roy:
Nope, you're not quite getting me.

Taking out the provide from swclock makes hwclock always start :-(.

If there is no {sw,hw}clock in the runlevels, then I want only hwclock to be considered. If I manually add swclock, then hwclock should not be brought in.

Alternatively, weights for providers, so we can deterministically say which one will be picked when none are explictly configured.
Comment 30 William Hubbs gentoo-dev 2009-11-14 02:47:37 UTC
(In reply to comment #29)
> roy:
> Nope, you're not quite getting me.
> Taking out the provide from swclock makes hwclock always start :-(.

This is how it should work since after you remove the provide from swclock hwclock is the only provider for clock.

> If there is no {sw,hw}clock in the runlevels, then I want only hwclock to be
> considered. If I manually add swclock, then hwclock should not be brought in.

The second part of this statement is how things work as they  stand.  If you remove hwclock from your run levels and add swclock, swclock will be run and hwclock will not.

> Alternatively, weights for providers, so we can deterministically say which one
> will be picked when none are explictly configured.

Hmm,do we really want openrc to try to figure out which service to run if there are multiple providers, or should we require that one be configured?

My vote would go toward requiring one to be configured.  In the case we are talking about, hwclock and swclock should not both be run on the same system anyway.
Comment 31 SpanKY gentoo-dev 2009-11-14 02:55:51 UTC
the swclock error has been fixed, and the remaining issues have been split
Comment 32 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2009-11-14 06:54:13 UTC
I'm fine with requiring that one be configured, but then we must throw large warnings if the user has none configured. This should be as a general concept, not hardcoded for {hw,sw}clock.