Skip to content

Commit

Permalink
Merge pull request #2403 from subutai-io/dev
Browse files Browse the repository at this point in the history
#2379 correcting depiction of quota on UI (Dev->Master)
  • Loading branch information
Dilshat authored Apr 12, 2018
2 parents 8cb90cc + 402690c commit 7a9b908
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -419,25 +419,6 @@ public ContainerHostState getContainerState( final ContainerId containerId ) thr
}


@Override
public io.subutai.common.host.Quota getRawQuota( final ContainerId containerId ) throws PeerException
{
Preconditions.checkNotNull( containerId );

try
{
ContainerHostInfo containerHostInfo =
( ContainerHostInfo ) hostRegistry.getHostInfoById( containerId.getId() );
return containerHostInfo.getRawQuota();
}
catch ( Exception e )
{
LOG.error( e.getMessage() );
throw new PeerException( String.format( "Error getting container quota: %s", e.getMessage() ), e );
}
}


@Override
public Containers getEnvironmentContainers( final EnvironmentId environmentId ) throws PeerException
{
Expand Down Expand Up @@ -3005,6 +2986,29 @@ public Quota getQuota( final ContainerId containerId, ContainerResourceType cont
}


@Override
public io.subutai.common.host.Quota getRawQuota( final ContainerId containerId ) throws PeerException
{
Preconditions.checkNotNull( containerId );

try
{
ContainerHostInfo containerHostInfo =
( ContainerHostInfo ) hostRegistry.getHostInfoById( containerId.getId() );

io.subutai.common.host.Quota quota = containerHostInfo.getRawQuota();

//temp workaround for btrfs quota issue https://github.com/subutai-io/agent/wiki/Switch-to-Soft-Quota
return new io.subutai.common.host.Quota( quota.getCpu(), quota.getRam(), quota.getDisk() / 2 );
}
catch ( Exception e )
{
LOG.error( e.getMessage() );
throw new PeerException( String.format( "Error getting container quota: %s", e.getMessage() ), e );
}
}


@Override
public ContainerQuota getQuota( final ContainerId containerId ) throws PeerException
{
Expand Down Expand Up @@ -3050,6 +3054,16 @@ public ContainerQuota getQuota( final ContainerId containerId ) throws PeerExcep
LOG.error( e.getMessage(), e );
throw new PeerException( String.format( "Could not obtain quota values of %s.", containerId.getId() ) );
}

//temp workaround for btrfs quota issue https://github.com/subutai-io/agent/wiki/Switch-to-Soft-Quota
if ( containerQuota.getContainerSize() == ContainerSize.CUSTOM )
{

containerQuota.add( new Quota( new ContainerDiskResource(
containerQuota.get( ContainerResourceType.DISK ).getAsDiskResource().longValue( ByteUnit.GB ) / 2,
ByteUnit.GB ), 0 ) );
}

return containerQuota;
}

Expand Down Expand Up @@ -3094,7 +3108,7 @@ public void setQuota( final ContainerId containerId, final ContainerQuota contai
quota = ContainerSize.getDefaultContainerQuota( ContainerSize.SMALL );
}

if ( quota.getAll().isEmpty() )
if ( containerQuota.getContainerSize() == ContainerSize.CUSTOM || quota.getAll().isEmpty() )
{
quota.copyValues( containerQuota );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ public static RequestBuilder getSetQuotaCommand( String containerName, Container
if ( r.getResource().getContainerResourceType() == ContainerResourceType.DISK )
{
//temp workaround for btrfs quota issue https://github.com/subutai-io/agent/wiki/Switch-to-Soft-Quota

quotaCommand.addArgument( String.valueOf( r.getAsDiskResource().longValue( ByteUnit.GB ) * 2 ) );
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ public class Quota implements Serializable
private Double disk;


public Quota( final Double cpu, final Double ram, final Double disk )
{
this.cpu = cpu;
this.ram = ram;
this.disk = disk;
}


public Double getCpu()
{
return cpu;
Expand Down

0 comments on commit 7a9b908

Please sign in to comment.