From 6eb1b3704779683e16fd800ba8c5f64f583d22a1 Mon Sep 17 00:00:00 2001 From: Bhumika Saini Date: Wed, 4 Oct 2023 21:35:11 +0530 Subject: [PATCH] Add default values for STORAGE_CLASS_SETTING and CANNED_ACL_SETTING for S3 Signed-off-by: Bhumika Saini --- .../java/org/opensearch/repositories/s3/S3Repository.java | 4 ++-- .../repositories/s3/RepositoryCredentialsTests.java | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/repository-s3/src/main/java/org/opensearch/repositories/s3/S3Repository.java b/plugins/repository-s3/src/main/java/org/opensearch/repositories/s3/S3Repository.java index 84df8739c18f9..473a0bb67a180 100644 --- a/plugins/repository-s3/src/main/java/org/opensearch/repositories/s3/S3Repository.java +++ b/plugins/repository-s3/src/main/java/org/opensearch/repositories/s3/S3Repository.java @@ -194,13 +194,13 @@ class S3Repository extends MeteredBlobStoreRepository { * Sets the S3 storage class type for the backup files. Values may be standard, reduced_redundancy, * standard_ia, onezone_ia and intelligent_tiering. Defaults to standard. */ - static final Setting STORAGE_CLASS_SETTING = Setting.simpleString("storage_class"); + static final Setting STORAGE_CLASS_SETTING = Setting.simpleString("storage_class", StorageClass.STANDARD.toString()); /** * The S3 repository supports all S3 canned ACLs : private, public-read, public-read-write, * authenticated-read, log-delivery-write, bucket-owner-read, bucket-owner-full-control. Defaults to private. */ - static final Setting CANNED_ACL_SETTING = Setting.simpleString("canned_acl"); + static final Setting CANNED_ACL_SETTING = Setting.simpleString("canned_acl", ObjectCannedACL.PRIVATE.toString()); static final Setting CLIENT_NAME = new Setting<>("client", "default", Function.identity()); diff --git a/plugins/repository-s3/src/test/java/org/opensearch/repositories/s3/RepositoryCredentialsTests.java b/plugins/repository-s3/src/test/java/org/opensearch/repositories/s3/RepositoryCredentialsTests.java index a4bfe11383b4f..8a788bb387173 100644 --- a/plugins/repository-s3/src/test/java/org/opensearch/repositories/s3/RepositoryCredentialsTests.java +++ b/plugins/repository-s3/src/test/java/org/opensearch/repositories/s3/RepositoryCredentialsTests.java @@ -113,7 +113,8 @@ public void testRepositoryCredentialsOverrideSecureCredentials() { final Settings.Builder repositorySettings = Settings.builder() // repository settings for credentials override node secure settings .put(S3Repository.ACCESS_KEY_SETTING.getKey(), "insecure_aws_key") - .put(S3Repository.SECRET_KEY_SETTING.getKey(), "insecure_aws_secret"); + .put(S3Repository.SECRET_KEY_SETTING.getKey(), "insecure_aws_secret") + .put("storage_class", "standard"); final String clientName = randomFrom("default", "other", null); if (clientName != null) { @@ -150,6 +151,7 @@ public void testReinitSecureCredentials() { final String clientName = randomFrom("default", "other"); final Settings.Builder repositorySettings = Settings.builder(); + repositorySettings.put("storage_class", "standard"); final boolean hasInsecureSettings = randomBoolean(); if (hasInsecureSettings) { // repository settings for credentials override node secure settings @@ -241,6 +243,7 @@ public void testInsecureRepositoryCredentials() throws Exception { Settings.builder() .put(S3Repository.ACCESS_KEY_SETTING.getKey(), "insecure_aws_key") .put(S3Repository.SECRET_KEY_SETTING.getKey(), "insecure_aws_secret") + .put("storage_class", "standard") .build() );