Skip to content
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

#2226 skip stopped containers, added logs #2247

Merged
merged 1 commit into from
Feb 7, 2018
Merged
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
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