You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ranger.apache.org by me...@apache.org on 2018/10/08 13:30:21 UTC

[1/2] ranger git commit: RANGER-2229 : Perform graceful terminate with retries before doing forceful kill for usersync and tagsync

Repository: ranger
Updated Branches:
  refs/heads/ranger-1 028de96b8 -> 2a392edc1


RANGER-2229 : Perform graceful terminate with retries before doing forceful kill for usersync and tagsync

Change-Id: I5608a64dec91f7ccbd85cc8a671158f9c0764dc2

Signed-off-by: Mehul Parikh <me...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/ranger/repo
Commit: http://git-wip-us.apache.org/repos/asf/ranger/commit/2a392edc
Tree: http://git-wip-us.apache.org/repos/asf/ranger/tree/2a392edc
Diff: http://git-wip-us.apache.org/repos/asf/ranger/diff/2a392edc

Branch: refs/heads/ranger-1
Commit: 2a392edc11df2383c2d32c9833a6a7930538cce1
Parents: 3d5e5eb
Author: Bhavik Patel <bh...@gmail.com>
Authored: Wed Sep 19 16:05:32 2018 +0530
Committer: Mehul Parikh <me...@apache.org>
Committed: Mon Oct 8 18:59:02 2018 +0530

----------------------------------------------------------------------
 tagsync/scripts/ranger-tagsync-services.sh      | 44 +++++++++++++++-----
 .../scripts/ranger-usersync-services.sh         | 41 ++++++++++++++----
 2 files changed, 67 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ranger/blob/2a392edc/tagsync/scripts/ranger-tagsync-services.sh
----------------------------------------------------------------------
diff --git a/tagsync/scripts/ranger-tagsync-services.sh b/tagsync/scripts/ranger-tagsync-services.sh
index 5686390..a4ad7b1 100755
--- a/tagsync/scripts/ranger-tagsync-services.sh
+++ b/tagsync/scripts/ranger-tagsync-services.sh
@@ -111,17 +111,41 @@ elif [ "${action}" == "STOP" ]; then
 	NR_ITER_FOR_SHUTDOWN_CHECK=15
 	if [ -f "$pidf" ] ; then
 		pid=`cat $pidf` > /dev/null 2>&1
-		echo "Found Apache Ranger TagSync Service with pid $pid, Stopping..."
-		kill -9 $pid > /dev/null 2>&1
-		sleep 1 #Give kill -9 sometime to "kill"
-		if ps -p $pid > /dev/null; then
-			echo "Wow, even kill -9 failed, giving up! Sorry.."
-                else
-			rm -f $pidf
-			echo "Apache Ranger Tagsync Service pid = ${pid} has been stopped."
-                fi
+		echo "Getting pid from $pidf .."
 	else
-            echo "Ranger Tagsync Service not running"
+		pid=`ps -ef | grep java | grep -- '-Dproc_rangertagsync' | grep -v grep | awk '{ print $2 }'`
+		if [ "$pid" != "" ];then
+			echo "pid file($pidf) not present, taking pid from \'ps\' command.."
+		else
+			echo "Apache Ranger Tagsync Service is not running"
+			exit 1	
+		fi
+	fi
+	echo "Found Apache Ranger Tagsync Service with pid $pid, Stopping it..."
+	kill -15 $pid
+	for ((i=0; i<$NR_ITER_FOR_SHUTDOWN_CHECK; i++))
+	do
+		sleep $WAIT_TIME_FOR_SHUTDOWN
+		if ps -p $pid > /dev/null ; then
+			echo "Shutdown in progress. Will check after $WAIT_TIME_FOR_SHUTDOWN secs again.."
+			continue;
+		else
+			break;
+		fi
+	done
+	# if process is still around, use kill -9
+	if ps -p $pid > /dev/null ; then
+		echo "Initial kill failed, getting serious now..."
+		kill -9 $pid
+	fi
+	sleep 1 #give kill -9  sometime to "kill"
+	if ps -p $pid > /dev/null ; then
+		echo "Wow, even kill -9 failed, giving up! Sorry.."
+		exit 1
+
+	else
+		rm -rf $pidf
+		echo "Apache Ranger Tagsync Service with pid ${pid} has been stopped."
 	fi
 	exit;
 	

http://git-wip-us.apache.org/repos/asf/ranger/blob/2a392edc/unixauthservice/scripts/ranger-usersync-services.sh
----------------------------------------------------------------------
diff --git a/unixauthservice/scripts/ranger-usersync-services.sh b/unixauthservice/scripts/ranger-usersync-services.sh
index 028ad08..476aa0c 100644
--- a/unixauthservice/scripts/ranger-usersync-services.sh
+++ b/unixauthservice/scripts/ranger-usersync-services.sh
@@ -129,18 +129,43 @@ if [ "${action}" == "START" ]; then
 elif [ "${action}" == "STOP" ]; then
 	WAIT_TIME_FOR_SHUTDOWN=2
 	NR_ITER_FOR_SHUTDOWN_CHECK=15
-	if [ -f $pidf ]; then
+	if [ -f "$pidf" ] ; then
 		pid=`cat $pidf` > /dev/null 2>&1
-		kill -9 $pid > /dev/null 2>&1
-		sleep 1 #Give kill -9 sometime to "kill"
-		if ps -p $pid > /dev/null; then
-			echo "Wow, even kill -9 failed, giving up! Sorry.."
+		echo "Getting pid from $pidf .."
+	else
+		pid=`ps -ef | grep java | grep -- '-Dproc_rangerusersync' | grep -v grep | awk '{ print $2 }'`
+		if [ "$pid" != "" ];then
+			echo "pid file($pidf) not present, taking pid from \'ps\' command.."
 		else
-			rm -f $pidf
-			echo "Apache Ranger Usersync Service [pid = ${pid}] has been stopped."
+			echo "Apache Ranger Usersync Service is not running"
+			exit 1	
 		fi
+	fi
+	echo "Found Apache Ranger Usersync Service with pid $pid, Stopping it..."
+	kill -15 $pid
+	for ((i=0; i<$NR_ITER_FOR_SHUTDOWN_CHECK; i++))
+	do
+		sleep $WAIT_TIME_FOR_SHUTDOWN
+		if ps -p $pid > /dev/null ; then
+			echo "Shutdown in progress. Will check after $WAIT_TIME_FOR_SHUTDOWN secs again.."
+			continue;
+		else
+			break;
+		fi
+	done
+	# if process is still around, use kill -9
+	if ps -p $pid > /dev/null ; then
+		echo "Initial kill failed, getting serious now..."
+		kill -9 $pid
+	fi
+	sleep 1 #give kill -9  sometime to "kill"
+	if ps -p $pid > /dev/null ; then
+		echo "Wow, even kill -9 failed, giving up! Sorry.."
+		exit 1
+
 	else
-		echo "Apache Ranger Usersync Service not running"
+		rm -rf $pidf
+		echo "Apache Ranger Usersync Service with pid ${pid} has been stopped."
 	fi
 	exit;
 	


[2/2] ranger git commit: RANGER-2235: Modify the login session detail page as a modal.

Posted by me...@apache.org.
RANGER-2235: Modify the login session detail page as a modal.

Signed-off-by: peng.jianhua <pe...@zte.com.cn>


Project: http://git-wip-us.apache.org/repos/asf/ranger/repo
Commit: http://git-wip-us.apache.org/repos/asf/ranger/commit/3d5e5eb1
Tree: http://git-wip-us.apache.org/repos/asf/ranger/tree/3d5e5eb1
Diff: http://git-wip-us.apache.org/repos/asf/ranger/diff/3d5e5eb1

Branch: refs/heads/ranger-1
Commit: 3d5e5eb1c04dafb018250eee58e222cd627a0e2c
Parents: 028de96
Author: zhangqiang2 <zh...@zte.com.cn>
Authored: Wed Sep 26 16:56:13 2018 +0800
Committer: Mehul Parikh <me...@apache.org>
Committed: Mon Oct 8 18:59:02 2018 +0530

----------------------------------------------------------------------
 .../webapp/scripts/views/reports/AuditLayout.js | 86 +++++++++++++++-----
 .../scripts/views/reports/LoginSessionDetail.js | 17 +++-
 .../reports/LoginSessionDetail_tmpl.html        | 67 +++++++--------
 3 files changed, 108 insertions(+), 62 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ranger/blob/3d5e5eb1/security-admin/src/main/webapp/scripts/views/reports/AuditLayout.js
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/scripts/views/reports/AuditLayout.js b/security-admin/src/main/webapp/scripts/views/reports/AuditLayout.js
index 697d33d..3da1567 100644
--- a/security-admin/src/main/webapp/scripts/views/reports/AuditLayout.js
+++ b/security-admin/src/main/webapp/scripts/views/reports/AuditLayout.js
@@ -46,6 +46,7 @@ define(function(require) {
 	var RangerPolicy 				= require('models/RangerPolicy');
 	var RangerPolicyRO				= require('views/policies/RangerPolicyRO');
 	var vPlugableServiceDiffDetail	= require('views/reports/PlugableServiceDiffDetail');
+    var vLoginSessionDetail         = require('views/reports/LoginSessionDetail');
 
 	var moment = require('moment');
 	require('bootstrap-datepicker');
@@ -92,7 +93,8 @@ define(function(require) {
                         btnShowLess : '[data-id="showLess"]',
             iconqueryInfo : '[data-name="queryInfo"]',
             hidePopup : '[data-id="hide-popup"]',
-            syncDetailes : '[data-id="syncDetailes"]'
+            syncDetailes : '[data-id="syncDetailes"]',
+            viewSession : '[data-name="viewSession"]',
 		},
 
 		/** ui events hash */
@@ -107,6 +109,7 @@ define(function(require) {
                 events['click ' + this.ui.hidePopup]  = 'onClickOutSide';
             }
             events['click '+this.ui.syncDetailes] = 'onSyncDetailes';
+            events['click ' + this.ui.viewSession]  = 'onViewSession';
             return events;
 		},
 
@@ -923,17 +926,24 @@ define(function(require) {
 						}
 					})
 				},
-				sessionId : {
-					label : localization.tt("lbl.sessionId"),
-					cell: "uri",
-					href: function(model){
-						return '#!/reports/audit/loginSession/extSessionId/'+model.get('sessionId');
-					},
-					click : false,
-					drag : false,
-					sortable:false,
-					editable:false
-				}
+                sessionId : {
+                    label : localization.tt("lbl.sessionId"),
+                    cell: "html",
+                    click : false,
+                    drag : false,
+                    sortable:false,
+                    editable:false,
+                    formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
+                        fromRaw: function (rawValue, model) {
+                            var sessionId = model.get('sessionId');
+                            if (!_.isUndefined(sessionId)) {
+                                return '<a href="javascript:void(0);" data-name ="viewSession" data-id="'+sessionId+'" title="'+sessionId+'">'+sessionId+'</a>';
+                            } else {
+                                return '';
+                            }
+                        }
+                    })
+                }
 			};
 			return this.trxLogList.constructor.getTableCols(cols, this.trxLogList);
 		},
@@ -1196,16 +1206,23 @@ define(function(require) {
 			});
 
 			var cols = {
-				id : {
-					label : localization.tt("lbl.sessionId"),
-					cell : "uri",
-					href: function(model){
-						return '#!/reports/audit/loginSession/id/'+model.get('id');
-					},
-					editable:false,
-					sortType: 'toggle',
-					direction: 'descending'
-				},
+                id : {
+                    label : localization.tt("lbl.sessionId"),
+                    cell : "html",
+                    editable:false,
+                    sortType: 'toggle',
+                    direction: 'descending',
+                    formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
+                        fromRaw: function (rawValue, model) {
+                            var sessionId = model.get('id');
+                            if (!_.isUndefined(sessionId)) {
+                                return '<a href="javascript:void(0);" data-name ="viewSession" data-id="'+sessionId+'" title="'+sessionId+'">'+sessionId+'</a>';
+                            } else {
+                                return '';
+                            }
+                        }
+                    })
+                },
 				loginId : {
 					label : localization.tt("lbl.loginId"),
 					cell: "String",
@@ -1645,6 +1662,31 @@ define(function(require) {
         onSyncDetailes : function(e){
             XAViewUtils.syncSourceDetail(e , this);
         },
+
+        onViewSession : function(e) {
+            var authSessionList = new VXAuthSession();
+            var sessionId = $(e.currentTarget).data('id');
+            authSessionList.fetch({
+                data : {
+                    id : sessionId
+                }
+            }).done(function() {
+                var view = new vLoginSessionDetail({
+                    model : authSessionList.first()
+                });
+                var modal = new Backbone.BootstrapModal({
+                    animate : true,
+                    content : view,
+                    title : localization.tt("lbl.sessionDetail"),
+                    okText : localization.tt("lbl.ok"),
+                    allowCancel : true,
+                    escape : true
+                }).open();
+                modal.$el.addClass('modal-diff').attr('tabindex', -1);
+                modal.$el.find('.cancel').hide();
+            });
+        },
+
         isDateDifferenceMoreThanHr : function(date1, date2){
                 var diff = Math.abs(date1 - date2) / 36e5;
                 return parseInt(diff) >= 1 ? true : false;

http://git-wip-us.apache.org/repos/asf/ranger/blob/3d5e5eb1/security-admin/src/main/webapp/scripts/views/reports/LoginSessionDetail.js
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/scripts/views/reports/LoginSessionDetail.js b/security-admin/src/main/webapp/scripts/views/reports/LoginSessionDetail.js
index e92929a..a0c2c1f 100644
--- a/security-admin/src/main/webapp/scripts/views/reports/LoginSessionDetail.js
+++ b/security-admin/src/main/webapp/scripts/views/reports/LoginSessionDetail.js
@@ -77,10 +77,19 @@ define(function(require){
 		/** all post render plugin initialization */
 		initializePlugins: function(){
 		},
-                /* on show action button*/
-                showAction : function(){
-                        App.sessionId = this.model.get('id');
-                },
+        /* on show action button*/
+        showAction : function(){
+            App.sessionId = this.model.get('id');
+
+            var view = require('views/reports/AuditLayout');
+            var VXAccessAuditList = require('collections/VXAccessAuditList');
+            var accessAuditList = new VXAccessAuditList();
+            _.extend(accessAuditList.queryParams, {'sortBy' : 'eventTime'});
+            App.rContent.show(new view({
+                accessAuditList : accessAuditList,
+                tab : "admin"
+            }));
+        },
 		/** on close */
 		onClose: function(){
 		}

http://git-wip-us.apache.org/repos/asf/ranger/blob/3d5e5eb1/security-admin/src/main/webapp/templates/reports/LoginSessionDetail_tmpl.html
----------------------------------------------------------------------
diff --git a/security-admin/src/main/webapp/templates/reports/LoginSessionDetail_tmpl.html b/security-admin/src/main/webapp/templates/reports/LoginSessionDetail_tmpl.html
index b11fa83..4d62cc5 100644
--- a/security-admin/src/main/webapp/templates/reports/LoginSessionDetail_tmpl.html
+++ b/security-admin/src/main/webapp/templates/reports/LoginSessionDetail_tmpl.html
@@ -1,4 +1,4 @@
-{{!-- 
+{{!--
   Licensed to the Apache Software Foundation (ASF) under one or more
   contributor license agreements.  See the NOTICE file distributed with
   this work for additional information regarding copyright ownership.
@@ -14,39 +14,34 @@
   See the License for the specific language governing permissions and
   limitations under the License.
 --}}
-<h3 class="wrap-header bold">Session Detail:</h3>
-<div class="wrap non-collapsible">
-	<div class="datagrid-stretch-wrapper "style="margin-left: 44px; margin-top: 35px;">
-		<table class="table table-bordered table-condensed">
-	<tbody>
-		<tr>
-			<th>{{tt 'lbl.loginId'}}</th>
-			<td>{{loginId}}</td>
-		</tr>
-		<tr>
-			<th>{{tt 'lbl.result'}}</th>
-			<td>{{{convertEnumValueToLabel 'AuthStatus' authStatus}}}</td>
-		</tr>
-		<tr>
-			<th>{{tt 'lbl.loginType'}}</th>
-			<td>{{{convertEnumValueToLabel 'AuthType' authType}}}</td>
-		</tr>
-		<tr>
-			<th>{{tt 'lbl.ip'}}</th>
-			<td>{{requestIP}}</td>
-		</tr>
-		<tr>
-			<th>{{tt 'lbl.userAgent'}}</th>
-			<td>{{requestUserAgent}}</td>
-		</tr>
-		<tr>
-			<th style="width: 10%;">{{tt 'lbl.loginTime'}}</th>
-			<td data-id="loginTime"></td>
-		</tr>
-	</tbody>
-</table>
-	</div>
-        <a href="#!/reports/audit/admin" class="link-tag" data-id="showAction">Show Actions</a>
+<div class="non-collapsible">
+    <table class="table table-bordered table-condensed">
+        <tbody>
+            <tr>
+                <th>{{tt 'lbl.loginId'}}</th>
+                <td>{{loginId}}</td>
+            </tr>
+            <tr>
+                <th>{{tt 'lbl.result'}}</th>
+                <td>{{{convertEnumValueToLabel 'AuthStatus' authStatus}}}</td>
+            </tr>
+            <tr>
+                <th>{{tt 'lbl.loginType'}}</th>
+                <td>{{{convertEnumValueToLabel 'AuthType' authType}}}</td>
+            </tr>
+            <tr>
+                <th>{{tt 'lbl.ip'}}</th>
+                <td>{{requestIP}}</td>
+            </tr>
+            <tr>
+                <th>{{tt 'lbl.userAgent'}}</th>
+                <td>{{requestUserAgent}}</td>
+            </tr>
+            <tr>
+                <th style="width: 10%;">{{tt 'lbl.loginTime'}}</th>
+                <td data-id="loginTime"></td>
+            </tr>
+        </tbody>
+    </table>
+    <a href="javascript:void(0);" class="link-tag" data-id="showAction">Show Actions</a>
 </div>
-
-