Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store ns in db #2698

Merged
merged 4 commits into from
Dec 5, 2019
Merged
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
20 changes: 9 additions & 11 deletions backend/src/apiserver/resource/model_converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,17 +200,15 @@ func (r *ResourceManager) toModelResourceReferences(
return nil, util.Wrap(err, "Failed to find the referred resource")
}
//TODO(gaoning777) further investigation: Is the plain namespace a good option? maybe uuid for distinctness even with namespace deletion/recreation.
if apiRef.Key.Type != api.ResourceType_NAMESPACE {
modelRef := &model.ResourceReference{
ResourceUUID: resourceId,
ResourceType: resourceType,
ReferenceUUID: apiRef.Key.Id,
ReferenceName: referenceName,
ReferenceType: modelReferenceType,
Relationship: modelRelationship,
}
modelRefs = append(modelRefs, modelRef)
}
modelRef := &model.ResourceReference{
ResourceUUID: resourceId,
ResourceType: resourceType,
ReferenceUUID: apiRef.Key.Id,
ReferenceName: referenceName,
ReferenceType: modelReferenceType,
Relationship: modelRelationship,
}
modelRefs = append(modelRefs, modelRef)
}
return modelRefs, nil
}
Expand Down
2 changes: 1 addition & 1 deletion backend/src/apiserver/resource/model_converter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func TestToModelResourceReferences_NamespaceRef(t *testing.T) {
{Key: &api.ResourceKey{Type: api.ResourceType_NAMESPACE, Id: "e1"}, Relationship: api.Relationship_OWNER},
})
assert.Nil(t, err)
assert.Equal(t, 0, len(modelRefs))
assert.Equal(t, 1, len(modelRefs))
}

func TestToModelResourceReferences_UnknownRelationship(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions backend/src/apiserver/server/api_converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ func toApiResourceType(modelType common.ResourceType) api.ResourceType {
return api.ResourceType_JOB
case common.PipelineVersion:
return api.ResourceType_PIPELINE_VERSION
case common.Namespace:
return api.ResourceType_NAMESPACE
default:
return api.ResourceType_UNKNOWN_RESOURCE_TYPE
}
Expand Down
4 changes: 4 additions & 0 deletions backend/src/apiserver/storage/resource_reference_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ func (s *ResourceReferenceStore) checkReferenceExist(tx *sql.Tx, referenceId str
selectBuilder = sq.Select("1").From("experiments").Where(sq.Eq{"uuid": referenceId})
case common.PipelineVersion:
selectBuilder = sq.Select("1").From("pipeline_versions").Where(sq.Eq{"uuid": referenceId})
case common.Namespace:
// This function is called to check the data validity when the data are transformed according to the DB schema.
// Since there is not a separate table to store the namespace data, thus always returning true.
return true
default:
return false
}
Expand Down