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

SUMO-248024: #691

Merged
merged 8 commits into from
Sep 26, 2024
Merged

SUMO-248024: #691

merged 8 commits into from
Sep 26, 2024

Conversation

namangoya
Copy link
Collaborator

@namangoya namangoya commented Sep 20, 2024

What are we doing?

  • Adding enabled to the documentation of sumologic_data_forwarding_destination, and adjusted default values.
  • Adding index_id in sumologic_scheduled_views, and adjusted necessary documentations.

Why is this required?

As a part of supporting Data Forwarding Rules creation via TF for Scheduled Views we need index_id, because the id is coming from the autoview table.

Please review commit by commit.

Testing

Manual testing has been performed via main.tf and we are successfully able to configure a DF Rule for a SV. Attached test results and the test file in the comment.

…warding_rule and data_forwarding_destination and added example to correctly configure the data forwarding rule for a scheduled view
@namangoya namangoya force-pushed the adding_index_Id_in_scheduled_view branch from fdf9bc4 to 78a8578 Compare September 21, 2024 05:10
@namangoya
Copy link
Collaborator Author

namangoya commented Sep 23, 2024

Manual Testing has been performed - Success

  • Steps to test the main.tf file are mentioned here.
  • File for manual testing (rename it to main.tf) - main.txt
  • All 3 resources will be created
Screenshot 2024-09-23 at 10 07 43 AM

@namangoya namangoya marked this pull request as ready for review September 23, 2024 07:57
@@ -62,7 +62,7 @@ func (s *Client) DeleteDataForwardingRule(indexId string) error {
type DataForwardingRule struct {
IndexId string `json:"indexId"`
DestinationId string `json:"destinationId"`
Enabled bool `json:"enabled,omitempty"`
Enabled bool `json:"enabled"`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we making this change? This will send value as false instead of not serialising it in json response(which eventually gets treated as null)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bad part is that enabled = false is treated as null.... and whenever we are trying to set false, it is not sent in the API call...

We are not setting any default for enabled .. so it will not be send as false in case left blank (see here).

I've tested this scenario..

Comment on lines +45 to +47
resource "sumologic_data_forwarding_rule" "test_rule_sv" {
index_id = sumologic_scheduled_view.failed_connections.index_id
destination_id = sumologic_data_forwarding_destination.test_destination.id

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens when user supplies both IndexName and IndexId ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IndexId will simply be ignored ... as IndexId is never taken into consideration in PUT/POST calls .. please check the API documentation here

Copy link
Collaborator Author

@namangoya namangoya Sep 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are just using IndexId for creating the DF Rule... it is never updated in the PUT call, nor it is ever required to maintain the SV resource's state.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IndexId will simply be ignored .

This behavior should be documented in the terraform docs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we are documenting it in the SV page itself as it belongs to SV.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the docs in the latest commit.

- `destination_id` - (Required) The data forwarding destination id.
- `enabled` - (Required) True when the data forwarding rule is enabled.
- `enabled` - (Optional) True when the data forwarding rule is enabled. Will be treated as _false_ if left blank.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add possible values for file_format here to aid customers?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed, we already have a descriptive documentation ... and that is added on top of this page - see here

Copy link
Collaborator

@sumovishal sumovishal Sep 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed

I disagree, we should cover the possible values here. Can't rely on an example to do that.

Copy link
Collaborator Author

@namangoya namangoya Sep 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall I update this Rule's TF documentation and add a pointer to the original documentation here (point 6) in that case?

Possible values for file_format are a combination of few placeholders, and adding all of them here will not look good in the TF docs imho.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the docs in the latest commit.

CHANGELOG.md Outdated
@@ -2,6 +2,11 @@
DEPRECATIONS:
* resource_sumologic_ingest_budget : Deprecated in favour of `resource_sumologic_ingest_budget_v2`.

## 2.31.5 (September 23, 2024)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove date. Date shall be added on the day of release

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, done

Copy link

@raghavxk raghavxk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@namangoya namangoya force-pushed the adding_index_Id_in_scheduled_view branch from 70b1648 to d33dd93 Compare September 24, 2024 04:13
@@ -2,6 +2,11 @@
DEPRECATIONS:
* resource_sumologic_ingest_budget : Deprecated in favour of `resource_sumologic_ingest_budget_v2`.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems a little strange to be doing a 2.x release while having the 3.0.0 section in the CHANGELOG, with content in it already. But I think it's ok.

(Also, an (Unreleased) on the 2.31.5 line would be appropriate, but there's no need to change it; one of us will be editing that line with the correct date anyway.)

Copy link
Collaborator Author

@namangoya namangoya Sep 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tbh, I thought that 3.0.0 is written for some other purpose.. and didn't thought of using that, just continued after 2.31.3 ..

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dagould are you planning to maintain two versions of the provider? I would be in favor of just continuing 3.x.x version.

@@ -33,12 +33,10 @@ func resourceSumologicDataForwardingRule() *schema.Resource {
"enabled": {
Type: schema.TypeBool,
Optional: true,
Default: true,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a change in behavior. A rule will be disabled by default now? This might be a breaking change. The good part is we are scheduled for a major release if this is a breaking change it should be fine. We should document the new behavior.

Copy link
Collaborator Author

@namangoya namangoya Sep 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amm, no it's not a breaking change. Because in the API, we don't enforce any default value for enabled, which means that it'll be treated as false if left blank.

Here, I'm correcting a mistake from my previous PR (#688) .. and and bringing it in-line with the API.

@@ -23,6 +23,7 @@ QUERY
retention_period = 365
lifecycle {
prevent_destroy = true
ignore_changes = [index_id]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add a comment here explaining why we need to add index_id to ignore_changes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added in this same doc a little below at line 48.

@@ -44,6 +45,7 @@ The following arguments are supported:
The following attributes are exported:

- `id` - The internal ID of the scheduled view.
- `index_id` - The Index ID of the scheduled view. It never updates at any point of time during resource updates, therefore make sure to ignore this via `ignore_changes = [index_id]`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a gap in the API. index_id is a write-only field and it never updates after the initial creation. This behavior should have been enforced in the API rather than relying on users to not update index_id.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already enforced in the API (PUT and POST api docs). Here we are just communicating/informing customers as it is a non-updatable field.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if the user passes index_id, it will simply be ignored at the API.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if the user passes index_id, it will simply be ignored at the API.

I don't think this is right behavior. We are silently dropping a field provided by the client. Instead we should return error b/c request is invalid as you are not allowed to change the index id. This is the real issue here.

It should be noted that ignore_changes is not strictly required if you don't change the index id which I believe most customer won't do, given we don't support it?

Copy link
Collaborator Author

@namangoya namangoya Sep 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be noted that ignore_changes is not strictly required if you don't change the index id which I believe most customer won't do, given we don't support it?

Yes, not a strict requirement to add ignore_changes .. but recommended, and hence conveying that msg in the documentation here.

I don't think this is right behavior. We are silently dropping a field provided by the client. Instead we should return error b/c request is invalid as you are not allowed to change the index id. This is the real issue here.

  • This will not even reach the API layer as it'll be dropped by OpenAPI translation itself and will not be translated into the request payload's Java Object.
  • Moreover, there can be some invalid fields added by the user (by mistake or intentionally), so those are also simply ignored and not translated by OpenAPI...
  • Therefore, we can't really do much with this index_id field being ignored.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will not even reach the API layer as it'll be dropped by OpenAPI translation itself and will not translated into the request payload's Java Object.

We can follow-up internally on this one. I don't see a reason why OpenAPI would silently drop a field.

Yes, not a strict requirement to add ignore_changes .. but recommended, and hence conveying that msg in the documentation here.

The language should be updated to reflect that. Currently, it seems we are asking to add ignore_changes rather than a recommendation.

Copy link
Collaborator Author

@namangoya namangoya Sep 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can follow-up internally on this one. I don't see a reason why OpenAPI would silently drop a field.

Sure, can I know the set of people who can help me here?

Also, is it a blocker for this PR?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The language should be updated to reflect that. Currently, it seems we are asking to add ignore_changes rather than a recommendation.

But without ignore_changes, we are running into this issue.. let's continue for this on the slack thread.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But without ignore_changes, we are running into this issue.. let's continue for this on the slack thread.

Issue is resolved with the introduction of computed prop for index_id. (see thread)

I'm updating the documentation that ignore_changes is just a recommendation and not a mandatory thing.

@@ -44,6 +45,7 @@ The following arguments are supported:
The following attributes are exported:

- `id` - The internal ID of the scheduled view.
- `index_id` - The Index ID of the scheduled view. It remains unchanged during resource updates, and any manual modifications will be disregarded. While it’s not mandatory, we recommend to ignore this via `ignore_changes = [index_id]`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now we have made this field as computed you can drop the "modification" and ignore_changes part

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I have just kept if for the fact that if someone explicitly tries to set index_id = "000000ABCDE..." (some random value) in the resource definition, then with the help of ignore_changes that will be ignored.

retention_period = 1
lifecycle {
prevent_destroy = true
ignore_changes = [index_id]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not needed now?

Copy link
Collaborator Author

@namangoya namangoya Sep 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I have just kept if for the fact that if someone explicitly tries to set index_id = "000000ABCDE..." (some random value) in the resource definition, then with the help of ignore_changes that will be ignored.

@namangoya namangoya merged commit ec0fcb0 into master Sep 26, 2024
7 checks passed
@namangoya namangoya deleted the adding_index_Id_in_scheduled_view branch September 26, 2024 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants