Repository: kserve/kserve

Issue:
Stop Error When disabled_grpc=True
/kind bug

**What steps did you take and what happened:**
In our use case we don't use the grpc_server inside `ModelServer` thus we set `enable_grpc=False`. But when server stops it will still call stop from this unstarted server thus got the error below:
```
>       await self._server.stop(grace=10)
E       AttributeError: 'NoneType' object has no attribute 'stop'
```

The bug is because that this [if](https://github.com/kserve/kserve/blob/master/python/kserve/kserve/model_server.py#L174) will always be evaluated as `True`. Can we please add a one line change to make it support `enable_grpc=False`? Maybe change it to `if self._grpc_server._server` or `if self.enable_grpc`? Should be a very quick fix and that helps a lot! Thank you!

**What did you expect to happen:**
A one line change from [code](https://github.com/kserve/kserve/blob/master/python/kserve/kserve/model_server.py#L174) to `if self._grpc_server._server` or `if self.enable_grpc`

**What's the InferenceService yaml:**
[To help us debug please run `kubectl get isvc $name -n $namespace -oyaml` and paste the output]

**Anything else you would like to add:**
[Miscellaneous information that will assist in solving the issue.]


**Environment:**

- Istio Version:
- Knative Version:
- KServe Version:
- Kubeflow version:
- Cloud Environment:[k8s_istio/istio_dex/gcp_basic_auth/gcp_iap/aws/aws_cognito/ibm]
- Minikube/Kind version:
- Kubernetes version: (use `kubectl version`):
- OS (e.g. from `/etc/os-release`):

Stop Error When disabled_grpc=True
/kind bug

**What steps did you take and what happened:**
In our use case we don't use the grpc_server inside `ModelServer` thus we set `enable_grpc=False`. But when server stops it will still call stop from this unstarted server thus got the error below:
```
>       await self._server.stop(grace=10)
E       AttributeError: 'NoneType' object has no attribute 'stop'
```

The bug is because that this [if](https://github.com/kserve/kserve/blob/master/python/kserve/kserve/model_server.py#L174) will always be evaluated as `True`. Can we please add a one line change to make it support `enable_grpc=False`? Maybe change it to `if self._grpc_server._server` or `if self.enable_grpc`? Should be a very quick fix and that helps a lot! Thank you!

**What did you expect to happen:**
A one line change from [code](https://github.com/kserve/kserve/blob/master/python/kserve/kserve/model_server.py#L174) to `if self._grpc_server._server` or `if self.enable_grpc`

**What's the InferenceService yaml:**
[To help us debug please run `kubectl get isvc $name -n $namespace -oyaml` and paste the output]

**Anything else you would like to add:**
[Miscellaneous information that will assist in solving the issue.]


**Environment:**

- Istio Version:
- Knative Version:
- KServe Version:
- Kubeflow version:
- Cloud Environment:[k8s_istio/istio_dex/gcp_basic_auth/gcp_iap/aws/aws_cognito/ibm]
- Minikube/Kind version:
- Kubernetes version: (use `kubectl version`):
- OS (e.g. from `/etc/os-release`):



Discussion:

Resolving patch:
diff --git a/python/kserve/kserve/model_server.py b/python/kserve/kserve/model_server.py
--- a/python/kserve/kserve/model_server.py
+++ b/python/kserve/kserve/model_server.py
@@ -107,7 +107,10 @@ def __init__(self, http_port: int = args.http_port,
         self.dataplane = DataPlane(model_registry=registered_models)
         self.model_repository_extension = ModelRepositoryExtension(
             model_registry=self.registered_models)
-        self._grpc_server = GRPCServer(grpc_port, self.dataplane, self.model_repository_extension)
+        self._grpc_server = None
+        if self.enable_grpc:
+            self._grpc_server = GRPCServer(grpc_port, self.dataplane,
+                                           self.model_repository_extension)
         self.log_config_file = log_config_file
         self.access_log_format = access_log_format
 


Test patch: