Skip to content

(catalog): Multi resource catalog item and instance#11

Merged
jenniferubah merged 5 commits into
dcm-project:mainfrom
jenniferubah:catalog/composite-resolution
Jul 3, 2026
Merged

(catalog): Multi resource catalog item and instance#11
jenniferubah merged 5 commits into
dcm-project:mainfrom
jenniferubah:catalog/composite-resolution

Conversation

@jenniferubah

@jenniferubah jenniferubah commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Add catalog item and and catalog instance resolution for multiple resource within a single request
Enhancement: dcm-project/enhancements#55
Note: Creation and Deletion for multi resource placement and rehydration are out of scope for this PR. These will be in a follow up PR and are marked as TODO in this PR.

@jenniferubah
jenniferubah force-pushed the catalog/composite-resolution branch 11 times, most recently from 67d0d55 to 98af244 Compare June 25, 2026 21:10
Assisted-By: Cursor AI

Signed-off-by: Jennifer Ubah <cju.cipher@gmail.com>
@jenniferubah
jenniferubah force-pushed the catalog/composite-resolution branch from 98af244 to 88da51a Compare June 25, 2026 21:28
@jenniferubah jenniferubah changed the title Composite catalog item component (feat): Multi resource catalog item and instance Jun 25, 2026
@jenniferubah
jenniferubah marked this pull request as ready for review June 25, 2026 21:35
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

Comment on lines +184 to +196
inst, err := s.Get(ctx, id)
if err != nil {
if errors.Is(err, ErrCatalogItemInstanceNotFound) {
return nil, ErrCatalogItemInstanceNotFound
}
return nil, fmt.Errorf("failed to get catalog item instance: %w", err)
}
if len(inst.Spec.ResourceIDs) == 0 || inst.Spec.ResourceIDs[0] != expectedResourceID {
return nil, ErrCatalogItemInstanceConflict
}

inst.Spec.ResourceIDs[0] = newResourceID
result := s.db.WithContext(ctx).Model(&inst).Where("id = ?", id).Select("spec").Updates(&inst)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the DB entry should be locked during this to avoid having potential race here where 2 requests race each other: we get the data from the DB, then some checks are performed on the app and only then the entry is updated in the DB. So during the time the checks are performed, some other changes may be applied to the DB.

So we should either block any change (or at least update) to be applied to the resource or do the update in 1 call as it was done previously

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the plan is to will be refactor this function in a follow up rehydration PR, hence the TODO. And I agree we should lock the transaction to prevent any race condition. Will do that in as part of the rehydration PR as well.

Comment thread internal/catalog/service/catalog_item_instance.go
Comment on lines +113 to +114
if err := validateUserValuesForCatalogItem(catalogItem.Spec, req.Spec.UserValues); err != nil {
return nil, err

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is called by BuildResourceGraph which is called by createInstance so I guess this call is duplicated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch. Removed it, e439426

Comment thread internal/catalog/store/catalog_item_filter.go Outdated
Comment thread internal/catalog/service/catalog_item_validation.go Outdated
if !ok {
return false
}
return strings.Contains(str, "${")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is to broad IMO. We should match for the whole pattern that we defined celReferencePattern

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check was used to fail any CEL expression in the user values but we don't want that so removed it. Updated it now to allow CEL in editable user values and validate it. See 2f3e26e.

Assisted-By: Cursor AI

Signed-off-by: Jennifer Ubah <cju.cipher@gmail.com>
Assisted-By: Cursor AI

Signed-off-by: Jennifer Ubah <cju.cipher@gmail.com>
// Call Placement Manager with the first resource
// until multi-resource placement deletion is wired.
s.logger.DebugContext(ctx, "Calling placement manager to delete resource", "id", id, "resource_id", instance.Spec.ResourceIDs[0])
if err := s.pmClient.DeleteResource(ctx, instance.Spec.ResourceIDs[0]); err != nil {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indexing [0] here can panic on empty rows

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I agree. It is only a placeholder since multi resource placement is not implemented yet. Will update this entirely when we have it.

Assisted-By: Cursor AI

Signed-off-by: Jennifer Ubah <cju.cipher@gmail.com>
Assisted-By: Cursor AI

Signed-off-by: Jennifer Ubah <cju.cipher@gmail.com>
@jenniferubah jenniferubah changed the title (feat): Multi resource catalog item and instance (catalog): Multi resource catalog item and instance Jul 2, 2026
@jenniferubah
jenniferubah merged commit f90aad9 into dcm-project:main Jul 3, 2026
6 checks passed
chadcrum pushed a commit to dcm-project/utilities that referenced this pull request Jul 20, 2026
## Summary

- Update `initRehydrationCatalogItem()` creation payload to use the new
`spec.resources[]` schema introduced by
[dcm-project/control-plane#11](dcm-project/control-plane#11)
- Update listing logic to find `service_type` inside `spec.resources[]`
(with fallback to legacy flat format)
- Add `resource` field to `UserValue` in `createTestInstance()` and
`defaultUserValues()`

## Problem

Since Jul 3 (control-plane PR #11 merge), the `BeforeSuite` in E2E tests
fails with:
```
catalog item creation returned unexpected status 400
```
This causes **all 145 tests to be skipped** on every nightly run (builds
170–194+).

The root cause is the catalog item API now requires
`spec.resources[{name, service_type, fields}]` instead of the old flat
`spec.service_type + spec.fields`. The OpenAPI validation middleware
rejects the old payload.

## Test plan

- [x] Trigger `CI/flightpath-dcm-deploy` job with this branch to verify
BeforeSuite passes
- [x] Confirm rehydration tests run (not skipped) and pass


Made with [Cursor](https://cursor.com)

Signed-off-by: Vladislav Kolodny <vkolodny@redhat.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
chadcrum added a commit to dcm-project/cli that referenced this pull request Jul 21, 2026
…ma (#28)

## Summary

- Update test fixtures in `catalog_item_test.go` to use the new
multi-resource catalog item schema (`spec.resources[]` instead of flat
`spec.service_type`)
- Fix `catalogItemTableDef` RowFunc in `catalog_item.go` to extract
`service_type` from `resources[0]` so the SERVICE TYPE table column
renders correctly against the updated control-plane

Relates to: FLPATH-4617

Depends on control-plane PR #11 (dcm-project/control-plane#11) which
introduced the multi-resource catalog item schema.

## User Impact

Users will now see catalog items in the CLI correctly when the
control-plane uses the new multi-resource schema, with service type
information displayed properly in table output.

Signed-off-by: Chad Crum <1462069+chadcrum@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants