code: def test_controller_gcs_failure(serve_ha, use_handle):  # noqa: F811
      @serve.deployment
      def d(*args):
          return f"{os.getpid()}"
  
      def call():
          if use_handle:
              handle = serve.get_app_handle(SERVE_DEFAULT_APP_NAME)
              ret = handle.remote().result()
          else:
              ret = requests.get("http://localhost:8000/d").text
          return ret
  
      serve.run(d.bind())
      pid = call()
  
      # Kill the GCS.
      print("Kill GCS")
      ray.worker._global_node.kill_gcs_server()
  
      # Make sure pid doesn't change within 5s.
      with pytest.raises(Exception):
          wait_for_condition(
              lambda: pid != call(), timeout=5, retry_interval_ms=1
          )
  
      print("Start GCS")
      ray.worker._global_node.start_gcs_server()
  
      # Make sure nothing changed even when GCS is back.
      with pytest.raises(Exception):
          wait_for_condition(lambda: call() != pid, timeout=4)
  
      serve.run(d.bind())
  
      # Make sure redeploy happens.
      for _ in range(10):
          assert pid != call()
  
      pid = call()
  
      print("Kill GCS")
      ray.worker._global_node.kill_gcs_server()
  
      # Redeploy should fail without a change going through.
      with pytest.raises(KVStoreError):
          serve.run(d.options().bind())
  
      for _ in range(10):
          assert pid == call()
  
file_path: ray/python/ray/serve/tests/test_gcs_failure.py
imports: import os
  import sys
  import grpc
  import pytest
  import requests
  import ray
  from ray import serve
  from ray._private.test_utils import wait_for_condition
  from ray.serve._private.constants import SERVE_DEFAULT_APP_NAME
  from ray.serve._private.storage.kv_store import KVStoreError, RayInternalKVStore
  from ray.serve.context import _get_global_client
  from ray.tests.conftest import external_redis
label_desc: Use image node_id 3 for calling a global function with example usage: test_controller_gcs_failure(serve_ha, use_handle) and returns: os, ret