-
Notifications
You must be signed in to change notification settings - Fork 121
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
CODENVY-957 Implement resources redistribution between suborganizations #1141
Conversation
45ed0d4
to
32662b6
Compare
@skabashnyuk @akorneta @evoevodin @mshaposhnik Please take a look my changes |
98619bb
to
fff6a09
Compare
These changes should be merged with changes for #1198 |
9cafe1d
to
04dfa49
Compare
* @throws ServerException | ||
* when any other error occurs | ||
*/ | ||
public void setResourcesLimit(OrganizationResourcesLimit resourcesLimit) throws NotFoundException, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name of the method looks inconsistent with get, i mean it's should be either
setResourcesLimit
getResourcesLimit
or(i like this one)
setLimit
getLimit
or even
set
get
but not
setResourcesLimit
get
if (existed != null) { | ||
try { | ||
final Resource deducted = resourceAggregator.deduct(existed, newResource); | ||
// existed resource amount is more than new one |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is greater than
29b1b48
to
900b5cb
Compare
case RESET_DISTRIBUTED_RESOURCES: | ||
//we should check permissions on parent organization level | ||
String suborganizationId = (String)arguments[0]; | ||
final String parentId = organizationManager.getById(suborganizationId).getParent(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't see any purpose from having 2 more variables.
e.g the following code looks also ok to me:
organizationId = organizationManager.getById((String)arguments[0]).getParent();
if (organizationid == null) {
return;
}
break;
} | ||
|
||
|
||
if (!currentSubject.hasPermission(DOMAIN_ID, organizationId, OrganizationDomain.MANAGE_RESOURCES)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would use class name along with DOMAIN_ID
, from the code it's not clear what domain is identified with this id.
Moreover you use SystemDomain.DOMAIN_ID
above, does it make any sense to you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also you use MANAGE_ORGANIZATION_ACTION
as static import
import static com.codenvy.organization.api.permissions.OrganizationPermissionsFilter.MANAGE_ORGANIZATIONS_ACTION;
but you don't do it with OrganizationDomain.MANAGE_RESOURCES
is there any regularity i don't see?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch. I removed static imports for domains' identifiers and action to make more clear their locations
*/ | ||
@Singleton | ||
public class OrganizationResourceLockKeyProvider implements ResourceLockKeyProvider { | ||
private OrganizationManager organizationManager; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like final
is missing
} | ||
return organization.getId(); | ||
} catch (NotFoundException e) { | ||
throw new ServerException(format("Organization with id '%s' was not found during resources locking.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
during resources locking
looks like you just trying to get a lock key, so i think the message should be a bit different
} | ||
|
||
@POST | ||
@Path("{suborganizationId}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reset
method path starts with /
while this path doesn't, i find it a bit inconsistent don't you?
@ApiOperation(value = "Distribute resources for suborganization.", | ||
notes = "Distributed resources is unavailable for usage by parent organization." + | ||
"It should reset resources distribution before consuming.", | ||
response = OrganizationDistributedResourcesDto.class) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lie, this method returns nothing
@Path("/{organizationId}") | ||
@ApiOperation(value = "Reset resources distribution.", | ||
notes = "After distribution resetting suborganization won't be able to use parent resources.") | ||
@ApiResponses({@ApiResponse(code = 201, message = "Resources distribution successfully reset"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why 201, it's 204 i think
} | ||
|
||
/** | ||
* TODO Revise doc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do it! 🚀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that you did a pretty big amount of work, good job! Some of the futures are context specific so it's hard to review all of them, the code in general looks okay to me.
-- from Codenvy S.A.. | ||
-- | ||
|
||
-- Organization distributed resources ))--------------------------------------------------------- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete the brackets please
*/ | ||
public interface OrganizationDistributedResourcesDao { | ||
/** | ||
* Stores distributed resources for suborganization. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it will be helpful to describe here how to store resources when there are already exist resources for the organization.
f5d23e2
to
9ef1706
Compare
f3f9ac1
to
461842f
Compare
461842f
to
e39a9fc
Compare
After running the selenium tests new regression has not been found |
e39a9fc
to
7e14a2e
Compare
7e14a2e
to
a3c529a
Compare
What does this PR do?
Added ability to redistribute resources between suborganizations.
Introduced new state for account's resources, it's called
reserved resources
. It means that account's license has resources but it can't use it for consumtion by workpace starting, creation etc.Implemented new organization resources API that allows to define resources that should be provided for usage by suborganization from its parent organization. Only users who have
manageResources
permissions can grant suborganization to use parent organization's resources. Resources become unavailable for his parent organization when user allows suborganization to use them, so they become reserved resources. By default all suborganizations don't have any resources limit and it means that they are not able to use resources of their parent organizations.What issues does this PR fix or reference?
#957
New Behavior
Organization can provide own resources to usage by their suborganizations.
Tests written?
Yes
Docs requirements?
Include the content for all the docs changes required.