Skip to content

Commit

Permalink
fix: multi-namespace mode configmap sync
Browse files Browse the repository at this point in the history
  • Loading branch information
FabianKramm committed Apr 8, 2024
1 parent 70b3b5b commit 584da1d
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions pkg/controllers/resources/configmaps/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ func (s *configMapSyncer) HostToVirtual(ctx context.Context, req types.Namespace
Name: "kube-root-ca.crt",
Namespace: s.NamespacedTranslator.HostToVirtual(ctx, req, pObj).Namespace,
}
} else if s.multiNamespaceMode && req.Name == "kube-root-ca.crt" {
// ignore kube-root-ca.crt from host
return types.NamespacedName{}
}

return s.NamespacedTranslator.HostToVirtual(ctx, req, pObj)
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/syncer/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ func (r *SyncController) excludePhysical(ctx context.Context, pObj, vObj client.
return false, fmt.Errorf("failed to check if physical object is managed: %w", err)
} else if !isManaged {
if vObj != nil {
msg := "conflict: cannot sync virtual object as unmanaged physical object exists with desired name"
msg := fmt.Sprintf("conflict: cannot sync virtual object %s/%s as unmanaged physical object %s/%s exists with desired name", vObj.GetNamespace(), vObj.GetName(), pObj.GetNamespace(), pObj.GetName())
r.vEventRecorder.Eventf(vObj, "Warning", "SyncError", msg)
return false, fmt.Errorf(msg)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/syncer/syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ func TestReconcile(t *testing.T) {
},

shouldErr: true,
errMsg: "conflict: cannot sync virtual object as unmanaged physical object exists with desired name",
errMsg: "conflict: cannot sync virtual object default/a as unmanaged physical object test/a-x-default-x-suffix exists with desired name",
},
}
sort.SliceStable(testCases, func(i, j int) bool {
Expand Down
2 changes: 1 addition & 1 deletion pkg/plugin/v2/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ func (m *Manager) WithInterceptors(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
info, ok := request.RequestInfoFrom(r.Context())
if !ok {
klog.V(1).Info("could not determine the infos from the request, serving next handler")
klog.V(1).Infof("could not determine the infos from the request %s, serving next handler", r.URL.Path)
next.ServeHTTP(w, r)
return
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/translate/multi_namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (s *multiNamespace) IsManaged(obj runtime.Object) bool {
// If obj is not in the synced namespace OR
// If object-name annotation is not set OR
// If object-name annotation is different from actual name
if !s.IsTargetedNamespace(metaAccessor.GetNamespace()) || metaAccessor.GetAnnotations() == nil || metaAccessor.GetAnnotations()[NameAnnotation] == "" || metaAccessor.GetAnnotations()[NameAnnotation] != metaAccessor.GetName() {
if !s.IsTargetedNamespace(metaAccessor.GetNamespace()) || metaAccessor.GetAnnotations() == nil || metaAccessor.GetAnnotations()[NameAnnotation] == "" {
return false
}

Expand Down

0 comments on commit 584da1d

Please sign in to comment.