You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2018/11/06 01:59:42 UTC

[GitHub] chikamichi opened a new issue #65: /action/exec is not executable

chikamichi opened a new issue #65: /action/exec is not executable
URL: https://github.com/apache/incubator-openwhisk-runtime-docker/issues/65
 
 
   Hi,
   
   Following along http://jamesthom.as/blog/2017/01/16/openwhisk-docker-actions/ (section _Running Locally_), I've been able to quickly iterate on a custom action/runtime, but for a specific issue: /action/exec ends up not being executable as a result of `initCodeFromZip`.
   
   The local file is 0755, but once pushed within the container as part of a base64 zip, it's 0544 (or 0744 I don't remember :see_no_evil:) and belongs to the root user. Therefore POST /init kept failing [on this line](https://github.com/apache/incubator-openwhisk-runtime-docker/blob/766419cc6ee59b74ccdd91652c3d41bb47abdc89/core/actionProxy/actionproxy.py#L104), specifically the `os.X_OK` check (which was not obvious at first but the local dev setup turned out great to debug as well).
   
   To work around the issue, I edited [both `initCode*` functions](https://github.com/apache/incubator-openwhisk-runtime-docker/blob/766419cc6ee59b74ccdd91652c3d41bb47abdc89/core/actionProxy/actionproxy.py#L187-L203) to add `os.chmod(self.source, 0755)` right before their return statements (could be refactored to DRY things up):
   
   ``` diff
        # initialize code from inlined string
        def initCodeFromString(self, message):
            with codecs.open(self.source, 'w', 'utf-8') as fp:
                fp.write(message['code'])
   +            os.chmod(self.source, 0755)
            return True
   
        # initialize code from base64 encoded archive
        def initCodeFromZip(self, message):
            try:
                bytes = base64.b64decode(message['code'])
                bytes = io.BytesIO(bytes)
                archive = zipfile.ZipFile(bytes)
                archive.extractall(self.zipdest)
                archive.close()
   +            os.chmod(self.source, 0755)
                return True
            except Exception as e:
                print('err', str(e))
                return False
   ```
   
   I'd like to believe it's a safe move to make, but I'm not sure really. What do you maintainers think? If it sounds about right, I could create a quick-win PR for this of course.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services