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

SSH Commands Randomly Failing on the Server #306

Open
erhanurgun opened this issue Oct 4, 2024 · 8 comments
Open

SSH Commands Randomly Failing on the Server #306

erhanurgun opened this issue Oct 4, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@erhanurgun
Copy link

Describe the bug
I am encountering an ongoing issue with SSH commands on the server, where I am frequently seeing the error "SSH command failed with an error" even when no changes have been made. This has caused disruption to normal operations, and I am unsure of the root cause. Below is the specific error message and trace that appears.

Error snippet:

if ($this->connection->getExitStatus() !== 0 || Str::contains($output, 'VITO_SSH_ERROR')) {
  throw new SSHCommandError('SSH command failed with an error', $this->connection->getExitStatus());
}

To Reproduce

  1. Go to the server instance where the SSH command is executed.
  2. Run the command under normal operation conditions (such as SSL delete, Nginx vhost update, etc.).
  3. Observe that the error occurs without any changes or specific trigger.

Expected behavior
I expect the SSH command to execute successfully without throwing this error when no changes are made to the server setup or commands being executed.

Screenshots
vito_bug_ss

Additional context
This error appears to occur randomly, and no alterations have been made to the server or environment. I believe it may be related to how the SSH connection is handled or managed. Any insights or potential fixes would be greatly appreciated, as this issue is negatively impacting our workflow.

@erhanurgun erhanurgun added the bug Something isn't working label Oct 4, 2024
@erhanurgun
Copy link
Author

#257 I would like to point out that I opened this issue considering that the solution mentioned here does not suit me !!!

@saeedvaziry
Copy link
Member

SSHCommandError is a general error when an ssh command that is being ran on your server by Vito is exited with status 1 which means failed. It can be anything, so you need to take a look at the logs to see why the command failed.

@erhanurgun
Copy link
Author

SSHCommandError is a general error when an ssh command that is being ran on your server by Vito is exited with status 1 which means failed. It can be anything, so you need to take a look at the logs to see why the command failed.

This error in your Laravel project indicates a problem with the execution of an SSH command.

I haven't come across a detailed error log, only this log appears... The only conclusion I can draw from this is that the main cause of the error is App\Exceptions\SSHCommandError.

Context:

{
  "userId": 1,
  "exception": "[object] (App\\Exceptions\\SSHCommandError(code: 1): SSH command failed with an error at /home/vito/vito/app/Helpers/SSH.php:133)
[stacktrace]
#0 /home/vito/vito/app/SSH/Services/Webserver/Nginx.php(69): App\\Helpers\\SSH->exec()
#1 /home/vito/vito/app/SSH/Services/Webserver/Nginx.php(162): App\\SSH\\Services\\Webserver\\Nginx->updateVHost()
#2 /home/vito/vito/app/Actions/SSL/DeleteSSL.php(11): App\\SSH\\Services\\Webserver\\Nginx->removeSSL()
#3 /home/vito/vito/app/Http/Controllers/SSLController.php(44): App\\Actions\\SSL\\DeleteSSL->delete()
#4 /home/vito/vito/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): App\\Http\\Controllers\\SSLController->destroy()
#5 /home/vito/vito/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(43): Illuminate\\Routing\\Controller->callAction()
#6 /home/vito/vito/vendor/laravel/framework/src/Illuminate/Routing/Route.php(262): Illuminate\\Routing\\ControllerDispatcher->dispatch()
#7 /home/vito/vito/vendor/laravel/framework/src/Illuminate/Routing/Route.php(208): Illuminate\\Routing\\Route->runController()
#8 /home/vito/vito/vendor/laravel/framework/src/Illuminate/Routing/Router.php(808): Illuminate\\Routing\\Route->run()
#9 /home/vito/vito/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(144): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}()
#10 /home/vito/vito/app/Http/Middleware/HandleSSHErrors.php(16): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#11 /home/vito/vito/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): App\\Http\\Middleware\\HandleSSHErrors->handle()
#12 /home/vito/vito/app/Http/Middleware/ServerIsReadyMiddleware.php(24): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#13 /home/vito/vito/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): App\\Http\\Middleware\\ServerIsReadyMiddleware->handle()
#14 /home/vito/vito/app/Http/Middleware/SelectCurrentProject.php(30): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#15 /home/vito/vito/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): App\\Http\\Middleware\\SelectCurrentProject->handle()
#16 /home/vito/vito/app/Http/Middleware/MustHaveCurrentProject.php(29): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#17 /home/vito/vito/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): App\\Http\\Middleware\\MustHaveCurrentProject->handle()
#18 /home/vito/vito/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(51): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#19 /home/vito/vito/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle()
#20 /home/vito/vito/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php(64): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#21 /home/vito/vito/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Auth\\Middleware\\Authenticate->handle()
#22 /home/vito/vito/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(88): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#23 /home/vito/vito/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle()
#24 /home/vito/vito/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#25 /home/vito/vito/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle()
#26 /home/vito/vito/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(121): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#27 /home/vito/vito/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\\Session\\Middleware\\StartSession->handleStatefulRequest()
#28 /home/vito/vito/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Session\\Middleware\\StartSession->handle()
#29 /home/vito/vito/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#30 /home/vito/vito/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle()
#31 /home/vito/vito/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(75): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#32 /home/vito/vito/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle()
#33 /home/vito/vito/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(119): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#34 /home/vito/vito/vendor/laravel/framework/src/Illuminate/Routing/Router.php(807): Illuminate\\Pipeline\\Pipeline->then()
#35 /home/vito/vito/vendor/laravel/framework/src/Illuminate/Routing/Router.php(786): Illuminate\\Routing\\Router->runRouteWithinStack()
#36 /home/vito/vito/vendor/laravel/framework/src/Illuminate/Routing/Router.php(750): Illuminate\\Routing\\Router->runRoute()
#37 /home/vito/vito/vendor/laravel/framework/src/Illuminate/Routing/Router.php(739): Illuminate\\Routing\\Router->dispatchToRoute()
#38 /home/vito/vito/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(201): Illuminate\\Routing\\Router->dispatch()
#39 /home/vito/vito/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(144): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}()
#40 /home/vito/vito/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#41 /home/vito/vito/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()
#42 /home/vito/vito/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull->handle()
#43 /home/vito/vito/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#44 /home/vito/vito/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(51): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()
#45 /home/vito/vito/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Foundation\\Http\\Middleware\\TrimStrings->handle()
#46 /home/vito/vito/vendor/laravel/framework/src/Illuminate/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#47 /home/vito/vito/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Http\\Middleware\\ValidatePostSize->handle()
#48 /home/vito/vito/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(110): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#49 /home/vito/vito/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance->handle()
#50 /home/vito/vito/vendor/laravel/framework/src/Illuminate/Http/Middleware/HandleCors.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#51 /home/vito/vito/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Http\\Middleware\\HandleCors->handle()
#52 /home/vito/vito/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php(58): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#53 /home/vito/vito/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Http\\Middleware\\TrustProxies->handle()
#54 /home/vito/vito/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(119): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#55 /home/vito/vito/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\\Pipeline\\Pipeline->then()
#56 /home/vito/vito/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(145): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter()
#57 /home/vito/vito/public/index.php(51): Illuminate\\Foundation\\Http\\Kernel->handle()
#58 {main}
"
}

ss_vito

@saeedvaziry
Copy link
Member

You need to look at the server logs not application logs.

Go to your server in Vito dashboard and then Logs

@MelTheDev
Copy link

MelTheDev commented Oct 6, 2024

Looks like I'm also getting the same error @saeedvaziry .
Steps I followed:

  1. Create a cloud server (I chose Vultr)
  2. Once completed, try creating a database
    Got the below error (screenshot)

1

@saeedvaziry
Copy link
Member

@MelTheDev my answer is the same. you need to check the server logs to see why it failed.

https://vitodeploy.com/servers/logs.html

@MelTheDev
Copy link

MelTheDev commented Oct 6, 2024

@saeedvaziry As you have mentioned, I checked logs from the path but it's empty.

Screenshot 2024-10-06 155426

Update:
I think I managed to get it working, for some reason it's throwing error if you provide value such as "-" and when I used "_" it started working.

Thanks

@saeedvaziry
Copy link
Member

yes those are the validations that the database itself has.

Like if you enter number instead of database name you will get the same error but in the logs you will see the actual reason.

in V2 #297 Vito will show an error message on creation with the logs from the server itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants