-
Notifications
You must be signed in to change notification settings - Fork 18
Use a more portable version of listUnits #44
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just let me know your thoughts on my comment, it might not make sense. I'm curious, but I'll approve after.
@@ -46,3 +47,30 @@ func StopUnit(d *dbus.Conn, unitName string) error { | |||
glog.Infof("Stopping systemd unit: %s ...", unitName) | |||
return executeSystemdAction(unitName, d.StopUnit) | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exported method needs a comment
pkg/util/systemd_action.go
Outdated
return nil, err | ||
} | ||
intersect := make(map[string]dbus.UnitStatus) | ||
for _, elt := range allUnits { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to check the jobID of a unit collected and make sure you are not adding the same unit with a different name several times. Because "units may be known by multiple names at the same time, and hence there might be more unit names loaded than actual units behind them." (From the doc)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this safety to the current code path.
I'm not sure where we could have this issue but it's easy to catch this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What does this PR do?
The method
ListUnitsByNames
only supports a systemd >= 230.See coreos/go-systemd#223
I used the generic ListUnits and @xvello tested it on systemd 229 👍
I also added the systemd prefix to the units in the manifests:
Because the link in
/run/systemd/system/p8s-kubelet.service
->~/sandbox/manifest-systemd-unit/kubelet.service
Give an unit name
kubelet.service
instead ofp8s-kubelet.service