Open xdevxy opened 6 months ago
@xdevxy @juliev0
I reviewed the code in syncer.go
and found that we have four scenarios:
StartWatching
, StopWatching
, Contains
, and Length
functions.StartFunction
.run
function.runOnce
function.What I think is that the Monitoring, Scheduling, and Dispatching logic form parts of the Watcher Logic, so I should decouple them and make them easily pluggable with other code. Please share your views on this.
Hey @shubhamdixit863. Good research.
I did want to clarify some things. I just realized this Issue mentions the Agent too. The Agent code already has a skeleton. For the Agent there is just a single Git definition defined in the ConfigMap which is evaluated (it could be templated) and then periodically fetches/syncs here. You probably can focus more on the Modular Watcher in the Controller than this, as this is something that will be done later. I think the main thing for this will be that we will ultimately need to have the ability to do cloning/fetching type code without needing to pass in a GitSync
into the functions...so making some of those functions more generic perhaps.
That is what Agent has in common with the Modular Watcher for Controller. The Modular Watcher is basically a set of repository paths that need to be defined in the ConfigMap that we watch. (Or maybe for simplicity should it only be one @xdevxy ?) Also, it will I suppose only consist of GitSyncs, so theoretically it could only use raw type, if it makes things easier (or if you want to reuse the existing functionality maybe it's easier for it to follow the same model as our GitSync RepositoryPaths and allow all).
So, regarding your findings above, I actually think it could be a lot simpler than this, since we will either have just one path that we watch or a small handful. (Of course, we'd still need to account for ConfigMap changes.)
Let me know if you disagree with any of this @xdevxy. Thanks!
Overall modular watcher requires the following functionalities:
These logic already exist in the syncer along with the git operations in git/util. We want to make it modular so the code can be shared/used by both watch control repo and the users repo (referred by gitsync).
On top of that, how the repo path with a target revision
is specified are different.
Summary
Extract out the current gitops watching logic out to be shared by both controller and agent. This also includes the logic to watching control repo.
Use Cases
A dedicated watcher for changes in repos
Message from the maintainers:
If you wish to see this enhancement implemented please add a 👍 reaction to this issue! We often sort issues this way to know what to prioritize.