Skip to content
This repository has been archived by the owner on Jun 13, 2023. It is now read-only.

Use a more portable version of listUnits #44

Merged
merged 2 commits into from
Jun 11, 2018

Conversation

JulienBalestra
Copy link
Collaborator

@JulienBalestra JulienBalestra commented Jun 8, 2018

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:

sandbox/manifest-systemd-unit/p8s-etcd.service
sandbox/manifest-systemd-unit/p8s-kube-apiserver.service
sandbox/manifest-systemd-unit/p8s-kubelet.service

Because the link in /run/systemd/system/p8s-kubelet.service -> ~/sandbox/manifest-systemd-unit/kubelet.service

Give an unit name kubelet.service instead of p8s-kubelet.service

@JulienBalestra JulienBalestra added the bug Something isn't working label Jun 8, 2018
@JulienBalestra JulienBalestra requested a review from a team June 8, 2018 16:09
@JulienBalestra JulienBalestra added this to the v0.3.1 milestone Jun 8, 2018
Copy link
Contributor

@CharlyF CharlyF left a 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)
}

Copy link
Contributor

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

return nil, err
}
intersect := make(map[string]dbus.UnitStatus)
for _, elt := range allUnits {
Copy link
Contributor

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)

Copy link
Collaborator Author

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.

Copy link
Contributor

@CharlyF CharlyF left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@JulienBalestra JulienBalestra merged commit c61ec84 into master Jun 11, 2018
@JulienBalestra JulienBalestra deleted the JulienBalestra/fix-list-units branch June 11, 2018 11:56
@JulienBalestra JulienBalestra modified the milestones: v0.3.1, v0.4.0 Jun 11, 2018
@JulienBalestra JulienBalestra mentioned this pull request Jun 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants