
                             S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJr	  SSKJ
r
  SSKJr  SS	KJr  SS
KJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  \R0                   " S S\R2                  5      5       rg)zDiagnose cluster command.    )absolute_import)division)unicode_literals)encoding)dataproc)
exceptions)storage_helpers)util)actions)base)flags)	arg_utils)log)retryc                   V    \ rS rSrSrSS0r\S 5       r\S 5       r	\S 5       r
S rS	rg
)Diagnose$   z'Run a detailed diagnostic on a cluster.EXAMPLESzT
    To diagnose a cluster, run:

      $ {command} my-cluster --region=us-central1
c                     [         R                  " USS9  [        R                  " U R	                  5       5      n[         R
                  " USUR                  5        [        R                  X5        g )N30m)defaultdiagnose)	r   AddTimeoutFlagdpDataprocReleaseTrackAddClusterResourceArgapi_versionr   addDiagnoseFlags)clsparserr   s      )lib/surface/dataproc/clusters/diagnose.pyArgsDiagnose.Args0   sQ     
/{{3++-.H	
H4H4HIf/    c                     U R                   R                  R                  nUR                  5        Vs/ s H!  nUS:w  d  M  [        R
                  " U5      PM#     sn$ s  snf )NTARBALL_ACCESS_UNSPECIFIED)messagesDiagnoseClusterRequestTarballAccessValueValuesEnumnamesr   ChoiceToEnumName)r   tarball_access_enumsns      r"   _GetValidTarballAccessChoices&Diagnose._GetValidTarballAccessChoices8   sd     	00MM 
 &++--A,, 	&	""1%-  s   
AAc                    U R                  S[        R                  [        R	                  U5      SS9  U R                  SSS9  U R                  SSS9  U R                  S	S
S[
        R                  " S	SSS9S9  U R                  SS
S[
        R                  " SSSS9S9  U R                  SS
SS9  U R                  SSS9  U R                  SSS9  U R                  SSS9  g )Nz--tarball-accessz0Target access privileges for diagnostic tarball.)typechoiceshelpz--start-timezKTime instant to start the diagnosis from (in %Y-%m-%dT%H:%M:%S.%fZ format).)r4   z
--end-timezHTime instant to stop the diagnosis at (in %Y-%m-%dT%H:%M:%S.%fZ format).z--job-idTz*The job on which to perform the diagnosis.zdThe {flag_name} option is deprecated and will be removed in upcoming release; use --job-ids instead.F)warnremoved)hiddenr4   actionz--yarn-application-idz7The yarn application on which to perform the diagnosis.zqThe {flag_name} option is deprecated and will be removed in upcoming release; use --yarn-application-ids instead.z	--workerszAA list of workers in the cluster to run the diagnostic script on.)r7   r4   z	--job-idsz1A list of jobs on which to perform the diagnosis.z--yarn-application-idsz>A list of yarn applications on which to perform the diagnosis.z--tarball-gcs-dirzThe output Cloud Storage directory for the diagnostic tarball. If not specified, a task-specific directory in the cluster's staging bucket will be used.)add_argumentr   r,   r   r/   r   DeprecationAction)r!   r   s     r"   r   Diagnose.addDiagnoseFlagsC   sS   
''66x@?	  A
 )  * )  * 9((< 
	   F((#I 
	     
 @    M   '  r%   c                 :  ^ [         R                  " U R                  5       5      nUR                  R                  R                  5       nS nUR                  R                  UR                  UR                  S9nUR                  R                  UR                  UR                  S9Ul        UR                  b4  UR                  R!                  UR                  R#                  S5      5        UR$                  b4  UR&                  R!                  UR$                  R#                  S5      5        UR(                  b4  UR(                  R!                  UR(                  R#                  S5      5        UR*                  bE  [,        R.                  " UR*                  UR                  R                  R0                  5      nXel        UR4                  b  UR4                  Ul        UR                  R9                  UR:                  UR<                  UR>                  US9nUR@                  RB                  RE                  U5      n[F        RH                  " UUSURJ                  S9nURL                  (       d  [N        RP                  " S5      e[R        RT                  " URL                  5      nUS   n	U	(       d  [N        RP                  " S	5      e[V        RX                  R[                  S
5        [V        RX                  R[                  S5        [\        R^                  " U	5      m[`        Rb                  " SS S9n
 U
Re                  U4S jSU4S jS9  [V        RX                  R[                  S5        U	$ ! [`        Rf                   a    [V        Rh                  " S5         NMf = f)N)jobyarnApplicationId)	startTimeendTime,)clusterNameregion	projectIddiagnoseClusterRequestz&Waiting for cluster diagnose operation)message	timeout_szOperation is missing response	outputUrizResponse is missing outputUrizOutput from diagnostic:z/-----------------------------------------------   )max_retrials	jitter_msc                  B   > T R                  [        R                  5      $ N)ReadIntoWritabler   err)driver_log_streams   r"   <lambda>Diagnose.Run.<locals>.<lambda>   s    #44SWW=r%   d   c                     > TR                   $ rM   )open)_rP   s    r"   rQ   rR      s    %6%;%;r%   )sleep_msshould_retry_ifzFDiagnostic finished successfully, but output did not finish streaming.)5r   r   r   CONCEPTSclusterParser(   r)   job_idyarn_application_idInterval
start_timeend_timediagnosisIntervaljob_idsjobsextendsplityarn_application_idsyarnApplicationIdsworkerstarball_accessr   ChoiceToEnumr*   tarballAccesstarball_gcs_dirtarballGcsDir.DataprocProjectsRegionsClustersDiagnoseRequestrB   rC   rD   clientprojects_regions_clustersr   r
   WaitForOperationtimeoutresponser   OperationErrorr   MessageToDictr   rO   Printr	   StorageObjectSeriesStreamr   RetryerRetryOnResultMaxRetrialsExceptionwarning)selfargsr   cluster_refrequestdiagnose_requestri   	operation
properties
output_uriread_retrierrP   s              @r"   RunDiagnose.Run   s   {{4,,./H--''--/KG((??KK4+C+C @  *2):):)C)C// *D *& ||""4<<#5#5c#:;  ,))00

#
#
)
)#
.0||%%dll&8&8&=>& --






2
2
O
OQn (6$''+';';$NN++!!''/	 O 1G 99BB7KI%%8,,	 I %%&EFF''	(:(:;JK(J%%&EFFGGMM+,GGMMCD'AA ==a4@L2  
=; ! = GGMMCD %% 2	kk122s   3M- -*NN N)__name__
__module____qualname____firstlineno____doc__detailed_helpclassmethodr#   staticmethodr/   r   r   __static_attributes__r   r%   r"   r   r   $   sY    /  - 0 0   : :xCr%   r   N)r   
__future__r   r   r   apitools.base.pyr   googlecloudsdk.api_lib.dataprocr   r   r   r	   r
   googlecloudsdk.callioper   r   #googlecloudsdk.command_lib.dataprocr   $googlecloudsdk.command_lib.util.apisr   googlecloudsdk.corer   googlecloudsdk.core.utilr   UniverseCompatibleCommandr   r   r%   r"   <module>r      s\       &  ' % : 6 ; 0 + ( 5 : # * ^t|| ^ ^r%   