Skip to content

Commit

Permalink
Merge pull request #2247 from subutai-io/base-2226
Browse files Browse the repository at this point in the history
#2226 skip stopped containers, added logs
  • Loading branch information
Dilshat authored Feb 7, 2018
2 parents d5b38f2 + 6bd38b4 commit f08a7f7
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import io.subutai.common.command.RequestBuilder;
import io.subutai.common.environment.ContainerDto;
import io.subutai.common.environment.EnvironmentDto;
import io.subutai.common.host.ContainerHostState;
import io.subutai.common.peer.ContainerHost;
import io.subutai.common.peer.LocalPeer;
import io.subutai.common.peer.ResourceHost;
Expand Down Expand Up @@ -66,6 +67,12 @@ private void checkDiskUsage( ContainerDto containerDto )
// b.b if du is >= 150 % of quota -> stop container, notify Hub
try
{

if ( containerDto.getState() != ContainerHostState.RUNNING )
{
return;
}

ResourceHost resourceHost = localPeer.getResourceHostById( containerDto.getRhId() );

ContainerHost containerHost = localPeer.getContainerHostById( containerDto.getId() );
Expand All @@ -80,12 +87,17 @@ private void checkDiskUsage( ContainerDto containerDto )

if ( diskUsed >= diskLimit * 0.9 )
{
LOG.info( "Container {} is exceeding disk quota: limit {}, actual usage {}",
containerDto.getContainerName(), diskLimit, diskUsed );

boolean stop = diskUsed >= diskLimit * 1.5;

if ( stop )
{
//stop container
containerHost.stop();

LOG.info( "Container {} is stopped due to disk quota excess", containerDto.getContainerName() );
}

//notify Hub
Expand Down

0 comments on commit f08a7f7

Please sign in to comment.