Fixed: Print pod log error when response status is 404 returned by te… (#3021)
* Fixed: Print pod log error when response status is 404 returned by test function * Update util.go --------- Signed-off-by: waitstory <waitstory@163.com>
This commit is contained in:
@@ -63,10 +63,17 @@ func GetFunctionPodLogs(ctx context.Context, client cmd.Client, logFilter LogFil
|
|||||||
podNs = logFilter.PodNamespace
|
podNs = logFilter.PodNamespace
|
||||||
}
|
}
|
||||||
// Get function Pods first
|
// Get function Pods first
|
||||||
selector := map[string]string{
|
var selector map[string]string
|
||||||
fv1.FUNCTION_UID: string(f.ObjectMeta.UID),
|
if f.Spec.InvokeStrategy.ExecutionStrategy.ExecutorType != fv1.ExecutorTypeContainer {
|
||||||
fv1.ENVIRONMENT_NAME: f.Spec.Environment.Name,
|
selector = map[string]string{
|
||||||
fv1.ENVIRONMENT_NAMESPACE: f.Spec.Environment.Namespace,
|
fv1.FUNCTION_UID: string(f.ObjectMeta.UID),
|
||||||
|
fv1.ENVIRONMENT_NAME: f.Spec.Environment.Name,
|
||||||
|
fv1.ENVIRONMENT_NAMESPACE: f.Spec.Environment.Namespace,
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
selector = map[string]string{
|
||||||
|
fv1.FUNCTION_UID: string(f.ObjectMeta.UID),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
podNs = util.ResolveFunctionNS(podNs)
|
podNs = util.ResolveFunctionNS(podNs)
|
||||||
|
|||||||
@@ -531,12 +531,8 @@ func GetSvcName(ctx context.Context, kClient kubernetes.Interface, application s
|
|||||||
// FunctionPodLogs : Get logs for a function directly from pod
|
// FunctionPodLogs : Get logs for a function directly from pod
|
||||||
func FunctionPodLogs(ctx context.Context, fnName, ns string, client cmd.Client) (err error) {
|
func FunctionPodLogs(ctx context.Context, fnName, ns string, client cmd.Client) (err error) {
|
||||||
|
|
||||||
podNs := "fission-function"
|
|
||||||
|
|
||||||
if len(ns) == 0 {
|
if len(ns) == 0 {
|
||||||
ns = metav1.NamespaceDefault
|
ns = metav1.NamespaceDefault
|
||||||
} else if ns != metav1.NamespaceDefault {
|
|
||||||
podNs = ns
|
|
||||||
}
|
}
|
||||||
|
|
||||||
f, err := client.FissionClientSet.CoreV1().Functions(ns).Get(ctx, fnName, metav1.GetOptions{})
|
f, err := client.FissionClientSet.CoreV1().Functions(ns).Get(ctx, fnName, metav1.GetOptions{})
|
||||||
@@ -545,12 +541,19 @@ func FunctionPodLogs(ctx context.Context, fnName, ns string, client cmd.Client)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get function Pods first
|
// Get function Pods first
|
||||||
selector := map[string]string{
|
var selector map[string]string
|
||||||
fv1.FUNCTION_UID: string(f.ObjectMeta.UID),
|
if f.Spec.InvokeStrategy.ExecutionStrategy.ExecutorType != fv1.ExecutorTypeContainer {
|
||||||
fv1.ENVIRONMENT_NAME: f.Spec.Environment.Name,
|
selector = map[string]string{
|
||||||
fv1.ENVIRONMENT_NAMESPACE: f.Spec.Environment.Namespace,
|
fv1.FUNCTION_UID: string(f.ObjectMeta.UID),
|
||||||
|
fv1.ENVIRONMENT_NAME: f.Spec.Environment.Name,
|
||||||
|
fv1.ENVIRONMENT_NAMESPACE: f.Spec.Environment.Namespace,
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
selector = map[string]string{
|
||||||
|
fv1.FUNCTION_UID: string(f.ObjectMeta.UID),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
podList, err := client.KubernetesClient.CoreV1().Pods(podNs).List(ctx, metav1.ListOptions{
|
podList, err := client.KubernetesClient.CoreV1().Pods(ns).List(ctx, metav1.ListOptions{
|
||||||
LabelSelector: labels.Set(selector).AsSelector().String(),
|
LabelSelector: labels.Set(selector).AsSelector().String(),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -566,7 +569,7 @@ func FunctionPodLogs(ctx context.Context, fnName, ns string, client cmd.Client)
|
|||||||
})
|
})
|
||||||
|
|
||||||
if len(pods) <= 0 {
|
if len(pods) <= 0 {
|
||||||
return errors.New("no active pods found for function in namespace " + podNs)
|
return errors.New("no active pods found for function in namespace " + ns)
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the pod with highest resource version
|
// get the pod with highest resource version
|
||||||
|
|||||||
Reference in New Issue
Block a user