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

fleetd: support conflict in global unit #1571

Merged

Conversation

dongsupark
Copy link
Contributor

@dongsupark dongsupark commented Apr 27, 2016

Support Conflict flag in global units, by allowing Conflict in metadata format, as well as allowing agent reconciler to check if a global unit has conflicts.
This PR is based on #1270 that was originally written by @wuqixuan, On top of that, I also implemented a small fix in agent reconciler, as well as a new functional test TestScheduleGlobalConflicts.

Fixes: #1109
Supersedes: #1270

wuqixuan and others added 3 commits May 30, 2016 15:35
In global unit, support Conflict flag. So in
some machine, the unit will not be launched.

Fixes coreos#1109
In global unit, support Conflict flag. So in
some machine, the unit will not be launched.

Fixes coreos#1109
Commit "fleetd: support conflict in global unit" split out the loop in
desiredAgentState() into 2 loops, one for non-global units and the
other for global units. To follow the maintainer's suggestion, squash
the loops again into a single one.
@dongsupark dongsupark force-pushed the dongsu/fleetd-conflict-global-unit branch 2 times, most recently from 2329f29 to c2e360d Compare May 30, 2016 14:07
Introduce a new test TestScheduleGlobalConflicts, to cover the case of
global units that conflict with each other. Start 2 global units one
after another, and check if only the first one can be found.
@ewoutp
Copy link
Contributor

ewoutp commented Jun 30, 2016

I would really like this PR merged.
What is it waiting for?

@dongsupark
Copy link
Contributor Author

@ewoutp Code review by someone else would really help, just like other pending PRs.
And I actually haven't thought this had a high priority.

@ewoutp
Copy link
Contributor

ewoutp commented Jun 30, 2016

I need this for the following setup.

  • ServiceA (single instance)
  • ServiceB (single instance on same host as ServiceA) (this I can already do)
  • ServiceC (global on all hosts except the host of ServiceA) (this I need this PR for)

I'll test this PR here and let you know my findings.

@dongsupark dongsupark added this to the v1.0.0 milestone Jun 30, 2016
@@ -142,16 +142,25 @@ func desiredAgentState(a *Agent, reg registry.Registry) (*AgentState, error) {
for _, u := range units {
u := u
md := u.RequiredTargetMetadata()
if u.IsGlobal() && !machine.HasMetadata(&ms, md) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this change? It does not seem to make a difference.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ewoutp Exactly. It doesn't make any difference.
Why did it change? Short answer is, there's no particular reason.

Long answer is like that: @wuqixuan wrote the 1st patch ("fleetd: support conflict in global unit") by splitting the loop into 2 loops. However, @jonboulle suggested keeping a single loop. Unfortunately the original author @wuqixuan didn't respond, so I took it over, and wrote the 3rd patch ("agent: squash loops into a single one in desiredAgentState") to follow @jonboulle's suggestion. The patch effectively changed it back to a single loop, but code style in that particular part changed slightly. Thus now you see the difference in a unified diff view.

I suppose this difference is not critical for the entire functionality. But if you want me to change it again, sure, I can update the patch again.

Copy link
Contributor

@ewoutp ewoutp Jun 30, 2016

Choose a reason for hiding this comment

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

Got it, I would not make more changes on it.

@ewoutp
Copy link
Contributor

ewoutp commented Jun 30, 2016

Code LGTM.

I've tried to test it but this was inconclusive. Unit tests are all ok.
When testing this PR merged into master and running on my cluster (other fleet instances are v0.11.7) I got errors. They seem not to come from this PR because I get the same errors (etcd key already exists & nil-ptr panic) when testing master.

@dongsupark
Copy link
Contributor Author

@ewoutp Thanks for the review. I'll merge it tomorrow.
BTW the other error sounds interesting, but that should be handled in other issue, I think.

@ewoutp
Copy link
Contributor

ewoutp commented Jun 30, 2016

@dongsupark Great.

For the other issue, see #1622

@dongsupark dongsupark merged commit 91c1213 into coreos:master Jul 1, 2016
@dongsupark
Copy link
Contributor Author

Merged. Thanks.

dongsupark pushed a commit that referenced this pull request Jul 1, 2016
…unit

fleetd: support conflict in global unit
dongsupark pushed a commit that referenced this pull request Jul 1, 2016
…unit

fleetd: support conflict in global unit
dongsupark pushed a commit that referenced this pull request Jul 1, 2016
…unit

fleetd: support conflict in global unit
dongsupark pushed a commit that referenced this pull request Jul 1, 2016
…unit

fleetd: support conflict in global unit
@dongsupark dongsupark deleted the dongsu/fleetd-conflict-global-unit branch July 1, 2016 11:23
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.

Support Conflicts when Global=true
2 participants