Skip to content

Restrict Service : Archetype to be 1:1 #63

Closed

Description

@evankanderson

Per UX review ( @steren @qelo ):

The API allows an N:N relation between Services and {Archetypes, Revisions}. This can be confusing to users and can be difficult to represent in user interfaces. Broken down:

N-1:

  • one Archetype can be used by multiple services,
  • a Revision can be referenced by multiple services.

Why is this a problem for the UI? The desire in the UI is to start with the main Services view and make things accessible from there, e.g. inside a service you see its revisions etc. However, this hierarchy is a lie compared to API and this creates incompatibilities and issues, e.g.:

Let’s say I have an Archetype without a Service (created via API or whatever) -- where in the UI I could see it? We would need a new “Archetypes” view, separate from our main “Services” view, which could be distracting to customers.

Let’s say I want to show details of a particular Revision. Assume the user got there from service X. I’d like to show the Revision in the context of X, and just say that the Revision is serving 50% for X, or is accessible at this URL etc. However, to fully show Revision details, the UI would need to determine that the Revision is also serving for unrelated service Y, or is routable with a different URL for service Z. This is magnified if you can reach the Revision from other paths, such as Archetype view or a Revision list view.

When a customer drills down to a Service, they want to be able to see a list of Revisions related to this service. If N:N relationships are present (and it can be difficult to determine if that is the case without a full list of resources in the namespace), it is difficult to suggest a query to find the relevant Revisions.

1-N: A service can use multiple Archetypes. This is another source of complexity:

We expect that the UI displays a single list of revisions (probably sorted by creation date). If these Revisions have been created by different Archetype, then displaying a single list might not map to the mental model of our users (they might consider them to in fact be multiple independent histories). Displaying multiple revision lists for a given Service complexifies the UI.

Activity

  1. added
    area/API
    on Feb 3, 2018
  2. evankanderson commented on Feb 3, 2018

    @evankanderson
    MemberAuthor

    My initial take:

    It's easier to relax restrictions later, so I'm sympathetic to attempting to restrict this relationship to 1:1 between Service and Archetype at the moment.

    One idea for how to do this (which would also simplify the initial deployment experience to a single API call):

    • When an Archetype is created, it implicitly creates an ElaService configured for automatic rollout with the same name, e.g.
    POST /api/elafros.dev/v1alpha/namespaces/jimmy/archetypes
    
    apiVersion: elafros.dev/v1alpha
    kind: Archetype
    metadata:
      name: thumbnailer
    ...
    

    This would turn around and create an ElaService like the following:

    apiVersion: elafros.dev/v1alpha
    type: ElaService
    metadata:
      name: thumbnailer
    spec:
      traffic:
      - archetypeName: thumbnailer
        percent: 100
    

    We could even set metadata.ownerReference on either the Archetype or the ElaService if we want to perform automatic garbage collection when the other is deleted.

    Two concerns about this solution:

    1. If we discover that 1:N or N:N are useful/requested by many customers, how do we signal to avoid the automatic ElaService creation and/or metadata.ownerReference management?
    2. If we use metadata.ownerReference, which way should the ownership go? If we think that 1:N from ElaService to Archetype is the most common pattern (e.g. an experimental/rewrite release train and the main production train off the same DNS name) and we think that ElaService is the top-level concept that customers will think of, then it would make sense to make the Service own the Archetype. (Obviously, in complex scenarios, customers could simply remove the ownerReferences completely to avoid garbage collection.)
  3. dewitt commented on Feb 3, 2018

    @dewitt
    Contributor

    If we wanted to go all in on the 1:1 relationship, we could address the naming problem of 'Archetype' (see issue #65) at the same time by inlining it into ElaService entirely.

    apiVersion: elafros.dev/v1alpha
    type: ElaService
    metadata:
      name: thumbnailer
    spec:
      template:
        serviceType: container
        env:
          - name: TARGET
            value: thumb_v1
        containerSpec:
          image: docker.io/elafros/thumbnailer:latest
      traffic:
        percent: 100
    
  4. mattmoor commented on Feb 3, 2018

    @mattmoor
    Contributor

    I like the separation we have, and leaving the door open to relaxing this later.

    What we have supports a lot of interesting scenarios, without significantly complicating the 99% case (IMO).

    I think that UX changes a lot over time, based on how folks use the product, so I'd rather not tie ourselves too closely to a particular model.

  5. qelo commented on Feb 3, 2018

    @qelo

    +1 to @dewitt, that would be the most elegant way to maintain 1:1 and would avoid all the confusion coming from a separate object

    Would be harder to relax back to n-n in the future, but: what if we embraced ElaService composition instead?

    Like: You wanted two Archetypes? Just have two sub-services and route between them using other Ela primitives (we can design those separately, like a service that just splits traffic between other services).

    I think service composition is a very powerful model, because we still allow for very sophisticated configurations/graphs, while the mental model of basic building blocks remains simple.

    Otherwise, I like the approach that @evankanderson is exploring, but we will run into the number of problems:

    1. "ElaService is the top-level concept that customers will think of" -- agree
    2. We end up with this awkwardness that you come with the intent "I'd like to create a new service", but you are doing /archetypes POST call for that.
    3. More preferred would be if ElaService created an Archetype automatically, but then where does initial Archetype spec fit in that call?
    4. Actually we risk problem (3) also in other direction: if we ever add some more settings to ElaService, it might be a problem to set them during Archetype creation (you would need to update ElaService just after creation -- not so nice)
  6. vaikas commented on Feb 3, 2018

    @vaikas
    Contributor
  7. mikehelmick commented on Feb 5, 2018

    @mikehelmick
    Contributor

    The decoupling here between ElaService and Archetype is the least restrictive for future expansion and we should prefer keeping this separation in the API. The original inclusion of everything included in the Archetype in the service definition was indeed complicated, another reason for maintaining the separation.

    For the future N:M case, if we go there, garbage collection may or may not be necessary or even desirable. There are configurations where and archetype could become temporarily orphaned. Detecting orphaned ElaService and/or Archetype objects could be easily done and clearly reflected in the status of the object. If we end up going that direction, l can see how we could go to configurable garbage collection for these entities.

    The lack of explicit service creation isn't without precedent. Google App Engine services are created by creating the first version of that service. There is a nice parallel here with the ElaService being created by the creation of the Archetype. The user intent is the same. I want to create a new service, but the creation of a service without something to run isn't necessarily meaningful. I don't find creating the ElaService through the creation of the Archetype to be a problem in that respect, it ensures that the service has a way for revisions to be created.

  8. evankanderson commented on Feb 5, 2018

    @evankanderson
    MemberAuthor

    Pulling out and cleaning up the doc referenced by @vaikas-google; this is re-treading existing territory, but new people have entered the discussion with new opinions. The double goal here is to satisfy their concerns and to document the decision for future generations. :-)

  9. evankanderson commented on Feb 5, 2018

    @evankanderson
    MemberAuthor

    I did a little wire-framing of a possible UI treatment to address some of @qelo 's concerns. The idea is that the basic UI would (like the CLI) rely on a few conventions to cover the 98% case, and then have a more complete and complex UI which would expose all the concepts available for both the 2% case and for users who were curious about the underlying system architecture.

    In the basic view, the system would display a list of Services with several workflows available based on the existence of the corresponding Archetype (e.g. "redeploy source", "update settings", etc). If the corresponding (same name) Archetype does not exist, the UI would degrade gracefully by offering a link to the Advanced view. Over time, the "same name" condition could be relaxed in cases where there was a single Archetype with a different name from the service, but this might not be desirable, as it might put an equivalent burden on other tools.
    basic view

    In the Advanced View, each resource would be represented graphically. Services and Archetypes (and their corresponding Revision histories) would be connected via "sends traffic to" arrows to represent arbitrarily complex configurations. While more accurate to the underlying resources, this view would require users to understand all three of the resource concepts in the API. I also forgot to draw the blue "deploy" button on Archetypes in these mocks. (oops!)
    advanced

    Note that both of these designs use a "stacked file" icon to represent the set of Revisions descended from an Archetype (see #65 for possible renaming), as I found that it was somewhat difficult to create individual graphical representations of all existing Revisions. For the Advanced view, it would be possible to have the actual live Revisions present as a third column in the UI; it would be expected that a single Service might link to 10 revisions (possibly via Archetype latestReadyRevisionName reference), but the number would typically be bounded even smaller than that.

  10. evankanderson commented on Feb 5, 2018

    @evankanderson
    MemberAuthor

    Some example scenarios for each direction of 1:N and N:1 between Service and Archetype:

    1:N

    • Experiments (what if we did things async, or doubled available RAM?).
      • With RBAC, it's possible to grant a developer access to update only one Archetype. If you delegate e.g. 1% of traffic to that Archetype, the developer can do 1% experimentation against the environment without the ability to cause further damage.
    • More generally, replacing an existing service with a new implementation while both are being built and deployed. (For a cutover where you don't ever need to go back and fix something in the old implementation, you can simply replace the old Archetype with new. We call this "big bang" deployment, for the sound it makes.)

    N:1

    These are slightly more esoteric; I've done these in previous production environments by slipping a separate load-balancer in front to provide the additional naming.

    • Strangler Application: while slipping the proxy in front, it may be desirable to have a second Service which only points at the legacy application.
    • Endpoint consolidation: use a single App to handle what used to be 2 or more named endpoints, by redirecting the traffic to the single implementation. This is particularly useful for low-traffic services where it may be hard to update all the callers. An alternate implementation of this is to deploy a forwarder service at N-1 of the other endpoint services (at which point, you get separate monitoring metrics, pay 2x invocations, etc).
  11. 18 remaining items

  12. cooperneil commented on Feb 9, 2018

    @cooperneil

    @dewitt, yep exactly - nice illustration. Borrowed this to help explain the rationale for a separate Archetype resource in issue #102

  13. mchmarny commented on Feb 9, 2018

    @mchmarny
    Contributor

    Capturing decision from today's sync on this:

    We will restrict Archetype (aka Configuration see #65) & Revisions such that an Archetype & created Revisions can only be pointed to by one Service (aka Route, see #65) at a time, using a mechanism like "claims" on the Archetype by the Service

    Will close this issue when the related PRs are committed to master.

  14. evankanderson commented on Feb 9, 2018

    @evankanderson
    MemberAuthor

    Details on proposed implementation:

    (via validation prior to etcd commit)
    For each Revision directly or indirectly referenced in the Route configuration, look up the Configuration from Revision.metadata.labels[elafros.dev/configuration]. The Route should then ensure that (for each such Configuration), the Configuration.metadata.labels[elafros.dev/route] label is either non-existent, or points to this Route. If the label is non-existent, update the Configuration to point the elafros.dev/route label to this Route.

  15. added
    kind/feature
    on Feb 9, 2018
  16. grantr commented on Feb 12, 2018

    @grantr
    Contributor

    If the label is non-existent, update the Configuration to point the elafros.dev/route label to this Route.

    I'm just catching up to the latest on this, so forgive me if this isn't relevant, but was there consideration of whether this automatic ownership field should be part of the Route Status instead of Labels? I don't have an argument either way, but I'd like to see the reasoning documented.

    Relevant k8s docs:
    https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#spec-and-status
    https://github.com/kubernetes/community/blob/master/contributors/devel/api-conventions.md#references-to-related-objects

  17. evankanderson commented on Feb 12, 2018

    @evankanderson
    MemberAuthor

    Two reasons why I'd suggested a label (I'd originally thought annotation):

    1. It may be convenient for the UI to be able to list all the Configurations that a Route points to using a label query rather than needing to perform the scatter/gather across referenced Revisions.

    2. We're not 100% sure whether this restriction rules out important use cases. Since it's easier to expand an API than restrict it*, I'd thought that implementing this restriction in a label might avoid making schema changes which would need to be backed out later.

    I'm not sure either of these is strongly compelling, so we could do this as a Status field as well.

    • This is only somewhat true, since users might take a dependency on item 1.
  18. jurekPapiorek commented on Feb 13, 2018

    @jurekPapiorek

    I'd like to understand argument 1) better, as I've seen it used in other contexts too.

    API clients will want to filter by many different attributes of Elafros resource objects - some of them will belong to the spec, some to the status, some could be labels. Is converting all filterable attributes into labels the only solution that k8s provides for filtering?

  19. evankanderson commented on Feb 13, 2018

    @evankanderson
    MemberAuthor
  20. mattmoor commented on Mar 15, 2018

    @mattmoor
    Contributor

    I believe this is now done. We set labels on Configurations that are used in a Route: elafros.dev/route: <route name>

  21. added a commit that references this issue on Jun 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

UI / UXarea/APIkind/featuremedium

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions