Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

fleetctl: check also systemd states after starting units #1566

Merged

Conversation

dongsupark
Copy link
Contributor

To resolve inconsistency between "systemctl start" and "fleetctl start", fleetctl needs to check systemd states after starting units. If the systemd state is not a desired one, wait until it gets an active state.

Fixes: #1025

@dongsupark dongsupark force-pushed the dongsu/fleetctl-start-systemd-state branch 5 times, most recently from 5496f06 to ef054cf Compare April 26, 2016 08:57
@dongsupark
Copy link
Contributor Author

Updated. (after several hiccups)

  • Handle return value of tryWaitForSystemdActiveState carefully. It should not return 1 only because of a missing systemd dbus connection. Otherwise it will break unit tests based on Travis, as that environment cannot correctly set up a systemd dbus connection.
  • Added a missing nil checking before conn.Close(). Also call conn.Close() after checking for nil.
  • Wrote comments etc.

Dongsu Park added 2 commits May 30, 2016 13:32
To resolve inconsistency between systemctl start and fleetctl start, fleetctl
needs to check systemd states after starting units. If the systemd state is
not a desired one, wait until it gets an active state.

Fixes: coreos#1025
To cover the case of a new change for making sure that started units
have active systemd states, CheckListUnits should also check the systemd
unit state, after having started each unit.
@dongsupark dongsupark force-pushed the dongsu/fleetctl-start-systemd-state branch from 6efb318 to 453e70a Compare May 30, 2016 11:38
@dongsupark dongsupark force-pushed the master branch 2 times, most recently from 14580b0 to 63b20dc Compare June 22, 2016 10:22
@dongsupark dongsupark force-pushed the master branch 3 times, most recently from 23d4b13 to 6fb1256 Compare July 1, 2016 11:07
@dongsupark dongsupark force-pushed the master branch 2 times, most recently from 54409ab to a1a21b8 Compare July 8, 2016 11:38
@dongsupark
Copy link
Contributor Author

I'm going to merge it soon, unless anyone has other opinions.

@dongsupark dongsupark merged commit 3f9e402 into coreos:master Jul 22, 2016
@dongsupark dongsupark deleted the dongsu/fleetctl-start-systemd-state branch July 22, 2016 09:52
dongsupark pushed a commit that referenced this pull request Jul 22, 2016
…state

fleetctl: check also systemd states after starting units
// it just means that the unit test environment based on Travis is not capable
// of setting up a DBUS connection of systemd, which would actually work fine
// for production systems or functional tests.
func tryWaitForSystemdActiveState(units []string) (ret int) {
Copy link
Contributor

Choose a reason for hiding this comment

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

imho the ret value is pretty unidiomatic; rather, return an error, and have the callers decide to log the error or not

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. I'll try to make it return an error.

}

if found {
err = nil
Copy link
Contributor

Choose a reason for hiding this comment

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

unnecessary

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct. I'll just remove err = nil.

@jonboulle
Copy link
Contributor

I think this is wrong; it's checking against a local systemd instance over dbus, but that will ONLY be right if fleetctl happens to be invoked on the same system on which the units are scheduled, right? Surely we need to check against the API, as we do with the other states?

@dongsupark
Copy link
Contributor Author

@jonboulle Ok. I'll try to take a different approach as you suggested. From my understanding, schema.UnitState has already its own fields like SystemdActiveState, SystemdLoadState, and SystemdSubState. So we should make use of cAPI.UnitStates() to retrieve these states, to make sure that these are the expected states. Is that correct?

@jonboulle
Copy link
Contributor

Yep, that sounds about right!

On 19 August 2016 at 10:28, Dongsu Park notifications@github.com wrote:

@jonboulle https://github.com/jonboulle Ok. I'll try to take a
different approach as you suggested. From my understanding,
schema.UnitState has already its own fields like SystemdActiveState,
SystemdLoadState, and SystemdSubState. So we should make use of
cAPI.UnitStates() to retrieve these states, to make sure that these are
the expected states. Is that correct?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#1566 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/ACewN-tGx7Yv86yZzL7X0TJt8xhP4t9Uks5qhWkrgaJpZM4IPDSK
.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fleetctl start != systemctl start
2 participants