Autoscaling using Ceilometer/Aodh failed to trigger an alarm in the openstack rocky

208 views Asked by At

Here is the document I refer to

1.sample_server.yaml

type: os.nova.server
version: 1.0
properties:
  name: cirros_server
  flavor: m1.small
  image: b86fb462-c5c2-4a08-9fe4-c9f86d05763d
  networks:
    - network: external-net

2.Execute the following command line

# openstack cluster create --profile pserver --desired-capacity 2 mycluster
# openstack cluster receiver create --type webhook --cluster mycluster --action CLUSTER_SCALE_OUT --params count=2 r_01
# export ALRM_URL01='http://vip:8777/v1/webhooks/aac3433a-40de-4d7d-830c-e0035f2a4d13/trigger?V=1&count=2'
# aodh alarm create --type gnocchi_resources_threshold --aggregation-method mean --name cpu-high --metric cpu_util --threshold 70 --comparison-operator gt --granularity 300 --evaluation-periods 1 --alarm-action $ALRM_URL01 --repeat-actions False --query metadata.user_metadata.cluster_id=$MYCLUSTER_ID --resource-type instance --resource-id f7e0e8a6-51a3-422d-b631-7ddaf65b3dfb

3.log into each cluster nodes and run some CPU burning workloads there to drive the CPU utilization high

I added log output to /usr/lib/python2.7/site-packages/aodh/notifier/rest.py when trigger the alert request

class RestAlarmNotifier(notifier.AlarmNotifier):
    def notify(self, action, alarm_id, alarm_name, severity, previous,
           current, reason, reason_data, headers=None):
    body = {'alarm_name': alarm_name, 'alarm_id': alarm_id,
            'severity': severity, 'previous': previous,
            'current': current, 'reason': reason,
            'reason_data': reason_data}
    headers['content-type'] = 'application/json'
    kwargs = {'data': json.dumps(body),
              'headers': headers}
    max_retries = self.conf.rest_notifier_max_retries
    session = requests.Session()
    LOG.info('#########################')
    LOG.info(session)
    LOG.info(kwargs)
    LOG.info(action.geturl())
    LOG.info('#########################')
    session.mount(action.geturl(),
                  requests.adapters.HTTPAdapter(max_retries=max_retries))
    resp = session.post(action.geturl(), **kwargs)
    LOG.info('$$$$$$$$$$$$$$$$$$$$$$$')
    LOG.info(resp.content)
    LOG.info('$$$$$$$$$$$$$$$$$$$$$$$')

Some error messages are output in the /var/log/aodh/notifier.log log, as follows: enter image description here

The reason is the error caused by adding the body request parameter, the direct post request can be successful, for example, using curl request without the body parameter

curl -g -i -X POST 'http://vip:8777/v1/webhooks/34e91386-7176-4b30-bc17-5c3503712696/trigger?V=1'

Aodh related version packages are as follows:

python2-aodhclient-1.1.1-1.el7.noarch
openstack-aodh-api-7.0.0-1.el7.noarch
openstack-aodh-common-7.0.0-1.el7.noarch
openstack-aodh-listener-7.0.0-1.el7.noarch
python-aodh-7.0.0-1.el7.noarch
openstack-aodh-notifier-7.0.0-1.el7.noarch
openstack-aodh-evaluator-7.0.0-1.el7.noarch
openstack-aodh-expirer-7.0.0-1.el7.noarch

Can anyone point me in the right direction? Thanks.

1

There are 1 answers

0
Jobin On

The problem has been solved. Here is the document I refer to

  1. Modify aodh rest.py(aodh/notifier/rest.py) https://github.com/openstack/aodh/blob/master/aodh/notifier/rest.py#L79 Under the headers['content-type'] , add this line: headers['openstack-api-version'] = 'clustering 1.10'

  2. Restart aodh service