Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

AzureCreateVirtualMachineTask: introduce new task #346

Merged
merged 3 commits into from
May 21, 2023

Conversation

nirarg
Copy link
Contributor

@nirarg nirarg commented May 17, 2023

Add new task creating VM on Azure cloud
Currently it create Ubuntu

What this PR does / why we need it:

This PR is created as part of the next demo requirements

*Which issue(s) this PR fixes:
Fixes #FLPATH-362

Change type

  • New feature
  • Bug fix
  • Unit tests
  • Integration tests
  • CI
  • Documentation
  • Auto-generated SDK code

Impacted services

  • Workflow Service
  • Notification Service

Checklist

  • Subject and description added to both, commit and PR.
  • Relevant issues have been referenced.

@openshift-ci openshift-ci bot requested review from masayag and RichardW98 May 17, 2023 14:54
import com.azure.core.management.AzureEnvironment;
import com.azure.core.management.Region;
import com.azure.core.management.profile.AzureProfile;
import com.azure.identity.*;
Copy link
Collaborator

Choose a reason for hiding this comment

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

pls expand.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

VirtualMachine virtualMachine = azureResourceManager.virtualMachines().define(resourcesPrefix + "VM")
.withRegion(Region.US_EAST).withExistingResourceGroup(resourcesPrefix + "ResourceGroup")
.withExistingPrimaryNetworkInterface(networkInterface)
.withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_18_04_LTS)
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 make this dynamic to support windows server or other systems?

Copy link
Collaborator

Choose a reason for hiding this comment

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

+1, I'd suggest to parameterized it (or a closed list of options) + also let the user specify VirtualMachineSizeTypes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I suggest to have this change after the demo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As from the first impression I got, its not just about changing the machine type, also the function (withPopularLinuxImage) and the size might be changed .
Need to investigate more about the types included.

@nirarg nirarg force-pushed the azure-task branch 2 times, most recently from 079c20e to 05db65b Compare May 17, 2023 17:33
Copy link
Collaborator

@pkliczewski pkliczewski left a comment

Choose a reason for hiding this comment

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

please add some tests

<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-core</artifactId>
<version>1.37.0</version>
Copy link
Collaborator

Choose a reason for hiding this comment

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

please use properties for versions like we do it for other dependencies.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

catch (MissingParameterException e) {
log.error("Task {} failed: missing required parameter, error: {}", getName(), e.getMessage());
}
catch (Exception e) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

please be specific which exceptions we want to catch here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Except to MissingParameterException there is no known declared Exception that should be catched
Therefore I catch Exception to cover any unexpected RuntimeException

@nirarg
Copy link
Contributor Author

nirarg commented May 18, 2023

please add some tests

@pkliczewski
I'm working on adding unit tests for the new task
Maybe would add this in new PR, in order to have this PR merged before the demo

@nirarg nirarg force-pushed the azure-task branch 3 times, most recently from b30678f to 0176a9c Compare May 18, 2023 07:05
Copy link
Collaborator

@pkliczewski pkliczewski left a comment

Choose a reason for hiding this comment

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

/lgtm

@nirarg
Copy link
Contributor Author

nirarg commented May 21, 2023

Added unit tests to the PR
Added all new changes in different commit: 887c633


@Test
public void testHappyFlow() {
String publicIP = "11.11.11.11";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Add new task creating VM on Azure cloud
Currently it create Ubuntu
In order to include the unit tests this commit also include changes in the task
Moving all azure API access to interface (mock it in the test)
@nirarg
Copy link
Contributor Author

nirarg commented May 21, 2023

Also added instructions how to use the example workflow configuration
see here

@masayag
Copy link
Collaborator

masayag commented May 21, 2023

/lgtm
/approve

@openshift-ci
Copy link

openshift-ci bot commented May 21, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: masayag

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot merged commit a6b9a39 into parodos-dev:main May 21, 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.

5 participants