From: norbert.bizet Date: Tue, 26 Jul 2022 09:44:24 +0000 (-0400) Subject: cloud: introduce a default object tier directive in Cloud X-Git-Tag: Beta-15.0.0~543 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0cfd1886c88932692c472f5783815324ebb46268;p=thirdparty%2Fbacula.git cloud: introduce a default object tier directive in Cloud --- diff --git a/bacula/src/stored/file_driver.c b/bacula/src/stored/file_driver.c index 990268ac3..c6e897f66 100644 --- a/bacula/src/stored/file_driver.c +++ b/bacula/src/stored/file_driver.c @@ -356,6 +356,7 @@ bool file_driver::copy_cache_part_to_cloud(transfer *xfer) POOLMEM *cloud_fname = get_pool_memory(PM_FNAME); make_cloud_filename(cloud_fname, xfer->m_volume_name, "part", xfer->m_part); Dmsg2(dbglvl, "Call put_object: %s, %s\n", xfer->m_cache_fname, cloud_fname); + Dmsg1(dbglvl, "objects_default_tier: %d\n", objects_default_tier); bool rtn = put_object(xfer, xfer->m_cache_fname, cloud_fname, &upload_limit); free_pool_memory(cloud_fname); return rtn; @@ -452,7 +453,7 @@ bool file_driver::init(CLOUD *cloud, POOLMEM *&err) uriStyle = cloud->uri_style; accessKeyId = cloud->access_key; secretAccessKey = cloud->secret_key; - + objects_default_tier = cloud->objects_default_tier; return true; } diff --git a/bacula/src/stored/file_driver.h b/bacula/src/stored/file_driver.h index 4e73158bb..3d1b8327f 100644 --- a/bacula/src/stored/file_driver.h +++ b/bacula/src/stored/file_driver.h @@ -47,7 +47,7 @@ public: int32_t protocol; int32_t uriStyle; btime_t wait_timeout; - + uint32_t objects_default_tier; private: void make_cloud_filename(POOLMEM *&filename, const char *VolumeName, const char *file, uint32_t part); diff --git a/bacula/src/stored/generic_driver.c b/bacula/src/stored/generic_driver.c index 1294ce574..2e034c6f4 100644 --- a/bacula/src/stored/generic_driver.c +++ b/bacula/src/stored/generic_driver.c @@ -162,6 +162,7 @@ bool generic_driver::init(CLOUD *cloud, POOLMEM *&err) { max_concurrent_downloads = cloud->max_concurrent_downloads; upload_limit.set_bwlimit(cloud->upload_limit); download_limit.set_bwlimit(cloud->download_limit); + objects_default_tier = cloud->objects_default_tier; driver_command = cloud->driver_command; diff --git a/bacula/src/stored/generic_driver.h b/bacula/src/stored/generic_driver.h index 442579e61..bd6d582e7 100644 --- a/bacula/src/stored/generic_driver.h +++ b/bacula/src/stored/generic_driver.h @@ -47,6 +47,7 @@ protected: char *endpoint_suffix; uint32_t max_concurrent_uploads; uint32_t max_concurrent_downloads; + uint32_t objects_default_tier; /* read_cb_type : returns the number of proceed bytes from char*. char* is the data buffer. diff --git a/bacula/src/stored/protos.h b/bacula/src/stored/protos.h index 5ef0485f7..21293224a 100644 --- a/bacula/src/stored/protos.h +++ b/bacula/src/stored/protos.h @@ -324,6 +324,7 @@ void store_devtype(LEX *lc, RES_ITEM *item, int index, int pass); void store_cloud_driver(LEX *lc, RES_ITEM *item, int index, int pass); void store_maxblocksize(LEX *lc, RES_ITEM *item, int index, int pass); void store_transfer_priority(LEX *lc, RES_ITEM *item, int index, int pass); +void store_objects_default_tier(LEX *lc, RES_ITEM *item, int index, int pass); /* from sdcollect.c */ bool update_permanent_stats(void *data); diff --git a/bacula/src/stored/s3_driver.c b/bacula/src/stored/s3_driver.c index 6186a9557..3f4f6993e 100644 --- a/bacula/src/stored/s3_driver.c +++ b/bacula/src/stored/s3_driver.c @@ -874,6 +874,7 @@ bool s3_driver::init(CLOUD *cloud, POOLMEM *&err) s3ctx.accessKeyId = cloud->access_key; s3ctx.secretAccessKey = cloud->secret_key; s3ctx.authRegion = cloud->region; + objects_default_tier = cloud->objects_default_tier; if ((status = S3_initialize("s3", S3_INIT_ALL, s3ctx.hostName)) != S3StatusOK) { Mmsg1(err, "Failed to initialize S3 lib. ERR=%s\n", S3_get_status_name(status)); diff --git a/bacula/src/stored/s3_driver.h b/bacula/src/stored/s3_driver.h index 9acda06b8..9f2c33f18 100644 --- a/bacula/src/stored/s3_driver.h +++ b/bacula/src/stored/s3_driver.h @@ -38,6 +38,7 @@ private: S3BucketContext s3ctx; /* Main S3 bucket context */ S3RestoreTier transfer_priority; uint32_t transfer_retention_days; + uint32_t objects_default_tier; public: cloud_dev *dev; /* device that is calling us */ diff --git a/bacula/src/stored/stored_conf.c b/bacula/src/stored/stored_conf.c index e000b0b26..01756af81 100644 --- a/bacula/src/stored/stored_conf.c +++ b/bacula/src/stored/stored_conf.c @@ -240,6 +240,7 @@ static RES_ITEM cloud_items[] = { {"DriverCommand", store_strname, ITEM(res_cloud.driver_command), 0, 0, 0}, {"TransferPriority", store_transfer_priority, ITEM(res_cloud.transfer_priority), 0, ITEM_DEFAULT, 0}, {"TransferRetention", store_time, ITEM(res_cloud.transfer_retention), 0, ITEM_DEFAULT, 5 * 3600 * 24}, + {"ObjectsDefaultTier", store_objects_default_tier, ITEM(res_cloud.objects_default_tier), 0, ITEM_DEFAULT, 0}, {NULL, NULL, {0}, 0, 0, 0} }; @@ -539,6 +540,25 @@ s_kw restore_prio_opts[] = { {NULL, 0} }; +/* + * Cloud Object tier level + * + * Option option code = token + */ +s_kw objects_default_tiers[] = { + + {"S3Standard", S3_STANDARD}, + {"S3StandardIA", S3_STANDARD_IA}, + {"S3IntelligentTiering", S3_INTELLIGENT_TIERING}, + {"S3OneZoneIA", S3_ONE_ZONE_IA}, + {"S3GlacierInstantRetrieval", S3_GLACIER_INSTANT_RETRIEVAL}, + {"S3GlacierFlexibleRetrieval", S3_GLACIER_FLEXIBLE_RETRIEVAL}, + {"S3GlacierDeepArchive", S3_GLACIER_DEEP_ARCHIVE}, + {"S3Rrs", S3_RRS}, + {NULL, 0} +}; + + /* * Store Cloud restoration priority */ @@ -562,6 +582,29 @@ void store_transfer_priority(LEX *lc, RES_ITEM *item, int index, int pass) set_bit(index, res_all.hdr.item_present); } +/* + * Store Cloud object default tier + */ +void store_objects_default_tier(LEX *lc, RES_ITEM *item, int index, int pass) +{ + bool found = false; + + lex_get_token(lc, T_NAME); + /* Store the label pass 2 so that type is defined */ + for (int i=0; objects_default_tiers[i].name; i++) { + if (strcasecmp(lc->str, objects_default_tiers[i].name) == 0) { + *(uint32_t *)(item->value) = objects_default_tiers[i].token; + found = true; + break; + } + } + if (!found) { + scan_err1(lc, _("Expected a Cloud Objects default tier, got: %s"), lc->str); + } + scan_to_eol(lc); + set_bit(index, res_all.hdr.item_present); +} + static void dump_store_resource(STORES *store, void sendit(const char *msg, int len, STATUS_PKT *sp), STATUS_PKT *sp) { diff --git a/bacula/src/stored/stored_conf.h b/bacula/src/stored/stored_conf.h index 25e727d94..3c3221a61 100644 --- a/bacula/src/stored/stored_conf.h +++ b/bacula/src/stored/stored_conf.h @@ -77,6 +77,17 @@ enum { CLOUD_RESTORE_PRIO_LOW }; +enum { + S3_STANDARD = 0, + S3_STANDARD_IA, + S3_INTELLIGENT_TIERING, + S3_ONE_ZONE_IA, + S3_GLACIER_INSTANT_RETRIEVAL, + S3_GLACIER_FLEXIBLE_RETRIEVAL, + S3_GLACIER_DEEP_ARCHIVE, + S3_RRS +}; + class CLOUD { public: RES hdr; @@ -102,6 +113,7 @@ public: char *driver_command; int32_t transfer_priority; utime_t transfer_retention; + uint32_t objects_default_tier; }; /*