Skip to content

Bug 1896051: Services should not have duplicate ownerrefs #1856

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions pkg/controller/certs/certs.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ import (
"time"
)

type CertGenerator interface {
Generate(notAfter time.Time, organization string, ca *KeyPair, hosts []string) (*KeyPair, error)
}

type CertGeneratorFunc func(notAfter time.Time, organization string, ca *KeyPair, hosts []string) (*KeyPair, error)

func (f CertGeneratorFunc) Generate(notAfter time.Time, organization string, ca *KeyPair, hosts []string) (*KeyPair, error) {
return f(notAfter, organization, ca, hosts)
}

var _ CertGenerator = CertGeneratorFunc(CreateSignedServingPair)

// KeyPair stores an x509 certificate and its ECDSA private key
type KeyPair struct {
Cert *x509.Certificate
Expand Down
6 changes: 5 additions & 1 deletion pkg/controller/install/certresources.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ var _ certResource = &apiServiceDescriptionsWithCAPEM{}

var _ certResource = &webhookDescriptionWithCAPEM{}

// TODO: to keep refactoring minimal for backports, this is factored out here so that it can be replaced
// during tests. but it should be properly injected instead.
var certGenerator certs.CertGenerator = certs.CertGeneratorFunc(certs.CreateSignedServingPair)

const (
// DefaultCertMinFresh is the default min-fresh value - 1 day
DefaultCertMinFresh = time.Hour * 24
Expand Down Expand Up @@ -256,7 +260,7 @@ func (i *StrategyDeploymentInstaller) installCertRequirementsForDeployment(deplo
fmt.Sprintf("%s.%s", service.GetName(), i.owner.GetNamespace()),
fmt.Sprintf("%s.%s.svc", service.GetName(), i.owner.GetNamespace()),
}
servingPair, err := certs.CreateSignedServingPair(rotateAt, Organization, ca, hosts)
servingPair, err := certGenerator.Generate(rotateAt, Organization, ca, hosts)
if err != nil {
logger.Warnf("could not generate signed certs for hosts %v", hosts)
return nil, nil, err
Expand Down
Loading