Fix issue where ceremony tool is not compiled in time

This commit is contained in:
Arjan H
2025-03-05 21:04:01 +01:00
parent 8b7f5145a8
commit 5904cebaa5

View File

@@ -175,6 +175,25 @@ func ceremonyConfig(path string, rewrites map[string]string) (string, error) {
return tmp.Name(), nil
}
func waitForFile(filePath string) error {
start := time.Now()
for {
if _, err := os.Stat(filePath); err == nil {
return nil // File found
} else if !os.IsNotExist(err) {
return fmt.Errorf("error checking file: %v", err) // Unexpected error
}
// Check if the timeout has been reached
if time.Since(start) > 2*time.Minute {
return fmt.Errorf("timeout reached while waiting for file")
}
// Sleep for a short interval before checking again
time.Sleep(5 * time.Second)
}
}
func (ci *CertificateInfo) CeremonyRoot(seqnr string, use_existing_key bool) (string, error) {
keytype := "rsa"
keyparam := strings.Replace(ci.KeyType, "rsa", "", -1)
@@ -230,6 +249,11 @@ func (ci *CertificateInfo) CeremonyRoot(seqnr string, use_existing_key bool) (st
}
defer os.Remove(ceremonyCfg)
err = waitForFile("/opt/boulder/bin/ceremony")
if err != nil {
return "", fmt.Errorf("could not wait for /opt/boulder/bin/ceremony to exist: %s", err.Error())
}
if _, err = exeCmd("/opt/boulder/bin/ceremony -config " + ceremonyCfg); err != nil {
ci.Errors["Generate"] = "failed to execute root ceremony, see logs for details"
cb.Restore()
@@ -291,6 +315,11 @@ func (ci *CertificateInfo) CeremonyIssuer(seqnr, rootseqnr string, use_existing_
}
defer os.Remove(keyCfg)
err = waitForFile("/opt/boulder/bin/ceremony")
if err != nil {
return "", fmt.Errorf("could not wait for /opt/boulder/bin/ceremony to exist: %s", err.Error())
}
if _, err = exeCmd("/opt/boulder/bin/ceremony -config " + keyCfg); err != nil {
ci.Errors["Generate"] = "failed to execute issuer key ceremony, see logs for details"
pb.Restore()
@@ -335,6 +364,11 @@ func (ci *CertificateInfo) CeremonyIssuer(seqnr, rootseqnr string, use_existing_
}
defer os.Remove(ceremonyCfg)
err = waitForFile("/opt/boulder/bin/ceremony")
if err != nil {
return "", fmt.Errorf("could not wait for /opt/boulder/bin/ceremony to exist: %s", err.Error())
}
if _, err = exeCmd("/opt/boulder/bin/ceremony -config " + ceremonyCfg); err != nil {
ci.Errors["Generate"] = "failed to execute issuer cert ceremony, see logs for details"
cb.Restore()
@@ -423,6 +457,11 @@ func (ci *CertificateInfo) CeremonyRootCRL(seqnr string) error {
}
defer os.Remove(keyCfg)
err = waitForFile("/opt/boulder/bin/ceremony")
if err != nil {
return fmt.Errorf("could not wait for /opt/boulder/bin/ceremony to exist: %s", err.Error())
}
if _, err = exeCmd("/opt/boulder/bin/ceremony -config " + keyCfg); err != nil {
ci.Errors["CRL"] = "failed to execute root crl ceremony, see logs for details"
cb.Restore()