Skip to content
Open
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
7 changes: 6 additions & 1 deletion pkg/datastore/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package datastore

import (
"context"
"errors"
"sync"

"github.com/sdcio/data-server/pkg/tree"
Expand Down Expand Up @@ -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
}
Expand Down
6 changes: 5 additions & 1 deletion pkg/tree/ops/navigatesdcpbpath.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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() {
Expand Down
Loading