Refactor Telemetry package - Unit tests and abstractions
Implementing the management of Plugins and the update of resources of those, I faced some issues when working with the Telemetry package (and with the related resources models), basically responsible to make the management of resources usage on the machine and for each service running.
IMPORTANT Update: the tasks related to organizing the resources-related models were moved to a new issue: #259
The problems that I faced were:
-
Confusing nomenclature between FreeResources, AvailableResources
Possible solution: change from AvailableResources to OnboardedResources or similar
-
Not specifying units of measurement on the models attribute names which then become confusing when adding/removing resources without knowing if we are dealing with (MHz or Hz) or (GiB or MB or GB)**
Possible solution:
- Changes on the nomeclature level: not preferable: Ram, RAM | preferable: RamGB, RAMGB, RamMb
- Changes on the type level: create custom types of each measurement unit and couple with those variables, as with (Ram GB)
-
Multiple Resources structs under models package which could be simplified
Context: we have FreeResources, AvailableResources, resources, ServiceResourceRequirements. Most of them share similar attributes, we don't necessarily need to delete almost all of them, but at least make an unique Resources model that are used by these other models. We also have DB tables depending on these structs so we must be careful with that.
Context 2: now not only services needs resources management but also Plugins
-
Separate resources Price from resources Usage
Context: right now we have structs which the RamUsage and the RamPrice are under the same struct, I think we maybe should change and separate ResourcesUsage from ResourcesPrice.
-
If useful, starting using the HardwareResources struct with its models created on ipfs-plugin branch
Context: I actually don't know how useful it's, but I implemented an unique struct and methods to simplify the increase, decrease of resources which is very abstracted from the business logic, all it cares is resourceUsage.
Possible Solution: Refact CalcFreeResources() to use this new struct and methods
-
Telemetry package/folder under firecracker/ folder
Possible solution: move to the root (Done within ipfs-plugin branch)
-
Maybe move every func resources-related to telemetry package
Maybe:
-
GPU info is separated model now, unify it also with the other resources usage
-
Other packages also use their own resources models structs, functions Possible solution: solve that also and use the same model for the entire DMS
Task | Description | Duration | Status | Start Date | End Date | Comment |
---|---|---|---|---|---|---|
A | Simplifying general structuring of Resources-related model | 6-8 Hrs | Done | All Ax tasks is basically on hold, and uncompleted implemented on separate branch, check comments | ||
A1 | Custom types to specify units of measurement (GB, MB...) | 1 Hrs | Done | |||
A2 | Solve confusing nomenclature (FreeResources, AvailableResources) | 0 Hrs | Done | |||
A3 | Move every func resources-related to telemetry package | 0 Hrs | Done | |||
A4 | Move telemetry folder to root and apply necessary changes on import paths | 0 Hrs | Done | |||
A5 | Solve the Price struct (embedding or separating) | 2 Hrs | Done | |||
A6 | Solving Migration problem | 6-12 Hrs | Done (incomplete) | See comments for more info regarding the situation | ||
B | Modify CalcFreeResources() to use the new struct and methods | 2-4 Hrs | Done | |||
B1 | Do necessary changes on ResourcesModifier struct and methods, and unit tests | 2-4 Hrs | Done | |||
C | Unit Test for B | 2-4 Hrs | Done | |||
D | Putting final touches (rebase to be in sync with develop, logs, improve error handling, small changes on functions and unit tests, documentation, testing with real scenario) | 1-3 Hrs | Done | I also have to create the new issue and add some conclusions here in this issue |