vmware-archive / service-metrics-release

Service Metrics BOSH Release
https://docs.pivotal.io/svc-sdk/service-metrics
Apache License 2.0
2 stars 11 forks source link

Replace unicode quote with ascii quote #4

Closed vlad-stoian closed 6 years ago

vlad-stoian commented 6 years ago

[#153251787]

Signed-off-by: Vlad Stoian vstoian@pivotal.io

cf-gitbot commented 6 years ago

We have created an issue in Pivotal Tracker to manage this. Unfortunately, the Pivotal Tracker project is private so you may be unable to view the contents of the story.

The labels on this github issue will be updated when the story is started.

avade commented 6 years ago

@vlad-stoian can you share any analysis of why this happens? It's in a comment block, so wouldn't have thought it would cause an issue.

vlad-stoian commented 6 years ago

I would've never guessed it as well.

We started seeing the problem when we tried using special characters in RabbitMQ passwords. OpsManager will transform some of them using the Unicode encoding. For example & will be passed into the BOSH manifest as \u0026. When we used & in our passwords, we started seeing this BOSH error:

Task 75379 | 15:32:33 | Error: Unable to render instance groups for deployment. Errors are:
   - Unable to render jobs for instance group 'rmq'. Errors are:
     - Unable to render templates for job 'service-metrics'. Errors are:
       - Error filling in template 'service_metrics_ctl.erb' (line 56: incompatible character encodings: ASCII-8BIT and UTF-8)

The service-metrics job was set up something along these lines:

  - name: service-metrics
    properties:
      service_metrics:
        execution_interval_seconds: 30
        metrics_command: "/var/vcap/packages/rabbitmq-server-metrics/bin/rabbitmq-server-metrics"
        metrics_command_args:
        - "-erlangBinPath=/var/vcap/packages/erlang/bin/"
        - "-rabbitmqCtlPath=/var/vcap/packages/rabbitmq-server/bin/rabbitmqctl"
        - "-logPath=/var/vcap/sys/log/service-metrics/rabbitmq-server-metrics.log"
        - "-rabbitmqUsername=admin"
        - "-rabbitmqPassword=!@£$%^\u0026*()_+=-:;?"
        - "-rabbitmqApiEndpoint=http://127.0.0.1:15672"
        origin: cf-rabbitmq-153251787

There are a few interesting observations here:

  1. The same string in our own release, cf-rabbitmq-release, does not have the same effect.
  2. Moving the line that contains !@£$%^\u0026*()_+=-:;? from service_metrics.metrics_command_args to service_metrics.origin, or anywhere else, still has the issue, so we pinpointed the problem was with the service_metrics_ctl.erb file in particular.
  3. Running file -I service_metrics_ctl.erb gave this output charset=utf-8 as opposed to all of our bosh templates which are charset=us-ascii
  4. We ran a command similar to iconv -f utf-8 -t ascii//TRANSLIT < service_metrics_ctl.erb > service_metrics_ctl.erb.reencoded and then did a diff, and the only character that was different was that one quote character

The last thing was testing this crazy hypothesis that that one quote was affecting everything. We manually created a service metrics with the ascii version of the quote, tested it, and it worked.

The reason we changed it everywhere is to prevent future copy-paste errors, at least in this release repo.

Hope this clarifies a little bit what the error is, although it is not quite straight forward.

avade commented 6 years ago

@cppforlife FYI this issue sounds like something that may interest you.

kirederik commented 6 years ago

Thanks!