diff options
author | gjoranv <gjoranv@gmail.com> | 2023-03-30 15:04:07 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-30 15:04:07 +0200 |
commit | 95bdba88075024110dab52fdcdf17a171081fad0 (patch) | |
tree | 680fb1efca85153010d34e0af6841fc9fe475b32 | |
parent | 6ca6775cd1c9647676327de8553137f7b612479f (diff) | |
parent | 74aed4ab92296c952399cc17ff1711c893adc547 (diff) |
Merge pull request #26649 from vespa-engine/olaa/remove-cloudwatch
Remove CloudWatch config
8 files changed, 0 insertions, 259 deletions
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/CloudWatch.java b/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/CloudWatch.java deleted file mode 100644 index 9d4e732d3f8..00000000000 --- a/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/CloudWatch.java +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.model.admin.monitoring; - -import java.util.Optional; - -/** - * Helper object for CloudWatch configuration. - * - * @author gjoranv - */ -public class CloudWatch { - - private final String region; - private final String namespace; - private final MetricsConsumer consumer; - - private HostedAuth hostedAuth; - private SharedCredentials sharedCredentials; - - public CloudWatch(String region, String namespace, MetricsConsumer consumer) { - this.region = region; - this.namespace = namespace; - this.consumer = consumer; - } - - public String region() { return region; } - public String namespace() { return namespace; } - public String consumer() { return consumer.id(); } - - public Optional<HostedAuth> hostedAuth() {return Optional.ofNullable(hostedAuth); } - public Optional<SharedCredentials> sharedCredentials() {return Optional.ofNullable(sharedCredentials); } - - public void setHostedAuth(String accessKeyName, String secretKeyName) { - hostedAuth = new HostedAuth(accessKeyName, secretKeyName); - } - - public void setSharedCredentials(String file, Optional<String> profile) { - sharedCredentials = new SharedCredentials(file, profile); - } - - public static class HostedAuth { - public final String accessKeyName; - public final String secretKeyName; - - HostedAuth(String accessKeyName, String secretKeyName) { - this.accessKeyName = accessKeyName; - this.secretKeyName = secretKeyName; - } - } - - public static class SharedCredentials { - public final String file; - public final Optional<String> profile; - - SharedCredentials(String file, Optional<String> profile) { - this.file = file; - this.profile = profile; - } - } - -} diff --git a/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/MetricsConsumer.java b/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/MetricsConsumer.java index 671a90a0fee..c6bd4c6e295 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/MetricsConsumer.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/MetricsConsumer.java @@ -41,9 +41,6 @@ public class MetricsConsumer { private final String id; private final MetricSet metricSet; - // TODO: This shouldn't be here - private final List<CloudWatch> cloudWatches = new ArrayList<>(); - /** * @param id the consumer * @param metricSet the metrics for this consumer @@ -66,14 +63,6 @@ public class MetricsConsumer { return metricSet.getMetrics(); } - public void addCloudWatch(CloudWatch cloudWatch) { - cloudWatches.add(cloudWatch); - } - - public List<CloudWatch> cloudWatches() { - return unmodifiableList(cloudWatches); - } - private static MetricsConsumer consumer(String id, MetricSet ... metricSets) { return new MetricsConsumer(id, new MetricSet(id + "-consumer-metrics", List.of(), Arrays.asList(metricSets))); } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/builder/Metrics.java b/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/builder/Metrics.java index 5e76311dce3..aa61d2ffb74 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/builder/Metrics.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/builder/Metrics.java @@ -29,12 +29,4 @@ public class Metrics { .anyMatch(existing -> existing.equalsIgnoreCase(id)); } - /** - * Returns true if any of the consumers have specified external metric systems. - */ - public boolean usesExternalMetricSystems() { - return consumers.values().stream() - .anyMatch(consumer -> ! consumer.cloudWatches().isEmpty()); - } - } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/builder/xml/CloudWatchBuilder.java b/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/builder/xml/CloudWatchBuilder.java deleted file mode 100644 index ada4cb76d8e..00000000000 --- a/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/builder/xml/CloudWatchBuilder.java +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.model.admin.monitoring.builder.xml; - -import com.yahoo.vespa.model.admin.monitoring.CloudWatch; -import com.yahoo.vespa.model.admin.monitoring.MetricsConsumer; -import org.w3c.dom.Element; - -import static com.yahoo.config.model.builder.xml.XmlHelper.getOptionalAttribute; -import static com.yahoo.config.model.builder.xml.XmlHelper.getOptionalChild; - -/** - * @author gjoranv - */ -public class CloudWatchBuilder { - - private static final String REGION_ATTRIBUTE = "region"; - private static final String NAMESPACE_ATTRIBUTE = "namespace"; - private static final String CREDENTIALS_ELEMENT = "credentials"; - private static final String ACCESS_KEY_ATTRIBUTE = "access-key-name"; - private static final String SECRET_KEY_ATTRIBUTE = "secret-key-name"; - private static final String SHARED_CREDENTIALS_ELEMENT = "shared-credentials"; - private static final String PROFILE_ATTRIBUTE = "profile"; - private static final String FILE_ATTRIBUTE = "file"; - - public static CloudWatch buildCloudWatch(Element cloudwatchElement, MetricsConsumer consumer) { - CloudWatch cloudWatch = new CloudWatch(cloudwatchElement.getAttribute(REGION_ATTRIBUTE), - cloudwatchElement.getAttribute(NAMESPACE_ATTRIBUTE), - consumer); - - getOptionalChild(cloudwatchElement, CREDENTIALS_ELEMENT) - .ifPresent(elem -> cloudWatch.setHostedAuth(elem.getAttribute(ACCESS_KEY_ATTRIBUTE), - elem.getAttribute(SECRET_KEY_ATTRIBUTE))); - - getOptionalChild(cloudwatchElement, SHARED_CREDENTIALS_ELEMENT) - .ifPresent(elem -> cloudWatch.setSharedCredentials(elem.getAttribute(FILE_ATTRIBUTE), - getOptionalAttribute(elem, PROFILE_ATTRIBUTE))); - - return cloudWatch; - } - -} diff --git a/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/builder/xml/MetricsBuilder.java b/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/builder/xml/MetricsBuilder.java index cfd2ebb2fd1..f75b2a864f9 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/builder/xml/MetricsBuilder.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/admin/monitoring/builder/xml/MetricsBuilder.java @@ -41,9 +41,6 @@ public class MetricsBuilder { MetricSet metricSet = buildMetricSet(consumerId, consumerElement); var consumer = new MetricsConsumer(consumerId, metricSet); - for (Element cloudwatchElement : XML.getChildren(consumerElement, "cloudwatch")) { - consumer.addCloudWatch(CloudWatchBuilder.buildCloudWatch(cloudwatchElement, consumer)); - } metrics.addConsumer(consumer); } return metrics; diff --git a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/CloudWatchValidator.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/CloudWatchValidator.java deleted file mode 100644 index 847a3402dc5..00000000000 --- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/CloudWatchValidator.java +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.model.application.validation; - -import com.yahoo.config.model.ConfigModelContext; -import com.yahoo.config.model.deploy.DeployState; -import com.yahoo.vespa.model.VespaModel; -import com.yahoo.vespa.model.admin.monitoring.MetricsConsumer; - -import java.util.List; - -/** - * @author gjoranv - */ -public class CloudWatchValidator extends Validator { - - @Override - public void validate(VespaModel model, DeployState deployState) { - if (!deployState.isHosted()) return; - if (deployState.zone().system().isPublic()) return; - if (model.getAdmin().getApplicationType() != ConfigModelContext.ApplicationType.DEFAULT) return; - - var offendingConsumers = model.getAdmin().getUserMetrics().getConsumers().values().stream() - .filter(consumer -> !consumer.cloudWatches().isEmpty()) - .toList(); - - if (! offendingConsumers.isEmpty()) { - throw new IllegalArgumentException("CloudWatch cannot be set up for non-public hosted Vespa and must " + - "be removed for consumers: " + consumerIds(offendingConsumers)); - } - } - - private List<String> consumerIds(List<MetricsConsumer> offendingConsumers) { - return offendingConsumers.stream().map(MetricsConsumer::id).toList(); - } - -} diff --git a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/Validation.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/Validation.java index c7a363010b7..2576d9cb392 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/Validation.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/Validation.java @@ -82,7 +82,6 @@ public class Validation { new SecretStoreValidator().validate(model, deployState); new EndpointCertificateSecretsValidator().validate(model, deployState); new AccessControlFilterValidator().validate(model, deployState); - new CloudWatchValidator().validate(model, deployState); new QuotaValidator().validate(model, deployState); new UriBindingsValidator().validate(model, deployState); new CloudDataPlaneFilterValidator().validate(model, deployState); diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/CloudWatchValidatorTest.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/CloudWatchValidatorTest.java deleted file mode 100644 index f600900d3cd..00000000000 --- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/CloudWatchValidatorTest.java +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.model.application.validation; - -import com.yahoo.config.application.api.ApplicationPackage; -import com.yahoo.config.model.NullConfigModelRegistry; -import com.yahoo.config.model.deploy.DeployState; -import com.yahoo.config.model.deploy.TestProperties; -import com.yahoo.config.model.test.MockApplicationPackage; -import com.yahoo.config.provision.Environment; -import com.yahoo.config.provision.RegionName; -import com.yahoo.config.provision.SystemName; -import com.yahoo.config.provision.Zone; -import com.yahoo.vespa.model.VespaModel; -import org.junit.jupiter.api.Test; -import org.xml.sax.SAXException; - -import java.io.IOException; - -import static com.yahoo.config.provision.Environment.prod; -import static org.junit.jupiter.api.Assertions.*; - - -/** - * @author gjoranv - */ -public class CloudWatchValidatorTest { - - @Test - void cloudwatch_in_public_zones_passes_validation() throws IOException, SAXException { - DeployState deployState = deployState(servicesWithCloudwatch(), true, true); - VespaModel model = new VespaModel(new NullConfigModelRegistry(), deployState); - - new CloudWatchValidator().validate(model, deployState); - } - - @Test - void cloudwatch_passes_validation_for_self_hosted_vespa() throws IOException, SAXException { - DeployState deployState = deployState(servicesWithCloudwatch(), false, false); - VespaModel model = new VespaModel(new NullConfigModelRegistry(), deployState); - - new CloudWatchValidator().validate(model, deployState); - } - - @Test - void cloudwatch_in_non_public_zones_fails_validation() throws IOException, SAXException { - DeployState deployState = deployState(servicesWithCloudwatch(), true, false); - VespaModel model = new VespaModel(new NullConfigModelRegistry(), deployState); - - try { - new CloudWatchValidator().validate(model, deployState); - fail(); - } catch (IllegalArgumentException e) { - assertEquals("CloudWatch cannot be set up for non-public hosted Vespa and must be removed for consumers: [cloudwatch-consumer]", - e.getMessage()); - } - } - - private static DeployState deployState(String servicesXml, boolean isHosted, boolean isPublic) { - ApplicationPackage app = new MockApplicationPackage.Builder() - .withServices(servicesXml) - .build(); - - DeployState.Builder builder = new DeployState.Builder() - .applicationPackage(app) - .properties(new TestProperties().setHostedVespa(isHosted)); - if (isHosted) { - var system = isPublic ? SystemName.Public : SystemName.main; - builder.zone(new Zone(system, Environment.prod, RegionName.from("foo"))); - } - final DeployState deployState = builder.build(); - - if (isHosted) { - assertTrue(deployState.isHosted(), "Test must emulate a hosted deployment."); - assertEquals(prod, deployState.zone().environment(), "Test must emulate a prod environment."); - } - return deployState; - } - - private String servicesWithCloudwatch() { - return String.join("\n", - "<services>", - " <admin version='2.0'>", - " <adminserver hostalias='node1'/>", - " <metrics>", - " <consumer id='cloudwatch-consumer'>", - " <metric id='my-metric'/>", - " <cloudwatch region='us-east-1' namespace='my-namespace' >", - " <credentials access-key-name='my-access-key' ", - " secret-key-name='my-secret-key' />", - " </cloudwatch>", - " </consumer>", - " </metrics>", - " </admin>", - "</services>" - ); - } - -} |