A routed name resolves to the node whose proxy serves it, never to a provider merely told it (hq 178)
The names region attributed a composed name to whichever labelled contribution a map yielded last. A dashboard contributes its label to its route and to the identity provider, which must know the public name for a redirect; so on one plan grafana.<domain> pointed at the proxy's machine and on the next at the identity provider's, and the whole region flipped with it (forge issue 227). And a module routed several times contributed no name at all, because the single-value reading of its contributions is empty for the many shape. Now every node's resolution is read first and the names are attributed across them at once: the terminus serves the name — the provider that is not itself published under a labelled name through another — walked in order, so one mesh yields one region. Name-agnostic, structural, deterministic.
This commit is contained in:
+16
-34
@@ -731,9 +731,13 @@ func routeNamesInTheMesh(ctx context.Context, open *stores) (map[string]string,
|
||||
return nil, fmt.Errorf("which machines the mesh has cannot be read: %w", err)
|
||||
}
|
||||
|
||||
out := map[string]string{}
|
||||
// Every machine's resolution first, then the names across them at once: which node serves a
|
||||
// name is a question about the graph — the consumer on one machine, the provider on another —
|
||||
// and answered wrongly by looking at one contribution at a time (novox/hq issue 178).
|
||||
plans := map[string]catalogue.Resolution{}
|
||||
settings := map[string]catalogue.SettingsBy{}
|
||||
for _, n := range nodes {
|
||||
plan, settings, err := planFor(ctx, open, n.Name)
|
||||
plan, layers, err := planFor(ctx, open, n.Name)
|
||||
switch {
|
||||
case unresolvable(err):
|
||||
// Their set does not compose, so they serve no names. Passed over, so one machine's
|
||||
@@ -745,38 +749,16 @@ func routeNamesInTheMesh(ctx context.Context, open *stores) (map[string]string,
|
||||
// operator having withdrawn them (novox/hq 04-ISSUES/152).
|
||||
return nil, fmt.Errorf("the names %s serves cannot be read: %w", n.Name, err)
|
||||
}
|
||||
for _, m := range plan.Modules {
|
||||
for to := range m.Contributes {
|
||||
values, asks, err := plan.ContributionsFrom(to, m.Module, settings)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !asks {
|
||||
continue
|
||||
}
|
||||
// A routed name, and only that: a contribution the mesh composed a name for from a
|
||||
// label it was given. A grant that happens to carry a `name` of its own — a database
|
||||
// name — carries no label and is left alone.
|
||||
if _, labelled := values["label"]; !labelled {
|
||||
continue
|
||||
}
|
||||
name, _ := values["name"].(string)
|
||||
if name == "" {
|
||||
continue
|
||||
}
|
||||
// The node that serves it: whoever answers this consumer's route requirement, or
|
||||
// this same node when the proxy is beside the consumer.
|
||||
serving := n.Name
|
||||
for _, need := range plan.Needs {
|
||||
if need.Name == to && need.For == m.Module {
|
||||
serving = need.From
|
||||
break
|
||||
}
|
||||
}
|
||||
if at := address[serving]; at != "" {
|
||||
out[strings.ToLower(name)] = at
|
||||
}
|
||||
}
|
||||
plans[n.Name], settings[n.Name] = plan, layers
|
||||
}
|
||||
served, err := catalogue.NamesServed(plans, settings)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out := map[string]string{}
|
||||
for name, node := range served {
|
||||
if at := address[node]; at != "" {
|
||||
out[name] = at
|
||||
}
|
||||
}
|
||||
return out, nil
|
||||
|
||||
Reference in New Issue
Block a user