Skip to content

Fix gitopsset not updating when gitrepo is nested inside matrix#82

Merged
sarataha merged 2 commits intomainfrom
reconcile-matrix-gitrepo
Jun 2, 2023
Merged

Fix gitopsset not updating when gitrepo is nested inside matrix#82
sarataha merged 2 commits intomainfrom
reconcile-matrix-gitrepo

Conversation

@sarataha
Copy link
Copy Markdown
Member

PR to fix repository changes aren't detected by indexing gitrepos that are in matrix generator and dedups the list before returning it.

@bigkevmcd
Copy link
Copy Markdown
Collaborator

--- FAIL: TestGitOpsSetUpdateOnGitRepoChange (0.00s)
    gitopsset_controller_test.go:424: no kind is registered for the type v1.GitRepository in scheme "pkg/runtime/scheme.go:100"

@sarataha sarataha force-pushed the reconcile-matrix-gitrepo branch from bc4ed45 to 2996469 Compare May 26, 2023 11:44
Comment thread tests/e2e/main_test.go Outdated

imagev1 "github.com/fluxcd/image-reflector-controller/api/v1beta2"
"github.com/fluxcd/pkg/runtime/testenv"
v1 "github.com/fluxcd/source-controller/api/v1"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about importing this as sourcev1 which follows the pattern?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When using sourcev1, it shows this error 🤔

cannot use &(sourcev1.Artifact literal) (value of type *"github.com/fluxcd/source-controller/api/v1beta2".Artifact) as *"github.com/fluxcd/source-controller/api/v1".Artifact value in struct literalcompilerIncompatibleAssign

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get a different error...

--- FAIL: TestReconcilingUpdatingImagePolicy_in_matrix (10.03s)
    gitopsset_controller_test.go:403:
        Timed out after 10.001s.
        Expected
            <bool>: false
        to be true
--- FAIL: TestGitOpsSetUpdateOnGitRepoChange (0.01s)
    gitopsset_controller_test.go:427: GitRepository.source.toolkit.fluxcd.io "my-git-repo" is invalid: status.artifact.lastUpdateTime: Required value

Looks like you need to populate that field?

Copy link
Copy Markdown
Collaborator

@bigkevmcd bigkevmcd Jun 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've had a further look at this.

There are three problems, getGitRepoStatusUpdate doesn't set the LastUpdateTime on the Artifact, you can set it to time.Now() without any issues.

Also, it's setting the Digest to be an invalid error, if you look at the error message:

gitopsset_controller_test.go:429: GitRepository.source.toolkit.fluxcd.io "my-git-repo" is invalid: status.artifact.digest: Invalid value: "f0a57ec1cdebda91cf00d89dfa298c6ac27791e7fdb0329990478061755eaca8": status.artifact.digest in body should match '^[a-z0-9]+(?:[.+_-][a-z0-9]+)*:[a-zA-Z0-9=_-]+$'

You can see that it needs to begin with some sort of string + ":" + another string.

Looking at an example GitRepository I have in cluster...I can see...

    digest: sha256:1c88565146a95dda6aa8ed198271816c3f609288ea5abd2a8628fc9a763e2a53

So, that first string looks like the Hash algorithm?

Finally https://github.com/weaveworks/gitopssets-controller/pull/82/files#diff-d29c6c9610af47fb141d08a9bd9c7b7f9d277c2d0a148960386cd4f69b8e84b4R427

The code is looking for files.tar.gz in the testdata/archive directory, I can see a files.tar.gz.sum so I think you just forgot to add the file?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you Kevin for the information! 🙂 I will fix the issues now 👍

@sarataha sarataha force-pushed the reconcile-matrix-gitrepo branch 2 times, most recently from a7559fb to c186ec9 Compare June 1, 2023 23:25
It indexes gitrepos that are in matrix generator and dedups the list before returning it.
@sarataha sarataha force-pushed the reconcile-matrix-gitrepo branch from c186ec9 to 4e8dbdc Compare June 2, 2023 10:42
@sarataha sarataha requested a review from bigkevmcd June 2, 2023 11:05
Copy link
Copy Markdown
Collaborator

@bigkevmcd bigkevmcd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@sarataha sarataha merged commit c82f67a into main Jun 2, 2023
@sarataha sarataha deleted the reconcile-matrix-gitrepo branch June 2, 2023 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants