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_orbital_contact #19036

Merged
merged 7 commits into from
Jan 26, 2023

Conversation

jiaweitao001
Copy link
Contributor

  • New resource to create a contact between ground stations and spacecrafts.
  • Acc tests are not runnable now. Due to restrictions of the service team, there're a few steps we need to follow to get the tests running.
  1. Submit the Azure Orbital preview onboarding form.
  2. Register a new spacecraft resource and make sure the spacecraft is authorized. Follow the steps here.
  3. Paste the ID of the authorized spacecraft in the PR.
  4. We will change the acc test accordingly after the spacecraft authorization to make sure they can run in team city.

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.

LGTM 📡 - just waiting on the service so we can test

@jiaweitao001
Copy link
Contributor Author

Hi @katbyte , just to make sure we are on the same page -- the steps I listed above in the comment are pending HashiCorp's action, it's because the authorized spacecraft must be created through your team's Azure Portal. If you have already submitted the request, please give us a heads up so we can catch up with the service team to see what we can do to enable the ACC tests. Thanks!

Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

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

hi @jiaweitao001

Thanks for this PR - I've taken a look through and left some comments inline, if we can fix those up then we should be able to take another look here.

Thanks!


"resource_group_name": azure.SchemaResourceGroupName(),

"spacecraft": {
Copy link
Contributor

Choose a reason for hiding this comment

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

is this the Spacecraft ID, if so, can we rename it that?

Suggested change
"spacecraft": {
"spacecraft_id": {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. Renamed.

ValidateFunc: validation.StringIsNotEmpty,
},

"resource_group_name": azure.SchemaResourceGroupName(),
Copy link
Contributor

Choose a reason for hiding this comment

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

since the Spacecraft ID includes the Resource Group Name, we could remove this and infer it from the Spacecraft ID?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, removed.

ReservationStartTime: props.ReservationStartTime,
ReservationEndTime: props.ReservationEndTime,
GroundStationName: props.GroundStationName,
ContactProfileId: *props.ContactProfile.Id,
Copy link
Contributor

Choose a reason for hiding this comment

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

this'll be a crash so we'll need to nil-check this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added nil check.

Comment on lines 193 to 197
if resp, err := client.Delete(ctx, *id); err != nil {
if !response.WasNotFound(resp.HttpResponse) {
return fmt.Errorf("deleting %s: %+v", *id, err)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

this would indicate a bug so we should remove this:

Suggested change
if resp, err := client.Delete(ctx, *id); err != nil {
if !response.WasNotFound(resp.HttpResponse) {
return fmt.Errorf("deleting %s: %+v", *id, err)
}
}
if _, err := client.Delete(ctx, *id); err != nil {
return fmt.Errorf("deleting %s: %+v", *id, err)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.

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.

LGTM once tests pass 📡

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.

test failures:
Uploading image.png…

@jiaweitao001
Copy link
Contributor Author

Hi @katbyte , could you please kindly paste the ID of the spacecraft created here? We will need to make a few modifications to ensure the acc tests can run with it.

@katbyte
Copy link
Collaborator

katbyte commented Dec 12, 2022

@jiaweitao001 - it should be in teamcity? either way the tests look like something unrelated to the service team?

------- Stdout: -------
=== RUN   TestAccContact_basic
=== PAUSE TestAccContact_basic
=== CONT  TestAccContact_basic
    testcase.go:110: Step 1/2 error: Error running pre-apply refresh: exit status 1
        
        Error: Invalid resource type
        
          on terraform_plugin_test.tf line 93, in resource "azurerm_orbital_contact" "test":
          93: resource "azurerm_orbital_contact" "test" {
        
        The provider hashicorp/azurerm does not support resource type
        "azurerm_orbital_contact".
--- FAIL: TestAccContact_basic (3

------- Stdout: -------
=== RUN   TestAccContactProfile_basic
=== PAUSE TestAccContactProfile_basic
=== CONT  TestAccContactProfile_basic
    testing_new.go:84: Error running post-test destroy, there may be dangling resources: exit status 1
        
        Error: deleting Subnet: (Name "testsubnet" / Virtual Network Name "testvnet" / Resource Group "acctestRG-221212000556754839"): network.SubnetsClient#Delete: Failure sending request: StatusCode=400 -- Original Error: Code="InUseSubnetCannotBeDeleted" Message="Subnet testsubnet is in use by /subscriptions/*******/resourceGroups/acctestRG-221212000556754839/providers/Microsoft.Network/virtualNetworks/testvnet/subnets/testsubnet/serviceAssociationLinks/OrbitalManagedDNC and cannot be deleted. In order to delete the subnet, delete all the resources within the subnet. See aka.ms/deletesubnet." Details=[]
        
--- FAIL: TestAccContactProfile_basic (104.12s)
FAIL

@catriona-m
Copy link
Member

Hi @jiaweitao001. Does this involve using the resource id of an authorised spacecraft? If so, would it make sense to have this input via an env var so anyone with an authorised spacecraft can run the tests?

@katbyte
Copy link
Collaborator

katbyte commented Jan 9, 2023

@jiaweitao001 - any updates on this one?

@jiaweitao001
Copy link
Contributor Author

Hi @catriona-m , as we discussed offline weeks ago, there's a request for registering a spacecraft submitted. Could you please check with the service team on how is that going? Thanks!

@@ -55,7 +55,7 @@ func (r ContactResource) basic(data acceptance.TestData) string {
resource "azurerm_orbital_contact" "test" {
name = "testcontact-%[2]d"
resource_group_name = azurerm_resource_group.test.name
spacecraft_id = azurerm_orbital_spacecraft.test.id
spacecraft_id = "/subscriptions/1a6092a6-137e-4025-9a7c-ef77f76f2c02/resourceGroups/spaceymcspaceface/providers/Microsoft.Orbital/spacecrafts/spaceymcspaceface"
Copy link
Member

Choose a reason for hiding this comment

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

could we have this id as an env var that gets passed in instead? For example, like these tests have: https://github.com/hashicorp/terraform-provider-azurerm/blob/main/internal/services/bot/bot_channel_facebook_resource_test.go

@jiaweitao001
Copy link
Contributor Author

Tested with spacecraft owned by our team:

=== RUN   TestAccContact_basic
=== PAUSE TestAccContact_basic
=== CONT  TestAccContact_basic
--- PASS: TestAccContact_basic (313.60s)

Copy link
Member

@catriona-m catriona-m left a comment

Choose a reason for hiding this comment

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

Thanks for this @jiaweitao001. I've left a couple of minor comments inline but once those get fixed up we can take a look at merging this. Thanks!

internal/services/orbital/contact_resource_test.go Outdated Show resolved Hide resolved
internal/services/orbital/contact_resource_test.go Outdated Show resolved Hide resolved
website/docs/r/orbital_contact.html.markdown Outdated Show resolved Hide resolved
Copy link
Member

@catriona-m catriona-m left a comment

Choose a reason for hiding this comment

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

Thanks @jiaweitao001 this LGTM!

@katbyte katbyte merged commit bc1e094 into hashicorp:main Jan 26, 2023
katbyte added a commit that referenced this pull request Jan 26, 2023
@github-actions github-actions bot added this to the v3.41.0 milestone Jan 26, 2023
@github-actions
Copy link

This functionality has been released in v3.41.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants