jwa: Expose a last-activity column (kubeflow/kubeflow#6544)
We want to extend JWA to have a column for showing the `Last activity` of a Notebook CR. Signed-off-by: Kimonas Sotirchos <kimwnasptd@arrikto.com>
This commit is contained in:
parent
bba1bf22ee
commit
ae4d647d3c
|
|
@ -16,6 +16,7 @@ FILE_ABS_PATH = os.path.abspath(os.path.dirname(__file__))
|
||||||
NOTEBOOK_TEMPLATE_YAML = os.path.join(
|
NOTEBOOK_TEMPLATE_YAML = os.path.join(
|
||||||
FILE_ABS_PATH, "yaml/notebook_template.yaml"
|
FILE_ABS_PATH, "yaml/notebook_template.yaml"
|
||||||
)
|
)
|
||||||
|
LAST_ACTIVITY_ANNOTATION = "notebooks.kubeflow.org/last-activity"
|
||||||
|
|
||||||
# The production configuration is mounted on the app's pod via a configmap
|
# The production configuration is mounted on the app's pod via a configmap
|
||||||
DEV_CONFIG = os.path.join(FILE_ABS_PATH, "yaml/spawner_ui_config.yaml")
|
DEV_CONFIG = os.path.join(FILE_ABS_PATH, "yaml/spawner_ui_config.yaml")
|
||||||
|
|
@ -113,6 +114,11 @@ def get_storage_class(vol):
|
||||||
|
|
||||||
|
|
||||||
# Functions for transforming the data from k8s api
|
# Functions for transforming the data from k8s api
|
||||||
|
def get_notebook_last_activity(notebook):
|
||||||
|
annotations = notebook["metadata"].get("annotations", {})
|
||||||
|
return annotations.get(LAST_ACTIVITY_ANNOTATION, "")
|
||||||
|
|
||||||
|
|
||||||
def notebook_dict_from_k8s_obj(notebook):
|
def notebook_dict_from_k8s_obj(notebook):
|
||||||
cntr = notebook["spec"]["template"]["spec"]["containers"][0]
|
cntr = notebook["spec"]["template"]["spec"]["containers"][0]
|
||||||
server_type = None
|
server_type = None
|
||||||
|
|
@ -125,6 +131,7 @@ def notebook_dict_from_k8s_obj(notebook):
|
||||||
"namespace": notebook["metadata"]["namespace"],
|
"namespace": notebook["metadata"]["namespace"],
|
||||||
"serverType": server_type,
|
"serverType": server_type,
|
||||||
"age": helpers.get_uptime(notebook["metadata"]["creationTimestamp"]),
|
"age": helpers.get_uptime(notebook["metadata"]["creationTimestamp"]),
|
||||||
|
"last_activity": get_notebook_last_activity(notebook),
|
||||||
"image": cntr["image"],
|
"image": cntr["image"],
|
||||||
"shortImage": cntr["image"].split("/")[-1],
|
"shortImage": cntr["image"].split("/")[-1],
|
||||||
"cpu": cntr["resources"]["requests"]["cpu"],
|
"cpu": cntr["resources"]["requests"]["cpu"],
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import {
|
||||||
ComponentValue,
|
ComponentValue,
|
||||||
TableConfig,
|
TableConfig,
|
||||||
TABLE_THEME,
|
TABLE_THEME,
|
||||||
|
DateTimeValue,
|
||||||
} from 'kubeflow';
|
} from 'kubeflow';
|
||||||
import { ServerTypeComponent } from './server-type/server-type.component';
|
import { ServerTypeComponent } from './server-type/server-type.component';
|
||||||
|
|
||||||
|
|
@ -73,6 +74,11 @@ export const defaultConfig: TableConfig = {
|
||||||
textAlignment: 'right',
|
textAlignment: 'right',
|
||||||
value: new PropertyValue({ field: 'age', truncate: true }),
|
value: new PropertyValue({ field: 'age', truncate: true }),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
matHeaderCellDef: $localize`Last activity`,
|
||||||
|
matColumnDef: 'last_activity',
|
||||||
|
value: new DateTimeValue({ field: 'last_activity' }),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
matHeaderCellDef: $localize`Image`,
|
matHeaderCellDef: $localize`Image`,
|
||||||
matColumnDef: 'image',
|
matColumnDef: 'image',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue