Skip to content

Commit 3253243

Browse files
nan-yugoogle-oss-prow[bot]
authored andcommitted
fix: update git-sync to v4.2.1 to fix a pulling issue (#1147)
There is a bug in git-sync v4.1.0. When branches in different remotes are out of sync, `git-sync` fetches the commit SHA from the last line, which may not be the latest. This leads to an issue that Config Sync couldn't pull the latest commit from HEAD. The issue was fixed in v4.2.0 by kubernetes/git-sync#845. This commit updates git-sync to v4.2.1 to include the fix. It also bumps the debian-base to latest version for CVE fixes. b/325341042
1 parent 860f7f7 commit 3253243

File tree

3 files changed

+13
-18
lines changed

3 files changed

+13
-18
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ GO_DIR := $(OUTPUT_DIR)/go
3939
# Base image used for all golang containers
4040
GOLANG_IMAGE := golang:1.21.5-bookworm
4141
# Base image used for debian containers
42-
DEBIAN_BASE_IMAGE := gcr.io/gke-release/debian-base:bookworm-v1.0.1-gke.0
42+
DEBIAN_BASE_IMAGE := gcr.io/gke-release/debian-base:bookworm-v1.0.1-gke.1
4343
# Base image used for gcloud install, primarily for test images.
4444
# We use -slim for a smaller base image where we can choose which components to install.
4545
# https://cloud.google.com/sdk/docs/downloads-docker#docker_image_options

e2e/testcases/git_sync_test.go

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"testing"
1919

2020
corev1 "k8s.io/api/core/v1"
21-
"k8s.io/apimachinery/pkg/types"
2221
"kpt.dev/configsync/e2e/nomostest"
2322
"kpt.dev/configsync/e2e/nomostest/gitproviders"
2423
nomostesting "kpt.dev/configsync/e2e/nomostest/testing"
@@ -34,15 +33,9 @@ func TestMultipleRemoteBranchesOutOfSync(t *testing.T) {
3433
if err := nt.KubeClient.Get(configsync.RootSyncName, configmanagement.ControllerNamespace, rs); err != nil {
3534
nt.T.Fatal(err)
3635
}
37-
initialSyncedCommit := rs.Status.LastSyncedCommit
3836

3937
nt.T.Log("Create an extra remote tracking branch")
4038
nt.Must(nt.RootRepos[configsync.RootSyncName].Push("HEAD:refs/remotes/upstream/main"))
41-
nt.T.Cleanup(func() {
42-
// Delete the remote tracking branch in the end so other subsequent tests
43-
// can pull from the latest commit, instead of the HEAD of the remote.
44-
nt.Must(nt.RootRepos[configsync.RootSyncName].Push(":refs/remotes/upstream/main"))
45-
})
4639

4740
nt.T.Logf("Update the remote main branch by adding a test namespace")
4841
nt.Must(nt.RootRepos[configsync.RootSyncName].Add("acme/namespaces/hello/ns.yaml", fake.NamespaceObject("hello")))
@@ -59,16 +52,18 @@ func TestMultipleRemoteBranchesOutOfSync(t *testing.T) {
5952
nt.T.Fatal(err)
6053
}
6154

62-
// Apply the mitigation first to validate Config Sync couldn't pull the latest commit.
63-
nt.T.Logf("Verify the issue exist with the default branch and revision")
55+
nt.T.Logf("Verify git-sync can pull the latest commit with the default branch and revision")
6456
nomostest.SetGitBranch(nt, configsync.RootSyncName, gitproviders.MainBranch)
65-
if err := nt.WatchForAllSyncs(nomostest.WithRootSha1Func(
66-
// DefaultRootSha1Fn returns the hash with `git rev-parse HEAD`, which is
67-
// different from `git ls-remote ...`
68-
// So, overwrite the root hash with the initial lastSyncedCommit.
69-
func(_ *nomostest.NT, _ types.NamespacedName) (string, error) {
70-
return initialSyncedCommit, nil
71-
})); err != nil {
57+
// WatchForAllSyncs validates RootSync's lastSyncedCommit is updated to the
58+
// local HEAD with the DefaultRootSha1Fn function.
59+
if err := nt.WatchForAllSyncs(); err != nil {
60+
nt.T.Fatal(err)
61+
}
62+
63+
nt.T.Logf("Remove the test namespace to make sure git-sync can fetch newer commit")
64+
nt.Must(nt.RootRepos[configsync.RootSyncName].Remove("acme/namespaces/hello/ns.yaml"))
65+
nt.Must(nt.RootRepos[configsync.RootSyncName].CommitAndPush("remove Namespace"))
66+
if err := nt.WatchForAllSyncs(); err != nil {
7267
nt.T.Fatal(err)
7368
}
7469
if err := nt.ValidateNotFound("hello", "", &corev1.Namespace{}); err != nil {

manifests/templates/reconciler-manager-configmap.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ data:
102102
- NET_RAW
103103
imagePullPolicy: IfNotPresent
104104
- name: git-sync
105-
image: gcr.io/config-management-release/git-sync:v4.1.0-gke.7__linux_amd64
105+
image: gcr.io/config-management-release/git-sync:v4.2.1-gke.1__linux_amd64
106106
args: ["--root=/repo/source", "--link=rev", "--max-failures=30", "--error-file=error.json"]
107107
volumeMounts:
108108
- name: repo

0 commit comments

Comments
 (0)