nebari icon indicating copy to clipboard operation
nebari copied to clipboard

Run schema validation during `qhub init`

Open iameskild opened this issue 2 years ago • 6 comments

We are currently only running schema validation when qhub render is called. Let's move this sort of validation as early in the process as we can.

Here is any example of the qhub init passing but qhub render failing a validation check that should be caught earlier in the process, as part of this failed gh action:

$ qhub init "do" --project "test--do-github-actions" --domain "do.qhub.dev" --auth-provider github --disable-prompt --ci-provider github-actions
$ qhub render -c "qhub-config.yaml" -o "qhub-do-github-actions-deployment"

Error: The schema validation of the qhub-config.yaml failed. The following error message may be helpful in determining what went wrong:

1 validation error for Main
project_name
  
        In order to successfully deploy QHub, there are some project naming conventions which need
        to be followed. First, ensure your name is compatible with the specific one for
        your chosen Cloud provider. In addition, the QHub project name should also obey the following
        format requirements:
        - Letters from A to Z (upper and lower case) and numbers;
        - Maximum accepted length of the name string is [16](https://github.com/Quansight/qhub/runs/6178700354?check_suite_focus=true#step:10:16) characters.
        - If using AWS: names should not start with the string "aws";
        - If using Azure: names should not contain "-".
        
Maximum accepted length of the project name string is 16 characters. (type=value_error)
Error: Process completed with exit code 1.

Related to #761

iameskild avatar May 04 '22 00:05 iameskild

Thanks for raising this @iameskild, I agree that having those checks as earlier as possible would be great. Though would we like those tests to be managed all by pydantic schema as we are doing for render? Another way of doing this would be to separate those validations to another python script and call those methods when needed in the schema and in the initialize.

viniciusdc avatar May 04 '22 22:05 viniciusdc

@tonyfast do you have any ideas how could we use pydantic schema here? the code which we should validate is:

  • here we defined the args that qhub init accepts;
  • here we generated the qhub-config based on a template;

viniciusdc avatar May 11 '22 17:05 viniciusdc

Once we get to a PR for this, we can update the naming convention that was missing for AWS (see comment)

viniciusdc avatar May 11 '22 20:05 viniciusdc

@iameskild @asmijafar20 is this being covered in your current PR?

trallard avatar Sep 22 '22 12:09 trallard

Yes, @trallard.

asmijafar20 avatar Sep 22 '22 16:09 asmijafar20

In this PR, we are currently validating most of the inputs that are being passed in when running nebari init ... but there are a few more checks that should be added. Unfortunately most of the remaining checks are scattered throughout qhub/initialize.py and need to be moved to qhub/schema.py.

iameskild avatar Sep 22 '22 17:09 iameskild

We are now performing validations during the init process. This was added during the large extension mechanism refactor.

iameskild avatar Oct 16 '23 16:10 iameskild