@@ -212,41 +212,42 @@ private String getCurrentClusterId() throws ComputeGroupException {
212212 String cluster = null ;
213213 ConnectContext context = ConnectContext .get ();
214214 if (context != null ) {
215- if (!Strings .isNullOrEmpty (context .getSessionVariable ().getCloudCluster ())) {
216- cluster = context .getSessionVariable ().getCloudCluster ();
215+ // TODO(wb) rethinking whether should update err status.
216+ cluster = context .getCloudCluster ();
217+
218+ if (LOG .isDebugEnabled ()) {
219+ LOG .debug ("get compute group by context {}" , cluster );
220+ }
221+
222+ if (context .getCurrentUserIdentity () != null ) {
217223 try {
218224 ((CloudEnv ) Env .getCurrentEnv ()).checkCloudClusterPriv (cluster );
219225 } catch (Exception e ) {
220- LOG .warn ("get compute group by session context exception" );
221- throw new ComputeGroupException (String .format ("session context compute group %s check auth failed" ,
222- cluster ),
223- ComputeGroupException .FailedTypeEnum .CURRENT_USER_NO_AUTH_TO_USE_DEFAULT_COMPUTE_GROUP );
224- }
225- if (LOG .isDebugEnabled ()) {
226- LOG .debug ("get compute group by session context compute group: {}" , cluster );
227- }
228- } else {
229- cluster = context .getCloudCluster (false );
230- if (LOG .isDebugEnabled ()) {
231- LOG .debug ("get compute group by context {}" , cluster );
232- }
233- String clusterStatus = ((CloudSystemInfoService ) Env .getCurrentSystemInfo ())
234- .getCloudStatusByName (cluster );
235- if (!Strings .isNullOrEmpty (clusterStatus )
236- && Cloud .ClusterStatus .valueOf (clusterStatus )
237- == Cloud .ClusterStatus .MANUAL_SHUTDOWN ) {
238- LOG .warn ("auto start compute group {} in manual shutdown status" , cluster );
226+ LOG .warn ("check cloud cluster {} for {} auth failed." , cluster ,
227+ context .getCurrentUserIdentity ().toString ());
239228 throw new ComputeGroupException (
229+ String .format ("context compute group %s check auth failed, user is %s" ,
230+ cluster , context .getCurrentUserIdentity ().toString ()),
231+ ComputeGroupException .FailedTypeEnum .CURRENT_USER_NO_AUTH_TO_USE_DEFAULT_COMPUTE_GROUP );
232+ }
233+ }
234+
235+ String clusterStatus = ((CloudSystemInfoService ) Env .getCurrentSystemInfo ())
236+ .getCloudStatusByName (cluster );
237+ if (!Strings .isNullOrEmpty (clusterStatus )
238+ && Cloud .ClusterStatus .valueOf (clusterStatus )
239+ == Cloud .ClusterStatus .MANUAL_SHUTDOWN ) {
240+ LOG .warn ("auto start compute group {} in manual shutdown status" , cluster );
241+ throw new ComputeGroupException (
240242 String .format ("The current compute group %s has been manually shutdown" , cluster ),
241243 ComputeGroupException .FailedTypeEnum .CURRENT_COMPUTE_GROUP_BEEN_MANUAL_SHUTDOWN );
242- }
243244 }
244245 } else {
245246 if (LOG .isDebugEnabled ()) {
246247 LOG .debug ("connect context is null in getBackendId" );
247248 }
248- throw new ComputeGroupException ("connect context not set" ,
249- ComputeGroupException .FailedTypeEnum .CONNECT_CONTEXT_NOT_SET );
249+ throw new ComputeGroupException ("connect context not set cluster " ,
250+ ComputeGroupException .FailedTypeEnum .CONNECT_CONTEXT_NOT_SET );
250251 }
251252
252253 return getCloudClusterIdByName (cluster );
0 commit comments