Synchronous Actions

Posted by Dan Krasinski-Oracle on Oracle Blogs See other posts from Oracle Blogs or by Dan Krasinski-Oracle
Published on Fri, 15 Aug 2014 16:10:12 +0000 Indexed on 2014/08/18 16:36 UTC
Read the original article Hit count: 314

Filed under:

Since the introduction of SMF, svcadm(1M) has had the ability to enable or disable a service instance and wait for that service instance to reach a final state.  With Oracle Solaris 11.2, we’ve expanded the set of administrative actions which can be invoked synchronously. Now all subcommands of svcadm(1M) have synchronous behavior. Let’s take a look at the new usage:


Usage: svcadm [-v] [cmd [args ... ]]


svcadm enable [-rt] [-s [-T timeout]] <service> ...

enable and online service(s)

svcadm disable [-t] [-s [-T timeout]] <service> ...

disable and offline service(s)

svcadm restart [-s [-T timeout]] <service> ...

restart specified service(s)

svcadm refresh [-s [-T timeout]] <service> ...

re-read service configuration

svcadm mark [-It] [-s [-T timeout]] <state> <service> ...

set maintenance state

svcadm clear [-s [-T timeout]] <service> ...

clear maintenance state

svcadm milestone [-d] [-s [-T timeout]] <milestone>

advance to a service milestone

svcadm delegate [-s] <restarter> <svc> ...

delegate service to a restarter



As you can see, each subcommand now has a ‘-s’ flag. That flag tells svcadm(1M) to wait for the subcommand to complete before returning. For enables, that means waiting until the instance is either ‘online’ or in the ‘maintenance’ state. For disable, the instance must reach the ‘disabled’ state. Other subcommands complete when:


restart


A restart is considered complete once the instance has gone offline after running the ‘stop’ method, and then has either returned to the ‘online’ state or has entered the ‘maintenance’ state.


refresh


If an instance is in the ‘online’ state, a refresh is considered complete once the ‘refresh’ method for the instance has finished.


mark maintenance


Marking an instance for maintenance completes when the instance has reached the ‘maintenance’ state.


mark degraded


Marking an instance as degraded completes when the instance has reached the ‘degraded’ state from the ‘online’ state.


milestone


A milestone transition can occur in one of two directions. Either the transition moves from a lower milestone to a higher one, or from a higher one to a lower one. When moving to a higher milestone, the transition is considered complete when the instance representing that milestone reaches the ‘online’ state. The transition to a lower milestone, on the other hand, completes only when all instances which are part of higher milestones have reached the ‘disabled’ state.


That’s not the whole story. svcadm(1M) will also try to determine if the actions initiated by a particular subcommand cannot complete. Trying to enable an instance which does not have its dependencies satisfied, for example, will cause svcadm(1M) to terminate before that instance reaches the ‘online’ state.


You’ll also notice the optional ‘-T’ flag which can be used in conjunction with the ‘-s’ flag. This flag sets a timeout, in seconds, after which svcadm gives up on waiting for the subcommand to complete and terminates. This is useful in many cases, but in particular when the start method for an instance has an infinite timeout but might get stuck waiting for some resource that may never become available.


For the C-oriented, each of these administrative actions has a corresponding function in libscf(3SCF), with names like smf_enable_instance_synchronous(3SCF) and smf_restart_instance_synchronous(3SCF).  Take a look at smf_enable_instance_synchronous(3SCF) for details.

© Oracle Blogs or respective owner

Related posts about /Oracle