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

general: add warnings when Layer1 topology is invalid #6611

Merged
merged 1 commit into from
Feb 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.Preconditions.checkArgument;
import static java.util.Objects.requireNonNull;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
Expand All @@ -22,9 +21,11 @@ public final class Layer1Node implements Comparable<Layer1Node> {

@JsonCreator
private static @Nonnull Layer1Node create(
@JsonProperty(PROP_HOSTNAME) String hostname,
@JsonProperty(PROP_INTERFACE_NAME) String interfaceName) {
return new Layer1Node(requireNonNull(hostname), requireNonNull(interfaceName));
@JsonProperty(PROP_HOSTNAME) @Nullable String hostname,
@JsonProperty(PROP_INTERFACE_NAME) @Nullable String interfaceName) {
checkArgument(hostname != null, "Missing %s", PROP_HOSTNAME);
checkArgument(interfaceName != null, "Missing %s", PROP_INTERFACE_NAME);
return new Layer1Node(hostname, interfaceName);
}

private final String _hostname;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
import net.jpountz.lz4.LZ4FrameOutputStream;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.batfish.common.BatfishException;
import org.batfish.common.BatfishLogger;
import org.batfish.common.BfConsts;
Expand Down Expand Up @@ -100,6 +102,7 @@
/** A utility class that abstracts the underlying file system storage used by Batfish. */
@ParametersAreNonnullByDefault
public class FileBasedStorage implements StorageProvider {
private static final Logger LOGGER = LogManager.getLogger(FileBasedStorage.class);

@VisibleForTesting static final Duration GC_SKEW_ALLOWANCE = Duration.ofMinutes(10L);
private static final String ID_EXTENSION = ".id";
Expand Down Expand Up @@ -222,6 +225,7 @@ public SortedMap<String, Configuration> loadConfigurations(
_logger.errorf(
"Failed to deserialize ConvertConfigurationAnswerElement: %s",
Throwables.getStackTraceAsString(e));
LOGGER.error("Failed to deserialize ConvertConfigurationAnswerElement", e);
return null;
}
}
Expand Down Expand Up @@ -253,6 +257,11 @@ public SortedMap<String, Configuration> loadConfigurations(
_logger.warnf(
"Unexpected exception caught while loading interface blacklist for snapshot %s: %s",
snapshot, Throwables.getStackTraceAsString(e));
LOGGER.warn(
String.format(
"Unexpected exception caught while loading interface blacklist for snapshot %s",
snapshot),
e);
return null;
}
}
Expand All @@ -277,6 +286,11 @@ static boolean keyInDir(String key, String dirName) {
_logger.warnf(
"Unexpected exception caught while loading ISP configuration for snapshot %s: %s",
snapshot, Throwables.getStackTraceAsString(e));
LOGGER.warn(
String.format(
"Unexpected exception caught while loading ISP configuration for snapshot %s",
snapshot),
e);
return null;
}
}
Expand Down Expand Up @@ -307,6 +321,10 @@ static boolean keyInDir(String key, String dirName) {
_logger.warnf(
"Unexpected exception caught while loading node blacklist for snapshot %s: %s",
snapshot, Throwables.getStackTraceAsString(e));
LOGGER.warn(
String.format(
"Unexpected exception caught while loading node blacklist for snapshot %s", snapshot),
e);
return null;
}
}
Expand Down Expand Up @@ -336,6 +354,11 @@ static boolean keyInDir(String key, String dirName) {
_logger.warnf(
"Unexpected exception caught while loading layer-1 topology for snapshot %s: %s",
snapshot, Throwables.getStackTraceAsString(e));
LOGGER.warn(
String.format(
"Unexpected exception caught while loading layer-1 topology for snapshot %s",
snapshot),
e);
return null;
} finally {
counter.incrementAndGet();
Expand Down Expand Up @@ -392,6 +415,10 @@ public String loadWorkJson(NetworkId network, SnapshotId snapshot, String workId
_logger.warnf(
"Unexpected exception caught while loading runtime data for snapshot %s: %s",
snapshot, Throwables.getStackTraceAsString(e));
LOGGER.warn(
String.format(
"Unexpected exception caught while loading runtime data for snapshot %s", snapshot),
e);
return null;
} finally {
counter.incrementAndGet();
Expand Down Expand Up @@ -589,6 +616,10 @@ private boolean cachedConfigsAreCompatible(NetworkId network, SnapshotId snapsho
_logger.warnf(
"Unexpected exception caught while deserializing configs for snapshot %s: %s",
snapshot, Throwables.getStackTraceAsString(e));
LOGGER.warn(
String.format(
"Unexpected exception caught while deserializing configs for snapshot %s", snapshot),
e);
return false;
}
}
Expand Down Expand Up @@ -1838,6 +1869,8 @@ public void runGarbageCollection(Instant expungeBeforeDate) throws IOException {
_logger.errorf(
"Failed to expunge old data for network with ID '%s': %s",
networkId, Throwables.getStackTraceAsString(e));
LOGGER.error(
String.format("Failed to expunge old data for network %s", networkId), e);
}
});
}
Expand Down