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

Added support for Upload Disk Feature #318

Merged
merged 15 commits into from
Jan 7, 2025

Conversation

damanMSFT
Copy link
Contributor

@damanMSFT damanMSFT commented Nov 5, 2024

No description provided.

}

// SetUploadStatus
func SetUploadStatus(s *common.Status, dProgressPercentage, dUploadSizeInBytes, dFileSizeInBytes int64, err ...error) {
Copy link

@niontive niontive Dec 6, 2024

Choose a reason for hiding this comment

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

Out of scope for this PR - I'm curious why this file has func Set...() and passes in a common.Status - it'd make sense for the Status object to have methods to set its upload status, upload error, etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I agree. This could be refactored to something like func (s *Status) SetUploadStatus(). I am not sure why this is done this way though. I just followed the pattern I saw in the rest of the file.

@@ -146,6 +167,8 @@ func GetStatuses(status *common.Status) map[string]*string {
if placementStatus != "" {
statuses["PlacementStatus"] = &placementStatus
}
ustate := status.GetUploadStatus().String()
Copy link
Contributor

Choose a reason for hiding this comment

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

Just to keep it consistent with the changes being made in the hydration PR, could we null check the result of status.GetUploadStatus like what's done here: https://github.com/microsoft/moc/pull/237/files#diff-1deea3647518183ee4915dd3c10ccfc7bb60e1ed860673c99eefaf5cfeefaa6b

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!

@damanMSFT
Copy link
Contributor Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@damanMSFT
Copy link
Contributor Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@damanMSFT
Copy link
Contributor Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Contributor

@jocardeMSFT jocardeMSFT left a comment

Choose a reason for hiding this comment

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

Completed inital pass review

@@ -129,6 +130,26 @@ func GetPlacementStatus(s *common.Status) common.PlacementStatusType {
return s.GetPlacementStatus().GetStatus()
}

// Set UploadError
func SetUploadError(s *common.Status, err ...error) {
s.UploadStatus.LastUploadError = errors.ErrorToProto(err[0])
Copy link
Contributor

Choose a reason for hiding this comment

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

I realize this might be following a pattern but there is a flaw that can result in a runtime panic. If someone calls this function with 0 errors (err ...error) is a variadic paramater that can be 0..many errors.

if it is 0 errors

this function will result in a runtime panic -> err[0] will panic due to out of bounds access.

suggested fix:

func SetUploadError(s *common.Status, err ...error) {
if len(err) == 0 {
s.UploadStatus.LastUploadError = nil
return
}
s.UploadStatus.LastUploadError = errors.ErrorToProto(err[0])
}

Copy link
Contributor

Choose a reason for hiding this comment

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

If the only place we are calling is below then why do we need a variadic parameter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing it out. I actually fixed it by removing the variadic err param.

int64 fileSizeInBytes = 3;
Error lastUploadError = 4;
}

message Status {
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like it wouldn't be a bad idea to throw a todo here to re-evaluate how to approach resource Status so we don't just keep creating a giant status that gets applied to every resource. Like a VM with a nil upload status.

Copy link
Contributor Author

@damanMSFT damanMSFT Jan 6, 2025

Choose a reason for hiding this comment

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

Agreed. Added a comment.

@damanMSFT
Copy link
Contributor Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

jocardeMSFT
jocardeMSFT previously approved these changes Jan 7, 2025
rbalwani
rbalwani previously approved these changes Jan 7, 2025
@@ -125,6 +126,26 @@ func GetPlacementStatus(s *common.Status) common.PlacementStatusType {
return s.GetPlacementStatus().GetStatus()
}

// Set UploadError
func SetUploadError(s *common.Status, err ...error) {
s.UploadStatus.LastUploadError = errors.ErrorToProto(err[0])
Copy link
Contributor

Choose a reason for hiding this comment

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

if len(err) > 0 { // check if it is not empty

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry. I am not sure how I missed it. I have remove the variadic error parameter.

@@ -346,6 +356,7 @@ enum ProviderAccessOperation {

VirtualHardDisk_Create = 3100;
VirtualHardDisk_Update = 3101;
VirtualHardDisk_Upload = 3102;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit please remove tabs for formatting

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 am not sure why it shows up like this here. It looks good on my local setup.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image

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

@damanMSFT damanMSFT dismissed stale reviews from rbalwani and jocardeMSFT via 84daa4d January 7, 2025 19:40
@damanMSFT
Copy link
Contributor Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@damanMSFT damanMSFT merged commit d25b204 into main Jan 7, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants