You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ambari.apache.org by xi...@sky-data.cn on 2018/06/25 08:01:40 UTC

why status can not use config['configurations']

Hi! 

config = Script.get_config() 
Then I want to use config['configurations']['ntpd']['deploy'] in status function, but it says: 

Fail: Configuration parameter 'ntpd' was not found in configurations dictionary! 

I also use config['configurations']['ntpd']['deploy'] in start and stop function, both ok. 

And i try to print config in status funtion, it only prints agentConfigParams. 

So how can i use config['configurations']['ntpd']['deploy']? 

Thanks. 




Re: why status can not use config['configurations']

Posted by Myroslav Papyrkovskyy <mp...@hortonworks.com>.
It is not clear what Ambari version you are referring, but I guess your
issue is that only "*-env" config types are sent to agent for status
command execution.
I believe this was done to save some bandwidth as those are pretty regular.

On 25.06.18 16:59, David Quiroga wrote:
> If possible can you share more code. Hard to understand what is going on.
> Are you modifying an existing script or creating a custom one?
>
> On Mon, Jun 25, 2018 at 3:01 AM, <xi...@sky-data.cn> wrote:
>
>> Hi!
>>
>> config = Script.get_config()
>> Then I want to use config['configurations']['ntpd']['deploy'] in status
>> function, but it says:
>>
>> Fail: Configuration parameter 'ntpd' was not found in configurations
>> dictionary!
>>
>> I also use config['configurations']['ntpd']['deploy'] in start and stop
>> function, both ok.
>>
>> And i try to print config in status funtion, it only prints
>> agentConfigParams.
>>
>> So how can i use config['configurations']['ntpd']['deploy']?
>>
>> Thanks.
>>
>>
>>
>>




Re: why status can not use config['configurations']

Posted by David Quiroga <qu...@gmail.com>.
Something to keep in mind regarding custom status functions.
While check_process_status via a PID file is very common it is possible to
determine the status by evaluating other commands.

It need only raise ComponentIsNotRunning() when it determines a component
is not running.

Example for Storm under supervisord

https://github.com/apache/ambari/blob/a8184e8b7f6d8d247ee2ef77303c6bce55ebca39/ambari-server/src/main/resources/common-services/STORM/0.9.1/package/scripts/supervisord_service.py#L30

def supervisord_check_status(component_name):
  try:
    Execute(format("supervisorctl status storm-{component_name} | grep
RUNNING"))
  except Fail:
    raise ComponentIsNotRunning()


The command within Execute() can be modified as needed i.e. systemctl
status ntpd | grep -q \(running\)





On Tue, Jun 26, 2018 at 8:26 PM, <xi...@sky-data.cn> wrote:

> Sure, it is a workaround which i have used.
>
> In my thought, use config['configurations'] directly could be cool, right?
>
> ----- Original Message -----
> From: "Steve Varnau" <st...@esgyn.com>
> To: dev@ambari.apache.org
> Sent: Tuesday, June 26, 2018 11:45:22 PM
> Subject: RE: why status can not use config['configurations']
>
> Speaking as a novice, but it seems to me that you can write out the config
> value into a system config file (/etc/<service>/conf/...) when installing
> the service, and then the status function has to read the value from there.
>
> --Steve
>
> > -----Original Message-----
> > From: Dai Xiang <xi...@sky-data.cn>
> > Sent: Monday, June 25, 2018 6:21 PM
> > To: dev@ambari.apache.org
> > Subject: Re: why status can not use config['configurations']
> >
> > On Mon, Jun 25, 2018 at 08:59:31AM -0500, David Quiroga wrote:
> > > If possible can you share more code. Hard to understand what is going
> on.
> > > Are you modifying an existing script or creating a custom one?
> >
> > I want to create a custom service and in status function, i want to
> > read config when install which is as
> > config['configurations']['ntpd']['deploy'].
> >
> > In install/start/stop function, this val can be got as expected,
> > but in status function can not, i tried to print it and it output
> > "agentConfigParams".
> >
> > So how can i get config when install?
> >
> > >
> > > On Mon, Jun 25, 2018 at 3:01 AM, <xi...@sky-data.cn> wrote:
> > >
> > > > Hi!
> > > >
> > > > config = Script.get_config()
> > > > Then I want to use config['configurations']['ntpd']['deploy'] in
> status
> > > > function, but it says:
> > > >
> > > > Fail: Configuration parameter 'ntpd' was not found in configurations
> > > > dictionary!
> > > >
> > > > I also use config['configurations']['ntpd']['deploy'] in start and
> stop
> > > > function, both ok.
> > > >
> > > > And i try to print config in status funtion, it only prints
> > > > agentConfigParams.
> > > >
> > > > So how can i use config['configurations']['ntpd']['deploy']?
> > > >
> > > > Thanks.
> > > >
> > > >
> > > >
> > > >
> >
> > --
> > Best Regards
> > Dai Xiang
> --
> 戴翔
> 南京天数信息科技有限公司
> 电话: +86 1 3382776490
> 公司官网: www.sky-data.cn
> 免费使用天数润科智能计算平台 SkyDiscovery
>

Re: why status can not use config['configurations']

Posted by xi...@sky-data.cn.
Sure, it is a workaround which i have used.

In my thought, use config['configurations'] directly could be cool, right?

----- Original Message -----
From: "Steve Varnau" <st...@esgyn.com>
To: dev@ambari.apache.org
Sent: Tuesday, June 26, 2018 11:45:22 PM
Subject: RE: why status can not use config['configurations']

Speaking as a novice, but it seems to me that you can write out the config value into a system config file (/etc/<service>/conf/...) when installing the service, and then the status function has to read the value from there.

--Steve

> -----Original Message-----
> From: Dai Xiang <xi...@sky-data.cn>
> Sent: Monday, June 25, 2018 6:21 PM
> To: dev@ambari.apache.org
> Subject: Re: why status can not use config['configurations']
> 
> On Mon, Jun 25, 2018 at 08:59:31AM -0500, David Quiroga wrote:
> > If possible can you share more code. Hard to understand what is going on.
> > Are you modifying an existing script or creating a custom one?
> 
> I want to create a custom service and in status function, i want to
> read config when install which is as
> config['configurations']['ntpd']['deploy'].
> 
> In install/start/stop function, this val can be got as expected,
> but in status function can not, i tried to print it and it output
> "agentConfigParams".
> 
> So how can i get config when install?
> 
> >
> > On Mon, Jun 25, 2018 at 3:01 AM, <xi...@sky-data.cn> wrote:
> >
> > > Hi!
> > >
> > > config = Script.get_config()
> > > Then I want to use config['configurations']['ntpd']['deploy'] in status
> > > function, but it says:
> > >
> > > Fail: Configuration parameter 'ntpd' was not found in configurations
> > > dictionary!
> > >
> > > I also use config['configurations']['ntpd']['deploy'] in start and stop
> > > function, both ok.
> > >
> > > And i try to print config in status funtion, it only prints
> > > agentConfigParams.
> > >
> > > So how can i use config['configurations']['ntpd']['deploy']?
> > >
> > > Thanks.
> > >
> > >
> > >
> > >
> 
> --
> Best Regards
> Dai Xiang
-- 
戴翔 
南京天数信息科技有限公司 
电话: +86 1 3382776490 
公司官网: www.sky-data.cn 
免费使用天数润科智能计算平台 SkyDiscovery

RE: why status can not use config['configurations']

Posted by Steve Varnau <st...@esgyn.com>.
Speaking as a novice, but it seems to me that you can write out the config value into a system config file (/etc/<service>/conf/...) when installing the service, and then the status function has to read the value from there.

--Steve

> -----Original Message-----
> From: Dai Xiang <xi...@sky-data.cn>
> Sent: Monday, June 25, 2018 6:21 PM
> To: dev@ambari.apache.org
> Subject: Re: why status can not use config['configurations']
> 
> On Mon, Jun 25, 2018 at 08:59:31AM -0500, David Quiroga wrote:
> > If possible can you share more code. Hard to understand what is going on.
> > Are you modifying an existing script or creating a custom one?
> 
> I want to create a custom service and in status function, i want to
> read config when install which is as
> config['configurations']['ntpd']['deploy'].
> 
> In install/start/stop function, this val can be got as expected,
> but in status function can not, i tried to print it and it output
> "agentConfigParams".
> 
> So how can i get config when install?
> 
> >
> > On Mon, Jun 25, 2018 at 3:01 AM, <xi...@sky-data.cn> wrote:
> >
> > > Hi!
> > >
> > > config = Script.get_config()
> > > Then I want to use config['configurations']['ntpd']['deploy'] in status
> > > function, but it says:
> > >
> > > Fail: Configuration parameter 'ntpd' was not found in configurations
> > > dictionary!
> > >
> > > I also use config['configurations']['ntpd']['deploy'] in start and stop
> > > function, both ok.
> > >
> > > And i try to print config in status funtion, it only prints
> > > agentConfigParams.
> > >
> > > So how can i use config['configurations']['ntpd']['deploy']?
> > >
> > > Thanks.
> > >
> > >
> > >
> > >
> 
> --
> Best Regards
> Dai Xiang

Re: why status can not use config['configurations']

Posted by Dai Xiang <xi...@sky-data.cn>.
On Mon, Jun 25, 2018 at 08:59:31AM -0500, David Quiroga wrote:
> If possible can you share more code. Hard to understand what is going on.
> Are you modifying an existing script or creating a custom one?

I want to create a custom service and in status function, i want to
read config when install which is as
config['configurations']['ntpd']['deploy'].

In install/start/stop function, this val can be got as expected,
but in status function can not, i tried to print it and it output
"agentConfigParams".

So how can i get config when install?

> 
> On Mon, Jun 25, 2018 at 3:01 AM, <xi...@sky-data.cn> wrote:
> 
> > Hi!
> >
> > config = Script.get_config()
> > Then I want to use config['configurations']['ntpd']['deploy'] in status
> > function, but it says:
> >
> > Fail: Configuration parameter 'ntpd' was not found in configurations
> > dictionary!
> >
> > I also use config['configurations']['ntpd']['deploy'] in start and stop
> > function, both ok.
> >
> > And i try to print config in status funtion, it only prints
> > agentConfigParams.
> >
> > So how can i use config['configurations']['ntpd']['deploy']?
> >
> > Thanks.
> >
> >
> >
> >

-- 
Best Regards
Dai Xiang

Re: why status can not use config['configurations']

Posted by David Quiroga <qu...@gmail.com>.
If possible can you share more code. Hard to understand what is going on.
Are you modifying an existing script or creating a custom one?

On Mon, Jun 25, 2018 at 3:01 AM, <xi...@sky-data.cn> wrote:

> Hi!
>
> config = Script.get_config()
> Then I want to use config['configurations']['ntpd']['deploy'] in status
> function, but it says:
>
> Fail: Configuration parameter 'ntpd' was not found in configurations
> dictionary!
>
> I also use config['configurations']['ntpd']['deploy'] in start and stop
> function, both ok.
>
> And i try to print config in status funtion, it only prints
> agentConfigParams.
>
> So how can i use config['configurations']['ntpd']['deploy']?
>
> Thanks.
>
>
>
>