vanvalenlab/kiosk-client

CostGetter only gets most recent creation event for every node.

Closed this issue · 0 comments

The CostGetter uses the Grafana API's kube_node_created event to calculate the lifetime of a node. The API returns a timeseries of timestamp and label (label being the creation timestamp). Therefore, if a node is created at time t1, our timeseries (from time 0 to 100) will look like:

[
  [0, "t1"],
  [1, "t1"],
  [2, "t1"],
  ...,
  [100, "t1"]
]

Currently, the CostGetter only examines the final event and calculates the difference between the creation label and the timestamp. This works fine if there is a single creation label in the time series. However, if the node is restarted, there will be multiple creation events:

[
  [0, "t1"],
  [1, "t1"],
  [2, "t2"],  # new creation event label, t2 due to a node restart.
  ...,
  [100, "t2"]
]

The CostGetter will only fetch data for "t2" and will miss the original 2 data points.


The CostGetter should find ALL creation events in the API response and sum the lifetime of each creation label.