Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

splunk_indexes type fixes #117

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ jobs:
uses: golangci/golangci-lint-action@v2
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.29
version: v1.45
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
##1.5.0

**WARNING: POTENTIAL BREAKING CHANGES**
* Change splunk_indexes field types:
* bucket_rebuild_memory_hint - Int
* max_hot_buckets - String
* rep_factor - Int

These settings must be changed to be of the correct type in the Terraform configuration. They were the incorrect type previously, and as such their values were never updated during state refresh.

* Deprecated splunk_indexes field `rep_factor`

##1.4.12
* FIx: Don't read all searches just to find one search

Expand Down
6 changes: 3 additions & 3 deletions client/models/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type IndexEntry struct {

type IndexObject struct {
BlockSignSize int `json:"blockSignSize,omitempty" url:"blockSignSize,omitempty"`
BucketRebuildMemoryHint string `json:"bucketRebuildMemoryHint,omitempty" url:"bucketRebuildMemoryHint,omitempty"`
BucketRebuildMemoryHint int `json:"bucketRebuildMemoryHint,omitempty" url:"bucketRebuildMemoryHint,omitempty"`
ColdPath string `json:"coldPath,omitempty" url:"coldPath,omitempty"`
ColdToFrozenDir string `json:"coldToFrozenDir,omitempty" url:"coldToFrozenDir,omitempty"`
ColdToFrozenScript string `json:"coldToFrozenScript,omitempty" url:"coldToFrozenScript,omitempty"`
Expand All @@ -25,7 +25,7 @@ type IndexObject struct {
MaxBloomBackfillBucketAge string `json:"maxBloomBackfillBucketAge,omitempty" url:"maxBloomBackfillBucketAge,omitempty"`
MaxConcurrentOptimizes int `json:"maxConcurrentOptimizes,omitempty" url:"maxConcurrentOptimizes,omitempty"`
MaxDataSize string `json:"maxDataSize,omitempty" url:"maxDataSize,omitempty"`
MaxHotBuckets int `json:"maxHotBuckets,omitempty" url:"maxHotBuckets,omitempty"`
MaxHotBuckets string `json:"maxHotBuckets,omitempty" url:"maxHotBuckets,omitempty"`
MaxHotIdleSecs int `json:"maxHotIdleSecs,omitempty" url:"maxHotIdleSecs,omitempty"`
MaxHotSpanSecs int `json:"maxHotSpanSecs,omitempty" url:"maxHotSpanSecs,omitempty"`
MaxMemMB int `json:"maxMemMB,omitempty" url:"maxMemMB,omitempty"`
Expand All @@ -41,7 +41,7 @@ type IndexObject struct {
QuarantineFutureSecs int `json:"quarantineFutureSecs,omitempty" url:"quarantineFutureSecs,omitempty"`
QuarantinePastSecs int `json:"quarantinePastSecs,omitempty" url:"quarantinePastSecs,omitempty"`
RawChunkSizeBytes int `json:"rawChunkSizeBytes,omitempty" url:"rawChunkSizeBytes,omitempty"`
RepFactor string `json:"repFactor,omitempty" url:"repFactor,omitempty"`
RepFactor int `json:"repFactor,omitempty" url:"repFactor,omitempty"`
RotatePeriodInSecs int `json:"rotatePeriodInSecs,omitempty" url:"rotatePeriodInSecs,omitempty"`
ServiceMetaPeriod int `json:"serviceMetaPeriod,omitempty" url:"serviceMetaPeriod,omitempty"`
SyncMeta bool `json:"syncMeta,omitempty" url:"syncMeta,omitempty"`
Expand Down
8 changes: 7 additions & 1 deletion docs/resources/indexes.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,15 @@ To disable, set to 0, but this is NOT recommended. Highest legal value is 214748
This is a mechanism to prevent main hot buckets from being polluted with fringe events.
* `quarantine_past_secs` - (Optional) Events with timestamp of quarantinePastSecs older than "now" are dropped into quarantine bucket. Defaults to 77760000 (900 days). This is a mechanism to prevent the main hot buckets from being polluted with fringe events.
* `raw_chunk_size_bytes` - (Optional) Target uncompressed size in bytes for individual raw slice in the rawdata journal of the index. Defaults to 131072 (128KB). 0 is not a valid value. If 0 is specified, rawChunkSizeBytes is set to the default value.
* `rep_factor` - (Optional) Index replication control. This parameter applies to only clustering slaves.
* `rep_factor` - (Deprecated, Optional) Index replication control. This parameter applies to only clustering slaves.
auto = Use the master index replication configuration value.
0 = Turn off replication for this index.

`rep_factor` is deprecated in this Terraform Provider.

The REST API returns a 0 for both `repFactor = 0` and `repFactor = auto`. These are the two valid values for `repFactor`, yet they cannot be detected as different from the API's response.

Additionally, `repFactor` only has meaning on clustered indexes, which should be configured by the Indexer Cluster Manager, not via REST.
* `rotate_period_in_secs` - (Optional) How frequently (in seconds) to check if a new hot bucket needs to be created. Also, how frequently to check if there are any warm/cold buckets that should be rolled/frozen.
* `service_meta_period` - (Optional) Defines how frequently metadata is synced to disk, in seconds. Defaults to 25 (seconds).
You may want to set this to a higher value if the sum of your metadata file sizes is larger than many tens of megabytes, to avoid the hit on I/O in the indexing fast path.
Expand Down
67 changes: 66 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,73 @@
module github.com/splunk/terraform-provider-splunk

go 1.14
go 1.17

require (
github.com/google/go-querystring v1.0.0
github.com/hashicorp/terraform-plugin-sdk v1.15.0
)

require (
cloud.google.com/go v0.45.1 // indirect
github.com/agext/levenshtein v1.2.2 // indirect
github.com/apparentlymart/go-cidr v1.0.1 // indirect
github.com/apparentlymart/go-textseg v1.0.0 // indirect
github.com/armon/go-radix v1.0.0 // indirect
github.com/aws/aws-sdk-go v1.25.3 // indirect
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
github.com/bgentry/speakeasy v0.1.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fatih/color v1.7.0 // indirect
github.com/golang/protobuf v1.3.4 // indirect
github.com/google/go-cmp v0.3.1 // indirect
github.com/google/uuid v1.1.1 // indirect
github.com/googleapis/gax-go/v2 v2.0.5 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.1 // indirect
github.com/hashicorp/go-getter v1.4.0 // indirect
github.com/hashicorp/go-hclog v0.9.2 // indirect
github.com/hashicorp/go-multierror v1.0.0 // indirect
github.com/hashicorp/go-plugin v1.2.0 // indirect
github.com/hashicorp/go-safetemp v1.0.0 // indirect
github.com/hashicorp/go-uuid v1.0.1 // indirect
github.com/hashicorp/go-version v1.2.0 // indirect
github.com/hashicorp/golang-lru v0.5.1 // indirect
github.com/hashicorp/hcl v0.0.0-20170504190234-a4b07c25de5f // indirect
github.com/hashicorp/hcl/v2 v2.0.0 // indirect
github.com/hashicorp/logutils v1.0.0 // indirect
github.com/hashicorp/terraform-config-inspect v0.0.0-20191115094559-17f92b0546e8 // indirect
github.com/hashicorp/terraform-exec v0.1.1 // indirect
github.com/hashicorp/terraform-json v0.5.0 // indirect
github.com/hashicorp/terraform-plugin-test v1.4.3 // indirect
github.com/hashicorp/terraform-svchost v0.0.0-20191011084731-65d371908596 // indirect
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af // indirect
github.com/mattn/go-colorable v0.1.1 // indirect
github.com/mattn/go-isatty v0.0.5 // indirect
github.com/mitchellh/cli v1.0.0 // indirect
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect
github.com/mitchellh/copystructure v1.0.0 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/go-testing-interface v1.0.0 // indirect
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.1.2 // indirect
github.com/mitchellh/reflectwalk v1.0.1 // indirect
github.com/oklog/run v1.0.0 // indirect
github.com/posener/complete v1.2.1 // indirect
github.com/spf13/afero v1.2.2 // indirect
github.com/ulikunitz/xz v0.5.5 // indirect
github.com/vmihailenco/msgpack v4.0.1+incompatible // indirect
github.com/zclconf/go-cty v1.2.1 // indirect
github.com/zclconf/go-cty-yaml v1.0.1 // indirect
go.opencensus.io v0.22.0 // indirect
golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586 // indirect
golang.org/x/net v0.0.0-20200301022130-244492dfa37a // indirect
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 // indirect
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527 // indirect
golang.org/x/text v0.3.2 // indirect
google.golang.org/api v0.9.0 // indirect
google.golang.org/appengine v1.6.1 // indirect
google.golang.org/genproto v0.0.0-20200310143817-43be25429f5a // indirect
google.golang.org/grpc v1.27.1 // indirect
)
26 changes: 18 additions & 8 deletions splunk/resource_splunk_indexes.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func index() *schema.Resource {
A recommended value is 100.`,
},
"bucket_rebuild_memory_hint": {
Type: schema.TypeString,
Type: schema.TypeInt,
Optional: true,
Computed: true,
Description: `Suggestion for the bucket rebuild process for the size of the time-series (tsidx) file to make.
Expand Down Expand Up @@ -146,7 +146,7 @@ func index() *schema.Resource {
Note: The precise size of your warm buckets may vary from maxDataSize, due to post-processing and timing issues with the rolling policy.`,
},
"max_hot_buckets": {
Type: schema.TypeInt,
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: `Maximum hot buckets that can exist per index. Defaults to 3.
Expand Down Expand Up @@ -284,9 +284,14 @@ func index() *schema.Resource {
WARNING: This is an advanced parameter. Only change it if you are instructed to do so by Splunk Support.`,
},
"rep_factor": {
Type: schema.TypeString,
Type: schema.TypeInt,
Optional: true,
Computed: true,
Deprecated: `rep_factor is deprecated in this Terraform Provider.

The REST API returns a 0 for both "repFactor = 0" and "repFactor = auto". These are the two valid values for repFactor, yet they cannot be detected as different from the API's response.

Additionally, repFactor only has meaning on clustered indexes, which should be configured by the Indexer Cluster Manager, not via REST.`,
Description: `Index replication control. This parameter applies to only clustering slaves.
auto = Use the master index replication configuration value.

Expand Down Expand Up @@ -615,7 +620,10 @@ func indexDelete(d *schema.ResourceData, meta interface{}) error {

default:
errorResponse := &models.IndexResponse{}
_ = json.NewDecoder(resp.Body).Decode(errorResponse)
if err := json.NewDecoder(resp.Body).Decode(errorResponse); err != nil {
return err
}

err := errors.New(errorResponse.Messages[0].Text)
return err
}
Expand All @@ -625,7 +633,7 @@ func indexDelete(d *schema.ResourceData, meta interface{}) error {
func getIndexConfig(d *schema.ResourceData) (indexConfigObject *models.IndexObject) {
indexConfigObject = &models.IndexObject{}
indexConfigObject.BlockSignSize = d.Get("block_sign_size").(int)
indexConfigObject.BucketRebuildMemoryHint = d.Get("bucket_rebuild_memory_hint").(string)
indexConfigObject.BucketRebuildMemoryHint = d.Get("bucket_rebuild_memory_hint").(int)
indexConfigObject.ColdPath = d.Get("cold_path").(string)
indexConfigObject.ColdToFrozenDir = d.Get("cold_to_frozen_dir").(string)
indexConfigObject.ColdToFrozenScript = d.Get("cold_to_frozen_script").(string)
Expand All @@ -637,7 +645,7 @@ func getIndexConfig(d *schema.ResourceData) (indexConfigObject *models.IndexObje
indexConfigObject.MaxBloomBackfillBucketAge = d.Get("max_bloom_backfill_bucket_age").(string)
indexConfigObject.MaxConcurrentOptimizes = d.Get("max_concurrent_optimizes").(int)
indexConfigObject.MaxDataSize = d.Get("max_data_size").(string)
indexConfigObject.MaxHotBuckets = d.Get("max_hot_buckets").(int)
indexConfigObject.MaxHotBuckets = d.Get("max_hot_buckets").(string)
indexConfigObject.MaxHotIdleSecs = d.Get("max_hot_idle_secs").(int)
indexConfigObject.MaxHotSpanSecs = d.Get("max_hot_span_secs").(int)
indexConfigObject.MaxMemMB = d.Get("max_mem_mb").(int)
Expand All @@ -653,7 +661,7 @@ func getIndexConfig(d *schema.ResourceData) (indexConfigObject *models.IndexObje
indexConfigObject.QuarantineFutureSecs = d.Get("quarantine_future_secs").(int)
indexConfigObject.QuarantinePastSecs = d.Get("quarantine_past_secs").(int)
indexConfigObject.RawChunkSizeBytes = d.Get("raw_chunk_size_bytes").(int)
indexConfigObject.RepFactor = d.Get("rep_factor").(string)
indexConfigObject.RepFactor = d.Get("rep_factor").(int)
indexConfigObject.RotatePeriodInSecs = d.Get("rotate_period_in_secs").(int)
indexConfigObject.ServiceMetaPeriod = d.Get("service_meta_period").(int)
indexConfigObject.SyncMeta = d.Get("sync_meta").(bool)
Expand All @@ -668,7 +676,9 @@ func getIndexConfigByName(name string, httpResponse *http.Response) (indexEntry
response := &models.IndexResponse{}
switch httpResponse.StatusCode {
case 200, 201:
_ = json.NewDecoder(httpResponse.Body).Decode(&response)
if err := json.NewDecoder(httpResponse.Body).Decode(&response); err != nil {
return nil, err
}
re := regexp.MustCompile(`(.*)`)
for _, entry := range response.Entry {
if name == re.FindStringSubmatch(entry.Name)[1] {
Expand Down
1 change: 0 additions & 1 deletion vendor/github.com/agext/levenshtein/go.mod

This file was deleted.

1 change: 0 additions & 1 deletion vendor/github.com/armon/go-radix/go.mod

This file was deleted.

1 change: 0 additions & 1 deletion vendor/github.com/google/uuid/go.mod

This file was deleted.

3 changes: 0 additions & 3 deletions vendor/github.com/googleapis/gax-go/v2/go.mod

This file was deleted.

25 changes: 0 additions & 25 deletions vendor/github.com/googleapis/gax-go/v2/go.sum

This file was deleted.

1 change: 0 additions & 1 deletion vendor/github.com/hashicorp/errwrap/go.mod

This file was deleted.

6 changes: 0 additions & 6 deletions vendor/github.com/hashicorp/go-checkpoint/go.mod

This file was deleted.

4 changes: 0 additions & 4 deletions vendor/github.com/hashicorp/go-checkpoint/go.sum

This file was deleted.

1 change: 0 additions & 1 deletion vendor/github.com/hashicorp/go-cleanhttp/go.mod

This file was deleted.

23 changes: 0 additions & 23 deletions vendor/github.com/hashicorp/go-getter/go.mod

This file was deleted.

Loading