Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update git-sync to v4.2.1 to fix a pulling issue #1147

Merged
merged 1 commit into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ GO_DIR := $(OUTPUT_DIR)/go
# Base image used for all golang containers
GOLANG_IMAGE := golang:1.21.5-bookworm
# Base image used for debian containers
DEBIAN_BASE_IMAGE := gcr.io/gke-release/debian-base:bookworm-v1.0.1-gke.0
DEBIAN_BASE_IMAGE := gcr.io/gke-release/debian-base:bookworm-v1.0.1-gke.1
# Base image used for gcloud install, primarily for test images.
# We use -slim for a smaller base image where we can choose which components to install.
# https://cloud.google.com/sdk/docs/downloads-docker#docker_image_options
Expand Down
27 changes: 11 additions & 16 deletions e2e/testcases/git_sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"testing"

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

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

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

// Apply the mitigation first to validate Config Sync couldn't pull the latest commit.
nt.T.Logf("Verify the issue exist with the default branch and revision")
nt.T.Logf("Verify git-sync can pull the latest commit with the default branch and revision")
nomostest.SetGitBranch(nt, configsync.RootSyncName, gitproviders.MainBranch)
if err := nt.WatchForAllSyncs(nomostest.WithRootSha1Func(
// DefaultRootSha1Fn returns the hash with `git rev-parse HEAD`, which is
// different from `git ls-remote ...`
// So, overwrite the root hash with the initial lastSyncedCommit.
func(_ *nomostest.NT, _ types.NamespacedName) (string, error) {
return initialSyncedCommit, nil
})); err != nil {
// WatchForAllSyncs validates RootSync's lastSyncedCommit is updated to the
// local HEAD with the DefaultRootSha1Fn function.
if err := nt.WatchForAllSyncs(); err != nil {
nt.T.Fatal(err)
}

nt.T.Logf("Remove the test namespace to make sure git-sync can fetch newer commit")
nt.Must(nt.RootRepos[configsync.RootSyncName].Remove("acme/namespaces/hello/ns.yaml"))
nt.Must(nt.RootRepos[configsync.RootSyncName].CommitAndPush("remove Namespace"))
if err := nt.WatchForAllSyncs(); err != nil {
nt.T.Fatal(err)
}
if err := nt.ValidateNotFound("hello", "", &corev1.Namespace{}); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion manifests/templates/reconciler-manager-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ data:
- ALL
imagePullPolicy: IfNotPresent
- name: git-sync
image: gcr.io/config-management-release/git-sync:v4.1.0-gke.7__linux_amd64
image: gcr.io/config-management-release/git-sync:v4.2.1-gke.1__linux_amd64
args: ["--root=/repo/source", "--link=rev", "--max-failures=30", "--error-file=error.json"]
volumeMounts:
- name: repo
Expand Down