Repository: PrefectHQ/prefect

Issue:
KubernetesJob job_watch_timeout_seconds none is not an allowed value (2.7.1 / Cloud)
### First check

- [X] I added a descriptive title to this issue.
- [X] I used the GitHub search to find a similar issue and didn't find it.
- [X] I searched the Prefect documentation for this issue.
- [X] I checked that this issue is related to Prefect and not one of its dependencies.

### Bug summary

With the (almost) new Prefect version 2.7.1, a Kubernetes job fails if the optional parameter `job_watch_timeout_seconds` is not set, as the default `None` is reported as not an accepted value. In older versions it worked as the default apparently was `5`. 

> improved timeout handling on the KubernetesJob block - this timeout is now disabled by default (i.e. job_watch_timeout_seconds is set to None)

[Prefect 2.7.1 release notes](https://discourse.prefect.io/t/prefect-2-7-1-is-released-with-a-new-ui-page-for-coordinating-task-run-concurrency-limits-bulk-delete-functionality-from-the-ui-for-flows-deployments-and-work-queues-improved-timeout-for-kubernetes-jobs-and-many-more/2036) mentions this parameter, so I think it might be related to this change. It was changed in #7786.

### Reproduction

Deploy and run this, then check the status in Prefect Cloud:

```python3
from prefect import flow
from prefect import get_run_logger
from prefect import task
from prefect.filesystems import GCS
from prefect.infrastructure import KubernetesJob

block = GCS(bucket_path="foobucket")
block.save("foobar-dev", overwrite=True)

k8s_job = KubernetesJob(image_pull_policy="Always")
k8s_job.save("foobar-dev", overwrite=True)


@task
def hello_world() -> str:
    logger = get_run_logger()
    text = "Hello from task"
    logger.info(text)
    return text


@flow(name="foobar")
def foobar() -> None:
    logger = get_run_logger()
    logger.info("Hello from flow!")
    hw = hello_world()
    logger.info("Output of task: " + hw)


# deploy & run me!
# prefect deployment build foobar.py:foobar --name dev -ib kubernetes-job/foobar-dev -sb gcs/foobar-dev -q kubernetes -a
# prefect deployment run foobar/dev
```


### Error

Prefect Cloud UI sets the flow to failed with the following *State Message*:

> Submission failed. pydantic.error_wrappers.ValidationError: 1 validation error for KubernetesJob job_watch_timeout_seconds none is not an allowed value (type=type_error.none.not_allowed)

### Versions

```Text
Version:             2.7.1
API version:         0.8.3
Python version:      3.8.16
Git commit:          33f7de50
Built:               Thu, Dec 8, 2022 4:09 PM
OS/Arch:             darwin/arm64
Server type:         cloud
```


### Additional context

_No response_


Discussion:
@quassy thanks for the report!

@zzstoatzz looks like we missed updating the type from `int` to `Optional[int]` — Pydantic does not type-check defaults but if the default is passed explicitly (as I presume is happening during roundtrip serialization here) it will not allow the `None`.

Resolving patch:
diff --git a/src/prefect/infrastructure/kubernetes.py b/src/prefect/infrastructure/kubernetes.py
--- a/src/prefect/infrastructure/kubernetes.py
+++ b/src/prefect/infrastructure/kubernetes.py
@@ -119,7 +119,7 @@ class KubernetesJob(Infrastructure):
     )
 
     # controls the behavior of execution
-    job_watch_timeout_seconds: int = Field(
+    job_watch_timeout_seconds: Optional[int] = Field(
         default=None,
         description=(
             "Number of seconds to wait for each event emitted by the job before "


Test patch: