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

Throw a warning instead of an error when the listener is in no state #163

Open
whg517 opened this issue Dec 26, 2024 · 0 comments
Open

Throw a warning instead of an error when the listener is in no state #163

whg517 opened this issue Dec 26, 2024 · 0 comments

Comments

@whg517
Copy link
Member

whg517 commented Dec 26, 2024

In csi, a listener object is created, the listener object status is obtained, and the address and port in the status are written to the volume sink mounted by the pod. When the listener controller has not updated the status urgently, the csi should throw a warning message, not an error message.

// getAddresses gets the listener address and ports from the listener status.
// When get address from listener status, if listener status is not ready,
// an error will raise. NodeController will retry to get address from listener status.
func (n *NodeServer) getAddresses(ctx context.Context, listener *listeners.Listener, pod *corev1.Pod) ([]util.IngressAddress, error) {
// Get fresh listener, to avoid get listener status error
if err := n.client.Get(ctx, client.ObjectKeyFromObject(listener), listener); err != nil {
return nil, err
}
if len(listener.Status.NodePorts) != 0 {
address, err := n.getNodeAddressByPod(ctx, pod)
if err != nil {
return nil, err
}
log.V(1).Info("get address from node", "address", address, "listener", listener.Name, "namespace", listener.Namespace)
return []util.IngressAddress{{AddressInfo: *address, Ports: listener.Status.NodePorts}}, nil
} else if len(listener.Status.IngressAddresses) != 0 {
var addresses []util.IngressAddress
for _, ingressAddress := range listener.Status.IngressAddresses {
addresses = append(addresses, util.IngressAddress{
AddressInfo: util.AddressInfo{
Address: ingressAddress.Address,
AddressType: ingressAddress.AddressType,
},
Ports: ingressAddress.Ports,
})
}
log.V(1).Info("get address from listener status", "addresses", addresses, "listener", listener.Name, "namespace", listener.Namespace)
return addresses, nil
}
return nil, status.Error(codes.Internal, "can not found address from listener status")
}

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

No branches or pull requests

1 participant