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

Fix DeleteOptions on Public Ip Address (issue#38806) #38987

Closed
wants to merge 4 commits into from
Closed

Fix DeleteOptions on Public Ip Address (issue#38806) #38987

wants to merge 4 commits into from

Conversation

v-hongli1
Copy link
Member

@v-hongli1 v-hongli1 commented Feb 28, 2024

relate to issue#38806

Description

Please add an informative description that covers that changes made by the pull request and link all relevant issues.

If an SDK is being regenerated based on a new swagger spec, a link to the pull request containing these swagger spec changes has been included above.

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

@github-actions github-actions bot added the Mgmt This issue is related to a management-plane library. label Feb 28, 2024
@azure-sdk
Copy link
Collaborator

azure-sdk commented Feb 28, 2024

API change check

APIView has identified API level changes in this PR and created following API reviews.

com.azure.resourcemanager:azure-resourcemanager-compute
com.azure.resourcemanager:azure-resourcemanager-network

Copy link
Member

@weidongxu-microsoft weidongxu-microsoft left a comment

Choose a reason for hiding this comment

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

There is too many issue in the PR.

Please book a meeting next week to discuss.

Comment on lines +424 to +429
for (NicIpConfiguration ipConfiguration : this.nicIPConfigurations.values()) {
if (ipConfigName.equals(ipConfiguration.name())) {
specifiedIPConfig = (NicIpConfigurationImpl) ipConfiguration;
break;
}
}
Copy link
Member

Choose a reason for hiding this comment

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

This part is just ipConfigurations().get(ipConfigName)?

Comment on lines +430 to +433
if (specifiedIPConfig == null) {
specifiedIPConfig = prepareNewNicIPConfiguration(ipConfigName);
withIPConfiguration(specifiedIPConfig);
}
Copy link
Member

Choose a reason for hiding this comment

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

No, we don't want to modify anything in a getter API.

* @param ipConfigName the name of th specified ip configuration
* @return the specified IP configuration of this network interface
*/
NicIpConfiguration specifiedIPConfiguration(String ipConfigName);
Copy link
Contributor

Choose a reason for hiding this comment

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

This is equivalent to ipConfigurations().get(ipoConfigName)?

Comment on lines +598 to +602
DeleteOptions deleteOptions, PublicIpAddress publicIpAddress, String ipConfigName) {
this.specifiedIPConfiguration(ipConfigName).withExistingPublicIpAddress(publicIpAddress);
this.specifiedIPConfiguration(ipConfigName).withPrivateIpVersion(publicIpAddress.version());
this.publicIPAddressDeleteOption = deleteOptions;
return this;
Copy link
Contributor

Choose a reason for hiding this comment

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

The implementation seems to differ from the interface declaration?

In interface, it's Update delete option for specified public ip address of specified network interface ip config, but here it seems to attach an existing PublicIpAddress to the NetworkInterface.

Comment on lines +2625 to +2650
/**
* Update delete option for the primary public ip address of the primary network interface.
*
* @param deleteOptions what happens to the public IP address when the VM using it is deleted
* @return the next stage of the update
*/
Update withPrimaryNicPrimaryPipDeleteOption(DeleteOptions deleteOptions);

/**
* Update delete option for the primary public ip address of the specified network interface.
*
* @param deleteOptions what happens to the public IP address when the VM using it is deleted
* @param nicIds resource Ids of the specified network interface
* @return the next stage of the update
*/
Update withSpecifiedNicPrimaryPIpDeleteOption(DeleteOptions deleteOptions, String... nicIds);

/**
* Update delete option for the specified public ip address of the specified network interface.
*
* @param deleteOptions what happens to the public IP address when the VM using it is deleted
* @param nicId resource id of the specified network interfac
* @param ipConfigIds resource Ids of specified network interface ip configs
* @return the next stage of the update
*/
Update withSpecifiedNicSpecifiedPIpDeleteOption(DeleteOptions deleteOptions, String nicId, String... ipConfigIds);
Copy link
Contributor

@XiaofeiCao XiaofeiCao Mar 4, 2024

Choose a reason for hiding this comment

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

Not sure whether user really needs these APIs.

IMHO, two types are needed:

  1. withPublicIPAddressDeleteOptions(DeleteOptions deleteOptions) to update all attached PublicIpAddress'es deleteOption
  2. withPublicIPAddressDeleteOption(PublicIpAddress(/String) publicIpAddress(id)), like what user specifies in the creation flow.

.withNewResourceGroup(rgName)
.withNewPrimaryNetwork("10.0.0.0/28")
.withPrimaryPrivateIPAddressDynamic()
.withExistingPrimaryPublicIPAddress(publicIPAddress)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we do .withExistingPrimaryPublicIPAddress(publicIPAddress, deleteOptions)?

.withAdminPassword(password())
.withNewDataDisk(127)
.withSize(VirtualMachineSizeTypes.fromString("Standard_D2a_v4"))
.withPublicIPAddressDeleteOptions(DeleteOptions.DELETE)
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure whether we should use this in creation flow. I think it's for update flow.

.withPrivateIpAddressDynamic()
.withExistingPublicIpAddress(publicIPAddress2)
.attach()
.withPublicIPAddressDeleteOptions(DeleteOptions.DELETE)
Copy link
Contributor

Choose a reason for hiding this comment

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

Update flow.

.withExistingPrimaryNetwork(vnet)
.withSubnet(subnetName)
.withPrimaryPrivateIPAddressDynamic()
.withExistingPrimaryPublicIPAddress(publicIPAddress1)
Copy link
Contributor

@XiaofeiCao XiaofeiCao Mar 4, 2024

Choose a reason for hiding this comment

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

withExistingPrimaryPublicIPAddress(publicIPAddress1, deleteOption)?

.withExistingNetwork(vnet)
.withSubnet(subnetName)
.withPrivateIpAddressDynamic()
.withExistingPublicIpAddress(publicIPAddress2)
Copy link
Contributor

Choose a reason for hiding this comment

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

withExistingPublicIpAddress(publicIPAddress2, deleteOption)?

* @param deleteOptions the delete options for primary network interfaces
* @return the next stage of the definition
*/
WithCreate withPublicIPAddressDeleteOptions(DeleteOptions deleteOptions);
Copy link
Contributor

Choose a reason for hiding this comment

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

Update flow?

* @param ipConfigName the name of specified network interface ip config
* @return the next stage of the update
*/
Update withSpecifiedNicSpecifiedPipDeleteOption(DeleteOptions deleteOptions, PublicIpAddress publicIpAddress, String ipConfigName);
Copy link
Contributor

Choose a reason for hiding this comment

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

`withPublicIpAddressDeleteOption(PublicIpAddress pip, DeleteOptions deleteOption)?

@v-hongli1 v-hongli1 closed this by deleting the head repository Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Mgmt This issue is related to a management-plane library.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants