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

Remove use of defer in printing logs #87

Merged
merged 3 commits into from
Mar 29, 2023

Conversation

rishabh-11
Copy link
Contributor

@rishabh-11 rishabh-11 commented Mar 27, 2023

What this PR does / why we need it:
This PR removes the usage of the defer keyword when printing logs in some of the methods. Deferred logging leads to confusing logs, as the logged statement is incorrect when the corresponding method has to return an error.

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Release note:

removed the use of `defer` in printing logs for resource creation methods

@rishabh-11 rishabh-11 requested review from a team as code owners March 27, 2023 16:18
@gardener-robot gardener-robot added needs/review Needs review size/s Size of pull request is small (see gardener-robot robot/bots/size.py) labels Mar 27, 2023
@gardener-robot-ci-3 gardener-robot-ci-3 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Mar 27, 2023
@gardener-robot-ci-2 gardener-robot-ci-2 added needs/ok-to-test Needs approval for testing (check PR in detail before setting this label because PR is run on CI/CD) and removed reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) labels Mar 27, 2023
@rishabh-11 rishabh-11 self-assigned this Mar 27, 2023
@rishabh-11
Copy link
Contributor Author

/invite @himanshu-kun

Copy link
Contributor

@himanshu-kun himanshu-kun 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 the PR
the log changes are required only for nic, disk related operations. I have pointed which changes are not relevant.


// Check if provider in the MachineClass is the provider we support
if req.MachineClass.Provider != ProviderAzure {
err := fmt.Errorf("requested for Provider '%s', we only support '%s'", req.MachineClass.Provider, ProviderAzure)
klog.V(2).Infof("Machine creation request failed for %q, Error: %v", req.Machine.Name, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this defer statement needs to be removed. as it says processed not successful or similar.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I remove the failed request logs for all the other methods?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed in d5d27b3

defer klog.V(2).Infof("Machine deletion request has been processed for %q", req.Machine.Name)
klog.V(2).Infof("Machine deletion request has been received for %q", req.Machine.Name)
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed in d5d27b3

pkg/azure/core.go Show resolved Hide resolved
Comment on lines 363 to 370
err := fillUpMachineClass(azureMachineClass, req.MachineClass)
if err == nil {
klog.V(2).Infof("MigrateMachineClass request has been processed successfully for %q", req.ClassSpec)
} else {
klog.V(2).Infof("MigrateMachineClass request has failed for %q, Error: %v", req.ClassSpec, err)
}

return &driver.GenerateMachineClassForMigrationResponse{}, err
Copy link
Contributor

Choose a reason for hiding this comment

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

we can revert 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.

addressed in d5d27b3

@gardener-robot gardener-robot added the needs/changes Needs (more) changes label Mar 28, 2023
@himanshu-kun himanshu-kun added needs/cherry-pick Needs to be cherry-picked to older version and removed needs/cherry-pick Needs to be cherry-picked to older version labels Mar 28, 2023
@himanshu-kun
Copy link
Contributor

himanshu-kun commented Mar 28, 2023

/needs cherry-pick on rel-v0.10

@gardener-robot gardener-robot added the needs/cherry-pick Needs to be cherry-picked to older version label Mar 28, 2023
@gardener-robot-ci-2 gardener-robot-ci-2 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Mar 28, 2023
@gardener-robot-ci-3 gardener-robot-ci-3 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Mar 28, 2023
@gardener-robot-ci-2 gardener-robot-ci-2 added reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) and removed reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) labels Mar 28, 2023
@rishabh-11 rishabh-11 requested a review from himanshu-kun March 28, 2023 17:10
Copy link
Contributor

@himanshu-kun himanshu-kun left a comment

Choose a reason for hiding this comment

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

/lgtm

@gardener-robot gardener-robot added reviewed/lgtm Has approval for merging and removed needs/changes Needs (more) changes needs/review Needs review labels Mar 29, 2023
@himanshu-kun himanshu-kun merged commit d546807 into gardener:master Mar 29, 2023
@gardener-robot gardener-robot added the status/closed Issue is closed (either delivered or triaged) label Mar 29, 2023
@gardener-robot-ci-1 gardener-robot-ci-1 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Mar 29, 2023
@himanshu-kun himanshu-kun removed their assignment Apr 4, 2023
@rishabh-11 rishabh-11 deleted the fix-logs branch April 17, 2023 10:46
@gardener-robot
Copy link

@himanshu-kun Labels needs/on, needs/rel-v0.10 do not exist.

himanshu-kun pushed a commit that referenced this pull request Apr 18, 2023
* remove use of defer in printing logs

* address review comments

* revert log to higher level
@himanshu-kun himanshu-kun removed the needs/cherry-pick Needs to be cherry-picked to older version label May 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs/ok-to-test Needs approval for testing (check PR in detail before setting this label because PR is run on CI/CD) reviewed/lgtm Has approval for merging reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) size/s Size of pull request is small (see gardener-robot robot/bots/size.py) status/closed Issue is closed (either delivered or triaged)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants