Skip to content

Commit

Permalink
Handle resource override not found in cluster resource controller (fl…
Browse files Browse the repository at this point in the history
  • Loading branch information
katrogan authored Jan 28, 2020
1 parent 4e87c2c commit 80e8964
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion flyteadmin/pkg/clusterresource/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,9 @@ func (c *controller) getCustomTemplateValues(
ResourceType: admin.MatchableResource_CLUSTER_RESOURCE,
})
if err != nil {
collectedErrs = append(collectedErrs, err)
if _, ok := err.(errors.FlyteAdminError); !ok || err.(errors.FlyteAdminError).Code() != codes.NotFound {
collectedErrs = append(collectedErrs, err)
}
}
if resource != nil && resource.Attributes != nil && resource.Attributes.GetClusterResourceAttributes() != nil {
for templateKey, templateValue := range resource.Attributes.GetClusterResourceAttributes().Attributes {
Expand Down
2 changes: 1 addition & 1 deletion flyteadmin/pkg/repositories/gormimpl/resource_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (r *ResourceRepo) Get(ctx context.Context, ID interfaces.ResourceID) (model
}
if tx.RecordNotFound() || len(resources) == 0 {
return models.Resource{}, flyteAdminErrors.NewFlyteAdminErrorf(codes.NotFound,
"%+v", ID)
"Resource [%+v] not found", ID)
}
return resources[0], nil
}
Expand Down
4 changes: 2 additions & 2 deletions flyteadmin/tests/attributes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func TestUpdateProjectDomainAttributes(t *testing.T) {
ResourceType: admin.MatchableResource_TASK_RESOURCE,
})
assert.Nil(t, response)
assert.EqualError(t, err, "rpc error: code = NotFound desc = {Project:admintests Domain:development Workflow: LaunchPlan: ResourceType:TASK_RESOURCE}")
assert.EqualError(t, err, "rpc error: code = NotFound desc = Resource [{Project:admintests Domain:development Workflow: LaunchPlan: ResourceType:TASK_RESOURCE}] not found")
}

func TestUpdateWorkflowAttributes(t *testing.T) {
Expand Down Expand Up @@ -142,5 +142,5 @@ func TestUpdateWorkflowAttributes(t *testing.T) {
Workflow: "workflow",
ResourceType: admin.MatchableResource_TASK_RESOURCE,
})
assert.EqualError(t, err, "rpc error: code = NotFound desc = {Project:admintests Domain:development Workflow:workflow LaunchPlan: ResourceType:TASK_RESOURCE}")
assert.EqualError(t, err, "rpc error: code = NotFound desc = Resource [{Project:admintests Domain:development Workflow:workflow LaunchPlan: ResourceType:TASK_RESOURCE}] not found")
}

0 comments on commit 80e8964

Please sign in to comment.