mirror of
https://github.com/google/nomulus.git
synced 2025-04-30 12:07:51 +02:00
Fix GCS bucket/subdir handling in IcannReportingStager (#1265)
After the migration to the new GCS API it becomes apparent that the BlobId.of() method needs to take the bucket name (without any trailing directories) as the first argument. I did a search on all occurrences of "BlobId.of" in the code base and verified that it is only in the ICANN reporting job that the API was misused. <!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/google/nomulus/1265) <!-- Reviewable:end -->
This commit is contained in:
parent
fa74048916
commit
d6808bba71
2 changed files with 7 additions and 7 deletions
|
@ -259,8 +259,8 @@ public class IcannReportingStager {
|
||||||
tld,
|
tld,
|
||||||
Ascii.toLowerCase(reportType.toString()),
|
Ascii.toLowerCase(reportType.toString()),
|
||||||
DateTimeFormat.forPattern("yyyyMM").print(yearMonth));
|
DateTimeFormat.forPattern("yyyyMM").print(yearMonth));
|
||||||
String reportBucketname = String.format("%s/%s", reportingBucket, subdir);
|
final BlobId gcsFilename =
|
||||||
final BlobId gcsFilename = BlobId.of(reportBucketname, reportFilename);
|
BlobId.of(reportingBucket, String.format("%s/%s", subdir, reportFilename));
|
||||||
gcsUtils.createFromBytes(gcsFilename, reportBytes);
|
gcsUtils.createFromBytes(gcsFilename, reportBytes);
|
||||||
logger.atInfo().log("Wrote %d bytes to file location %s", reportBytes.length, gcsFilename);
|
logger.atInfo().log("Wrote %d bytes to file location %s", reportBytes.length, gcsFilename);
|
||||||
return reportFilename;
|
return reportFilename;
|
||||||
|
@ -268,8 +268,8 @@ public class IcannReportingStager {
|
||||||
|
|
||||||
/** Creates and stores a manifest file on GCS, indicating which reports were generated. */
|
/** Creates and stores a manifest file on GCS, indicating which reports were generated. */
|
||||||
void createAndUploadManifest(String subdir, ImmutableList<String> filenames) throws IOException {
|
void createAndUploadManifest(String subdir, ImmutableList<String> filenames) throws IOException {
|
||||||
String reportBucketname = String.format("%s/%s", reportingBucket, subdir);
|
final BlobId gcsFilename =
|
||||||
final BlobId gcsFilename = BlobId.of(reportBucketname, MANIFEST_FILE_NAME);
|
BlobId.of(reportingBucket, String.format("%s/%s", subdir, MANIFEST_FILE_NAME));
|
||||||
StringBuilder manifestString = new StringBuilder();
|
StringBuilder manifestString = new StringBuilder();
|
||||||
filenames.forEach((filename) -> manifestString.append(filename).append("\n"));
|
filenames.forEach((filename) -> manifestString.append(filename).append("\n"));
|
||||||
gcsUtils.createFromBytes(gcsFilename, manifestString.toString().getBytes(UTF_8));
|
gcsUtils.createFromBytes(gcsFilename, manifestString.toString().getBytes(UTF_8));
|
||||||
|
|
|
@ -145,10 +145,10 @@ public final class IcannReportingUploadAction implements Runnable {
|
||||||
String.format(
|
String.format(
|
||||||
"icann/monthly/%d-%02d",
|
"icann/monthly/%d-%02d",
|
||||||
cursorTimeMinusMonth.getYear(), cursorTimeMinusMonth.getMonthOfYear());
|
cursorTimeMinusMonth.getYear(), cursorTimeMinusMonth.getMonthOfYear());
|
||||||
String reportBucketname = String.format("%s/%s", reportingBucket, reportSubdir);
|
|
||||||
String filename = getFileName(cursorType, cursorTime, tldStr);
|
String filename = getFileName(cursorType, cursorTime, tldStr);
|
||||||
final BlobId gcsFilename = BlobId.of(reportBucketname, filename);
|
final BlobId gcsFilename =
|
||||||
logger.atInfo().log("Reading ICANN report %s from bucket %s", filename, reportBucketname);
|
BlobId.of(reportingBucket, String.format("%s/%s", reportSubdir, filename));
|
||||||
|
logger.atInfo().log("Reading ICANN report %s from bucket %s", filename, reportingBucket);
|
||||||
// Check that the report exists
|
// Check that the report exists
|
||||||
try {
|
try {
|
||||||
verifyFileExists(gcsFilename);
|
verifyFileExists(gcsFilename);
|
||||||
|
|
Loading…
Add table
Reference in a new issue