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
19 changes: 13 additions & 6 deletions rest-api/api/pkg/api/handler/allocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,11 @@ func (cah CreateAllocationHandler) Handle(c echo.Context) error {
imAcAdd := []cdbm.AllocationConstraint{}
imAcUpd := []cdbm.AllocationConstraint{}
for _, ac := range dbacs {
retac, serr := acDAO.CreateFromParams(ctx, tx, a.ID, ac.ResourceType, ac.ResourceTypeID, ac.ConstraintType, ac.ConstraintValue, ac.DerivedResourceID, dbUser.ID)
retac, serr := acDAO.Create(ctx, tx, cdbm.AllocationConstraintCreateInput{
AllocationID: a.ID, ResourceType: ac.ResourceType, ResourceTypeID: ac.ResourceTypeID,
ConstraintType: ac.ConstraintType, ConstraintValue: ac.ConstraintValue,
DerivedResourceID: ac.DerivedResourceID, CreatedBy: dbUser.ID,
})
if serr != nil {
logger.Error().Err(serr).Msg("error creating Allocation Constraint DB entry")
return cutil.NewAPIError(http.StatusInternalServerError, "Failed to create Allocation Constraint entry for Allocation", nil)
Expand Down Expand Up @@ -750,7 +754,7 @@ func (gaah GetAllAllocationHandler) Handle(c echo.Context) error {

// Get allocation constraints based on allocation filter by resource type
acDAO := cdbm.NewAllocationConstraintDAO(gaah.dbSession)
alcs, _, err := acDAO.GetAll(ctx, nil, aids, nil, nil, nil, nil, nil, nil, cutil.GetPtr(cdbp.TotalLimit), nil)
alcs, _, err := acDAO.GetAll(ctx, nil, cdbm.AllocationConstraintFilterInput{AllocationIDs: aids}, cdbp.PageInput{Limit: cutil.GetPtr(cdbp.TotalLimit)}, nil)
if err != nil {
logger.Error().Err(err).Msg("error retrieving Allocation Constraints for Allocations from DB")
return cutil.NewAPIErrorResponse(c, http.StatusInternalServerError, "Failed to populate Constraints for Allocations", nil)
Expand Down Expand Up @@ -884,7 +888,7 @@ func (gah GetAllocationHandler) Handle(c echo.Context) error {
return cutil.NewAPIErrorResponse(c, http.StatusInternalServerError, "Failed to retrieve Status Details for Allocation", nil)
}
acDAO := cdbm.NewAllocationConstraintDAO(gah.dbSession)
acs, _, err := acDAO.GetAll(ctx, nil, []uuid.UUID{a.ID}, nil, nil, nil, nil, nil, nil, nil, nil)
acs, _, err := acDAO.GetAll(ctx, nil, cdbm.AllocationConstraintFilterInput{AllocationIDs: []uuid.UUID{a.ID}}, cdbp.PageInput{}, nil)
if err != nil {
logger.Error().Err(err).Msg("error retrieving Allocation Constraints for Allocation from DB")
return cutil.NewAPIErrorResponse(c, http.StatusInternalServerError, "Failed to retrieve Allocation Constraints for Allocation", nil)
Expand Down Expand Up @@ -1059,7 +1063,10 @@ func (uah UpdateAllocationHandler) Handle(c echo.Context) error {
// If this was an IP Block allocation, then update the derived resource name
// Get IP Block Allocation Constraints, if any
acDAO := cdbm.NewAllocationConstraintDAO(uah.dbSession)
ipbAcs, _, derr := acDAO.GetAll(ctx, tx, []uuid.UUID{a.ID}, cutil.GetPtr(cdbm.AllocationResourceTypeIPBlock), nil, nil, nil, nil, nil, nil, nil)
ipbAcs, _, derr := acDAO.GetAll(ctx, tx, cdbm.AllocationConstraintFilterInput{
AllocationIDs: []uuid.UUID{a.ID},
ResourceType: cutil.GetPtr(cdbm.AllocationResourceTypeIPBlock),
}, cdbp.PageInput{}, nil)
if derr != nil {
logger.Error().Err(derr).Msg("error retrieving Allocation Constraints for Allocation from DB")
return cutil.NewAPIError(http.StatusInternalServerError, "Failed to retrieve Allocation Constraints for Allocation", nil)
Expand Down Expand Up @@ -1097,7 +1104,7 @@ func (uah UpdateAllocationHandler) Handle(c echo.Context) error {
ssds = retSsds

acDAO := cdbm.NewAllocationConstraintDAO(uah.dbSession)
retAcs, _, derr := acDAO.GetAll(ctx, tx, []uuid.UUID{a.ID}, nil, nil, nil, nil, nil, nil, nil, nil)
retAcs, _, derr := acDAO.GetAll(ctx, tx, cdbm.AllocationConstraintFilterInput{AllocationIDs: []uuid.UUID{a.ID}}, cdbp.PageInput{}, nil)
if derr != nil {
logger.Error().Err(derr).Msg("error retrieving Allocation Constraints for Allocation from DB")
return cutil.NewAPIError(http.StatusInternalServerError, "Failed to retrieve Allocation Constraints for Allocation", nil)
Expand Down Expand Up @@ -1233,7 +1240,7 @@ func (dah DeleteAllocationHandler) Handle(c echo.Context) error {

// check dependent objects (instances or subnets for the tenant) in allocation constraints for the allocation
acDAO := cdbm.NewAllocationConstraintDAO(dah.dbSession)
acs, _, derr := acDAO.GetAll(ctx, tx, []uuid.UUID{a.ID}, nil, nil, nil, nil, nil, nil, cutil.GetPtr(cdbp.TotalLimit), nil)
acs, _, derr := acDAO.GetAll(ctx, tx, cdbm.AllocationConstraintFilterInput{AllocationIDs: []uuid.UUID{a.ID}}, cdbp.PageInput{Limit: cutil.GetPtr(cdbp.TotalLimit)}, nil)
if derr != nil && derr != cdb.ErrDoesNotExist {
logger.Error().Err(derr).Msg("error retrieving Allocation Constraints from DB")
return cutil.NewAPIError(http.StatusInternalServerError, "Error getting allocation constraints for allocation", nil)
Expand Down
20 changes: 11 additions & 9 deletions rest-api/api/pkg/api/handler/allocationconstraint.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,14 +243,13 @@ func (uach UpdateAllocationConstraintHandler) Handle(c echo.Context) error {
allocConstraints, _, derr := acDAO.GetAll(
ctx,
tx,
allocationIDs,
cutil.GetPtr(cdbm.AllocationResourceTypeInstanceType),
[]uuid.UUID{dbit.ID},
cutil.GetPtr(cdbm.AllocationConstraintTypeReserved),
nil,
nil,
nil,
cutil.GetPtr(paginator.TotalLimit),
cdbm.AllocationConstraintFilterInput{
AllocationIDs: allocationIDs,
ResourceType: cutil.GetPtr(cdbm.AllocationResourceTypeInstanceType),
ResourceTypeIDs: []uuid.UUID{dbit.ID},
ConstraintType: cutil.GetPtr(cdbm.AllocationConstraintTypeReserved),
},
paginator.PageInput{Limit: cutil.GetPtr(paginator.TotalLimit)},
nil,
)
if derr != nil {
Expand Down Expand Up @@ -424,7 +423,10 @@ func (uach UpdateAllocationConstraintHandler) Handle(c echo.Context) error {
}
}

newac, derr := acDAO.UpdateFromParams(ctx, tx, ac.ID, nil, nil, nil, nil, cutil.GetPtr(apiRequest.ConstraintValue), nil)
newac, derr := acDAO.Update(ctx, tx, cdbm.AllocationConstraintUpdateInput{
AllocationConstraintID: ac.ID,
ConstraintValue: cutil.GetPtr(apiRequest.ConstraintValue),
})
if derr != nil {
logger.Error().Err(derr).Msg("error updating Allocation Constraint in DB")
return nil, cutil.NewAPIError(http.StatusInternalServerError, "Failed to update Allocation Constraint with new constraint value, DB error", nil)
Expand Down
11 changes: 6 additions & 5 deletions rest-api/api/pkg/api/handler/allocationconstraint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
cutil "github.com/NVIDIA/infra-controller/rest-api/common/pkg/util"
"github.com/NVIDIA/infra-controller/rest-api/db/pkg/db/ipam"
cdbm "github.com/NVIDIA/infra-controller/rest-api/db/pkg/db/model"
cdbp "github.com/NVIDIA/infra-controller/rest-api/db/pkg/db/paginator"
"github.com/google/uuid"
"github.com/labstack/echo/v4"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -162,19 +163,19 @@ func TestAllocationConstraintHandler_Update(t *testing.T) {

// Get Allocation Constraints for above Allocations
acDAO := cdbm.NewAllocationConstraintDAO(dbSession)
acsit1, _, _ := acDAO.GetAll(ctx, nil, []uuid.UUID{aID1}, nil, nil, nil, nil, nil, nil, nil, nil)
acsit1, _, _ := acDAO.GetAll(ctx, nil, cdbm.AllocationConstraintFilterInput{AllocationIDs: []uuid.UUID{aID1}}, cdbp.PageInput{}, nil)
assert.NotNil(t, acsit1)

acsip1, _, _ := acDAO.GetAll(ctx, nil, []uuid.UUID{aipID1}, nil, nil, nil, nil, nil, nil, nil, nil)
acsip1, _, _ := acDAO.GetAll(ctx, nil, cdbm.AllocationConstraintFilterInput{AllocationIDs: []uuid.UUID{aipID1}}, cdbp.PageInput{}, nil)
assert.NotNil(t, acsip1)

acsit2, _, _ := acDAO.GetAll(ctx, nil, []uuid.UUID{aID2}, nil, nil, nil, nil, nil, nil, nil, nil)
acsit2, _, _ := acDAO.GetAll(ctx, nil, cdbm.AllocationConstraintFilterInput{AllocationIDs: []uuid.UUID{aID2}}, cdbp.PageInput{}, nil)
assert.NotNil(t, acsit2)

acsip2, _, _ := acDAO.GetAll(ctx, nil, []uuid.UUID{aipID2}, nil, nil, nil, nil, nil, nil, nil, nil)
acsip2, _, _ := acDAO.GetAll(ctx, nil, cdbm.AllocationConstraintFilterInput{AllocationIDs: []uuid.UUID{aipID2}}, cdbp.PageInput{}, nil)
assert.NotNil(t, acsip2)

acsip3, _, _ := acDAO.GetAll(ctx, nil, []uuid.UUID{aipID3}, nil, nil, nil, nil, nil, nil, nil, nil)
acsip3, _, _ := acDAO.GetAll(ctx, nil, cdbm.AllocationConstraintFilterInput{AllocationIDs: []uuid.UUID{aipID3}}, cdbp.PageInput{}, nil)
assert.NotNil(t, acsip3)

// Setup test data for Allocation Constraint Update
Expand Down
5 changes: 4 additions & 1 deletion rest-api/api/pkg/api/handler/instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,10 @@ func testInstanceSiteBuildAllocation(t *testing.T, dbSession *cdb.Session, st *c
func testInstanceSiteBuildAllocationContraints(t *testing.T, dbSession *cdb.Session, al *cdbm.Allocation, rt string, rtID uuid.UUID, ct string, cv int, user *cdbm.User) *cdbm.AllocationConstraint {
alctDAO := cdbm.NewAllocationConstraintDAO(dbSession)

alct, err := alctDAO.CreateFromParams(context.Background(), nil, al.ID, rt, rtID, ct, cv, nil, user.ID)
alct, err := alctDAO.Create(context.Background(), nil, cdbm.AllocationConstraintCreateInput{
AllocationID: al.ID, ResourceType: rt, ResourceTypeID: rtID,
ConstraintType: ct, ConstraintValue: cv, CreatedBy: user.ID,
})
assert.Nil(t, err)

return alct
Expand Down
5 changes: 4 additions & 1 deletion rest-api/api/pkg/api/handler/instancetype.go
Original file line number Diff line number Diff line change
Expand Up @@ -1411,7 +1411,10 @@ func (dith DeleteInstanceTypeHandler) Handle(c echo.Context) error {
return cutil.NewAPIError(http.StatusBadRequest, "Instance Type is being used by one or more Instances and cannot be deleted", nil)
}

acs, _, derr := acDAO.GetAll(ctx, tx, nil, &resourceType, []uuid.UUID{it.ID}, nil, nil, nil, nil, nil, nil)
acs, _, derr := acDAO.GetAll(ctx, tx, cdbm.AllocationConstraintFilterInput{
ResourceType: &resourceType,
ResourceTypeIDs: []uuid.UUID{it.ID},
}, cdbp.PageInput{}, nil)
if derr != nil {
logger.Error().Err(derr).Msg("error retrieving Allocation Constraints for Instance Type from DB")
return cutil.NewAPIError(http.StatusInternalServerError, "Failed to retrieve Allocation Constraints for Instance Type", nil)
Expand Down
9 changes: 7 additions & 2 deletions rest-api/api/pkg/api/handler/ipblock.go
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,9 @@ func (gadipbh GetAllDerivedIPBlockHandler) Handle(c echo.Context) error {

// Get allocation constraints by resourcetype ID (parent IPBlock)
acDAO := cdbm.NewAllocationConstraintDAO(gadipbh.dbSession)
acs, _, err := acDAO.GetAll(ctx, nil, nil, nil, []uuid.UUID{ipb.ID}, nil, nil, nil, nil, cutil.GetPtr(cdbp.TotalLimit), nil)
acs, _, err := acDAO.GetAll(ctx, nil, cdbm.AllocationConstraintFilterInput{
ResourceTypeIDs: []uuid.UUID{ipb.ID},
}, cdbp.PageInput{Limit: cutil.GetPtr(cdbp.TotalLimit)}, nil)
if err != nil {
logger.Error().Err(err).Msg("error retrieving Allocation Constraints for parent IPBlock from DB")
return cutil.NewAPIErrorResponse(c, http.StatusInternalServerError, "Failed to retrieve Allocation Constraints for parent IPBlock", nil)
Expand Down Expand Up @@ -1129,7 +1131,10 @@ func (dipbh DeleteIPBlockHandler) Handle(c echo.Context) error {

// Verify that the IPBlock does not have any allocations associated with it
acDAO := cdbm.NewAllocationConstraintDAO(dipbh.dbSession)
_, acCount, err := acDAO.GetAll(ctx, nil, nil, cutil.GetPtr(cdbm.AllocationResourceTypeIPBlock), []uuid.UUID{ipb.ID}, nil, nil, nil, nil, nil, nil)
_, acCount, err := acDAO.GetAll(ctx, nil, cdbm.AllocationConstraintFilterInput{
ResourceType: cutil.GetPtr(cdbm.AllocationResourceTypeIPBlock),
ResourceTypeIDs: []uuid.UUID{ipb.ID},
}, cdbp.PageInput{}, nil)
if err != nil {
logger.Error().Err(err).Msg("error getting allocation constraints")
return cutil.NewAPIErrorResponse(c, http.StatusInternalServerError, "Error retrieving Allocations for IP Block", nil)
Expand Down
6 changes: 5 additions & 1 deletion rest-api/api/pkg/api/handler/ipblock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,11 @@ func testIPBlockBuildAllocation(t *testing.T, dbSession *cdb.Session, st *cdbm.S
func testIPBlockBuildAllocationConstraint(t *testing.T, dbSession *cdb.Session, allocationID uuid.UUID, resourceType string, resourceTypeID uuid.UUID, constraintType string, constraintValue int, derivedResourceID *uuid.UUID, createdBy uuid.UUID) *cdbm.AllocationConstraint {
alcDAO := cdbm.NewAllocationConstraintDAO(dbSession)

alc, err := alcDAO.CreateFromParams(context.Background(), nil, allocationID, resourceType, resourceTypeID, constraintType, constraintValue, derivedResourceID, createdBy)
alc, err := alcDAO.Create(context.Background(), nil, cdbm.AllocationConstraintCreateInput{
AllocationID: allocationID, ResourceType: resourceType, ResourceTypeID: resourceTypeID,
ConstraintType: constraintType, ConstraintValue: constraintValue,
DerivedResourceID: derivedResourceID, CreatedBy: createdBy,
})
assert.Nil(t, err)

return alc
Expand Down
5 changes: 4 additions & 1 deletion rest-api/api/pkg/api/handler/machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,10 @@ func testMachineBuildAllocation(t *testing.T, dbSession *cdb.Session, ip *cdbm.I
func testMachineBuildAllocationContraints(t *testing.T, dbSession *cdb.Session, al *cdbm.Allocation, rt string, rtID uuid.UUID, ct string, cv int, user *cdbm.User) *cdbm.AllocationConstraint {
alctDAO := cdbm.NewAllocationConstraintDAO(dbSession)

alct, err := alctDAO.CreateFromParams(context.Background(), nil, al.ID, rt, rtID, ct, cv, nil, user.ID)
alct, err := alctDAO.Create(context.Background(), nil, cdbm.AllocationConstraintCreateInput{
AllocationID: al.ID, ResourceType: rt, ResourceTypeID: rtID,
ConstraintType: ct, ConstraintValue: cv, CreatedBy: user.ID,
})
assert.Nil(t, err)

return alct
Expand Down
2 changes: 1 addition & 1 deletion rest-api/api/pkg/api/handler/machineinstancetype_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ func TestDeleteMachineInstanceTypeHandler_Handle(t *testing.T) {

al, err := alDAO.GetByID(context.Background(), nil, uuid.MustParse(apial.ID), nil)
assert.NoError(t, err)
alcs, _, err := alcDAO.GetAll(context.Background(), nil, []uuid.UUID{al.ID}, nil, nil, nil, nil, nil, nil, nil, nil)
alcs, _, err := alcDAO.GetAll(context.Background(), nil, cdbm.AllocationConstraintFilterInput{AllocationIDs: []uuid.UUID{al.ID}}, paginator.PageInput{}, nil)
assert.NoError(t, err)
assert.Equal(t, 1, len(alcs))

Expand Down
16 changes: 10 additions & 6 deletions rest-api/api/pkg/api/handler/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,11 @@ func (gtitsh GetTenantInstanceTypeStatsHandler) Handle(c echo.Context) error {
var constraints []cdbm.AllocationConstraint
if len(allocationIDs) > 0 {
acDAO := cdbm.NewAllocationConstraintDAO(gtitsh.dbSession)
constraints, _, err = acDAO.GetAll(ctx, nil, allocationIDs,
cutil.GetPtr(cdbm.AllocationResourceTypeInstanceType), instanceTypeIDs,
nil, nil, []string{"Allocation.Tenant"}, nil, cutil.GetPtr(cdbp.TotalLimit), nil)
constraints, _, err = acDAO.GetAll(ctx, nil, cdbm.AllocationConstraintFilterInput{
AllocationIDs: allocationIDs,
ResourceType: cutil.GetPtr(cdbm.AllocationResourceTypeInstanceType),
ResourceTypeIDs: instanceTypeIDs,
}, cdbp.PageInput{Limit: cutil.GetPtr(cdbp.TotalLimit)}, []string{"Allocation.Tenant"})
if err != nil {
logger.Error().Err(err).Msg("error retrieving allocation constraints")
return cutil.NewAPIErrorResponse(c, http.StatusInternalServerError, "Failed to retrieve allocation constraints", nil)
Expand Down Expand Up @@ -526,9 +528,11 @@ func (gmitsh GetMachineInstanceTypeStatsHandler) Handle(c echo.Context) error {
var constraints []cdbm.AllocationConstraint
if len(allocationIDs) > 0 {
acDAO := cdbm.NewAllocationConstraintDAO(gmitsh.dbSession)
constraints, _, err = acDAO.GetAll(ctx, nil, allocationIDs,
cutil.GetPtr(cdbm.AllocationResourceTypeInstanceType), instanceTypeIDs,
nil, nil, []string{"Allocation.Tenant"}, nil, cutil.GetPtr(cdbp.TotalLimit), nil)
constraints, _, err = acDAO.GetAll(ctx, nil, cdbm.AllocationConstraintFilterInput{
AllocationIDs: allocationIDs,
ResourceType: cutil.GetPtr(cdbm.AllocationResourceTypeInstanceType),
ResourceTypeIDs: instanceTypeIDs,
}, cdbp.PageInput{Limit: cutil.GetPtr(cdbp.TotalLimit)}, []string{"Allocation.Tenant"})
if err != nil {
logger.Error().Err(err).Msg("error retrieving allocation constraints")
return cutil.NewAPIErrorResponse(c, http.StatusInternalServerError, "Failed to retrieve allocation constraints", nil)
Expand Down
31 changes: 26 additions & 5 deletions rest-api/api/pkg/api/handler/util/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,12 @@ func GetAllocationConstraintsForInstanceType(ctx context.Context, tx *cdb.Tx, db
var alconstraints []cdbm.AllocationConstraint
for _, ac := range allocations {
// improve this query by adding allocation slices in allocation constraints model
alcoss, _, err := alcsDAO.GetAll(ctx, tx, []uuid.UUID{ac.ID}, cutil.GetPtr(cdbm.AllocationResourceTypeInstanceType), []uuid.UUID{instancetype.ID}, cutil.GetPtr(cdbm.AllocationConstraintTypeReserved), nil, nil, nil, cutil.GetPtr(cdbp.TotalLimit), nil)
alcoss, _, err := alcsDAO.GetAll(ctx, tx, cdbm.AllocationConstraintFilterInput{
AllocationIDs: []uuid.UUID{ac.ID},
ResourceType: cutil.GetPtr(cdbm.AllocationResourceTypeInstanceType),
ResourceTypeIDs: []uuid.UUID{instancetype.ID},
ConstraintType: cutil.GetPtr(cdbm.AllocationConstraintTypeReserved),
}, cdbp.PageInput{Limit: cutil.GetPtr(cdbp.TotalLimit)}, nil)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -458,7 +463,10 @@ func GetSiteMachineCountStats(ctx context.Context, tx *cdb.Tx, dbSession *cdb.Se

// Get all Allocation Constraints for Allocation IDs
acDAO := cdbm.NewAllocationConstraintDAO(dbSession)
acs, _, err := acDAO.GetAll(ctx, tx, allocationIDs, cutil.GetPtr(cdbm.AllocationResourceTypeInstanceType), nil, nil, nil, nil, nil, cutil.GetPtr(cdbp.TotalLimit), nil)
acs, _, err := acDAO.GetAll(ctx, tx, cdbm.AllocationConstraintFilterInput{
AllocationIDs: allocationIDs,
ResourceType: cutil.GetPtr(cdbm.AllocationResourceTypeInstanceType),
}, cdbp.PageInput{Limit: cutil.GetPtr(cdbp.TotalLimit)}, nil)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -495,7 +503,12 @@ func GetTotalAllocationConstraintValueForInstanceType(ctx context.Context, tx *c
if instanceTypeID != nil {
instanceTypeIDs = []uuid.UUID{*instanceTypeID}
}
acs, _, err := acDAO.GetAll(ctx, tx, paramAllocationIDs, cutil.GetPtr(cdbm.AllocationResourceTypeInstanceType), instanceTypeIDs, constraintType, nil, nil, nil, cutil.GetPtr(cdbp.TotalLimit), nil)
acs, _, err := acDAO.GetAll(ctx, tx, cdbm.AllocationConstraintFilterInput{
AllocationIDs: paramAllocationIDs,
ResourceType: cutil.GetPtr(cdbm.AllocationResourceTypeInstanceType),
ResourceTypeIDs: instanceTypeIDs,
ConstraintType: constraintType,
}, cdbp.PageInput{Limit: cutil.GetPtr(cdbp.TotalLimit)}, nil)
if err != nil {
return 0, err
}
Expand Down Expand Up @@ -552,7 +565,11 @@ func GetAllAllocationConstraintsForInstanceType(ctx context.Context, tx *cdb.Tx,
for _, alloc := range allocs {
allocIDs = append(allocIDs, alloc.ID)
}
acs, tot, serr := acDAO.GetAll(ctx, tx, allocIDs, cutil.GetPtr(cdbm.AllocationResourceTypeInstanceType), resourceTypeIDs, nil, nil, nil, nil, cutil.GetPtr(cdbp.TotalLimit), nil)
acs, tot, serr := acDAO.GetAll(ctx, tx, cdbm.AllocationConstraintFilterInput{
AllocationIDs: allocIDs,
ResourceType: cutil.GetPtr(cdbm.AllocationResourceTypeInstanceType),
ResourceTypeIDs: resourceTypeIDs,
}, cdbp.PageInput{Limit: cutil.GetPtr(cdbp.TotalLimit)}, nil)
if serr != nil {
return nil, 0, serr
}
Expand Down Expand Up @@ -646,7 +663,11 @@ func GetAllInstanceTypeAllocationStats(ctx context.Context, dbSession *cdb.Sessi

// Get all Allocation Constraints for the Instance Type IDs and Allocation IDs
acDAO := cdbm.NewAllocationConstraintDAO(dbSession)
acss, _, err := acDAO.GetAll(ctx, nil, aids, cutil.GetPtr(cdbm.AllocationResourceTypeInstanceType), instanceTypeIDs, nil, nil, nil, nil, cutil.GetPtr(cdbp.TotalLimit), nil)
acss, _, err := acDAO.GetAll(ctx, nil, cdbm.AllocationConstraintFilterInput{
AllocationIDs: aids,
ResourceType: cutil.GetPtr(cdbm.AllocationResourceTypeInstanceType),
ResourceTypeIDs: instanceTypeIDs,
}, cdbp.PageInput{Limit: cutil.GetPtr(cdbp.TotalLimit)}, nil)
if err != nil {
return nil, cutil.NewAPIError(http.StatusInternalServerError, "Error retrieving Allocations for Instance Type, DB error", nil)
}
Expand Down
Loading
Loading