Skip to content

Commit

Permalink
Make find_many_at_once private; explain ActiveState dependency.
Browse files Browse the repository at this point in the history
  • Loading branch information
mvidner committed Sep 6, 2017
1 parent 7496e63 commit 4989b1a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
8 changes: 7 additions & 1 deletion library/systemd/src/lib/yast2/systemd_unit.rb
Expand Up @@ -41,8 +41,14 @@ class SystemdUnit
#
# systemctl.c:check_unit_active uses (active, reloading)
# For bsc#884756 we also consider "activating" to be active.
#
# (The remaining states are "deactivating", "inactive", "failed".)
#
# Yes, depending on systemd states that are NOT covered by their
# interface stability promise is fragile.
# But: 10 to 50ms per call of systemctl is-active, times 100 to 300 services
# (depending on hardware and software installed, VM or not)
# is a 1 to 15 second delay (bsc#1045658).
# That is why we try hard to avoid many systemctl calls.
ACTIVE_STATES = ["active", "activating", "reloading"].freeze

# A Property Map is a plain Hash(Symbol => String).
Expand Down
9 changes: 6 additions & 3 deletions library/systemd/src/modules/systemd_service.rb
Expand Up @@ -91,9 +91,12 @@ def find!(service_name, propmap = {})

# @param service_names [Array<String>] "foo" or "foo.service"
# @param propmap [SystemdUnit::PropMap]
# @return [Array<Service,nil>] `nil` if not found, [] if no can do
# @raise [SystemdServiceNotFound] if an unexpected problem occurs
def find_many_at_once(service_names, propmap = {})
# @return [Array<Service,nil>] `nil` if a service is not found,
# [] if this helper cannot be used:
# either we're in the inst-sys without systemctl,
# or it has returned fewer services than requested
# (and we cannot match them up)
private def find_many_at_once(service_names, propmap = {})
return [] if Stage.initial

snames = service_names.map { |n| n + UNIT_SUFFIX unless n.end_with?(UNIT_SUFFIX) }
Expand Down

0 comments on commit 4989b1a

Please sign in to comment.