Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Ambari 2.7.3 Dashboard "Yarn Container" widget shows n/a when number of containers is other than 0

avatar
Explorer

"Yarn Container" widget shows 0/0/0 when no containers are allocated,pending or reserved, but if any of the 3 metrics changed, the widget shows n/a, wonder if it is a bug or not?

1 ACCEPTED SOLUTION

avatar
Master Mentor

@JayZhang 


Until the mentioned JIRA is fixed permanently can you  please try this workaround. One time One line change inside the "/usr/lib/ambari-server/web/javascripts/app.js" file should work.

 

Step-1). Take a Safe Backup of the file "/usr/lib/ambari-server/web/javascripts/app.js" on ambari server host.

 

# cp -f /usr/lib/ambari-server/web/javascripts/app.js /PATH/To/Backup/app.js.ORIGINAL

 


Step-2). Also just above the "App.YarnContainersView = App.TextDashboardWidgetView.extend" line inside the above file you will see a function declaration like "counterOr" we will need to make one change there.

(BEFORE CHANGE)

 

# grep -B12 'App.YarnContainersView' /usr/lib/ambari-server/web/javascripts/app.js

var App = require('app');

function counterOrNA(key) {
  var _key = 'model.{0}.length'.format(key);
  return Em.computed(_key, function () {
    if (Em.isNone(this.get('model.' + key)) || this.get('model.metricsNotAvailable')) {
      return Em.I18n.t('services.service.summary.notAvailable');
    }
    return this.get(_key);
  });
}

 

 

Step-3).  IN the above function block you will see a line as "var _key = 'model.{0}.length'.format(key);"
We need to just remove the ".length" work from that string.

(AFTER CHANGE)

 

# grep -B12 'App.YarnContainersView' /usr/lib/ambari-server/web/javascripts/app.js 

var App = require('app');

function counterOrNA(key) {
  var _key = 'model.{0}'.format(key);
  return Em.computed(_key, function () {
    if (Em.isNone(this.get('model.' + key)) || this.get('model.metricsNotAvailable')) {
      return Em.I18n.t('services.service.summary.notAvailable');
    }
    return this.get(_key);
  });
}

 


Step-4).  Save the file and then Hard Refresh the Browser. On Mac (command + Shift + R)

View solution in original post

7 REPLIES 7

avatar
Explorer

Screenshot_1.png

avatar
New Contributor

I am facing same issue with ambari 2.7.3 dashboard. Is this a bug? 

https://issues.apache.org/jira/browse/AMBARI-25170

avatar
Explorer

AMBARI-25170 was closed as "not a problem", obviously the reporter hadn't tested with container change.

avatar
New Contributor

Hello,

 

Could you please add  more insights here please to understand it explicitly. What do you mean by container change, is there a resolution for the mentioned issue. 

avatar
Master Mentor

@JayZhang 


Until the mentioned JIRA is fixed permanently can you  please try this workaround. One time One line change inside the "/usr/lib/ambari-server/web/javascripts/app.js" file should work.

 

Step-1). Take a Safe Backup of the file "/usr/lib/ambari-server/web/javascripts/app.js" on ambari server host.

 

# cp -f /usr/lib/ambari-server/web/javascripts/app.js /PATH/To/Backup/app.js.ORIGINAL

 


Step-2). Also just above the "App.YarnContainersView = App.TextDashboardWidgetView.extend" line inside the above file you will see a function declaration like "counterOr" we will need to make one change there.

(BEFORE CHANGE)

 

# grep -B12 'App.YarnContainersView' /usr/lib/ambari-server/web/javascripts/app.js

var App = require('app');

function counterOrNA(key) {
  var _key = 'model.{0}.length'.format(key);
  return Em.computed(_key, function () {
    if (Em.isNone(this.get('model.' + key)) || this.get('model.metricsNotAvailable')) {
      return Em.I18n.t('services.service.summary.notAvailable');
    }
    return this.get(_key);
  });
}

 

 

Step-3).  IN the above function block you will see a line as "var _key = 'model.{0}.length'.format(key);"
We need to just remove the ".length" work from that string.

(AFTER CHANGE)

 

# grep -B12 'App.YarnContainersView' /usr/lib/ambari-server/web/javascripts/app.js 

var App = require('app');

function counterOrNA(key) {
  var _key = 'model.{0}'.format(key);
  return Em.computed(_key, function () {
    if (Em.isNone(this.get('model.' + key)) || this.get('model.metricsNotAvailable')) {
      return Em.I18n.t('services.service.summary.notAvailable');
    }
    return this.get(_key);
  });
}

 


Step-4).  Save the file and then Hard Refresh the Browser. On Mac (command + Shift + R)

avatar
Explorer

@jsensharma  It works after the change. Thanks a lot for your help! 

avatar
New Contributor

Hey @jsensharma , 
  Thanks for providing patch for this issue. I tested patch from https://github.com/apache/ambari/pull/3125/commits/973bb3fafdfb3c8e1f8516ca7a6efbb27897fb11 and it fix issue for yarn container metric.

But above accepted solution does not work for "yarn container" metrics. Trick is to find correct counterOrNA function as this function is available at 4 places in app.js file . Just thought to let you and others know. 

Regards

Ajit Mote