[SURE-6871] Fleet: changing the Gitrepo watch from revision to branch results in an error.
SURE-6871, SURE-7365(?)
Rancher Server Setup
- Rancher version: 2.7.6
- Fleet version: 102.1.1+up0.7.1
Information about the Cluster
-
Kubernetes version: v1.26.6+rke2r1
-
Cluster Type (Local/Downstream): Local
User Information
- What is the role of the user logged in? Admin
Describe the bug When editing a GitRepo changing from watch a Revision (tag) to Branch results in an error: Invalid Commit Id
To Reproduce
- Create a GitRepo
- Watch a Revision and Save
- Change to Watch a Branch as Save
Result Error: Invalid Commit Id
Expected Result No error, GitRepo watches the Branch
Additional context Changing the tag to a full commit id and then back to Branch works.
@bvankampen I am not able to reproduce the issue with Rancher 2.8.0 which is shipped with Fleet 0.9.0. Could you verify if the issue is fixed for you too with the latest Rancher or Fleet version?
@thardeck I still can reproduce the issue with Rancher 2.8.0 with Fleet 0.9.0. Please let me know if you need more information.
I can confirm it now. I have tried to reproduce it with a commit id instead of a tag - which seems to work fine - but I am running into the same issue using tags.
The issue is in Gitjob.
The problem is that instead of the commit hash referenced by the tag, the tag itself is stored in gitjob.Status.Commit.
The function lsRemote(branch string, commit string) is called with gitjob.Status.Commit as parameter and it runs the function
validateCommit(commit string).
This function errors out if no hash is provided in the commit variable.
The tag is provided as revision, and the value of it is most likely stored in gitjob.Status.Commit in func (w *Webhook) ServeHTTP(rw http.ResponseWriter, r *http.Request)
We either have to distinguish properly between tags and commits or adapt the validate function to allow tags and maybe use the term revision instead of commit. Git itself should not care if the revision is a commit reference or tag.
I'm unable to recreate this with master (which will be released in version 2.9.0 of Rancher)
With 0.9.1-rc6 we still get the following Status (as Tim pointed out):
Status:
Commit: v1.0
And the issue is reproduced.
With master we get the right Commit in Status, and the issue is no longer happening.
Status:
Commit: 44f4634747e3dd6c9d1ad6c9d402b430f7aae20b
System Information:
Rancher Version: 2.9-head
Fleet Version: fleet:104.0.0+up0.10.0-rc.11
Scenario's checked:
1. Test GitRepo deploys application without any error when change branch with tag --> :heavy_check_mark:
- Created a GitRepo with branch.
- Checked that application is deployed successfully.
- Edited GitRepo by changing branch to revision/tag.
- Verified that installed application is not changed
- Verified that there is no error in the UI after changing branch to tag.
Scenario's Un-checked: (~In-Progress~ Not Working as expected.)
1. Test GitRepo deploys application without any error when change tag with branch --> :red_circle:
- Created a GitRepo with tag.
- Checked that application is deployed successfully.
- Edited GitRepo by changing revision/tag to branch.
- Verified that installed application is not changed
- Verified that there is no error in the UI after changing revision/tag to branch.
#2404 and #2403 will fix the second scenario.
Rancher Version: v2.9.0-alpha4 Fleet Version: 0.10.0-rc.14
~### Scenario's Un-checked: (~In-Progress~ Not Working as expected.)~
This scenario is working as expected.
~### 1. Test GitRepo deploys application without any error when change tag with branch --> 🔴~
1. Test GitRepo deploys application without any error when change tag with branch --> ✔️
- Created a GitRepo with tag.
- Checked that application is deployed successfully.
- Edited GitRepo by changing revision/tag to branch.
- Verified that installed application is not changed
- Verified that there is no error in the UI after changing revision/tag to branch.
- Created GitRepo with tag/revision
- Changed to main branch from tag/revision