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

Fix config validation for feast.jobs.metrics.host #662

Merged
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
18 changes: 16 additions & 2 deletions core/src/main/java/feast/core/config/FeastProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

import feast.core.config.FeastProperties.StreamProperties.FeatureStreamOptions;
import feast.core.validators.OneOfStrings;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.*;
import javax.annotation.PostConstruct;
import javax.validation.*;
Expand All @@ -26,7 +28,6 @@
import javax.validation.constraints.Positive;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.validator.constraints.URL;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.info.BuildProperties;
Expand Down Expand Up @@ -91,6 +92,7 @@ public Runner getActiveRunner() {
@Getter
@Setter
public static class Runner {

/** Job runner name. This must be unique. */
String name;

Expand Down Expand Up @@ -173,7 +175,7 @@ public static class MetricsProperties {
private String type;

/* Host of metric sink */
@URL private String host;
private String host;

/* Port of metric sink */
@Positive private int port;
Expand Down Expand Up @@ -221,6 +223,18 @@ public void validate() {
if (!jobMetricViolations.isEmpty()) {
throw new ConstraintViolationException(jobMetricViolations);
}
// Additional custom check for hostname value because there is no built-in Spring annotation
// to validate the value is a DNS resolvable hostname or an IP address.
try {
//noinspection ResultOfMethodCallIgnored
InetAddress.getByName(getJobs().getMetrics().getHost());
} catch (UnknownHostException e) {
throw new IllegalArgumentException(
"Invalid config value for feast.jobs.metrics.host: "
+ getJobs().getMetrics().getHost()
+ ". Make sure it is a valid IP address or DNS hostname e.g. localhost or 10.128.10.40. Error detail: "
+ e.getMessage());
}
}
}
}