#Service DAGs / diamonds and duplication

1 messages ยท Page 1 of 1 (latest)

austere vale
#

Another issue I suspect is myself holding Dagger wrong...

I have 4 services in the Diamond Dependency pattern through Service binding

  A
 / \
B   C
 \ /
  D

When I run D, with B & C bound, I get 2xA

  • Is this expected even when passing the same pointer to bind in A->B&C
  • Do I need to use up with hostname instead of bind twice so they share? Does this mean I lose the automatic dependency inference?
  • Is there some way to have both bring up when needed and sharing?
austere vale
#

Tried to make a minimal repro and it worked as expected, so progress I suppose

austere vale
#

ok, finally figured this out

If I do not set the frontend port on a service, it gets duplicated by Dagger when binding.

This seems unintuitive, because I thought that was for exposing, and that it ought to be deduplicated anyhow because it is the same pointer being passed to two BindService steps

#

Is this possibly a bug or other limitation?

austere vale
#

Ok, I think I found the bug

  1. Define services in a DAG like above, give them all the same backend/frontend port
  2. Bind them all up as above
  3. Expose one or more services

Any non-exposed services that have the same frontend port as the exposed port are duplicated. I think this is what I'm seeing

austere vale
#

ok, at this point, it seems flakey, like a cache miss or something. I get different sets of copies running without code changes

attached an example with 2 /relay running, sometimes it's the PLC, sometimes both, sometimes neither. I can count the duplication by the number of postgres running. There should be only 2, but I see 2-4

austere vale
#

omg... it's always non-deterministic map iteration

wicked mesa
#

hmmm. strange ๐Ÿค”

wicked mesa
#

@austere vale this seem to work for me without setting any frontend ports.

func (m *Svctest) Test() *dagger.Container {
    a := dag.Container().From("nginx").WithExposedPort(80).AsService()

    b := dag.Container().From("nginx").
        WithServiceBinding("a", a).
        WithExec([]string{"curl", "a:80"}).
        WithExposedPort(80).
        AsService()
    c := dag.Container().From("nginx").
        WithServiceBinding("a", a).
        WithExec([]string{"curl", "a:80"}).
        WithExposedPort(80).
        AsService()

    return dag.Container().From("alpine").WithServiceBinding("b", b).WithServiceBinding("c", c).
        WithExec([]string{"apk", "add", "curl"}).
        WithEnvVariable("CACHE", time.Now().String()).
        WithExec([]string{"curl", "b:80"}).
        WithExec([]string{"curl", "c:80"})
}

and then I can call dagger call test up --ports 8080:80 and that works without issues

wicked mesa
#

ok, just saw this. Is this working as expected then?

austere vale
modest ivy
#

FYI @gritty depot for visibility ๐Ÿ‘†

austere vale
#

this would be great to call out in the docs as a gotchya for caching or similar

wicked mesa
wicked mesa
modest ivy
#

No specific action (since there's no bug it looks like)

gritty depot
#

so was the issue something like out-of-order withServiceBindings resulting in two different services because they're keyed on how they're constructed?

austere vale