Skip to content

Commit

Permalink
Merge pull request #8 from openshift/inf
Browse files Browse the repository at this point in the history
cherry-pick: pkg/certagent: wait forever for CSR request to reply
  • Loading branch information
openshift-merge-robot committed Apr 5, 2019
2 parents 9d3e068 + 7522873 commit 48eb189
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions pkg/certagent/agent.go
Expand Up @@ -99,18 +99,25 @@ func GenerateCSRObject(config CSRConfig) (*capi.CertificateSigningRequest, error

// RequestCertificate will create a certificate signing request for a node
// with the config given and send it to a signer via a POST request.
// If something goes wrong it returns an error.
// If something goes wrong it returns an error but wait forever for
// server to respond to request.
// NOTE: This method does not return the approved CSR from the signer.
func (c *CertAgent) RequestCertificate() error {
csr, err := GenerateCSRObject(c.config)
if err != nil {
return fmt.Errorf("error generating CSR Object: %v", err)
}

// send CSR to the signer
if _, err := c.client.Create(csr); err != nil {
return fmt.Errorf("error sending CSR to signer: %v", err)
}
duration := 10 * time.Second
// wait forever for success and retry every duration interval
wait.PollInfinite(duration, func() (bool, error) {
_, err := c.client.Create(csr)
if err != nil {
glog.Errorf("error sending CSR to signer: %v", err)
return false, nil
}
return true, nil
})

rcvdCSR, err := c.WaitForCertificate()
if err != nil {
Expand Down

0 comments on commit 48eb189

Please sign in to comment.