-
Notifications
You must be signed in to change notification settings - Fork 299
fleetd: process dependencies in [Install] section #1523
Conversation
|
TODO:
|
7aaf1db to
4aec26f
Compare
systemd/manager.go
Outdated
| if err != nil { | ||
| return err | ||
| } | ||
| if u.HasReverseDependencies() { |
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 think the idea was to try always enabling units on load? This kind of special-casing seems fragile, unnecessary, and confusing...
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.
It is not posible to enable unit when it doesn't have Install section
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.
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.
What if this section is empty or it has invalid data?
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 tested this functionality and noticed few issues. Here is the input data: [Service]
ExecStart=/bin/bash -c "while true; do echo wants@%i.service unit file; sleep 1; done"[Unit]
Before=wants@%i.service
BindsTo=wants@%i.service
[Service]
ExecStart=/bin/bash -c "while true; do echo wanted@%i.service unit file; sleep 1; done"
[Install]
WantedBy=wants@%i.service
[X-Fleet]
MachineOf=wants@%i.serviceIssue 1 fleectl submit [email protected] [email protected]
fleetctl start [email protected]In this case fleetd doesn't process fleectl submit [email protected] [email protected]
fleetctl load [email protected]
fleetctl start [email protected]And here comes Issue 2: Within this situation fleetd doesn't monitor the fleetctl list-unit-files
UNIT HASH DSTATE STATE TARGET
[email protected] 2797f9a inactive inactive -
[email protected] 2797f9a loaded loaded 6ed03b01.../coreos1
[email protected] 038ee83 inactive inactive -
[email protected] 038ee83 launched launched 6ed03b01.../coreos1But systemd status is correct: systemctl status [email protected]
● [email protected]
Loaded: loaded (/run/fleet/units/[email protected]; enabled-runtime; vendor preset: disabled)
Active: active (running) since Wed 2016-03-30 16:52:54 UTC; 11min ago
Main PID: 17765 (bash)
CGroup: /system.slice/system-wanted.slice/[email protected]
├─17765 /bin/bash -c while true; do echo [email protected] unit file; sleep 1; done
└─19108 sleep 1
Mar 30 17:03:50 coreos1 bash[17765]: [email protected] unit file
Mar 30 17:03:51 coreos1 bash[17765]: [email protected] unit file
Mar 30 17:03:52 coreos1 bash[17765]: [email protected] unit file
Mar 30 17:03:53 coreos1 bash[17765]: [email protected] unit file
Mar 30 17:03:54 coreos1 bash[17765]: [email protected] unit file
Mar 30 17:03:55 coreos1 bash[17765]: [email protected] unit file
Mar 30 17:03:56 coreos1 bash[17765]: [email protected] unit file
Mar 30 17:03:57 coreos1 bash[17765]: [email protected] unit file
Mar 30 17:03:58 coreos1 bash[17765]: [email protected] unit file
Mar 30 17:03:59 coreos1 bash[17765]: [email protected] unit filesystemctl list-dependencies --reverse [email protected]
[email protected]
● └─[email protected]Should fleet monitor unit status on the systemd side? And what should it do when it will find that desired status doesn't correspond to the real state? Should fleetd change unit's state by itself (not by systemd)? The answer to the last question could be as follows: When Looks like this issue has lots pitfalls. UPD: some fleet specific options (dependencies) were already discussed in #464 |
|
@jonboulle comments? |
|
@kayrus I don't think your Issue 1 is actually a problem -- as far as I can see, it's perfectly in line with the conversation in #1382 . As for Issue 2... This does sound like a problem -- but isn't it just the same when using |
64ffe99 to
6753795
Compare
|
@joshix @robszumski could you review documentation part? |
| MachineOf=my.service | ||
| ``` | ||
|
|
||
| Fleet will load and automatically enable unit above because it contains `[Install]` section. Systemd will create a `my.service.wants/my_discovery.service` symlink to the `my_discovery.service` unit file. And when you start `my.service`, systemd will start `my_discovery.service` independently on `my_discovery.service` desired state defined in fleet. This situation may casue confusion between `fleetctl list-units` and `systemd list-units` outputs. It is recommended to use `fleetctl status my_discovery.service` to get real unit status (`fleetctl status` just passes arguments to `systemctl status` command). |
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.
Can you elaborate on "this may cause confusion between fleetctl list-units and systemctl list-units"?
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.
It worries me and I'm starting to wonder if this is a bad idea.
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 think we need to specifically define what "enable" means for the user, ie. starts on boot
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.
It doesn't suite fleet behavior. Because fleet stores unit files inside tmpfs and they will not be booted automatically using only systemd routines.
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.
@jonboulle I agree that this is a problem -- but AIUI it's actually not a new problem: according to the discussion in #1382 , systemd was already handling dependencies expressed by "Wants" relationships even without enabling; it's just "WantedBy" that changes... So unless I'm missing something, enabling units doesn't fundamentally change the situation -- it only makes it manifest in another case. (Which was somewhat inconsistent before.)
AIUI, the issue should be mostly mitigated once fleet implements dependencies such as X-Requires etc. -- though I guess it might be worthwhile to look into the inconsistency problem regardless. But I really think this is a separate issue.
0d4e50e to
8ee465e
Compare
|
Updated tests. Now semaphoreci works. |
functional/install_test.go
Outdated
|
|
||
| // Verify that discovery.service unit is stopped | ||
| timeout, err := util.WaitForState( | ||
| func() bool { return checkInactiveState() }, |
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.
No need to wrap it in closure like that -- you can just pass checkInactiveState directly.
1e4142b to
291afb0
Compare
|
|
||
| ## Definition of the Install Section | ||
|
|
||
| Unit files which have `[Install]` section will be automatically enabled by fleet. This means that states of such unit files may not be tracked by fleet. For example you have loaded `my.service` unit file: |
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.
s/which have/which have an/
s/states/the states/
s/may not/cannot/
"For example, assume we have loaded this my.service unit file:"
291afb0 to
b8bab3f
Compare
| ExecStart=/bin/bash -c "while true; do echo my.service unit file; sleep 1; done" | ||
| ``` | ||
|
|
||
| and then loaded additional [sidekick][sidekick] discovery unit `my_discovery.service`: |
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.
s/additional/an additional/
b8bab3f to
427913c
Compare
|
docs LGTM for purpose |
functional/install_test.go
Outdated
| if stdout, stderr, err := cluster.Fleetctl(m0, "--strict-host-key-checking=false", "ssh", machine, "uptime"); err != nil { | ||
| t.Fatalf("Unable to SSH into fleet machine: \nstdout: %s\nstderr: %s\nerr: %v", stdout, stderr, err) | ||
| } | ||
| } |
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.
Why do you need to check this here? We have separate tests for this?...
functional/install_test.go
Outdated
| return true | ||
| } else { | ||
| return false | ||
| } |
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.
You don't need an if here: the comparison already produces a bool...
427913c to
1d563e5
Compare
|
@antrik updated. |
1d563e5 to
ccfe955
Compare
|
Looks good to me now :-) |
|
Punting this to the next milestone as @kayrus thinks it should be reconsidered (?) but is afk |
14580b0 to
63b20dc
Compare
23d4b13 to
6fb1256
Compare
54409ab to
a1a21b8
Compare
|
This PR looks good to me. Besides I had to think about a couple of open questions:
So I think I'll merge this one, probably some time in August. |
|
Closed via #1655 |
resolves #1382