Skip to content

Commit

Permalink
fix: get lorry container (#5897)
Browse files Browse the repository at this point in the history
  • Loading branch information
xuriwuyun authored Nov 22, 2023
1 parent 92472fe commit 0dd82c8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lorry/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ func NewHTTPClientWithChannelPod(pod *corev1.Pod, characterType string) (*Operat
if ip == "" {
return nil, fmt.Errorf("pod %v has no ip", pod.Name)
}
container, err := intctrlutil.GetProbeContainerName(pod)
container, err := intctrlutil.GetLorryContainerName(pod)
if err != nil {
return nil, err
}
Expand Down
13 changes: 7 additions & 6 deletions pkg/controllerutil/pod_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,15 +371,16 @@ func GuessLorryHTTPPort(pod *corev1.Pod) (int32, error) {
return 0, fmt.Errorf("lorry port not found")
}

// GetProbeContainerName gets the probe container from pod
func GetProbeContainerName(pod *corev1.Pod) (string, error) {
lorryImage := viper.GetString(constant.KBToolsImage)
// GetLorryContainerName gets the probe container from pod
func GetLorryContainerName(pod *corev1.Pod) (string, error) {
for _, container := range pod.Spec.Containers {
if container.Image == lorryImage {
return container.Name, nil
for _, port := range container.Ports {
if port.Name == constant.LorryHTTPPortName {
return container.Name, nil
}
}
}
return "", fmt.Errorf("container %s not found", lorryImage)
return "", fmt.Errorf("lorry container not found")

}

Expand Down

0 comments on commit 0dd82c8

Please sign in to comment.