-
Notifications
You must be signed in to change notification settings - Fork 6
Description
Enhancement Proposal
- To enable ssh with proxy, socat was added to the rock.
- We should probably replace the update-status approach with using git-sync's
--period. Basically need to rewrite the charm. - See migration guide below. The charm is affected by the breaking changes.
Via Gemini (ref: https://github.com/thockin/git-sync/blob/master/v3-to-v4.md)
Summary of Changes (v3 -> v4)
The transition to v4 is a significant architectural overhaul focused on simplifying the internal sync loop and standardizing configuration.
- New Internal Loop:
- v3: Distinguished between "initial clone" and "subsequent fetch," leading to complex logic and potential race conditions.
- v4: Uses a "always fetch" strategy. Every pass is identical, efficient, and idempotent. It fetches the specific SHA needed rather than cloning branches, closing race conditions where references might change during the process.
- Flag Parsing (Breaking Change):
- v3: Used Go's default flag style, accepting both
-flagand--flag. - v4: Enforces standard flag syntax. Long flags must use double-dashes (
--flag). Short flags use single-dashes (-v). Using-repo(single dash) will now fail.
- v3: Used Go's default flag style, accepting both
- Logging:
- v3: Text-based logs with standard Go flags (e.g.,
-logtostderr). - v4: Structured JSON logs are the default. All old log-formatting flags have been removed.
- v3: Text-based logs with standard Go flags (e.g.,
- Environment Variables:
- The prefix has changed from
GIT_SYNC_toGITSYNC_. (e.g.,GIT_SYNC_REPOis nowGITSYNC_REPO).
- The prefix has changed from
- git-sync v3 would sync the entire history of the remote repo by default. v4 syncs just one commit by default.
Migration Guide
1. Update Flag Syntax (Critical)
You must update all command-line arguments in your Deployment/Pod specs. Single-dash long flags are no longer supported.
- Wrong:
-repo=... - Right:
--repo=...
2. Replace Renamed & Deprecated Flags
Update your configuration to use the new flag names. While v4 attempts to honor some old flags for backward compatibility, you should migrate to the new ones to ensure future stability.
| v3 Flag (Deprecated) | v4 Flag (New) | Notes |
|---|---|---|
--branch, --rev |
--ref |
Unified flag for branch, tag, or hash (full, not an abbreviated form). Default: HEAD. |
--dest |
--link |
The name of the symlink to create. |
--wait |
--period |
Now requires units (e.g., 10s, 100ms). v3 used float seconds (10.5); v4 uses Duration strings. |
--max-sync-failures |
--max-failures |
Any non-recoverable error in the sync loop counts as a failure. |
--timeout |
--sync-timeout |
Total time allowed for one complete sync. v3 using integer seconds, v4 takes Duration string. |
--v |
-v or --verbose |
Controls log level. |
-logtostderr, etc. |
Removed | v4 always logs to stderr. |
--ssh |
Removed | The value of --repo determines when SSH is used. |
3. Update Environment Variables
Switch your environment variables to the new GITSYNC_ prefix.
- Old:
GIT_SYNC_REPO,GIT_SYNC_DEST,GIT_SYNC_USERNAME - New:
GITSYNC_REPO,GITSYNC_LINK,GITSYNC_USERNAME
Note: v4 generally prefers the new names but may fall back to checking GIT_SYNC_ variables if the new ones are unset.
4. Adjust Configuration Values
- Sync Period: If you used
--wait=10(seconds), you must now use--period=10s. - Depth: v4 defaults to
--depth=1(shallow clone). If you need the full history (e.g., for runninggit login your app), you must explicitly set--depth=0. - Root Directory: If you are using the official image, the default root has moved from
/tmp/gitto/git. Ensure yourvolumeMountsmatch this new path or strictly define--root.
5. Verify Hook Behavior
Since v4 treats the startup sequence as a "sync" event, any configured webhooks or exec hooks will fire immediately upon container startup, even if the repo hasn't changed since the last run. Ensure your hook handlers are idempotent (safe to run multiple times).
6. Self-monitoring
The logging output for v3 was semi-free-form text. Log output in v4 is structured and rendered as strict JSON.
7. Root dir
git-sync v3 container images defaulted --root to "/tmp/git". In v4, that has moved to "/git". Users who mount a volume and expect to use the default --root must mount it on "/git".