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

Do not silently fail in k8s agent initialization #1766

Closed
wants to merge 1 commit into from

Conversation

jeromerobert
Copy link

What type of PR is this?

bug/cleanup

What does this PR do / Why do we need it:

It logs aws-k8s-agent initialisation error. Currently, aws-k8s-agent may fail without any error message in the log file, for example if the API server cannot be found.

*Will this break upgrades or downgrades. Has updating a running cluster been tested?**:

No.

Does this change require updates to the CNI daemonset config files to work?:

No.

Does this PR introduce any user-facing change?:

Not a change that deserve inclusion in the release notes IMHO.

@jeromerobert jeromerobert requested a review from a team as a code owner November 24, 2021 11:39
@@ -39,17 +39,21 @@ func _main() int {
version.RegisterMetric()

//Check API Server Connectivity
if k8sapi.CheckAPIServerConnectivity() != nil {
err := k8sapi.CheckAPIServerConnectivity()
Copy link
Member

Choose a reason for hiding this comment

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

Doing a direct comparison to nil since there is no other return value seems better.

So, this line can reduced to simply adding a log.Errorf

Copy link
Author

Choose a reason for hiding this comment

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

Do you mean this ?

--- a/cmd/aws-k8s-agent/main.go
+++ b/cmd/aws-k8s-agent/main.go
@@ -40,6 +40,7 @@ func _main() int {
 
        //Check API Server Connectivity
        if k8sapi.CheckAPIServerConnectivity() != nil {
+               log.Errorf("Failed to connect to the API server")
                return 1
        }

It would prevent to display the returned error while it contains valuable information.

@ChrisMcKee
Copy link

Isnt this the same as #1650

@jeromerobert
Copy link
Author

Oh yes it is, I missed it.

@Shreya027
Copy link
Contributor

Closing PR as identical PR made earlier exists as mentioned above.

@Shreya027 Shreya027 closed this Dec 12, 2021
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.

4 participants