AzBuilder / terrakube

Open source IaC Automation and Collaboration Software.
https://docs.terrakube.io
Apache License 2.0
510 stars 43 forks source link

Git SSH private repository clone is not working for new workspaces #959

Closed kspradheep closed 4 months ago

kspradheep commented 4 months ago

Bug description 🐞

We have 10+ workspaces and all uses SSH based VCS git clone. They're working with no issues. However, the private repository git clone is not working for newly created workspaces hence terraform plan shows "No changes. Your infrastructure matches the configuration."

Logs:

[threadPoolTaskExecutor-1] INFO org.terrakube.executor.service.workspace.SetupWorkspaceImpl - User Home Directory: /home/cnb
[threadPoolTaskExecutor-1] INFO org.terrakube.executor.service.workspace.SetupWorkspaceImpl - Workspace git clone directory: /home/cnb/.terraform-spring-boot/executor/00cc49f5-4f9f-432c-b296-e74402819a5a/54fb29e9-1ba0-4a14-9dc2-64c1540a2316
[threadPoolTaskExecutor-1] INFO org.terrakube.executor.service.workspace.SetupWorkspaceImpl - vcsType: PUBLIC
[sshd-JGitSshClient[6a1ee05b]-nio2-thread-5] WARN org.eclipse.jgit.internal.transport.sshd.JGitClientSession - exceptionCaught(JGitClientSession[git@hostname/hostip:hostport])[state=Opened] SshException: Server key did not validate
[sshd-JGitSshClient[6a1ee05b]-nio2-thread-5] INFO org.eclipse.jgit.internal.transport.sshd.JGitClientSession - Disconnecting(JGitClientSession[git@hostname/hostip:hostport]): SSH2_DISCONNECT_HOST_KEY_NOT_VERIFIABLE - Server key did not validate
[threadPoolTaskExecutor-1] ERROR org.terrakube.executor.service.workspace.SetupWorkspaceImpl - ssh://git@hostname:hostport/projectkey/reponame.git: Server key did not validate
[threadPoolTaskExecutor-1] ERROR org.terrakube.executor.service.workspace.security.WorkspaceSecurityImpl - Generate Dex Authentication Private Token
[threadPoolTaskExecutor-1] INFO org.terrakube.executor.service.workspace.SetupWorkspaceImpl - Executor WorkingDir: /home/cnb/.terraform-spring-boot/executor/00cc49f5-4f9f-432c-b296-e74402819a5a/54fb29e9-1ba0-4a14-9dc2-64c1540a2316
[threadPoolTaskExecutor-1] ERROR org.terrakube.executor.service.executor.ExecutorJobImpl - /home/cnb/.terraform-spring-boot/executor/00cc49f5-4f9f-432c-b296-e74402819a5a/54fb29e9-1ba0-4a14-9dc2-64c1540a2316/commitHash.info (No such file or directory)

Steps to reproduce

  1. Create a workspace using VCS private repo with SSH as mentioned https://docs.terrakube.io/user-guide/vcs-providers/ssh
  2. Run plan job

Expected behavior

The plan should show changes of terraform resources

Example repository

No response

Anything else?

No response

alfespa17 commented 4 months ago

Maybe you can check your SSH key because for me it is working

I have this workspace that is using ssh connectivity as you can see here

image

I can see the plan correctly

image

kspradheep commented 4 months ago

Delete and recreate the workspace seems fixed the issue for me. I suspect SSH key was not selected/picked during workspace creation. Can we make "SSH Key" parameter as required field or automatically choose default Org level ssh key?

alfespa17 commented 4 months ago

That wont be possible because not all the workspaces are private, terrakube also support public workspaces so the SSH Key should be optional