init_cgrules(), tries creating a directory '/etc/cgconfig.d' and relies
on stderr from RunError to check if the directory already exists and
fails on other exceptions. The exception logic can be simplified by,
passing `-p` to mkdir and fail on any RunError exceptions.
This patch replaces except UnicodeDecodeError RunError to catch
any exceptions raised when running the command
`mkdir -p /etc/cgconfig.d`.
Suggested-by: Tom Hromatka <tom.hromatka@oracle.com>
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
cmd.append('sudo')
cmd.append('mkdir')
+ cmd.append('-p')
cmd.append('/etc/cgconfig.d')
try:
config.container.run(cmd, shell_bool=True)
else:
Run.run(cmd, shell_bool=True)
- except UnicodeDecodeError as ude:
- # A unicode error is thrown when the directory already exists
- pass
+ except RunError as re:
+ raise re
cmd2 = list()