Skip to content

Commit

Permalink
Add Deployment Images for Reporting V2 (#1099)
Browse files Browse the repository at this point in the history
  • Loading branch information
tristanvuong2021 authored Jul 19, 2023
1 parent e34c15b commit 5eac37b
Show file tree
Hide file tree
Showing 17 changed files with 777 additions and 6 deletions.
42 changes: 38 additions & 4 deletions src/main/docker/images.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,44 @@ REPORTING_GKE_IMAGES = [
),
]

ALL_GKE_IMAGES = COMMON_IMAGES + GKE_IMAGES + REPORTING_COMMON_IMAGES + REPORTING_GKE_IMAGES
REPORTING_V2_COMMON_IMAGES = [
struct(
name = "reporting_v2alpha_public_api_server_image",
image = "//src/main/kotlin/org/wfanet/measurement/reporting/deploy/v2/common/server:v2alpha_public_api_server_image",
repository = _PREFIX + "/reporting/v2/v2alpha-public-api",
),
]

REPORTING_V2_LOCAL_IMAGES = [
struct(
name = "internal_reporting_v2_server_image",
image = "//src/main/kotlin/org/wfanet/measurement/reporting/deploy/v2/postgres/server:postgres_internal_reporting_server_image",
repository = _PREFIX + "/reporting/v2/local-postgres-internal",
),
struct(
name = "reporting_v2_postgres_update_schema_image",
image = "//src/main/kotlin/org/wfanet/measurement/reporting/deploy/v2/postgres/tools:update_schema_image",
repository = _PREFIX + "/reporting/v2/local-postgres-update-schema",
),
]

REPORTING_V2_GKE_IMAGES = [
struct(
name = "gcloud_reporting_v2_internal_server_image",
image = "//src/main/kotlin/org/wfanet/measurement/reporting/deploy/v2/gcloud/postgres/server:gcloud_postgres_internal_reporting_server_image",
repository = _PREFIX + "/reporting/v2/postgres-internal-server",
),
struct(
name = "gcloud_reporting_v2_postgres_update_schema_image",
image = "//src/main/kotlin/org/wfanet/measurement/reporting/deploy/v2/gcloud/postgres/tools:update_schema_image",
repository = _PREFIX + "/reporting/v2/postgres-update-schema",
),
]

ALL_GKE_IMAGES = COMMON_IMAGES + GKE_IMAGES + REPORTING_COMMON_IMAGES + REPORTING_GKE_IMAGES + REPORTING_V2_COMMON_IMAGES + REPORTING_V2_GKE_IMAGES

ALL_LOCAL_IMAGES = COMMON_IMAGES + LOCAL_IMAGES + REPORTING_COMMON_IMAGES + REPORTING_LOCAL_IMAGES
ALL_LOCAL_IMAGES = COMMON_IMAGES + LOCAL_IMAGES + REPORTING_COMMON_IMAGES + REPORTING_LOCAL_IMAGES + REPORTING_V2_COMMON_IMAGES + REPORTING_V2_LOCAL_IMAGES

ALL_IMAGES = COMMON_IMAGES + LOCAL_IMAGES + GKE_IMAGES + REPORTING_COMMON_IMAGES + REPORTING_LOCAL_IMAGES + REPORTING_GKE_IMAGES
ALL_IMAGES = COMMON_IMAGES + LOCAL_IMAGES + GKE_IMAGES + REPORTING_COMMON_IMAGES + REPORTING_LOCAL_IMAGES + REPORTING_GKE_IMAGES + REPORTING_V2_COMMON_IMAGES + REPORTING_V2_LOCAL_IMAGES + REPORTING_V2_GKE_IMAGES

ALL_REPORTING_GKE_IMAGES = REPORTING_COMMON_IMAGES + REPORTING_GKE_IMAGES
ALL_REPORTING_GKE_IMAGES = REPORTING_COMMON_IMAGES + REPORTING_GKE_IMAGES + REPORTING_V2_COMMON_IMAGES + REPORTING_V2_GKE_IMAGES
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library")

package(
default_visibility = [
"//src/main/kotlin/org/wfanet/measurement/reporting:__subpackages__",
"//src/test/kotlin/org/wfanet/measurement/reporting:__subpackages__",
],
)

kt_jvm_library(
name = "encryption_key_pair_map",
srcs = ["EncryptionKeyPairMap.kt"],
deps = [
"//src/main/proto/wfa/measurement/config/reporting:encryption_key_pair_config_kt_jvm_proto",
"@wfa_common_jvm//imports/java/picocli",
"@wfa_common_jvm//src/main/kotlin/org/wfanet/measurement/common/crypto/tink",
],
)

kt_jvm_library(
name = "flags",
srcs = ["InternalApiFlags.kt"],
deps = [
"@wfa_common_jvm//imports/java/picocli",
],
)

kt_jvm_library(
name = "kingdom_flags",
srcs = ["KingdomApiFlags.kt"],
deps = [
"@wfa_common_jvm//imports/java/picocli",
],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright 2023 The Cross-Media Measurement Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.wfanet.measurement.reporting.deploy.v2.common

import com.google.protobuf.ByteString
import java.io.File
import org.wfanet.measurement.common.crypto.PrivateKeyHandle
import org.wfanet.measurement.common.crypto.tink.loadPrivateKey
import org.wfanet.measurement.common.parseTextProto
import org.wfanet.measurement.common.readByteString
import org.wfanet.measurement.config.reporting.encryptionKeyPairConfig
import picocli.CommandLine.Option

class EncryptionKeyPairMap {
@Option(
names = ["--key-pair-dir"],
description = ["Path to the directory of MeasurementConsumer's encryption keys"],
)
private lateinit var keyFilesDirectory: File

@Option(
names = ["--key-pair-config-file"],
description = ["Path to the textproto file of EncryptionKeyPairConfig that contains key pairs"],
required = true
)
private lateinit var keyPairConfigFile: File

private fun loadKeyPairs(): Map<String, List<Pair<ByteString, PrivateKeyHandle>>> {
val keyPairConfig =
parseTextProto(keyPairConfigFile, encryptionKeyPairConfig {}).principalKeyPairsList
return keyPairConfig.associate { config ->
val keyPairs =
config.keyPairsList.map { keyPair ->
val publicKey = keyFilesDirectory.resolve(keyPair.publicKeyFile).readByteString()
val privateKey = loadPrivateKey(keyFilesDirectory.resolve(keyPair.privateKeyFile))
publicKey to privateKey
}
checkNotNull(config.principal) to keyPairs
}
}

val keyPairs: Map<String, List<Pair<ByteString, PrivateKeyHandle>>> by lazy { loadKeyPairs() }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright 2023 The Cross-Media Measurement Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.wfanet.measurement.reporting.deploy.v2.common

import picocli.CommandLine

class InternalApiFlags {
@set:CommandLine.Option(
names = ["--internal-api-target"],
description = ["gRPC target (authority) of the Reporting internal API server"],
required = true,
)
lateinit var target: String

@CommandLine.Option(
names = ["--internal-api-cert-host"],
description =
[
"Expected hostname (DNS-ID) in the Reporting internal API server's TLS certificate.",
"This overrides derivation of the TLS DNS-ID from --internal-api-target.",
],
required = false,
)
var certHost: String? = null
private set
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright 2023 The Cross-Media Measurement Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.wfanet.measurement.reporting.deploy.v2.common

import picocli.CommandLine

class KingdomApiFlags {
@set:CommandLine.Option(
names = ["--kingdom-api-target"],
description = ["gRPC target (authority) of the Kingdom public API server"],
required = true,
)
lateinit var target: String

@CommandLine.Option(
names = ["--kingdom-api-cert-host"],
description =
[
"Expected hostname (DNS-ID) in the Kingdom public API server's TLS certificate.",
"This overrides derivation of the TLS DNS-ID from --kingdom-api-target.",
],
required = false,
)
var certHost: String? = null
private set
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library")
load("@rules_java//java:defs.bzl", "java_binary")
load("//src/main/docker:macros.bzl", "java_image")

kt_jvm_library(
name = "internal_reporting_server",
Expand All @@ -17,3 +19,59 @@ kt_jvm_library(
"@wfa_common_jvm//src/main/kotlin/org/wfanet/measurement/common/grpc",
],
)

kt_jvm_library(
name = "reporting_api_server_flags",
srcs = ["ReportingApiServerFlags.kt"],
deps = [
"//src/main/kotlin/org/wfanet/measurement/reporting/deploy/v2/common:flags",
"@wfa_common_jvm//imports/java/picocli",
],
)

kt_jvm_library(
name = "v2alpha_public_api_server",
srcs = ["V2AlphaPublicApiServer.kt"],
runtime_deps = ["@wfa_common_jvm//imports/java/io/grpc/netty"],
deps = [
":reporting_api_server_flags",
"//src/main/kotlin/org/wfanet/measurement/common/api:memoizing_principal_lookup",
"//src/main/kotlin/org/wfanet/measurement/reporting/deploy/common:encryption_key_pair_map",
"//src/main/kotlin/org/wfanet/measurement/reporting/deploy/common:kingdom_flags",
"//src/main/kotlin/org/wfanet/measurement/reporting/service/api:cel_env_provider",
"//src/main/kotlin/org/wfanet/measurement/reporting/service/api:encryption_key_pair_store",
"//src/main/kotlin/org/wfanet/measurement/reporting/service/api/v2alpha:akid_principal_lookup",
"//src/main/kotlin/org/wfanet/measurement/reporting/service/api/v2alpha:event_groups_service",
"//src/main/kotlin/org/wfanet/measurement/reporting/service/api/v2alpha:metrics_service",
"//src/main/kotlin/org/wfanet/measurement/reporting/service/api/v2alpha:reporting_sets_service",
"//src/main/kotlin/org/wfanet/measurement/reporting/service/api/v2alpha:reports_service",
"//src/main/proto/wfa/measurement/api/v2alpha:certificates_service_kt_jvm_grpc_proto",
"//src/main/proto/wfa/measurement/api/v2alpha:data_providers_service_kt_jvm_grpc_proto",
"//src/main/proto/wfa/measurement/api/v2alpha:event_group_metadata_descriptors_service_kt_jvm_grpc_proto",
"//src/main/proto/wfa/measurement/api/v2alpha:event_groups_service_kt_jvm_grpc_proto",
"//src/main/proto/wfa/measurement/api/v2alpha:measurement_consumers_service_kt_jvm_grpc_proto",
"//src/main/proto/wfa/measurement/api/v2alpha:measurements_service_kt_jvm_grpc_proto",
"//src/main/proto/wfa/measurement/internal/reporting/v2:measurement_consumers_service_kt_jvm_grpc_proto",
"//src/main/proto/wfa/measurement/internal/reporting/v2:measurements_service_kt_jvm_grpc_proto",
"//src/main/proto/wfa/measurement/internal/reporting/v2:metrics_service_kt_jvm_grpc_proto",
"//src/main/proto/wfa/measurement/internal/reporting/v2:reporting_sets_service_kt_jvm_grpc_proto",
"//src/main/proto/wfa/measurement/internal/reporting/v2:reports_service_kt_jvm_grpc_proto",
"@wfa_common_jvm//imports/java/io/grpc:api",
"@wfa_common_jvm//imports/java/picocli",
"@wfa_common_jvm//src/main/kotlin/org/wfanet/measurement/common",
"@wfa_common_jvm//src/main/kotlin/org/wfanet/measurement/common/grpc",
],
)

java_binary(
name = "V2AlphaPublicApiServer",
main_class = "org.wfanet.measurement.reporting.deploy.v2.common.server.V2AlphaPublicApiServerKt",
runtime_deps = [":v2alpha_public_api_server"],
)

java_image(
name = "v2alpha_public_api_server_image",
binary = ":V2AlphaPublicApiServer",
main_class = "org.wfanet.measurement.reporting.deploy.v2.common.server.V2AlphaPublicApiServerKt",
visibility = ["//src:docker_image_deployment"],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright 2023 The Cross-Media Measurement Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.wfanet.measurement.reporting.deploy.v2.common.server

import java.time.Duration
import kotlin.properties.Delegates
import org.wfanet.measurement.reporting.deploy.v2.common.InternalApiFlags
import picocli.CommandLine

class ReportingApiServerFlags {
@CommandLine.Mixin
lateinit var internalApiFlags: InternalApiFlags
private set

@set:CommandLine.Option(
names = ["--debug-verbose-grpc-client-logging"],
description = ["Enables full gRPC request and response logging for outgoing gRPCs"],
defaultValue = "false"
)
var debugVerboseGrpcClientLogging by Delegates.notNull<Boolean>()
private set

@CommandLine.Option(
names = ["--event-group-metadata-descriptor-cache-duration"],
description =
[
"How long the event group metadata descriptors are cached for before refreshing in format 1d1h1m1s1ms1ns"
],
defaultValue = "1h",
required = false,
)
lateinit var eventGroupMetadataDescriptorCacheDuration: Duration
private set
}
Loading

0 comments on commit 5eac37b

Please sign in to comment.