ceph / teuthology-api

A REST API to execute teuthology commands.
MIT License
2 stars 10 forks source link

suite: `config_yaml` should contain yaml content instead of path/to/yaml #44

Open VallariAg opened 10 months ago

VallariAg commented 10 months ago

Route /suite has <config_yaml> in request schema. It takes path to the yaml config file in the data body, for example:

{
        "--ceph": "main",
        "--ceph-repo": "https://github.com/ceph/ceph-ci.git",
        "--machine-type": "testnode",
        "--num": "1",
        "--priority": "70",
        "--suite": "teuthology:no-ceph",
        "--suite-branch": "main",
        "--suite-repo": "https://github.com/ceph/ceph-ci.git",
        "--teuthology-branch": "main",
        "--verbose": "1",
        "--user": "example",
        "<config_yaml>": ["/path/to/yaml"]
     }

https://github.com/ceph/teuthology-api/blob/9af7fb0d39501feedac82f030c7060eb4b7e8a03/src/teuthology_api/schemas/suite.py#L44

This would mean that the config file should already exist on t-api's server. For more practical use-case, we can accept a string with the yaml config content. After receiving a request, teuthology-api can save this yaml content in a temporary file and then pass path to that file to teuthology.suite.main function.

Devansh3712 commented 9 months ago

I'd like to work on this issue. So basically instead of the YAML file path the request would contain the contents of the file, and we need to save it as a temporary file (something like <username>_<timestamp>.yaml) and pass that to the teuthology function?

VallariAg commented 9 months ago

Correct! You can create the temporary file using https://docs.python.org/3/library/tempfile.html and then delete it after the scheduling is finished.

Devansh3712 commented 9 months ago

Understood, I'll take a look at this library and start working on it!

Devansh3712 commented 9 months ago

I looked at the tempfile module and this is what I was able to gather. Once the with block is over, the temporary file will be deleted automatically and until then it will show as a temporary file on the system.

image

after writing the YAML content to this tmp, we can pass it on to the teuthology.main function, and can put the user's name as suffix if required

VallariAg commented 9 months ago

Yes, that sounds good! Like in our docker setup, we use this yaml config while scheduling: https://github.com/ceph/teuthology/blob/main/docs/docker-compose/teuthology/containerized_node.yaml

Also it's possible to get multiple configs which is why "" param is a list in /suite schema. So you'll probably want to create a new file for every config and then send path of each temp file to teuthology.main.

Devansh3712 commented 8 months ago

So after creating temporary files for all configs, I should replace the <config_yaml> key with the list of names of those temporary files?

octonawish-akcodes commented 8 months ago

can i work on this? @VallariAg

VallariAg commented 8 months ago

So after creating temporary files for all configs, I should replace the key with the list of names of those temporary files?

@Devansh3712 sorry for late reply! And yes, you pass the path of all the temporary config files like: {"<config_yaml>": ["path/to/config.yaml"] ....}. I think that should work!

@octonawish-akcodes please check with Devansh if he's still working on this issue.

Devansh3712 commented 8 months ago

understood, and yes i'm working on this issue