fix: add CPU quota on che-plugin-artifacts-broker container (#183)
* Add CPU quota Signed-off-by: disaster37 <linuxworkgroup@hotmail.com> * fix: add CPU quota on che-plugin-artifacts-broker containerpull/171/head
parent
cf741dbc4d
commit
f289ec619f
|
|
@ -209,6 +209,8 @@ public abstract class BrokerEnvironmentFactory<E extends KubernetesEnvironment>
|
|||
Container container = cb.build();
|
||||
Containers.addRamLimit(container, "250Mi");
|
||||
Containers.addRamRequest(container, "250Mi");
|
||||
Containers.addCpuLimit(container, "300m");
|
||||
Containers.addCpuRequest(container, "300m");
|
||||
return container;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import com.google.common.collect.ImmutableList;
|
|||
import io.fabric8.kubernetes.api.model.ConfigMap;
|
||||
import io.fabric8.kubernetes.api.model.Container;
|
||||
import io.fabric8.kubernetes.api.model.PodSpec;
|
||||
import io.fabric8.kubernetes.api.model.Quantity;
|
||||
import java.net.URI;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
|
@ -379,6 +380,34 @@ public class BrokerEnvironmentFactoryTest {
|
|||
String.format("Should generate name '%s' from image '%s'.", expected, image));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQuotasBroker() throws Exception {
|
||||
// given
|
||||
Collection<PluginFQN> pluginFQNs = singletonList(new PluginFQN(null, "id"));
|
||||
ArgumentCaptor<BrokersConfigs> captor = ArgumentCaptor.forClass(BrokersConfigs.class);
|
||||
|
||||
// when
|
||||
factory.createForMetadataBroker(pluginFQNs, runtimeId, false);
|
||||
|
||||
// then
|
||||
verify(factory).doCreate(captor.capture());
|
||||
BrokersConfigs brokersConfigs = captor.getValue();
|
||||
|
||||
List<Container> containers =
|
||||
brokersConfigs
|
||||
.pods
|
||||
.values()
|
||||
.stream()
|
||||
.flatMap(p -> p.getSpec().getContainers().stream())
|
||||
.collect(Collectors.toList());
|
||||
assertEquals(containers.size(), 1);
|
||||
Container container = containers.get(0);
|
||||
assertEquals(container.getResources().getRequests().get("memory"), new Quantity("250Mi"));
|
||||
assertEquals(container.getResources().getLimits().get("memory"), new Quantity("250Mi"));
|
||||
assertEquals(container.getResources().getRequests().get("cpu"), new Quantity("300m"));
|
||||
assertEquals(container.getResources().getLimits().get("cpu"), new Quantity("300m"));
|
||||
}
|
||||
|
||||
@DataProvider(name = "imageRefs")
|
||||
public Object[][] imageRefs() {
|
||||
return new Object[][] {
|
||||
|
|
|
|||
Loading…
Reference in New Issue