Skip to content

Commit

Permalink
BOR-449: fb_apt: Add apt_update_strace_path
Browse files Browse the repository at this point in the history
  • Loading branch information
adsr committed Mar 15, 2024
1 parent d290feb commit 43d3004
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
8 changes: 8 additions & 0 deletions cookbooks/fb_apt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Attributes
* node['fb_apt']['preserve_unknown_keyrings']
* node['fb_apt']['allow_modified_pkg_keyrings']
* node['fb_apt']['apt_update_log_path']
* node['fb_apt']['apt_update_strace_path']

Usage
-----
Expand Down Expand Up @@ -113,3 +114,10 @@ want to use Chef to upgrade across distros, however, you can set
Set `node['fb_apt']['apt_update_log_path']` to log stdout and stderr of the
`apt-get update` command invoked by this cookbook. This may be useful for
debugging purposes. The caller must handle log rotation.

Similarly, set `node['fb_apt']['apt_update_strace_path']` to capture strace
output of the `apt-get update` command invoked by this cookbook. This may be
useful for debugging purposes. Set `node['fb_apt']['apt_update_strace_flags']`
to override the default strace flags (`-v -f -yy -Y -ttt -T -s4096 -A`). Note
that by default, the log is appended to on each invocation. The caller must
handle log rotation.
2 changes: 2 additions & 0 deletions cookbooks/fb_apt/attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
'preserve_unknown_keyrings' => false,
'allow_modified_pkg_keyrings' => false,
'apt_update_log_path' => nil,
'apt_update_strace_path' => nil,
'apt_update_strace_flags' => '-v -f -yy -Y -ttt -T -s4096 -A',
}
# fb_apt must be defined for this to work...
keys = FB::Apt.get_official_keyids(node).map { |id| [id, nil] }.to_h
Expand Down
7 changes: 5 additions & 2 deletions cookbooks/fb_apt/recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,11 @@
execute 'apt-get update' do
command(lazy do
log_path = node['fb_apt']['apt_update_log_path']
cmd_suffix = " >>#{Shellwords.shellescape(log_path)} 2>&1" if log_path
"apt-get update#{cmd_suffix}"
strace_path = node['fb_apt']['apt_update_strace_path']
strace_flags = node['fb_apt']['apt_update_strace_flags']
cmd_suffix = " >>#{log_path.shellescape} 2>&1" if log_path
cmd_prefix = "strace #{strace_flags} -o #{strace_path.shellescape} " if strace_path && ::File.exist?('/usr/bin/strace')
"#{cmd_prefix}apt-get update#{cmd_suffix}"
end)
action :nothing
end
Expand Down

0 comments on commit 43d3004

Please sign in to comment.