Jenkins is restarted on every Puppet Agent run
This is always happening when I manually run Puppet Agent in our Jenkins VM:
Info: Applying configuration version '1652881148'
Notice: /Stage[main]/Loginrecords::Btmp::Enable/File[/var/log/btmp]/ensure: removed (corrective)
Notice: /Stage[main]/Loginrecords::Lastlog::Enable/File[/var/log/lastlog]/ensure: removed (corrective)
Notice: /Stage[main]/Loginrecords::Utmp::Unprotect/File[/var/run/utmp]/mode: mode changed '0664' to '0660' (corrective)
Notice: /Stage[main]/Loginrecords::Wtmp::Enable/File[/var/log/wtmp]/ensure: removed (corrective)
Notice: /Stage[main]/Tails::Jenkins::Master/Jenkins::Plugin[resource-disposer]/Exec[force resource-disposer.jpi-0.17]/returns: executed successfull
y (corrective)
Notice: /Stage[main]/Tails::Jenkins::Master/Jenkins::Plugin[resource-disposer]/Archive[resource-disposer.jpi]/ensure: download archive from https:/
/updates.jenkins.io/download/plugins/resource-disposer/0.17/resource-disposer.hpi to /var/lib/jenkins/plugins/resource-disposer.jpi without cleanu
p (corrective)
Info: /Stage[main]/Tails::Jenkins::Master/Jenkins::Plugin[resource-disposer]/Archive[resource-disposer.jpi]: Scheduling refresh of Class[Jenkins::S
ervice]
Notice: /Stage[main]/Tails::Jenkins::Master/Jenkins::Plugin[resource-disposer]/File[/var/lib/jenkins/plugins/resource-disposer.jpi]/owner: owner ch
anged 'root' to 'jenkins' (corrective)
Notice: /Stage[main]/Tails::Jenkins::Master/Jenkins::Plugin[resource-disposer]/File[/var/lib/jenkins/plugins/resource-disposer.jpi]/group: group ch
anged 'root' to 'jenkins' (corrective)
Notice: /Stage[main]/Tails::Jenkins::Master/Jenkins::Plugin[ws-cleanup]/Exec[force ws-cleanup.jpi-0.40]/returns: executed successfully (corrective)
Notice: /Stage[main]/Tails::Jenkins::Master/Jenkins::Plugin[ws-cleanup]/Archive[ws-cleanup.jpi]/ensure: download archive from https://updates.jenki
ns.io/download/plugins/ws-cleanup/0.40/ws-cleanup.hpi to /var/lib/jenkins/plugins/ws-cleanup.jpi without cleanup (corrective) Info: /Stage[main]/Tails::Jenkins::Master/Jenkins::Plugin[ws-cleanup]/Archive[ws-cleanup.jpi]: Scheduling refresh of Class[Jenkins::Service]
Notice: /Stage[main]/Tails::Jenkins::Master/Jenkins::Plugin[ws-cleanup]/File[/var/lib/jenkins/plugins/ws-cleanup.jpi]/owner: owner changed 'root' t
o 'jenkins' (corrective)
Notice: /Stage[main]/Tails::Jenkins::Master/Jenkins::Plugin[ws-cleanup]/File[/var/lib/jenkins/plugins/ws-cleanup.jpi]/group: group changed 'root' t
o 'jenkins' (corrective)
Info: Class[Jenkins::Service]: Scheduling refresh of Service[jenkins]
I found that the metadata files for the ws-cleanup
and resource-disposer
plugins contain non-ASCII characters:
zen@jenkins ~> for i in /var/lib/jenkins/plugins/*/META-INF/MANIFEST.MF; file $i; end | grep -v ASCII
/var/lib/jenkins/plugins/resource-disposer/META-INF/MANIFEST.MF: UTF-8 Unicode text, with CRLF line terminators
/var/lib/jenkins/plugins/ws-cleanup/META-INF/MANIFEST.MF: UTF-8 Unicode text, with CRLF line terminators
And this is causing trouble to Ruby when parsing their metadata file contents to conclude that those plugins are already installed:
zen@jenkins ~> irb
irb(main):001:0> c = File.read('/var/lib/jenkins/plugins/ws-cleanup/META-INF/MANIFEST.MF')
=> "Manifest-Version: 1.0\r\nHudson-Version: 2.235.5\r\nPlugin-Dependencies: matrix-project:1.18,resource-disposer:0.16,struct\r\n s:1.23\r\nI...
irb(main):002:0> c.split("\n")
Traceback (most recent call last):
5: from /usr/bin/irb:23:in `<main>'
4: from /usr/bin/irb:23:in `load'
3: from /usr/lib/ruby/gems/2.7.0/gems/irb-1.2.6/exe/irb:11:in `<top (required)>'
2: from (irb):2
1: from (irb):2:in `split'
ArgumentError (invalid byte sequence in US-ASCII)
I found that this workaround in the Jenkins Puppet module fixes the issue:
$ git diff
diff --git a/lib/puppet/jenkins/plugins.rb b/lib/puppet/jenkins/plugins.rb
index 59edc43..c31a2e3 100644
--- a/lib/puppet/jenkins/plugins.rb
+++ b/lib/puppet/jenkins/plugins.rb
@@ -12,7 +12,7 @@ module Puppet
return {} if manifest_str.nil? || manifest_str.empty?
data = {}
- manifest_str.split("\n").each do |line|
+ manifest_str.encode('UTF-8', :invalid => :replace).split("\n").each do |line|
next if line.empty?
# Parse out "Plugin-Version: 1.2" for example
parts = line.split(': ')
I don't yet know why we haven't noticed this before.
Edited by Zen Fu