aneoconsulting / ArmoniK.Core

Task manager for ArmoniK (submission, scheduling, IO data, monitoring). Implements API located in https://github.com/aneoconsulting/ArmoniK.Api
https://aneoconsulting.github.io/ArmoniK.Core/
GNU Affero General Public License v3.0
10 stars 8 forks source link

feat: add static init for instances of Partition and Authentication #766

Open aneojgurhem opened 3 weeks ago

aneojgurhem commented 3 weeks ago

Motivation

Description

An InitServices options class was introduced to initialize services. It contains two classes : Authentication and Partitionning to configure authentications and Partitions respectively. Authentication has several list of strings as fields: UserCertificates, Roles and Users. Those fields are JSON strings that are deserialized into corresponding objects that will be inserted into the database. Partitions works the same with the Partitionning class with the field Partitions.

These options can be configured as environment variables. Lists should be converted into an environment variable per element with its index as shown below.

See the classes Partition, User, Role and Certificate for the field that should be given has JSON strings.

export InitServices__Partitioning__Partitions__0='{"ParentPartitionIds":[],"PartitionId":"TestPartition0","PodConfiguration":null,"PodMax":100,"PodReserved":50,"PreemptionPercentage":20,"Priority":1}'
export InitServices__Authentication__Users__0='{"Name":"User1","Roles":["Role1"]}'
export InitServices__Authentication__Roles__0='{"Name":"Role1","Permissions":["Perm1"]}'
export InitServices__Authentication__UserCertificates__0='{"User": "User1", "CN": "CN1", "Fingerprint": "Fingerprint1"}'

Testing

Unit tests were added to validate the behavior of the implementation. ArmoniK.Core infrastructure was also updated to support a deployment with and without initialization activated in the compute plane and control plane. It can be toggled during deployment with the just option cinit.

Impact

Additional Information

Infrastructure will need to be modified to use the new way to initialize database. However, current (2.20 as of today) infrastructure should still be compatible with this development.

Integer are used as Id for Roles, Users and Certificates. When we will try to create new instances and insert them into the database through new APIs, we have two ways to generate the Id:

Checklist