diff --git a/pkg/datastore/sync.go b/pkg/datastore/sync.go index c252b1bc..6017a9db 100644 --- a/pkg/datastore/sync.go +++ b/pkg/datastore/sync.go @@ -2,6 +2,7 @@ package datastore import ( "context" + "errors" "sync" "github.com/sdcio/data-server/pkg/tree" @@ -29,7 +30,11 @@ func (d *Datastore) ApplyToRunning(ctx context.Context, deletes []*sdcpb.Path, i for _, delete := range deletes { // navigate to delete path deleteRoot, err := ops.NavigateSdcpbPath(ctx, d.syncTree.Entry, delete) - if err != nil { + switch { + case errors.Is(err, ops.ErrNavigateSdcpbPathNotFound): + log.V(logger.VDebug).Info("skipping delete config subtree from internal running with no content", "path", delete.ToXPath(false)) + continue + case err != nil: log.Error(err, "failed navigating to delete path", "path", delete.ToXPath(false)) continue } diff --git a/pkg/tree/ops/navigatesdcpbpath.go b/pkg/tree/ops/navigatesdcpbpath.go index 2ae4e6b2..379cf67b 100644 --- a/pkg/tree/ops/navigatesdcpbpath.go +++ b/pkg/tree/ops/navigatesdcpbpath.go @@ -10,6 +10,10 @@ import ( sdcpb "github.com/sdcio/sdc-protos/sdcpb" ) +var ( + ErrNavigateSdcpbPathNotFound = fmt.Errorf("path not found in tree") +) + func NavigateSdcpbPath(ctx context.Context, e api.Entry, path *sdcpb.Path) (api.Entry, error) { pathElems := path.GetElem() var err error @@ -40,7 +44,7 @@ func NavigateSdcpbPath(ctx context.Context, e api.Entry, path *sdcpb.Path) (api. child, exists := e.GetChilds(types.DescendMethodActiveChilds)[pathElems[0].Name] if !exists { pth := &sdcpb.Path{Elem: pathElems} - return nil, fmt.Errorf("navigating tree, reached %v but child %v does not exist, trying to load defaults yielded %v", e.SdcpbPath().ToXPath(false), pth.ToXPath(false), err) + return nil, fmt.Errorf("%w: reached %v but child %v does not exist. Trying to load defaults failed", ErrNavigateSdcpbPathNotFound, e.SdcpbPath().ToXPath(false), pth.ToXPath(false)) } for v := range pathElems[0].PathElemNamesKeysOnly() {