-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Add exception details to the toComposeNetwork log. #12271
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: liu.shiyu <shencangsheng@126.com>
@@ -222,6 +224,7 @@ func (s *composeService) toComposeNetwork(networks map[string]*network.EndpointS | |||
for name, net := range networks { | |||
inspect, err := s.apiClient().NetworkInspect(context.Background(), name, network.InspectOptions{}) | |||
if err != nil { | |||
logrus.Warnf("Failed to inspect network %s: %v", name, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO would be legitimate to just return err
As inspected container which we guess network from exists, not being able to inspect network should just demonstrate and API call or engine failure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As described, the containers orchestrated by docker compose up
in my production environment have experienced network loss issues more than once. This problem persists even in the latest version and has troubled me for a long time. I have not been able to find any relevant error logs anywhere to pinpoint the issue. Even in the cli
, no anomalies are recorded, which is very frustrating for me.
Would it be more appropriate to print the logs in the NetworkInspect
method of cli
?
// NetworkInspect returns the information for a specific network configured in the docker host.
func (cli *Client) NetworkInspect(ctx context.Context, networkID string, options network.InspectOptions) (network.Inspect, error) {
networkResource, _, err := cli.NetworkInspectWithRaw(ctx, networkID, options)
if err != nil {
logrus.Warnf("Failed to inspect network %v", err)
}
return networkResource, err
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generate
command is not designed to be used as a diagnostic tool! You can wrap engine error to give more context, but I don't expect this will give you more than "not found":
return fmt.Errorf("failed to inspect network %s: %w", networkID, err)
``
Description
When creating a compose, the latest version still frequently encounters issues where containers cannot join the network. #11601
Issue
I found in the source code that when there is an exception during network allocation, an empty network is assigned directly without logging.
Proposal
I would like to add a log message in this case to help identify and resolve the issue.