Skip to content

Commit

Permalink
Change default value of namespace in task.kubernetes to be None (a…
Browse files Browse the repository at this point in the history
…pache#43402)

* change default namespace value to be None

* passing namespace to decorator when in_cluster=False

* add breaking change

* change changelog

* revert ui change
  • Loading branch information
romsharon98 authored Nov 5, 2024
1 parent e9bc557 commit 9ede38a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
8 changes: 8 additions & 0 deletions providers/src/airflow/providers/cncf/kubernetes/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@
Changelog
---------


main
.....

.. warning::
Set the default value of ``namespace`` in ``@task.kubernetes`` to ``None``, so it uses the cluster namespace when ``in_cluster`` is True. Be sure to specify a namespace when using this decorator. To retain the previous behavior, set ``namespace="default"``


9.0.1
.....

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class _KubernetesDecoratedOperator(DecoratedOperator, KubernetesPodOperator):
# there are some cases we can't deepcopy the objects (e.g protobuf).
shallow_copy_attrs: Sequence[str] = ("python_callable",)

def __init__(self, namespace: str = "default", use_dill: bool = False, **kwargs) -> None:
def __init__(self, namespace: str | None = None, use_dill: bool = False, **kwargs) -> None:
self.use_dill = use_dill
super().__init__(
namespace=namespace,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ state: ready
source-date-epoch: 1730012271
# note that those versions are maintained by release manager - do not update them manually
versions:
- 10.0.0
- 9.0.1
- 9.0.0
- 8.4.2
Expand Down
2 changes: 2 additions & 0 deletions providers/tests/cncf/kubernetes/decorators/test_kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def test_basic_kubernetes(dag_maker, session, mock_create_pod: mock.Mock, mock_h
in_cluster=False,
cluster_context="default",
config_file="/tmp/fake_file",
namespace="default",
)
def f():
import random
Expand Down Expand Up @@ -122,6 +123,7 @@ def test_kubernetes_with_input_output(
in_cluster=False,
cluster_context="default",
config_file="/tmp/fake_file",
namespace="default",
)
def f(arg1, arg2, kwarg1=None, kwarg2=None):
return {"key1": "value1", "key2": "value2"}
Expand Down

0 comments on commit 9ede38a

Please sign in to comment.