Merge pull request #17516 from rook/mergify/bp/release-1.19/pr-17472

mgr: retry self-signed cert creation on wrapped context deadline errors (backport #17472)
This commit is contained in:
Travis Nielsen authored and GitHub committed 2026-05-12 13:37:39 -10:00
commit 458ab183ce
2 files changed
+37 -1

No files matched your search

+1 -1
View File
@@ -248,7 +248,7 @@ func (c *Cluster) createSelfSignedCert() (bool, error) {
// retry a few times in the case that the mgr module is not ready to accept commands
for i := 0; i < 5; i++ {
_, err := client.NewCephCommand(c.context, c.clusterInfo, args).RunWithTimeout(exec.CephCommandsTimeout)
if err == context.DeadlineExceeded {
if errors.Is(err, context.DeadlineExceeded) {
log.NamespacedWarning(c.clusterInfo.Namespace, logger, "cert creation timed out. trying again")
continue
}
@@ -187,3 +187,39 @@ func TestStartSecureDashboard(t *testing.T) {
assert.Equal(t, 8443, int(svc.Spec.Ports[0].Port))
assert.Equal(t, 8443, int(svc.Spec.Ports[0].TargetPort.IntVal))
}
func TestCreateSelfSignedCertRetriesWrappedDeadlineExceeded(t *testing.T) {
ctx := context.TODO()
clientset := test.New(t, 3)
attempts := 0
executor := &exectest.MockExecutor{
MockExecuteCommandWithTimeout: func(timeout time.Duration, command string, arg ...string) (string, error) {
if arg[0] == "config-key" && arg[1] == "get" {
return "", errors.New("cert not found")
}
if arg[0] == "dashboard" && arg[1] == "create-self-signed-cert" {
attempts++
if attempts < 3 {
return "", errors.Wrap(context.DeadlineExceeded, "test timeout")
}
}
return "", nil
},
}
ownerInfo := cephclient.NewMinimumOwnerInfoWithOwnerRef()
clusterInfo := &cephclient.ClusterInfo{
Namespace: "myns",
OwnerInfo: ownerInfo,
Context: ctx,
}
c := &Cluster{
clusterInfo: clusterInfo,
context: &clusterd.Context{Clientset: clientset, Executor: executor},
}
alreadyCreated, err := c.createSelfSignedCert()
assert.NoError(t, err)
assert.False(t, alreadyCreated)
assert.Equal(t, 3, attempts)
}