voxpupuli / puppet-jenkins

Puppet module for Jenkins
http://forge.puppetlabs.com/puppet/jenkins
Apache License 2.0
275 stars 565 forks source link

jenkins_plugins fact is locale-dependent which can cause a plugin installation loop #993

Open aptituz opened 4 years ago

aptituz commented 4 years ago

Affected Puppet, Ruby, OS and module versions/distributions

How to reproduce (e.g Puppet code you use)

The problem is triggered when installing plugins, for which the manifest contains UTF-8 sequences. This is the case, for example, when jenkins::plugins_hash contains the ws-cleanup plugin in version 0.38.

The problem can then be reproduced in two ways:

  1. Invoking puppet agent with a non utf8 locale, like C.
  2. Invoking facter without any modifications to the locale configuration.
LANG=C puppet agent -t

When invoking facter directly, the problem seems to be independent from the locale, so just running

facter -p jenkins_plugins

should be enough to reproduce it.

What are you seeing

When running puppet it will try to install some plugins again and again. In the facter output the plugins will be missing.

What behaviour did you expect instead

I would expect the plugin to install modules only once and the jenkins_plugins fact to return all facts.

Any additional information you'd like to impart

We are running puppet as part of bootstrapping machines via cloud-init. In this constellation puppet runs with a very minimal environment and in this case this means that no LANG variable is set.

The problem can be traced down to the code that reads the manifest file (https://github.com/voxpupuli/puppet-jenkins/blob/master/lib/puppet/jenkins/plugins.rb#L57). In files that contain UTF-8 sequences this would trigger an exception which leads to the plugin being excluded from the output.

A possible fix is to to change the File.read invocation like this:

File.read(manifest, :encoding => 'UTF-8')
ekohl commented 4 years ago

I wonder if this explains the EL7 acceptance test failure in docker. Could you come up with a patch?

ekohl commented 4 years ago

I opened https://github.com/voxpupuli/puppet-jenkins/pull/996 with your suggestion to see if it fixes the EL7 Docker install test.