nebari icon indicating copy to clipboard operation
nebari copied to clipboard

[BUG] - ValidationError for `kube_context` when deploying on existing k8s

Open viniciusdc opened this issue 1 year ago â€Ē 1 comments

Describe the bug

A ValidationError occurs when initializing ExistingInputVars as part of the nebari deploy without passing an explicit value for kube_context. According to the schema validation rules, the validation expects a non-null string for this field when configuring the existing provider type. However, it seems that the default values is not being correctly accessed.

Expected behavior

Default value should be used instead, as originally suggested https://github.com/nebari-dev/nebari/blob/a26b8df19c31363082ca3104e4e7b2e9354b22ae/RELEASE.md?plain=1#L1137

OS and architecture in which you are running Nebari

Linux

How to Reproduce the problem?

  • Set the provider to existing in the configuration.
  • Do not provide a value for kube_context
  • Attempt to deploy, for easier reproduction running nebari render would trigger the validation as well

Command output

│ 8 in input_vars                                                                                  │
│                                                                                                  │
│   695 │   │   if self.config.provider == schema.ProviderEnum.local:                              │
│   696 │   │   │   return LocalInputVars(kube_context=self.config.local.kube_context).dict()      │
│   697 │   │   elif self.config.provider == schema.ProviderEnum.existing:                         │
│ ❱ 698 │   │   │   return ExistingInputVars(                                                      │
│   699 │   │   │   │   kube_context=self.config.existing.kube_context                             │
│   700 │   │   │   ).dict()                                                                       │
│   701 │   │   elif self.config.provider == schema.ProviderEnum.do:                               │
│                                                                                                  │
│ in pydantic.main.BaseModel.__init__:341                                                          │
╰──────────────────────────────────────────────────────────────────────────────────────────────────â•Ŋ
ValidationError: 1 validation error for ExistingInputVars
kube_context
  none is not an allowed value (type=type_error.none.not_allowed)

Versions and dependencies used.

2024.4.1rc1

Compute environment

None

Integrations

No response

Anything else?

No response

viniciusdc avatar Apr 17 '24 20:04 viniciusdc

As an extra comment here, I think we should get the current default context from kubectl (we are doing this somewhere already), and apply as the default value. Though, I would also like to add a message to the user to validate such information when attempting to run deploy

$ nebari deploy -c ***
Do you approve deploying Nebari using the current kube_context configuration <value+from+yaml>? (Y/n)

viniciusdc avatar Apr 17 '24 20:04 viniciusdc