use of com.yahoo.vespa.hosted.node.admin.maintenance.acl.iptables.FlushCommand in project vespa by vespa-engine.
the class AclMaintainer method applyAcl.
private void applyAcl(ContainerName containerName, Acl acl) {
if (isAclActive(containerName, acl)) {
return;
}
final Command flush = new FlushCommand(Chain.INPUT);
final Command rollback = new PolicyCommand(Chain.INPUT, Action.ACCEPT);
try {
String commands = Stream.concat(Stream.of(flush), acl.toCommands().stream()).map(command -> command.asString(IPTABLES_COMMAND)).collect(Collectors.joining("; "));
log.debug("Running ACL command '" + commands + "' in " + containerName.asString());
dockerOperations.executeCommandInNetworkNamespace(containerName, "/bin/sh", "-c", commands);
containerAcls.put(containerName, acl);
} catch (Exception e) {
log.error("Exception occurred while configuring ACLs for " + containerName.asString() + ", attempting rollback", e);
try {
dockerOperations.executeCommandInNetworkNamespace(containerName, rollback.asArray(IPTABLES_COMMAND));
} catch (Exception ne) {
log.error("Rollback of ACLs for " + containerName.asString() + " failed, giving up", ne);
}
}
}
Aggregations