From 513bbbaccbbbedd1c33776cbbd9a24bc7614d1fe Mon Sep 17 00:00:00 2001 From: Adrian Parreiras Horta Date: Mon, 13 Feb 2023 14:29:18 -0800 Subject: [PATCH] Add default 90 day bucket retention --- lib/puppet/type/influxdb_bucket.rb | 2 +- manifests/init.pp | 2 +- manifests/profile/toml.pp | 2 + .../influxdb_bucket/influxdb_bucket_spec.rb | 396 ------------------ 4 files changed, 4 insertions(+), 398 deletions(-) diff --git a/lib/puppet/type/influxdb_bucket.rb b/lib/puppet/type/influxdb_bucket.rb index e53d949..47793cc 100644 --- a/lib/puppet/type/influxdb_bucket.rb +++ b/lib/puppet/type/influxdb_bucket.rb @@ -39,7 +39,7 @@ desc: 'Rules to determine retention of data inside the bucket', default: [{ 'type' => 'expire', - 'everySeconds' => 0, + 'everySeconds' => 7_776_000, 'shardGroupDurationSeconds' => 604_800, }] }, diff --git a/manifests/init.pp b/manifests/init.pp index afdafaa..188cf27 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -83,7 +83,7 @@ unless $host == $facts['networking']['fqdn'] or $host == $facts['networking']['hostname'] or $host == 'localhost' { fail( @("MSG") - Unable to manage InfluxDB installation on host: ${host}. + Unable to manage InfluxDB installation on host: ${host}. Management of repos, packages and services etc is only possible on the local host (${facts['networking']['fqdn']}). | MSG ) diff --git a/manifests/profile/toml.pp b/manifests/profile/toml.pp index 16d1227..006fda5 100644 --- a/manifests/profile/toml.pp +++ b/manifests/profile/toml.pp @@ -1,6 +1,8 @@ # @summary Installs the toml-rb gem inside Puppet server # @example Basic usage # include influxdb::profile::toml +# @param version +# Version of the toml-rb gem to install class influxdb::profile::toml ( String $version = '2.1.1', ) { diff --git a/spec/unit/puppet/provider/influxdb_bucket/influxdb_bucket_spec.rb b/spec/unit/puppet/provider/influxdb_bucket/influxdb_bucket_spec.rb index 0b7f6e8..1a16916 100644 --- a/spec/unit/puppet/provider/influxdb_bucket/influxdb_bucket_spec.rb +++ b/spec/unit/puppet/provider/influxdb_bucket/influxdb_bucket_spec.rb @@ -166,402 +166,6 @@ expect(provider.get(context)).to eq should_hash end end - - # context 'with paginated api response' do - # it 'processes paginated responses' do - # response_1 = [{ - # 'links' => { - # 'self' => '/api/v2/buckets?descending=false&limit=20&offset=0', - # 'next' => '/api/v2/buckets?descending=false&limit=20&offset=20' - # }, - # 'buckets' => [ - # { - # 'id' => '1231', - # 'orgID' => '123', - # 'type' => 'user', - # 'name' => '1', - # 'links' => { - # 'self' => '/api/v2/buckets/1', - # }, - # 'retentionRules' => [ - # { - # 'type' => 'expire', - # 'everySeconds' => 2_592_000, - # 'shardGroupDurationSeconds' => 604_800 - # }, - # ], - # 'labels' => { 'links' => { 'self' => '/api/v2/labels' }, 'labels' => [] } - # }, - # { - # 'id' => '1232', - # 'orgID' => '123', - # 'type' => 'user', - # 'name' => '2', - # 'links' => { - # 'self' => '/api/v2/buckets/2', - # }, - # 'retentionRules' => [ - # { - # 'type' => 'expire', - # 'everySeconds' => 2_592_000, - # 'shardGroupDurationSeconds' => 604_800 - # }, - # ], - # 'labels' => { 'links' => { 'self' => '/api/v2/labels' }, 'labels' => [] } - # }, - # { - # 'id' => '1233', - # 'orgID' => '123', - # 'type' => 'user', - # 'name' => '3', - # 'links' => { - # 'self' => '/api/v2/buckets/3', - # }, - # 'retentionRules' => [ - # { - # 'type' => 'expire', - # 'everySeconds' => 2_592_000, - # 'shardGroupDurationSeconds' => 604_800 - # }, - # ], - # 'labels' => { 'links' => { 'self' => '/api/v2/labels' }, 'labels' => [] } - # }, - # { - # 'id' => '1234', - # 'orgID' => '123', - # 'type' => 'user', - # 'name' => '4', - # 'links' => { - # 'self' => '/api/v2/buckets/4', - # }, - # 'retentionRules' => [ - # { - # 'type' => 'expire', - # 'everySeconds' => 2_592_000, - # 'shardGroupDurationSeconds' => 604_800 - # }, - # ], - # 'labels' => { 'links' => { 'self' => '/api/v2/labels' }, 'labels' => [] } - # }, - # { - # 'id' => '1235', - # 'orgID' => '123', - # 'type' => 'user', - # 'name' => '5', - # 'links' => { - # 'self' => '/api/v2/buckets/5', - # }, - # 'retentionRules' => [ - # { - # 'type' => 'expire', - # 'everySeconds' => 2_592_000, - # 'shardGroupDurationSeconds' => 604_800 - # }, - # ], - # 'labels' => { 'links' => { 'self' => '/api/v2/labels' }, 'labels' => [] } - # }, - # { - # 'id' => '1236', - # 'orgID' => '123', - # 'type' => 'user', - # 'name' => '6', - # 'links' => { - # 'self' => '/api/v2/buckets/6', - # }, - # 'retentionRules' => [ - # { - # 'type' => 'expire', - # 'everySeconds' => 2_592_000, - # 'shardGroupDurationSeconds' => 604_800 - # }, - # ], - # 'labels' => { 'links' => { 'self' => '/api/v2/labels' }, 'labels' => [] } - # }, - # { - # 'id' => '1237', - # 'orgID' => '123', - # 'type' => 'user', - # 'name' => '7', - # 'links' => { - # 'self' => '/api/v2/buckets/7', - # }, - # 'retentionRules' => [ - # { - # 'type' => 'expire', - # 'everySeconds' => 2_592_000, - # 'shardGroupDurationSeconds' => 604_800 - # }, - # ], - # 'labels' => { 'links' => { 'self' => '/api/v2/labels' }, 'labels' => [] } - # }, - # { - # 'id' => '1238', - # 'orgID' => '123', - # 'type' => 'user', - # 'name' => '8', - # 'links' => { - # 'self' => '/api/v2/buckets/8', - # }, - # 'retentionRules' => [ - # { - # 'type' => 'expire', - # 'everySeconds' => 2_592_000, - # 'shardGroupDurationSeconds' => 604_800 - # }, - # ], - # 'labels' => { 'links' => { 'self' => '/api/v2/labels' }, 'labels' => [] } - # }, - # { - # 'id' => '1239', - # 'orgID' => '123', - # 'type' => 'user', - # 'name' => '9', - # 'links' => { - # 'self' => '/api/v2/buckets/9', - # }, - # 'retentionRules' => [ - # { - # 'type' => 'expire', - # 'everySeconds' => 2_592_000, - # 'shardGroupDurationSeconds' => 604_800 - # }, - # ], - # 'labels' => { 'links' => { 'self' => '/api/v2/labels' }, 'labels' => [] } - # }, - # { - # 'id' => '12310', - # 'orgID' => '123', - # 'type' => 'user', - # 'name' => '10', - # 'links' => { - # 'self' => '/api/v2/buckets/10', - # }, - # 'retentionRules' => [ - # { - # 'type' => 'expire', - # 'everySeconds' => 2_592_000, - # 'shardGroupDurationSeconds' => 604_800 - # }, - # ], - # 'labels' => { 'links' => { 'self' => '/api/v2/labels' }, 'labels' => [] } - # }, - # { - # 'id' => '12311', - # 'orgID' => '123', - # 'type' => 'user', - # 'name' => '11', - # 'links' => { - # 'self' => '/api/v2/buckets/11', - # }, - # 'retentionRules' => [ - # { - # 'type' => 'expire', - # 'everySeconds' => 2_592_000, - # 'shardGroupDurationSeconds' => 604_800 - # }, - # ], - # 'labels' => { 'links' => { 'self' => '/api/v2/labels' }, 'labels' => [] } - # }, - # { - # 'id' => '12312', - # 'orgID' => '123', - # 'type' => 'user', - # 'name' => '12', - # 'links' => { - # 'self' => '/api/v2/buckets/12', - # }, - # 'retentionRules' => [ - # { - # 'type' => 'expire', - # 'everySeconds' => 2_592_000, - # 'shardGroupDurationSeconds' => 604_800 - # }, - # ], - # 'labels' => { 'links' => { 'self' => '/api/v2/labels' }, 'labels' => [] } - # }, - # { - # 'id' => '12313', - # 'orgID' => '123', - # 'type' => 'user', - # 'name' => '13', - # 'links' => { - # 'self' => '/api/v2/buckets/13', - # }, - # 'retentionRules' => [ - # { - # 'type' => 'expire', - # 'everySeconds' => 2_592_000, - # 'shardGroupDurationSeconds' => 604_800 - # }, - # ], - # 'labels' => { 'links' => { 'self' => '/api/v2/labels' }, 'labels' => [] } - # }, - # { - # 'id' => '12314', - # 'orgID' => '123', - # 'type' => 'user', - # 'name' => '14', - # 'links' => { - # 'self' => '/api/v2/buckets/14', - # }, - # 'retentionRules' => [ - # { - # 'type' => 'expire', - # 'everySeconds' => 2_592_000, - # 'shardGroupDurationSeconds' => 604_800 - # }, - # ], - # 'labels' => { 'links' => { 'self' => '/api/v2/labels' }, 'labels' => [] } - # }, - # { - # 'id' => '12315', - # 'orgID' => '123', - # 'type' => 'user', - # 'name' => '15', - # 'links' => { - # 'self' => '/api/v2/buckets/15', - # }, - # 'retentionRules' => [ - # { - # 'type' => 'expire', - # 'everySeconds' => 2_592_000, - # 'shardGroupDurationSeconds' => 604_800 - # }, - # ], - # 'labels' => { 'links' => { 'self' => '/api/v2/labels' }, 'labels' => [] } - # }, - # { - # 'id' => '12316', - # 'orgID' => '123', - # 'type' => 'user', - # 'name' => '16', - # 'links' => { - # 'self' => '/api/v2/buckets/16', - # }, - # 'retentionRules' => [ - # { - # 'type' => 'expire', - # 'everySeconds' => 2_592_000, - # 'shardGroupDurationSeconds' => 604_800 - # }, - # ], - # 'labels' => { 'links' => { 'self' => '/api/v2/labels' }, 'labels' => [] } - # }, - # { - # 'id' => '12317', - # 'orgID' => '123', - # 'type' => 'user', - # 'name' => '17', - # 'links' => { - # 'self' => '/api/v2/buckets/17', - # }, - # 'retentionRules' => [ - # { - # 'type' => 'expire', - # 'everySeconds' => 2_592_000, - # 'shardGroupDurationSeconds' => 604_800 - # }, - # ], - # 'labels' => { 'links' => { 'self' => '/api/v2/labels' }, 'labels' => [] } - # }, - # { - # 'id' => '12318', - # 'orgID' => '123', - # 'type' => 'user', - # 'name' => '18', - # 'links' => { - # 'self' => '/api/v2/buckets/18', - # }, - # 'retentionRules' => [ - # { - # 'type' => 'expire', - # 'everySeconds' => 2_592_000, - # 'shardGroupDurationSeconds' => 604_800 - # }, - # ], - # 'labels' => { 'links' => { 'self' => '/api/v2/labels' }, 'labels' => [] } - # }, - # { - # 'id' => '12319', - # 'orgID' => '123', - # 'type' => 'user', - # 'name' => '19', - # 'links' => { - # 'self' => '/api/v2/buckets/19', - # }, - # 'retentionRules' => [ - # { - # 'type' => 'expire', - # 'everySeconds' => 2_592_000, - # 'shardGroupDurationSeconds' => 604_800 - # }, - # ], - # 'labels' => { 'links' => { 'self' => '/api/v2/labels' }, 'labels' => [] } - # }, - # { - # 'id' => '12320', - # 'orgID' => '123', - # 'type' => 'user', - # 'name' => '20', - # 'links' => { - # 'self' => '/api/v2/buckets/20', - # }, - # 'retentionRules' => [ - # { - # 'type' => 'expire', - # 'everySeconds' => 2_592_000, - # 'shardGroupDurationSeconds' => 604_800 - # }, - # ], - # 'labels' => { 'links' => { 'self' => '/api/v2/labels' }, 'labels' => [] } - # }, - # ] - # }] - - # response_2 = [{ - # 'links' => { - # 'self' => '/api/v2/buckets?descending=false&limit=20&offset=20', - # 'prev' => '/api/v2/buckets?descending=false&limit=20&offset=0' - # }, - # 'buckets' => [ - # { - # 'id' => '12321', - # 'orgID' => '123', - # 'type' => 'user', - # 'name' => '21', - # 'links' => { - # 'self' => '/api/v2/buckets/21', - # }, - # 'retentionRules' => [ - # { - # 'type' => 'expire', - # 'everySeconds' => 2_592_000, - # 'shardGroupDurationSeconds' => 604_800 - # }, - # ], - # 'labels' => { 'links' => { 'self' => '/api/v2/labels' }, 'labels' => [] } - # }, - # ] - # }] - - # allow(provider).to receive(:influx_get).with('/api/v2/orgs').and_return(org_response) - # #allow(provider).to receive(:get_bucket_info) - # allow(provider).to receive(:influx_get).with('/api/v2/buckets').and_return(response_1) - # allow(provider).to receive(:influx_get).with('/api/v2/labels').and_return(label_response) - # allow(provider).to receive(:influx_get).with('/api/v2/dbrps?orgID=123').and_return(dbrp_response) - # allow(provider).to receive(:influx_get).with('/api/v2/users').and_return(user_response) - - # provider.instance_variable_set('@use_ssl', true) - # provider.instance_variable_set('@host', 'foo.bar.com') - # provider.instance_variable_set('@port', 8086) - # provider.instance_variable_set('@token_file', '/root/.influxdb_token') - # provider.instance_variable_set('@token', RSpec::Puppet::Sensitive.new('puppetlabs')) - - # expect(provider).to receive(:influx_get).with("/api/v2/buckets") - # expect(provider).to receive(:influx_get).with("/api/v2/buckets?descending=false&limit=20&offset=20") - # provider.get(context) - # end - # end end describe '#create' do