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

new resource: azurerm_log_analytics_workspace_datasource_linux_syslog #6449

Conversation

magodo
Copy link
Collaborator

@magodo magodo commented Apr 13, 2020

This implements one of the log analytics workspace data sources required in #3182

NOTE: There is a dedicated workspace-level resource called linux_syslog_collection, which has only a state indicating whether linux_syslog DS is applied to all the machines in this workspace. Rather than creating a corresponding resource for the "collection", making it a workspace property seems more intuitive in the context of terraform.

Test result

💤 via 🦉 v1.14.1 make testacc TEST=./azurerm/internal/services/loganalytics/tests TESTARGS="-run='(TestAccAzureRMLogAnalyticsWorkspace_update|TestAccDataSourceAzureRMLogAnalyticsWorkspace_basic)'"
==> Checking that code complies with gofmt requirements...
==> Checking that Custom Timeouts are used...
TF_ACC=1 go test ./azurerm/internal/services/loganalytics/tests -v -run='(TestAccAzureRMLogAnalyticsWorkspace_update|TestAccDataSourceAzureRMLogAnalyticsWorkspace_basic)' -timeout 180m -ldflags="-X=github.com/terraform-providers/terraform-provider-azurerm/version.ProviderVersion=acc"
=== RUN   TestAccDataSourceAzureRMLogAnalyticsWorkspace_basic
=== PAUSE TestAccDataSourceAzureRMLogAnalyticsWorkspace_basic
=== RUN   TestAccAzureRMLogAnalyticsWorkspace_update
=== PAUSE TestAccAzureRMLogAnalyticsWorkspace_update
=== CONT  TestAccDataSourceAzureRMLogAnalyticsWorkspace_basic
=== CONT  TestAccAzureRMLogAnalyticsWorkspace_update
--- PASS: TestAccDataSourceAzureRMLogAnalyticsWorkspace_basic (220.81s)
--- PASS: TestAccAzureRMLogAnalyticsWorkspace_update (405.41s)
PASS
ok      github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/loganalytics/tests  405.450s

magodo added 2 commits April 13, 2020 16:45
There is a dedicated workspace-level resource called `linux_syslog_collection`,
which has only a `state` indicating whether `linux_syslog` DS is applied
to all the machines in this workspace. Rather than creating a
corresponding resource for the "collection", making it as a workspace
property seems more intuitive in context of terraform.
Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

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

Thanks @magodo,

overall this looks good, but i question that the SDK is missing the required objects for this resource. Shouldn't we update the swagger and use the SDK?

location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
sku = "PerGB2018"
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we include the toggle in here?

Comment on lines +108 to +115
type dataSourceLinuxSyslog struct {
Name string `json:"syslogName"`
Severities []dataSourceLinuxSyslogSeverity `json:"syslogSeverities"`
}

type dataSourceLinuxSyslogSeverity struct {
Severity string `json:"severity"`
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't this be added to the sagger and become part of the SDK?


resp, err := client.Get(ctx, resourceGroup, workspaceName, name)
if err != nil {
return fmt.Errorf("failed to retrieve Log Analytics Data Source Linux Syslog %q (Resource Group %q / Workspace: %q): %+v", name, resourceGroup, workspaceName, err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

replacing error with failed doesn't really change the fact we start the error message with a ERROR or FAILED. maybe we should change to grammar like

Suggested change
return fmt.Errorf("failed to retrieve Log Analytics Data Source Linux Syslog %q (Resource Group %q / Workspace: %q): %+v", name, resourceGroup, workspaceName, err)
return fmt.Errorf("retrieving Log Analytics Data Source Linux Syslog %q (Resource Group %q / Workspace: %q): %+v", name, resourceGroup, workspaceName, err)

return fmt.Errorf("failed to retrieve Log Analytics Data Source Linux Syslog %q (Resource Group %q / Workspace: %q): %+v", name, resourceGroup, workspaceName, err)
}
if resp.ID == nil || *resp.ID == "" {
return fmt.Errorf("cannot read Log Analytics Data Source Linux Syslog %q (Resource Group %q / Workspace: %q) ID", name, resourceGroup, workspaceName)
Copy link
Collaborator

Choose a reason for hiding this comment

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

and

Suggested change
return fmt.Errorf("cannot read Log Analytics Data Source Linux Syslog %q (Resource Group %q / Workspace: %q) ID", name, resourceGroup, workspaceName)
return fmt.Errorf("reading Log Analytics Data Source Linux Syslog %q (Resource Group %q / Workspace: %q) ID", name, resourceGroup, workspaceName)

as the error or failed is implied? YDYT?

@magodo
Copy link
Collaborator Author

magodo commented Apr 15, 2020

@katbyte Thank you for the quick response 👍
I have made the update according to your comment. For the type issue, I have submitted a PR (Azure/azure-rest-api-specs#9072) to azure-api-spec to track and once it's been addressed, then we can switch to the SDK type.

@katbyte katbyte added sdk/requires-swagger-changes Changes need to be made in the Swagger specifications to enable this functionality sdk/requires-upgrade This is dependent upon upgrading an SDK labels Apr 21, 2020
@katbyte katbyte added this to the Blocked milestone Apr 21, 2020
@magodo
Copy link
Collaborator Author

magodo commented Apr 24, 2020

@katbyte is it possible to get this merged for now (at least it works)?
Per reply from service team, the issue seems not likely to be addressed in the near future.

@tombuildsstuff
Copy link
Contributor

hey @magodo

Unfortunately we need the SDK to define these types else they can change on Azure's side without correctly handling semantic versioning - as such these types need to be present in the Azure SDK/Swagger here. Since this is currently blocked on this upstream API Issue - I'm going to temporarily close this issue for the moment (it's already in the Blocked milestone) - but once the upstream issue has been resolved then we can re-open this and take another look.

Thanks!

@tombuildsstuff tombuildsstuff added the upstream/microsoft Indicates that there's an upstream issue blocking this issue/PR label Jun 26, 2020
@ghost
Copy link

ghost commented Jul 26, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Jul 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation new-resource sdk/requires-swagger-changes Changes need to be made in the Swagger specifications to enable this functionality sdk/requires-upgrade This is dependent upon upgrading an SDK service/log-analytics size/XL upstream/microsoft Indicates that there's an upstream issue blocking this issue/PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants