]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
cloud: introduce a default object tier directive in Cloud
authornorbert.bizet <norbert.bizet@baculasystems.com>
Tue, 26 Jul 2022 09:44:24 +0000 (05:44 -0400)
committerEric Bollengier <eric@baculasystems.com>
Thu, 14 Sep 2023 11:56:58 +0000 (13:56 +0200)
bacula/src/stored/file_driver.c
bacula/src/stored/file_driver.h
bacula/src/stored/generic_driver.c
bacula/src/stored/generic_driver.h
bacula/src/stored/protos.h
bacula/src/stored/s3_driver.c
bacula/src/stored/s3_driver.h
bacula/src/stored/stored_conf.c
bacula/src/stored/stored_conf.h

index 990268ac356e0e941ad94e267253ba6b9e72fa6d..c6e897f6641a3e52cf17ed2119a0378590c92a99 100644 (file)
@@ -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;
 }
 
index 4e73158bb581e0af54b02d6b8e9ac7d60f08a089..3d1b8327f600389574ac3a4bdbc267424264fc77 100644 (file)
@@ -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);
index 1294ce574871a911b2da14540b0990679dfc0c5f..2e034c6f45a56032a928119ac1dc5349018e443f 100644 (file)
@@ -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;
 
index 442579e6172dba740705e57876123e5bec730d27..bd6d582e7c1907ec7ab3faf2a484fde9079322c5 100644 (file)
@@ -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. 
index 5ef0485f77799c8c1c9489c2dffd3fbe642499b3..21293224adff37248c3f828f9c01724f539c5363 100644 (file)
@@ -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);
index 6186a95572305bc8dc8f1e4a8aa06f5125313a77..3f4f6993e1d738a86a84afd11e7f195155e426ed 100644 (file)
@@ -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));
index 9acda06b87f6d2f783c55f3f1ed95becbf4e988f..9f2c33f18d270f6049575dd28b97fb59dfe6af83 100644 (file)
@@ -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 */
 
index e000b0b268c0ecdbaf26e279db03b5ae3f275e3e..01756af811499e7966dd49befd93295f7556af39 100644 (file)
@@ -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)
 {
index 25e727d945c2064915c6b89250d473819ad33641..3c3221a61e62cff79e149b5bd60f2733c639185d 100644 (file)
@@ -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;
 };
 
 /*