def test_project_configuration_gcloud(self, mock_execute_kubectl_command): """Tests gcloud commands.""" dkc.get_kubectl_configuration(dkc.Commands.GET_PODS) mock_execute_kubectl_command.assert_called_once_with( ['get', 'pods', '--all-namespaces'], human_readable=False) dkc.get_kubectl_configuration(dkc.Commands.GET_CONFIGURED_CONTEXT) mock_execute_kubectl_command.assert_called_with(['config', 'view'], human_readable=False) dkc.get_kubectl_configuration(dkc.Commands.GET_KUBECTL_VERSION) mock_execute_kubectl_command.assert_called_with(['version'], human_readable=False) dkc.get_kubectl_configuration(dkc.Commands.GET_PODS, kubernetes_context='test_context') mock_execute_kubectl_command.assert_called_with( ['get', 'pods', '--context', 'test_context', '--all-namespaces'], human_readable=False) dkc.get_kubectl_configuration(dkc.Commands.GET_PODS, kubernetes_context='test_context') mock_execute_kubectl_command.assert_called_with( ['get', 'pods', '--context', 'test_context', '--all-namespaces'], human_readable=False)
def diagnose_me(ctx, json, project_id, namespace): """Runs environment diagnostic with specified parameters. Feature stage: [Alpha](https://github.com/kubeflow/pipelines/blob/07328e5094ac2981d3059314cc848fbb71437a76/docs/release/feature-stages.md#alpha) """ # validate kubectl, gcloud , and gsutil exist local_env_gcloud_sdk = gcp.get_gcp_configuration( gcp.Commands.GET_GCLOUD_VERSION, project_id=project_id, human_readable=False) for app in ['Google Cloud SDK', 'gsutil', 'kubectl']: if app not in local_env_gcloud_sdk.json_output: raise RuntimeError( '%s is not installed, gcloud, gsutil and kubectl are required ' % app + 'for this app to run. Please follow instructions at ' + 'https://cloud.google.com/sdk/install to install the SDK.') click.echo('Collecting diagnostic information ...', file=sys.stderr) # default behaviour dump all configurations results = {} for gcp_command in gcp.Commands: results[gcp_command] = gcp.get_gcp_configuration( gcp_command, project_id=project_id, human_readable=not json) for k8_command in k8.Commands: results[k8_command] = k8.get_kubectl_configuration( k8_command, human_readable=not json) for dev_env_command in dev_env.Commands: results[dev_env_command] = dev_env.get_dev_env_configuration( dev_env_command, human_readable=not json) print_to_sdtout(results, not json)
def diagnose_me(ctx: click.Context, json: bool, project_id: str, namespace: str): """Runs KFP environment diagnostic.""" # validate kubectl, gcloud , and gsutil exist local_env_gcloud_sdk = gcp.get_gcp_configuration( gcp.Commands.GET_GCLOUD_VERSION, project_id=project_id, human_readable=False) for app in ['Google Cloud SDK', 'gsutil', 'kubectl']: if app not in local_env_gcloud_sdk.json_output: raise RuntimeError( f'{app} is not installed, gcloud, gsutil and kubectl are required ' + 'for this app to run. Please follow instructions at ' + 'https://cloud.google.com/sdk/install to install the SDK.') click.echo('Collecting diagnostic information ...', file=sys.stderr) # default behaviour dump all configurations results: ResultsType = { gcp_command: gcp.get_gcp_configuration(gcp_command, project_id=project_id, human_readable=not json) for gcp_command in gcp.Commands } for k8_command in k8.Commands: results[k8_command] = k8.get_kubectl_configuration( k8_command, human_readable=not json) for dev_env_command in dev_env.Commands: results[dev_env_command] = dev_env.get_dev_env_configuration( dev_env_command, human_readable=not json) print_to_sdtout(results, not json)