mirror of
https://github.com/vmware-tanzu/pinniped.git
synced 2026-02-07 05:21:24 +00:00
Merge pull request #1922 from vmware-tanzu/clarify_err_msg
clarify error message for when there is no healthy controller manager
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
// Copyright 2021-2023 the Pinniped contributors. All Rights Reserved.
|
// Copyright 2021-2024 the Pinniped contributors. All Rights Reserved.
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
// Package kubecertagent provides controllers that ensure a pod (the kube-cert-agent), is
|
// Package kubecertagent provides controllers that ensure a pod (the kube-cert-agent), is
|
||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -278,7 +279,13 @@ func (c *agentController) Sync(ctx controllerlib.Context) error {
|
|||||||
// If there are no healthy controller manager pods, we alert the user that we can't find the keypair via
|
// If there are no healthy controller manager pods, we alert the user that we can't find the keypair via
|
||||||
// the CredentialIssuer.
|
// the CredentialIssuer.
|
||||||
if newestControllerManager == nil {
|
if newestControllerManager == nil {
|
||||||
err := fmt.Errorf("could not find a healthy kube-controller-manager pod (%s)", pluralize(controllerManagerPods))
|
msg := fmt.Sprintf("could not find a healthy kube-controller-manager pod (%s)", pluralize(controllerManagerPods))
|
||||||
|
if len(controllerManagerPods) == 0 {
|
||||||
|
err = fmt.Errorf("%s: note that this error is the expected behavior for some cluster types, "+
|
||||||
|
"including most cloud provider clusters (e.g. GKE, AKS, EKS)", msg)
|
||||||
|
} else {
|
||||||
|
err = errors.New(msg)
|
||||||
|
}
|
||||||
return c.failStrategyAndErr(ctx.Context, credIssuer, err, configv1alpha1.CouldNotFetchKeyStrategyReason)
|
return c.failStrategyAndErr(ctx.Context, credIssuer, err, configv1alpha1.CouldNotFetchKeyStrategyReason)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -270,13 +270,15 @@ func TestAgentController(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
wantDistinctErrors: []string{
|
wantDistinctErrors: []string{
|
||||||
"could not find a healthy kube-controller-manager pod (0 candidates)",
|
"could not find a healthy kube-controller-manager pod (0 candidates): " +
|
||||||
|
"note that this error is the expected behavior for some cluster types, including most cloud provider clusters (e.g. GKE, AKS, EKS)",
|
||||||
},
|
},
|
||||||
wantStrategy: &configv1alpha1.CredentialIssuerStrategy{
|
wantStrategy: &configv1alpha1.CredentialIssuerStrategy{
|
||||||
Type: configv1alpha1.KubeClusterSigningCertificateStrategyType,
|
Type: configv1alpha1.KubeClusterSigningCertificateStrategyType,
|
||||||
Status: configv1alpha1.ErrorStrategyStatus,
|
Status: configv1alpha1.ErrorStrategyStatus,
|
||||||
Reason: configv1alpha1.CouldNotFetchKeyStrategyReason,
|
Reason: configv1alpha1.CouldNotFetchKeyStrategyReason,
|
||||||
Message: "could not find a healthy kube-controller-manager pod (0 candidates)",
|
Message: "could not find a healthy kube-controller-manager pod (0 candidates): " +
|
||||||
|
"note that this error is the expected behavior for some cluster types, including most cloud provider clusters (e.g. GKE, AKS, EKS)",
|
||||||
LastUpdateTime: metav1.NewTime(now),
|
LastUpdateTime: metav1.NewTime(now),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright 2020-2021 the Pinniped contributors. All Rights Reserved.
|
// Copyright 2020-2024 the Pinniped contributors. All Rights Reserved.
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
package integration
|
package integration
|
||||||
@@ -90,7 +90,8 @@ func TestCredentialIssuer(t *testing.T) {
|
|||||||
} else {
|
} else {
|
||||||
require.Equal(t, configv1alpha1.ErrorStrategyStatus, actualStatusStrategy.Status)
|
require.Equal(t, configv1alpha1.ErrorStrategyStatus, actualStatusStrategy.Status)
|
||||||
require.Equal(t, configv1alpha1.CouldNotFetchKeyStrategyReason, actualStatusStrategy.Reason)
|
require.Equal(t, configv1alpha1.CouldNotFetchKeyStrategyReason, actualStatusStrategy.Reason)
|
||||||
require.Contains(t, actualStatusStrategy.Message, "could not find a healthy kube-controller-manager pod (0 candidates)")
|
require.Contains(t, actualStatusStrategy.Message, "could not find a healthy kube-controller-manager pod (0 candidates): "+
|
||||||
|
"note that this error is the expected behavior for some cluster types, including most cloud provider clusters (e.g. GKE, AKS, EKS)")
|
||||||
require.Nil(t, actualStatusKubeConfigInfo)
|
require.Nil(t, actualStatusKubeConfigInfo)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user