Skip to content

Commit

Permalink
Adding logs to resolve.go to debug BindingResolutionError (flyteorg#62)
Browse files Browse the repository at this point in the history
* Adding logs to resolve.go to debug BindingResolutionError and the empty error msg

* use debugf instead
  • Loading branch information
bnsblue authored Mar 19, 2020
1 parent 38ba9c1 commit e90c9e2
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions pkg/controller/nodes/resolve.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,28 @@ import (
"context"

"github.com/lyft/flyteidl/gen/pb-go/flyteidl/core"

"github.com/lyft/flytepropeller/pkg/apis/flyteworkflow/v1alpha1"
"github.com/lyft/flytepropeller/pkg/controller/nodes/errors"
"github.com/lyft/flytestdlib/logger"
)

func ResolveBindingData(ctx context.Context, outputResolver OutputResolver, w v1alpha1.BaseWorkflowWithStatus, bindingData *core.BindingData) (*core.Literal, error) {
logger.Debugf(ctx, "Resolving binding data")

literal := &core.Literal{}
if bindingData == nil {
logger.Debugf(ctx, "bindingData is nil")
return nil, nil
}
switch bindingData.GetValue().(type) {
case *core.BindingData_Collection:

logger.Debugf(ctx, "bindingData.GetValue() [%v] is of type Collection", bindingData.GetValue())
literalCollection := make([]*core.Literal, 0, len(bindingData.GetCollection().GetBindings()))
for _, b := range bindingData.GetCollection().GetBindings() {
l, err := ResolveBindingData(ctx, outputResolver, w, b)
if err != nil {
logger.Debugf(ctx, "Failed to resolve binding data. Error: [%v]", err)
return nil, err
}

Expand All @@ -32,10 +38,12 @@ func ResolveBindingData(ctx context.Context, outputResolver OutputResolver, w v1
},
}
case *core.BindingData_Map:
logger.Debugf(ctx, "bindingData.GetValue() [%v] is of type Map", bindingData.GetValue())
literalMap := make(map[string]*core.Literal, len(bindingData.GetMap().GetBindings()))
for k, v := range bindingData.GetMap().GetBindings() {
l, err := ResolveBindingData(ctx, outputResolver, w, v)
if err != nil {
logger.Debugf(ctx, "Failed to resolve binding data. Error: [%v]", err)
return nil, err
}

Expand All @@ -48,8 +56,11 @@ func ResolveBindingData(ctx context.Context, outputResolver OutputResolver, w v1
},
}
case *core.BindingData_Promise:
logger.Debugf(ctx, "bindingData.GetValue() [%v] is of type Promise", bindingData.GetValue())

upstreamNodeID := bindingData.GetPromise().GetNodeId()
bindToVar := bindingData.GetPromise().GetVar()

if w == nil {
return nil, errors.Errorf(errors.IllegalStateError, upstreamNodeID,
"Trying to resolve output from previous node, without providing the workflow for variable [%s]",
Expand All @@ -69,15 +80,17 @@ func ResolveBindingData(ctx context.Context, outputResolver OutputResolver, w v1

return outputResolver.ExtractOutput(ctx, w, n, bindToVar)
case *core.BindingData_Scalar:
logger.Debugf(ctx, "bindingData.GetValue() [%v] is of type Scalar", bindingData.GetValue())
literal.Value = &core.Literal_Scalar{Scalar: bindingData.GetScalar()}
}

return literal, nil
}

func Resolve(ctx context.Context, outputResolver OutputResolver, w v1alpha1.BaseWorkflowWithStatus, nodeID v1alpha1.NodeID, bindings []*v1alpha1.Binding) (*core.LiteralMap, error) {
logger.Debugf(ctx, "bindings: [%v]", bindings)
literalMap := make(map[string]*core.Literal, len(bindings))
for _, binding := range bindings {
logger.Debugf(ctx, "Resolving binding: [%v]", binding)
varName := binding.GetVar()
l, err := ResolveBindingData(ctx, outputResolver, w, binding.GetBinding())
if err != nil {
Expand Down

0 comments on commit e90c9e2

Please sign in to comment.