Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug seen during deployment getcwd: cannot access parent directories: No such file or directory #339

Closed
Ruchira-R opened this issue Nov 2, 2022 · 5 comments

Comments

@Ruchira-R
Copy link

Ruchira-R commented Nov 2, 2022

Version : Latest version of CodeDeploy Agent.

Machine VM : Centos 7 (Linux)

Deployment : In-place
Error message : shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory

This happens when I create a new directory to copy my deployment files(Created in the BeforeInstall hook) and I remove this directory in ApplicationStart hook.

NOTE : The steps actually are successfully executed and the deployment is successful. But, the logs show this error for every step executed in the specified hooks above.

@t0shiii
Copy link
Contributor

t0shiii commented Nov 8, 2022

@Ruchira-R Can you provide some more information?
Version: Please provide the exact version of the agent. Here is the documentation on how to retrieve this info: doc

appspec: Is it possible for you to paste your whole appspec.yml file?

logs: Please provide the CodeDeploy agent logs or deployment logs which shows this error message. For information about how to retrieve this message please see this doc

@Ruchira-R
Copy link
Author

Ruchira-R commented Nov 11, 2022

@t0shiii
Version : agent_version: OFFICIAL_1.4.1-2244_rpm

appspec : Has ApplicationStop, BeforeInstall, AfterInstall, ApplicationStart

All hooks only run shell scripts.

  • ApplicationStop has an export command and has an if command and if it's true, it in turn runs a shell script, which stops the Application.
  • BeforeInstall run a few common shell script commands.
  • AfterInstall has a few conditions and runs other scripts, which are already there on the VM.
  • ApplicationStart has a few checks and starts the application - again, runs a shell script.

Currently, the ApplicationStop part is not running during the very first Deployment.

Logs

Logfile created on 2022-11-02 05:07:46 +0000 by logger.rb/41954
[2022-11-02 05:07:46.751] [d-B2BQPICUK]LifecycleEvent - BeforeInstall
[2022-11-02 05:07:46.751] [d-B2BQPICUK]Script - before_install.sh
[2022-11-02 05:07:46.771] [d-B2BQPICUK][stderr]shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
[2022-11-02 05:07:46.772] [d-B2BQPICUK][stderr]shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
[2022-11-02 05:07:46.803] [d-B2BQPICUK][stderr]shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
[2022-11-02 05:07:48.883] [d-B2BQPICUK]LifecycleEvent - AfterInstall
[2022-11-02 05:07:48.883] [d-B2BQPICUK]Script - after_install.sh
[2022-11-02 05:07:48.898] [d-B2BQPICUK][stderr]shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
[2022-11-02 05:07:48.898] [d-B2BQPICUK][stderr]shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
[2022-11-02 05:07:48.921] [d-B2BQPICUK][stderr]shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
[2022-11-02 05:07:48.924] [d-B2BQPICUK][stderr]chdir: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory

Also, the very first time I run the deployment, I only see it starting from Before Install, why does/did it not run the ApplicationStop hook? It's very weird.

DOES IT ASSUME THAT WE ARE INSTALLING THE APPLICATION THE FIRST TIME AND NOT UPDATING THE APPLICATION? (And so it doesn't run the ApplicationStop part?)

@t0shiii
Copy link
Contributor

t0shiii commented Nov 16, 2022

ApplicationStop does not run the first time a deployment is triggered for a host. This is by design since there is no application to stop the first time a deployment is run.

The error retrieving current directory: getcwd: cannot access parent directories: No such file or directory error is typically due to the current working directory no longer existing.

Please provide your full appspec.yml content.

@Ruchira-R
Copy link
Author

Ruchira-R commented Dec 1, 2022

@t0shiii
I have runas: root, and also had sudo su in all of my scripts, maybe this was cause of the issue.

It is working as expected now.

I also had another doubt, how can I make sure the Deployment shows FAILURE, even if one of the instances that were undergoing deployment have FAILED?

Currently, I'm using "CodeDeployDefault.AllAtOnce", according to the documentation, it succeeds even if one of the instances has successfully been upgraded.

I know that using "CodeDeployDefault.OneAtATime" will help but it will still show SUCCESS if the deployment to the last instance fails, is there any way I can override this feature?

I just want to STOP/make sure the deployment shows FAILURE, if any of the instances fail to upgrade during the deployment.

I have a limited amount of instances running (Using EC2/On-Prem Deployment), therefore, this is expected result needed, is there any alternative?

@aj-aws
Copy link
Contributor

aj-aws commented Dec 7, 2022

@Ruchira-R Thank you for the question. We will close this issue as the original question has been resolved. Please open a new issue re: your deployment config question.

@aj-aws aj-aws closed this as completed Dec 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants