Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

frontend: Update Map graph model #2751

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

frontend: Update Map graph model #2751

wants to merge 7 commits into from

Conversation

sniok
Copy link
Contributor

@sniok sniok commented Jan 16, 2025

GraphNode model is simplified

export type GraphNode = {
  /**
   * Unique ID for this node.
   * If this node represents a kubernetes object
   * then uid of that object is preferred.
   **/
  id: string;
  /** Display label for this node */
  label?: string;
  /** Subtitle for this node */
  subtitle?: string;
  /**
   * If this property is set  then it means this graph Node
   * represents a kubernetes object.
   * Label and subtitle will be set based on the object's name and kind.
   */
  kubeObject?: KubeObject;
  /** A node may contain children Nodes. */
  nodes?: GraphNode[];
  /** A node may containain Edges that connect children Nodes. */
  edges?: GraphEdge[];
  /** Whether this Node is collapsed. Only applies to Nodes that have child Nodes. */
  collapsed?: boolean;
  /** Any custom data */
  data?: any;
};

GraphNode can have label and subtitle or kubeObject

Node Preview
{ id: "some-node", label: "Node Label" } image
{ id: "some-node", label: "Node Label", subtitle: "Node Subtitle" } image
{ id: "some-node", label: "Node with an icon", subtitle: "Node Subtitle", icon: <Icon icon="mdi:plus-circle-outline" width="32px" /> } image
{ id: pod.metadata.uid, kubeObject: pod } image
{ id: "some-node", label: "Node with children", nodes: [...], edges: [...] } image

Since any GraphNode now can represent kubernetes object we can have better representation of groups like Namespaces and Nodes

Updated Namespace representation

There's now Icon and when clicking on namespace it shows details

image


A new way of creating edges is introduced called Relation

export interface Relation {
  fromSource: string;
  toSource?: string;
  predicate: (from: GraphNode, to: GraphNode) => boolean;
}

With Relation it's easier to define relationships between nodes. For example here's a definition for relation between Pods and ConfigMaps

const configMapUsedInPods = makeRelation(Pod, ConfigMap, (pod, configMap) =>
  pod.spec.volumes?.find(volume => volume.configMap?.name === configMap.metadata.name)
);

This change also allows to optimize which nodes are loaded. Before if you had ConfigMaps enabled in the Map it would load all Pods to see if there are any connections, even if Pod were deselected from the Map filters.
And now Relations are decoupled from sources and can be called only if both sources are activated.
You can still add edges from a Source if you need to.


Improved perfrormance

When I measured performance of the current implementation one thing that was overlooked is GPU load.
During simple things like panning around GPU load was high, causing dropped or partial frames.

Before:
image

will-change CSS hints allow the engine to dramatically reduce GPU usage
After:
image


Improved Grouping buttons

Now it takes a little less space

image

@sniok sniok force-pushed the simplify-map branch 7 times, most recently from baa2d4d to 2cbca37 Compare January 20, 2025 14:13
@sniok sniok changed the title WIP frontend: Update Map graph model frontend: Update Map graph model Jan 20, 2025
sniok added 6 commits January 24, 2025 10:55
Signed-off-by: Oleksandr Dubenko <oldubenko@microsoft.com>
Signed-off-by: Oleksandr Dubenko <oldubenko@microsoft.com>
Signed-off-by: Oleksandr Dubenko <oldubenko@microsoft.com>
Signed-off-by: Oleksandr Dubenko <oldubenko@microsoft.com>
Signed-off-by: Oleksandr Dubenko <oldubenko@microsoft.com>
…lations

Signed-off-by: Oleksandr Dubenko <oldubenko@microsoft.com>
Signed-off-by: Oleksandr Dubenko <oldubenko@microsoft.com>
@sniok sniok marked this pull request as ready for review January 24, 2025 15:03
@dosubot dosubot bot added the size:XXL This PR changes 1000+ lines, ignoring generated files. label Jan 24, 2025
@sniok sniok requested a review from a team January 24, 2025 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:XXL This PR changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant