pulumi / pulumi-kubernetes

A Pulumi resource provider for Kubernetes to manage API resources and workloads in running clusters
https://www.pulumi.com/docs/reference/clouds/kubernetes/
Apache License 2.0
415 stars 115 forks source link

`Provider` fails to validate `namespace` parameter (Python) #2250

Open sanmai-NL opened 2 years ago

sanmai-NL commented 2 years ago

What happened?

Provider() fails to validate namespace parameter, and reverts to currently globally selected namespace.

Steps to reproduce

from pulumi import Config, get_project
from pulumi_kubernetes import Provider

project = get_project()
config = Config("infra")

provider = Provider(
    namespace="data_pipeline",
    resource_name="pulumi-1",
)

pulumi up

Expected Behavior

Provider() validates each parameter, including namespace.

Actual Behavior

After pulumi up Pulumi just shows the diff, and lets me apply it. Then it complains that the selected namespace (not referenced in Pulumi-related source code or config) does not exist (indeed, I removed it). In fact, Pulumi reverts to the currently globally selected namespace for the operations ... 💥

Here, namespace contains a _, which is invalid).

Output of pulumi about


CLI          
Version      3.48.0
Go Version   go1.19.2
Go Compiler  gc

Plugins
NAME          VERSION
azure-native  1.82.0
kubernetes    3.21.4
python        unknown

Host     
OS       darwin
Version  13.0.1
Arch     x86_64

This project is written in python: executable='/usr/local/bin/python3' version='3.10.8
'

Backend        
Name           MacBook-Pro.fritz.box
URL            file://~
User           sanderhan
Organizations  

Dependencies:
NAME                                   VERSION
autoflake                              1.7.5
autopep8                               1.7.0
bandit                                 1.7.4
black                                  22.8.0
componentresource-datapipelinesegment  0.1.0
debugpy                                1.6.3
flake8-bugbear                         22.10.27
flake8-noqa                            1.2.9
infra                                  0.1.0
mypy                                   0.961.0
pre-commit                             2.20.0
pylint                                 2.15.4
pytest                                 7.1.3
python-dotenv                          0.21.0
rope                                   1.3.0
sourcery-cli                           0.12.12
toml-sort                              0.20.1
vulture                                2.6.0

Pulumi locates its logs in /var/folders/n8/zd60g3bx1n38k0s48crxwwwc0000gn/T/ by default
warning: Failed to get information about the current stack: No current stack111

### Additional context

_No response_

### Contributing

Vote on this issue by adding a 👍 reaction. 
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already). 
danielrbradley commented 2 years ago

Thanks for the detail of the issue @sanmai-NL

This would appear to be incorrect behaviour, though I'll defer to the code-owners to confirm that. Just to confirm: this issue isn't blocking deployments, but does cause undesirable behaviour in the case of a missing namespace?

Would your expected behaviour here be for the deployment to fail with an error that the namespace can't be found?

sanmai-NL commented 2 years ago

Thanks for the detail of the issue @sanmai-NL

This would appear to be incorrect behaviour, though I'll defer to the code-owners to confirm that. Just to confirm: this issue isn't blocking deployments, but does cause undesirable behaviour in the case of a missing namespace?

Would your expected behaviour here be for the deployment to fail with an error that the namespace can't be found?

Yes, or rather an exception at the source code level rather than the CLI tool bailing out straight.