fleet icon indicating copy to clipboard operation
fleet copied to clipboard

[SURE-6871] Fleet: changing the Gitrepo watch from revision to branch results in an error.

Open bvankampen opened this issue 2 years ago • 7 comments

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 Screenshot 2023-09-06 at 09 39 37
  • Change to Watch a Branch as Save Screenshot 2023-09-06 at 09 39 52

Result Error: Invalid Commit Id

Screenshot 2023-09-06 at 09 40 07

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 avatar Sep 06 '23 07:09 bvankampen

@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 avatar Dec 22 '23 13:12 thardeck

@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.

bvankampen avatar Dec 22 '23 13:12 bvankampen

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.

thardeck avatar Dec 22 '23 15:12 thardeck

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.

thardeck avatar Jan 04 '24 16:01 thardeck

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

0xavi0 avatar Mar 18 '24 15:03 0xavi0

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:

  1. Created a GitRepo with branch.
  2. Checked that application is deployed successfully.
  3. Edited GitRepo by changing branch to revision/tag.
  4. Verified that installed application is not changed
  5. Verified that there is no error in the UI after changing branch to tag.

sbulage avatar Apr 23 '24 14:04 sbulage

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:

  1. Created a GitRepo with tag.
  2. Checked that application is deployed successfully.
  3. Edited GitRepo by changing revision/tag to branch.
  4. Verified that installed application is not changed
  5. Verified that there is no error in the UI after changing revision/tag to branch.

sbulage avatar Apr 24 '24 08:04 sbulage

#2404 and #2403 will fix the second scenario.

sbulage avatar Jun 11 '24 11:06 sbulage

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 --> ✔️

  1. Created a GitRepo with tag.
  2. Checked that application is deployed successfully.
  3. Edited GitRepo by changing revision/tag to branch.
  4. Verified that installed application is not changed
  5. Verified that there is no error in the UI after changing revision/tag to branch.

sbulage avatar Jun 12 '24 11:06 sbulage

- Created GitRepo with tag/revision

Screenshot from 2024-06-12 16-47-15


- Changed to main branch from tag/revision

Screenshot from 2024-06-12 16-48-19

sbulage avatar Jun 12 '24 11:06 sbulage