mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-08 14:21:21 +02:00
pick first container if postgres is not found (#1505)
* pick first container if postgres is not found * minor change
This commit is contained in:
+3
-2
@@ -12,6 +12,7 @@ import (
|
||||
"k8s.io/client-go/tools/remotecommand"
|
||||
|
||||
"github.com/zalando/postgres-operator/pkg/spec"
|
||||
"github.com/zalando/postgres-operator/pkg/util/constants"
|
||||
)
|
||||
|
||||
//ExecCommand executes arbitrary command inside the pod
|
||||
@@ -31,14 +32,14 @@ func (c *Cluster) ExecCommand(podName *spec.NamespacedName, command ...string) (
|
||||
// iterate through all containers looking for the one running PostgreSQL.
|
||||
targetContainer := -1
|
||||
for i, cr := range pod.Spec.Containers {
|
||||
if cr.Name == c.containerName() {
|
||||
if cr.Name == constants.PostgresContainerName {
|
||||
targetContainer = i
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if targetContainer < 0 {
|
||||
return "", fmt.Errorf("could not find %s container to exec to", c.containerName())
|
||||
return "", fmt.Errorf("could not find %s container to exec to", constants.PostgresContainerName)
|
||||
}
|
||||
|
||||
req := c.KubeClient.RESTClient.Post().
|
||||
|
||||
Reference in New Issue
Block a user