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

Fleet Manager - createFleet #1150

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Fleet Manager - createFleet #1150

wants to merge 10 commits into from

Conversation

JunyuQian
Copy link

Initial work from Tatsat + createFleet panel setup

@JunyuQian
Copy link
Author

@JunyuQian please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"

Contributor License Agreement

@microsoft-github-policy-service agree company="Microsoft"

@JunyuQian
Copy link
Author

@serbrech @dvadas

private readonly resourceManagementClient: ResourceManagementClient;
private readonly fleetClient: ContainerServiceFleetClient;
private readonly featureClient: FeatureClient;
// private readonly commandId: string;
Copy link
Member

Choose a reason for hiding this comment

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

what is the command id for? will it be used later?

// args.isNewResourceGroup,
// args.resourceGroupName,
// args.location,
// args.name,
Copy link
Member

Choose a reason for hiding this comment

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

should these commented out lines be deleted?

@Tatsinnit Tatsinnit added the enhancement 🚀 New feature or request or improvements on existing code. label Jan 6, 2025
name: string,
resource: Fleet,
// sessionProvider: ReadyAzureSessionProvider,
// subscriptionId: string,
Copy link
Member

Choose a reason for hiding this comment

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

the client is created using the session and the subscriptionId, so I don't think that you would ever need these parameters here.
if the list of argument increases (probably, to support all the fleet options) then you should create a type to encapsulate them. That way, the function signature won't change when you add more options

Copy link
Collaborator

Choose a reason for hiding this comment

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

I feel this PR is still undergoing changes, testing etc.. it could be still work in progress. Please reach out if you have any questions, Thank you.

Copy link
Member

Choose a reason for hiding this comment

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

It is absolutely work in progress, I'm commenting to help get to a mergeable state in a reasonable time :)
Thanks for reviewing as well @hsubramanianaks!

Copy link
Collaborator

Choose a reason for hiding this comment

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

@serbrech agreed to your point above where it has to be a type for the function parameter.

portalUrl: string;
};

export interface CreateFleetParams {
Copy link
Member

@serbrech serbrech Jan 6, 2025

Choose a reason for hiding this comment

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

isn't this the create fleet argument list?
should this be used as an argument to the createFleet func?

I'm not familiar with typescript, @Tatsinnit might be better guidance here to get to a good place.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 6 out of 15 changed files in this pull request and generated 2 comments.

Files not reviewed (9)
  • package.json: Language not supported
  • webview-ui/src/manualTest/main.tsx: Evaluated as low risk
  • src/commands/aksFleet/aksFleetManager.ts: Evaluated as low risk
  • src/webview-contract/webviewTypes.ts: Evaluated as low risk
  • webview-ui/src/main.tsx: Evaluated as low risk
  • src/extension.ts: Evaluated as low risk
  • src/commands/utils/arm.ts: Evaluated as low risk
  • webview-ui/src/manualTest/createFleetTests.tsx: Evaluated as low risk
  • src/panels/CreateFleetPanel.ts: Evaluated as low risk
Comments suppressed due to low confidence (8)

webview-ui/src/CreateFleet/CreateFleetInput.tsx:60

  • [nitpick] The error message for the fleet name validation is too verbose. Consider simplifying it to: 'Fleet name can only contain letters, numbers, dashes, and underscores, and must start and end with a letter or number.'
The only allowed characters are letters, numbers, dashes, and underscore. The first and last character must be a letter or a number.

webview-ui/src/CreateFleet/helpers/state.ts:13

  • Enum values should be in uppercase. Rename 'InProgress' to 'IN_PROGRESS'.
    InProgress,

webview-ui/src/CreateFleet/helpers/state.ts:15

  • Enum values should be in uppercase. Rename 'Cancelled' to 'CANCELLED'.
    Cancelled,

webview-ui/src/CreateFleet/helpers/state.ts:17

  • Enum values should be in uppercase. Rename 'Failed' to 'FAILED'.
    Failed,

webview-ui/src/CreateFleet/helpers/state.ts:17

  • Enum values should be in uppercase. Rename 'Success' to 'SUCCESS'.
    Success,

webview-ui/src/CreateFleet/helpers/state.ts:83

  • [nitpick] Consider adding a success message for the 'ProgressEventType.SUCCESS' case.
            return { stage: Stage.Succeeded, message: null };

src/commands/utils/fleet.ts:12

  • Ensure that result.name is not null or undefined before using it. Consider adding a check to handle the case where result.name is null or undefined.
return { succeeded: true, result: result.name! };

src/webview-contract/webviewDefinitions/createFleet.ts:32

  • [nitpick] The enum values 'With' and 'Without' are ambiguous. They should be renamed to 'WithHubCluster' and 'WithoutHubCluster' to make it clear what they represent.
export enum HubClusterMode { With, Without }

console.log("Location:", props.locations);
validate();
setLocation(missing<string>("somewhere"));
// const parameters = validate();
Copy link
Preview

Copilot AI Jan 6, 2025

Choose a reason for hiding this comment

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

The handleSubmit function contains commented-out code and incomplete logic. Consider removing the commented-out code and ensuring the form submission logic is complete.

Suggested change
// const parameters = validate();
const parameters = validate(); if (parameters.isJust) { props.eventHandlers.onSetCreating({ parameters: parameters.value }); }

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
case ProgressEventType.InProgress:
return { stage: Stage.Creating, message: operationDescription };
case ProgressEventType.Cancelled:
return { stage: Stage.Failed, message: "Fleet Creation is cancelled" };
Copy link
Preview

Copilot AI Jan 6, 2025

Choose a reason for hiding this comment

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

The error message should end with a period.

Suggested change
return { stage: Stage.Failed, message: "Fleet Creation is cancelled" };
return { stage: Stage.Failed, message: "Fleet Creation is cancelled." };

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
@@ -0,0 +1,91 @@
import {
Copy link
Member

Choose a reason for hiding this comment

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

could you add comment at the top of this file to explain what state this file defines and encodes, where it's used, etc?

Copy link
Collaborator

@hsubramanianaks hsubramanianaks Jan 6, 2025

Choose a reason for hiding this comment

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

this state.ts file is required for communication between webview and extension. webview is for user experience (UI components) and actual extension handles everything with the vscode. this file is for state management of create fleet flow.

isNewResourceGroup = false;
// } else if (newResourceGroupName) {
// resourceGroupName = newResourceGroupName;
// isNewResourceGroup = true;
Copy link
Member

Choose a reason for hiding this comment

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

can we delete all code related to "is new resource group" and just require the resource group to be pre-created at first? we can think about this create RG flow later if necessary

this.fleetClient = getAksFleetClient(sessionProvider, this.subscriptionId);
this.featureClient = getFeatureClient(sessionProvider, this.subscriptionId);
// this.commandId = commandId;
console.log(this.resourceManagementClient, this.featureClient, this.sessionProvider);
Copy link
Collaborator

Choose a reason for hiding this comment

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

this console.log was added for testing purpose? can this be removed ?

try {
await createFleet(this.fleetClient, resourceGroupName, name, resource);
} catch (error) {
console.log(error);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please throw the error message as notification to the user. Please refer other CreateClusterPanel.ts for error handling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement 🚀 New feature or request or improvements on existing code.
Projects
None yet
4 participants