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

Problem: RERUN is not working when using an inventory from a git repo #2137

Open
vaz-ar opened this issue Jun 26, 2024 · 1 comment
Open
Labels

Comments

@vaz-ar
Copy link

vaz-ar commented Jun 26, 2024

Issue

When trying to rerun a task, I get the following error:

 2:47:09 PM
Task 2147483511 added to queue
2:47:09 PM
Started: 2147483511
2:47:09 PM
Run TaskRunner with template: Setup ZSH and omzsh
2:47:09 PM
Preparing: 2147483511
2:47:10 PM
Warning: Permanently added 'github.com' (ECDSA) to the list of known hosts.
2:47:12 PM
From github.com:xxxxxx/yyyyy
2:47:12 PM
 + f56a464...03011c5 main       -> origin/main  (forced update)
2:47:12 PM
Cloning Repository git@github.com:xxxxxx/yyyyy
2:47:12 PM
Cloning into 'repository_1_1'...
2:47:13 PM
Warning: Permanently added 'github.com' (ECDSA) to the list of known hosts.
2:47:15 PM
cloning inventory repository
2:47:15 PM
Cloning Repository git@github.com:xxxxxx/zzzzzz
2:47:15 PM
fatal: destination path 'inventory_2147483511' already exists and is not an empty directory.
2:47:15 PM
Failed to install inventory: exit status 128
2:47:15 PM
Running playbook failed: exit status 128

(I have redacted the git repo names)

The inventory is of type "file" and located in one of the git repo configured in semaphore.
There are no issue when running the task from the first time, it only happens when using "RERUN"

Impact

Ansible (task execution)

Installation method

Docker

Database

BoltDB

Browser

Firefox

Semaphore Version

v2.10.7-6bcf476-1718821016

Ansible Version

No response

Logs & errors

No response

Manual installation - system information

No response

Configuration

No response

Additional information

No response

@vaz-ar vaz-ar changed the title Problem: RERUN is not working when using an invetory from a git repo Problem: RERUN is not working when using an inventory from a git repo Jun 26, 2024
@vaz-ar
Copy link
Author

vaz-ar commented Jun 26, 2024

Not 100% sure but from what I can see in func (t *LocalJob) updateRepository() error something like this might solve this issue:

diff --git a/services/tasks/LobalJob_inventory.go b/services/tasks/LobalJob_inventory.go
index d461dc7c..f1475918 100644
--- a/services/tasks/LobalJob_inventory.go
+++ b/services/tasks/LobalJob_inventory.go
@@ -61,9 +61,19 @@ func (t *LocalJob) cloneInventoryRepo() error {
 		Client:     db_lib.CreateDefaultGitClient(),
 	}
 
-	err := repo.Clone()
+	if repo.CanBePulled() {
+		err := repo.Pull()
+		if err == nil {
+			return nil
+		}
+	}
+
+	err := os.RemoveAll(repo.GetFullPath())
+	if err != nil {
+		return err
+	}
 
-	return err
+	return repo.Clone()
 }
 
 func (t *LocalJob) installStaticInventory() error {

@fiftin fiftin added the bug label Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: To triage
Development

No branches or pull requests

2 participants