Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • lava lava
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 96
    • Issues 96
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 64
    • Merge requests 64
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • lava
  • lavalava
  • Issues
  • #592

Closed
Open
Created Feb 23, 2023 by Igor Ponomarev@igo95862Contributor

JSONField for TestCase.metadata?

Since version 3.1 Django supports JSON fields:

https://docs.djangoproject.com/en/3.1/ref/models/fields/#jsonfield

This field allows database to keep JSON objects as a separate type.

For example, currently the JobErrorsView relies on matching the string in the YAML string.

https://git.lavasoftware.org/lava/lava/-/blob/f03c1ff14d027c65a6bcb305ead3a6bc75001574/lava_scheduler_app/views.py#L325

This is very slow to filter and is unreliable if for example the formatting changes.

Using the JSON field the lookups will be extremely fast and an index even possible.

You might ask ...but isn't metadata kept in YAML. However, did you know that valid JSON object is a valid YAML?

import yaml
import json

yaml.safe_load(json.dumps({'a': 1, 'b': 'c'}))
# {'a': 1, 'b': 'c'}

So metadata can be kept as JSON but be served as YAML. Since only safe YAML is currently used there should not be any issues with primitive types.

Because Debian 11 only ships Django 2.2 this change will have to wait until Debian 11 support gets dropped.

Edited Feb 23, 2023 by Igor Ponomarev
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking