Skip to content

Icinga: actionExecutor.py doesn't assure the working dir while generation Zip file(s) #72

Open
@b-a-t

Description

@b-a-t

During processing of the alert integration script tries to create ZIPed observation document with histogram and trend images from Icinga.

As a first step of it it creates a ZIP file with the embedded date in the name, but doesn't specify in which directory that file will be created.

actionExecutor.py#L259

Apparently, somewhere in the process the current working directory either changes or initially set to the non-writable directory.

Hence, we are getting this error:

Executed [Create] action via OEC[integrationId: fd2c40c5-xxxxxxxxxxxxxxxxxxx integrationType: Icinga] with errors.
Reason: Err: exit status 1, Stderr: 
Traceback (most recent call last): 
File "/home/opsgenie/oec/scripts/actionExecutor.py", line 425, in <module> main() 
File "/home/opsgenie/oec/scripts/actionExecutor.py", line 408, in main send_create_request() 
File "/home/opsgenie/oec/scripts/actionExecutor.py", line 288, in send_create_request attach() 
File "/home/opsgenie/oec/scripts/actionExecutor.py", line 261, in attach zip = zipfile.ZipFile(file_name, 'w') 
File "/usr/lib64/python3.6/zipfile.py", line 1113, in __init__ self.fp = io.open(file, filemode) PermissionError: [Errno 13] 
Permission denied: 'details_2021_03_21_21_03_1616359507.zip' 

Either script should set CWD in the beginning to it's home directory(and hope it's writable) or should use /tmp or /var/tmp for creating a temporary ZIP file or should have an option to specify writable tmp directory and use it in the filename.

Also, readability of the script may benefit from using f'strings or format...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions