Merge pull request #2097 from JoshVanL/status-subresource

Adds status sub resource and changes updates
This commit is contained in:
jetstack-bot
2019-10-02 16:40:11 +01:00
committed by GitHub
25 changed files with 221 additions and 120 deletions
+12 -4
View File
@@ -29,7 +29,8 @@ spec:
kind: Challenge
plural: challenges
scope: Namespaced
subresources: {}
subresources:
status: {}
validation:
openAPIV3Schema:
description: Challenge is a type to represent a Challenge request with an ACME
@@ -1404,7 +1405,8 @@ spec:
kind: Order
plural: orders
scope: Namespaced
subresources: {}
subresources:
status: {}
validation:
openAPIV3Schema:
description: Order is a type to represent an Order with an ACME server
@@ -1613,7 +1615,8 @@ spec:
- cr
- crs
scope: Namespaced
subresources: {}
subresources:
status: {}
validation:
openAPIV3Schema:
description: CertificateRequest is a type to represent a Certificate Signing
@@ -1803,7 +1806,8 @@ spec:
- cert
- certs
scope: Namespaced
subresources: {}
subresources:
status: {}
validation:
openAPIV3Schema:
description: Certificate is a type to represent a Certificate from ACME
@@ -2016,6 +2020,8 @@ spec:
kind: ClusterIssuer
plural: clusterissuers
scope: Cluster
subresources:
status: {}
validation:
openAPIV3Schema:
properties:
@@ -3676,6 +3682,8 @@ spec:
kind: Issuer
plural: issuers
scope: Namespaced
subresources:
status: {}
validation:
openAPIV3Schema:
properties:
@@ -14,6 +14,11 @@ resources which represent certificate authorities.
More information on configuring different Issuer types can be found in the
:doc:`respective setup guides </tasks/issuers/index>`.
.. note::
From cert-manager v0.11.0 onwards, the minimum supported version of
Kubernetes is v1.11.0. Users still running Kubernetes v1.10 or below should
upgrade to a supported version before installing cert-manager.
.. warning::
You should not install multiple instances of cert-manager on a single
@@ -31,6 +31,7 @@ import (
// +kubebuilder:printcolumn:name="Domain",type="string",JSONPath=".spec.dnsName"
// +kubebuilder:printcolumn:name="Reason",type="string",JSONPath=".status.reason",description="",priority=1
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="CreationTimestamp is a timestamp representing the server time when this object was created. It is not guaranteed to be set in happens-before order across separate operations. Clients may not set this value. It is represented in RFC3339 form and is in UTC."
// +kubebuilder:subresource:status
// +kubebuilder:resource:path=challenges
type Challenge struct {
metav1.TypeMeta `json:",inline"`
+1
View File
@@ -34,6 +34,7 @@ import (
// +kubebuilder:printcolumn:name="Issuer",type="string",JSONPath=".spec.issuerRef.name",description="",priority=1
// +kubebuilder:printcolumn:name="Reason",type="string",JSONPath=".status.reason",description="",priority=1
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="CreationTimestamp is a timestamp representing the server time when this object was created. It is not guaranteed to be set in happens-before order across separate operations. Clients may not set this value. It is represented in RFC3339 form and is in UTC."
// +kubebuilder:subresource:status
// +kubebuilder:resource:path=orders
type Order struct {
metav1.TypeMeta `json:",inline"`
@@ -32,6 +32,7 @@ import (
// +kubebuilder:printcolumn:name="Issuer",type="string",JSONPath=".spec.issuerRef.name",description="",priority=1
// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].message",priority=1
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="CreationTimestamp is a timestamp representing the server time when this object was created. It is not guaranteed to be set in happens-before order across separate operations. Clients may not set this value. It is represented in RFC3339 form and is in UTC."
// +kubebuilder:subresource:status
// +kubebuilder:resource:path=certificates,shortName=cert;certs
type Certificate struct {
metav1.TypeMeta `json:",inline"`
@@ -37,6 +37,7 @@ const (
// +kubebuilder:printcolumn:name="Issuer",type="string",JSONPath=".spec.issuerRef.name",description="",priority=1
// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].message",priority=1
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="CreationTimestamp is a timestamp representing the server time when this object was created. It is not guaranteed to be set in happens-before order across separate operations. Clients may not set this value. It is represented in RFC3339 form and is in UTC."
// +kubebuilder:subresource:status
// +kubebuilder:resource:path=certificaterequests,shortName=cr;crs
type CertificateRequest struct {
metav1.TypeMeta `json:",inline"`
@@ -28,6 +28,7 @@ import (
// +k8s:openapi-gen=true
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:subresource:status
// +kubebuilder:resource:path=clusterissuers,scope=Cluster
type ClusterIssuer struct {
metav1.TypeMeta `json:",inline"`
@@ -51,6 +52,7 @@ type ClusterIssuerList struct {
// +k8s:openapi-gen=true
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:subresource:status
// +kubebuilder:resource:path=issuers
type Issuer struct {
metav1.TypeMeta `json:",inline"`
+1 -1
View File
@@ -164,7 +164,7 @@ func (c *controller) runScheduler(ctx context.Context) {
ch = ch.DeepCopy()
ch.Status.Processing = true
_, err := c.cmClient.AcmeV1alpha2().Challenges(ch.Namespace).Update(ch)
_, err := c.cmClient.AcmeV1alpha2().Challenges(ch.Namespace).UpdateStatus(ch)
if err != nil {
log.Error(err, "error scheduling challenge for processing")
return
+25 -8
View File
@@ -65,21 +65,21 @@ func (c *controller) Sync(ctx context.Context, ch *cmacme.Challenge) (err error)
oldChal := ch
ch = ch.DeepCopy()
if ch.DeletionTimestamp != nil {
return c.handleFinalizer(ctx, ch)
}
defer func() {
// TODO: replace with more efficient comparison
if reflect.DeepEqual(oldChal.Status, ch.Status) && len(oldChal.Finalizers) == len(ch.Finalizers) {
return
}
_, updateErr := c.cmClient.AcmeV1alpha2().Challenges(ch.Namespace).Update(ch)
if err != nil {
_, updateErr := c.cmClient.AcmeV1alpha2().Challenges(ch.Namespace).UpdateStatus(ch)
if updateErr != nil {
err = utilerrors.NewAggregate([]error{err, updateErr})
}
}()
if ch.DeletionTimestamp != nil {
return c.handleFinalizer(ctx, ch)
}
// bail out early on if processing=false, as this challenge has not been
// scheduled yet.
if ch.Status.Processing == false {
@@ -233,7 +233,9 @@ func handleError(ch *cmacme.Challenge, err error) error {
return err
}
func (c *controller) handleFinalizer(ctx context.Context, ch *cmacme.Challenge) error {
// handleFinalizer will attempt to 'finalize' the Challenge resource by calling
// CleanUp if the resource is in a 'processing' state.
func (c *controller) handleFinalizer(ctx context.Context, ch *cmacme.Challenge) (err error) {
log := logf.FromContext(ctx, "finalizer")
if len(ch.Finalizers) == 0 {
return nil
@@ -242,7 +244,22 @@ func (c *controller) handleFinalizer(ctx context.Context, ch *cmacme.Challenge)
log.V(logf.DebugLevel).Info("waiting to run challenge finalization...")
return nil
}
ch.Finalizers = ch.Finalizers[1:]
defer func() {
// call UpdateStatus first as we may have updated the challenge.status.reason field
ch, updateErr := c.cmClient.AcmeV1alpha2().Challenges(ch.Namespace).UpdateStatus(ch)
if updateErr != nil {
err = utilerrors.NewAggregate([]error{err, updateErr})
return
}
// call Update to remove the metadata.finalizers entry
ch.Finalizers = ch.Finalizers[1:]
_, updateErr = c.cmClient.AcmeV1alpha2().Challenges(ch.Namespace).Update(ch)
if updateErr != nil {
err = utilerrors.NewAggregate([]error{err, updateErr})
return
}
}()
if !ch.Status.Processing {
return nil
+24 -11
View File
@@ -97,12 +97,15 @@ func TestSyncHappyPath(t *testing.T) {
gen.SetChallengeURL("testurl"),
), testIssuerHTTP01Enabled},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(cmacme.SchemeGroupVersion.WithResource("challenges"), gen.DefaultTestNamespace,
gen.ChallengeFrom(baseChallenge,
gen.SetChallengeProcessing(true),
gen.SetChallengeURL("testurl"),
gen.SetChallengeState(cmacme.Pending),
))),
testpkg.NewAction(
coretesting.NewUpdateSubresourceAction(cmacme.SchemeGroupVersion.WithResource("challenges"),
"status",
gen.DefaultTestNamespace,
gen.ChallengeFrom(baseChallenge,
gen.SetChallengeProcessing(true),
gen.SetChallengeURL("testurl"),
gen.SetChallengeState(cmacme.Pending),
))),
},
},
acmeClient: &acmecl.FakeACME{
@@ -134,7 +137,9 @@ func TestSyncHappyPath(t *testing.T) {
gen.SetChallengeType("http-01"),
), testIssuerHTTP01Enabled},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(cmacme.SchemeGroupVersion.WithResource("challenges"), gen.DefaultTestNamespace,
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(cmacme.SchemeGroupVersion.WithResource("challenges"),
"status",
gen.DefaultTestNamespace,
gen.ChallengeFrom(baseChallenge,
gen.SetChallengeProcessing(true),
gen.SetChallengeURL("testurl"),
@@ -176,7 +181,9 @@ func TestSyncHappyPath(t *testing.T) {
gen.SetChallengePresented(true),
), testIssuerHTTP01Enabled},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(cmacme.SchemeGroupVersion.WithResource("challenges"), gen.DefaultTestNamespace,
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(cmacme.SchemeGroupVersion.WithResource("challenges"),
"status",
gen.DefaultTestNamespace,
gen.ChallengeFrom(baseChallenge,
gen.SetChallengeProcessing(true),
gen.SetChallengeURL("testurl"),
@@ -228,7 +235,9 @@ func TestSyncHappyPath(t *testing.T) {
gen.SetChallengePresented(true),
), testIssuerHTTP01Enabled},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(cmacme.SchemeGroupVersion.WithResource("challenges"), gen.DefaultTestNamespace,
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(cmacme.SchemeGroupVersion.WithResource("challenges"),
"status",
gen.DefaultTestNamespace,
gen.ChallengeFrom(baseChallenge,
gen.SetChallengeProcessing(true),
gen.SetChallengeURL("testurl"),
@@ -283,7 +292,9 @@ func TestSyncHappyPath(t *testing.T) {
gen.SetChallengePresented(true),
), testIssuerHTTP01Enabled},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(cmacme.SchemeGroupVersion.WithResource("challenges"), gen.DefaultTestNamespace,
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(cmacme.SchemeGroupVersion.WithResource("challenges"),
"status",
gen.DefaultTestNamespace,
gen.ChallengeFrom(baseChallenge,
gen.SetChallengeProcessing(false),
gen.SetChallengeURL("testurl"),
@@ -316,7 +327,9 @@ func TestSyncHappyPath(t *testing.T) {
gen.SetChallengePresented(true),
), testIssuerHTTP01Enabled},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(cmacme.SchemeGroupVersion.WithResource("challenges"), gen.DefaultTestNamespace,
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(cmacme.SchemeGroupVersion.WithResource("challenges"),
"status",
gen.DefaultTestNamespace,
gen.ChallengeFrom(baseChallenge,
gen.SetChallengeProcessing(false),
gen.SetChallengeURL("testurl"),
+2 -2
View File
@@ -54,8 +54,8 @@ func (c *controller) Sync(ctx context.Context, o *cmacme.Order) (err error) {
return
}
log.Info("updating Order resource status")
_, updateErr := c.cmClient.AcmeV1alpha2().Orders(o.Namespace).Update(o)
if err != nil {
_, updateErr := c.cmClient.AcmeV1alpha2().Orders(o.Namespace).UpdateStatus(o)
if updateErr != nil {
log.Error(err, "failed to update status")
err = utilerrors.NewAggregate([]error{err, updateErr})
return
+12 -4
View File
@@ -153,7 +153,9 @@ dGVzdA==
builder: &testpkg.Builder{
CertManagerObjects: []runtime.Object{testIssuerHTTP01TestCom, testOrder},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(cmacme.SchemeGroupVersion.WithResource("orders"), testOrderPending.Namespace,
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(cmacme.SchemeGroupVersion.WithResource("orders"),
"status",
testOrderPending.Namespace,
gen.OrderFrom(testOrder, gen.SetOrderStatus(cmacme.OrderStatus{
State: cmacme.Pending,
URL: "http://testurl.com/abcde",
@@ -216,7 +218,9 @@ dGVzdA==
builder: &testpkg.Builder{
CertManagerObjects: []runtime.Object{testIssuerHTTP01TestCom, testOrderPending, testAuthorizationChallengeValid},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(cmacme.SchemeGroupVersion.WithResource("orders"), testOrderReady.Namespace, testOrderReady)),
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(cmacme.SchemeGroupVersion.WithResource("orders"),
"status",
testOrderReady.Namespace, testOrderReady)),
},
},
acmeClient: &acmecl.FakeACME{
@@ -234,7 +238,9 @@ dGVzdA==
builder: &testpkg.Builder{
CertManagerObjects: []runtime.Object{testIssuerHTTP01TestCom, testOrderReady, testAuthorizationChallengeValid},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(cmacme.SchemeGroupVersion.WithResource("orders"), testOrderValid.Namespace, testOrderValid)),
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(cmacme.SchemeGroupVersion.WithResource("orders"),
"status",
testOrderValid.Namespace, testOrderValid)),
},
ExpectedEvents: []string{
"Normal Complete Order completed successfully",
@@ -259,7 +265,9 @@ dGVzdA==
builder: &testpkg.Builder{
CertManagerObjects: []runtime.Object{testIssuerHTTP01TestCom, testOrderPending, testAuthorizationChallengeInvalid},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(cmacme.SchemeGroupVersion.WithResource("orders"), testOrderInvalid.Namespace, testOrderInvalid)),
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(cmacme.SchemeGroupVersion.WithResource("orders"),
"status",
testOrderInvalid.Namespace, testOrderInvalid)),
},
},
acmeClient: &acmecl.FakeACME{
@@ -132,8 +132,9 @@ func TestSign(t *testing.T) {
"Warning BadConfig Resource validation failed: spec.csr: Invalid value: []byte{0x61, 0x20, 0x62, 0x61, 0x64, 0x20, 0x63, 0x73, 0x72}: failed to decode csr: error decoding certificate request PEM block",
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificaterequests"),
"status",
gen.DefaultTestNamespace,
gen.CertificateRequestFrom(baseCR,
gen.SetCertificateRequestCSR([]byte("a bad csr")),
@@ -166,8 +167,9 @@ func TestSign(t *testing.T) {
gen.DefaultTestNamespace,
baseOrder,
)),
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificaterequests"),
"status",
gen.DefaultTestNamespace,
gen.CertificateRequestFrom(baseCR,
gen.SetCertificateRequestStatusCondition(cmapi.CertificateRequestCondition{
@@ -191,8 +193,9 @@ func TestSign(t *testing.T) {
},
CertManagerObjects: []runtime.Object{baseCR.DeepCopy(), baseIssuer.DeepCopy()},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificaterequests"),
"status",
gen.DefaultTestNamespace,
gen.CertificateRequestFrom(baseCR,
gen.SetCertificateRequestStatusCondition(cmapi.CertificateRequestCondition{
@@ -230,8 +233,9 @@ func TestSign(t *testing.T) {
),
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificaterequests"),
"status",
gen.DefaultTestNamespace,
gen.CertificateRequestFrom(baseCR,
gen.SetCertificateRequestStatusCondition(cmapi.CertificateRequestCondition{
@@ -260,8 +264,9 @@ func TestSign(t *testing.T) {
),
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificaterequests"),
"status",
gen.DefaultTestNamespace,
gen.CertificateRequestFrom(baseCR,
gen.SetCertificateRequestStatusCondition(cmapi.CertificateRequestCondition{
@@ -288,8 +293,9 @@ func TestSign(t *testing.T) {
gen.SetOrderCertificate(certPEM),
), baseCR.DeepCopy(), baseIssuer.DeepCopy()},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificaterequests"),
"status",
gen.DefaultTestNamespace,
gen.CertificateRequestFrom(baseCR,
gen.SetCertificateRequestStatusCondition(cmapi.CertificateRequestCondition{
@@ -159,8 +159,9 @@ func TestSign(t *testing.T) {
`Normal SecretMissing Referenced secret default-unit-test-ns/root-ca-secret not found: secret "root-ca-secret" not found`,
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificaterequests"),
"status",
gen.DefaultTestNamespace,
gen.CertificateRequestFrom(baseCR.DeepCopy(),
gen.SetCertificateRequestStatusCondition(cmapi.CertificateRequestCondition{
@@ -184,8 +185,9 @@ func TestSign(t *testing.T) {
"Normal SecretInvalidData Failed to parse signing CA keypair from secret default-unit-test-ns/root-ca-secret: error decoding private key PEM block",
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificaterequests"),
"status",
gen.DefaultTestNamespace,
gen.CertificateRequestFrom(baseCR.DeepCopy(),
gen.SetCertificateRequestStatusCondition(cmapi.CertificateRequestCondition{
@@ -209,8 +211,9 @@ func TestSign(t *testing.T) {
`Normal SecretGetError Failed to get certificate key pair from secret default-unit-test-ns/root-ca-secret: this is a network error`,
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificaterequests"),
"status",
gen.DefaultTestNamespace,
gen.CertificateRequestFrom(baseCR,
gen.SetCertificateRequestStatusCondition(cmapi.CertificateRequestCondition{
@@ -247,8 +250,9 @@ func TestSign(t *testing.T) {
"Warning SigningError Error generating certificate template: this is a sign error",
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificaterequests"),
"status",
gen.DefaultTestNamespace,
gen.CertificateRequestFrom(baseCR.DeepCopy(),
gen.SetCertificateRequestStatusCondition(cmapi.CertificateRequestCondition{
@@ -281,8 +285,9 @@ func TestSign(t *testing.T) {
"Normal CertificateIssued Certificate fetched from issuer successfully",
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificaterequests"),
"status",
gen.DefaultTestNamespace,
gen.CertificateRequestFrom(baseCR,
gen.SetCertificateRequestStatusCondition(cmapi.CertificateRequestCondition{
@@ -180,8 +180,9 @@ func TestSign(t *testing.T) {
`Warning MissingAnnotation Annotation "cert-manager.io/private-key-secret-name" missing or reference empty: secret name missing`,
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificaterequests"),
"status",
gen.DefaultTestNamespace,
gen.CertificateRequestFrom(baseCR,
gen.SetCertificateRequestAnnotations(map[string]string{}),
@@ -213,8 +214,9 @@ func TestSign(t *testing.T) {
`Warning MissingAnnotation Annotation "cert-manager.io/private-key-secret-name" missing or reference empty: secret name missing`,
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificaterequests"),
"status",
gen.DefaultTestNamespace,
gen.CertificateRequestFrom(baseCR,
gen.SetCertificateRequestAnnotations(map[string]string{cmapi.CRPrivateKeyAnnotationKey: ""}),
@@ -240,8 +242,9 @@ func TestSign(t *testing.T) {
`Normal MissingSecret Referenced secret default-unit-test-ns/test-rsa-key not found: secret "test-rsa-key" not found`,
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificaterequests"),
"status",
gen.DefaultTestNamespace,
gen.CertificateRequestFrom(baseCR,
gen.SetCertificateRequestStatusCondition(cmapi.CertificateRequestCondition{
@@ -265,8 +268,9 @@ func TestSign(t *testing.T) {
`Normal ErrorParsingKey Failed to get key "test-rsa-key" referenced in annotation "cert-manager.io/private-key-secret-name": error decoding private key PEM block`,
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificaterequests"),
"status",
gen.DefaultTestNamespace,
gen.CertificateRequestFrom(baseCR,
gen.SetCertificateRequestStatusCondition(cmapi.CertificateRequestCondition{
@@ -290,8 +294,9 @@ func TestSign(t *testing.T) {
`Normal ErrorGettingSecret Failed to get certificate key pair from secret default-unit-test-ns/test-rsa-key: this is a network error`,
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificaterequests"),
"status",
gen.DefaultTestNamespace,
gen.CertificateRequestFrom(baseCR,
gen.SetCertificateRequestStatusCondition(cmapi.CertificateRequestCondition{
@@ -329,8 +334,9 @@ func TestSign(t *testing.T) {
"Warning BadConfig Resource validation failed: spec.csr: Invalid value: []byte{0x74, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x61, 0x20, 0x62, 0x61, 0x64, 0x20, 0x43, 0x53, 0x52}: failed to decode csr: error decoding certificate request PEM block",
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificaterequests"),
"status",
gen.DefaultTestNamespace,
gen.CertificateRequestFrom(baseCR,
gen.SetCertificateRequestCSR([]byte("this is a bad CSR")),
@@ -356,8 +362,9 @@ func TestSign(t *testing.T) {
"Warning ErrorKeyMatch Error generating certificate template: CSR not signed by referenced private key",
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificaterequests"),
"status",
gen.DefaultTestNamespace,
gen.CertificateRequestFrom(ecCR,
gen.SetCertificateRequestStatusCondition(cmapi.CertificateRequestCondition{
@@ -385,8 +392,9 @@ func TestSign(t *testing.T) {
"Warning ErrorSigning Error signing certificate: this is a signing error",
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificaterequests"),
"status",
gen.DefaultTestNamespace,
gen.CertificateRequestFrom(baseCR,
gen.SetCertificateRequestStatusCondition(cmapi.CertificateRequestCondition{
@@ -421,8 +429,9 @@ func TestSign(t *testing.T) {
"Normal CertificateIssued Certificate fetched from issuer successfully",
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificaterequests"),
"status",
gen.DefaultTestNamespace,
gen.CertificateRequestFrom(baseCR,
gen.SetCertificateRequestStatusCondition(cmapi.CertificateRequestCondition{
@@ -458,8 +467,9 @@ func TestSign(t *testing.T) {
"Normal CertificateIssued Certificate fetched from issuer successfully",
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificaterequests"),
"status",
gen.DefaultTestNamespace,
gen.CertificateRequestFrom(ecCR,
gen.SetCertificateRequestStatusCondition(cmapi.CertificateRequestCondition{
+1 -4
View File
@@ -157,8 +157,5 @@ func (c *Controller) updateCertificateRequestStatus(ctx context.Context, old, ne
}
log.V(logf.DebugLevel).Info("updating resource due to change in status", "diff", pretty.Diff(string(oldBytes), string(newBytes)))
// TODO: replace Update call with UpdateStatus. This requires a custom API
// server with the /status subresource enabled and/or subresource support
// for CRDs (https://github.com/kubernetes/kubernetes/issues/38113)
return c.cmClient.CertmanagerV1alpha2().CertificateRequests(new.Namespace).Update(new)
return c.cmClient.CertmanagerV1alpha2().CertificateRequests(new.Namespace).UpdateStatus(new)
}
@@ -188,8 +188,9 @@ func TestSync(t *testing.T) {
`Normal IssuerNotFound Referenced "Issuer" not found: issuer.cert-manager.io "test-issuer" not found`,
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificaterequests"),
"status",
gen.DefaultTestNamespace,
gen.CertificateRequestFrom(baseCR,
gen.SetCertificateRequestStatusCondition(cmapi.CertificateRequestCondition{
@@ -231,8 +232,9 @@ func TestSync(t *testing.T) {
),
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificaterequests"),
"status",
gen.DefaultTestNamespace,
gen.CertificateRequestFrom(baseCR,
gen.SetCertificateRequestStatusCondition(cmapi.CertificateRequestCondition{
@@ -276,8 +278,9 @@ func TestSync(t *testing.T) {
"Warning BadConfig Resource validation failed: spec.csr: Invalid value: []byte{0x62, 0x61, 0x64, 0x20, 0x63, 0x73, 0x72}: failed to decode csr: error decoding certificate request PEM block",
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificaterequests"),
"status",
gen.DefaultTestNamespace,
gen.CertificateRequestFrom(baseCR,
gen.SetCertificateRequestCSR([]byte("bad csr")),
@@ -350,8 +353,9 @@ func TestSync(t *testing.T) {
"Warning DecodeError Failed to decode returned certificate: error decoding cert PEM block",
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificaterequests"),
"status",
gen.DefaultTestNamespace,
gen.CertificateRequestFrom(baseCR,
gen.SetCertificateRequestCertificate([]byte("a bad certificate")),
@@ -383,8 +387,9 @@ func TestSync(t *testing.T) {
"Normal CertificateIssued Certificate fetched from issuer successfully",
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificaterequests"),
"status",
gen.DefaultTestNamespace,
gen.CertificateRequestFrom(baseCR,
gen.SetCertificateRequestCertificate(certRSAPEM),
@@ -415,8 +420,9 @@ func TestSync(t *testing.T) {
"Normal CertificateIssued Certificate fetched from issuer successfully",
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificaterequests"),
"status",
gen.DefaultTestNamespace,
gen.CertificateRequestFrom(baseCR,
gen.SetCertificateRequestCertificate(certRSAPEMExpired),
@@ -447,8 +453,9 @@ func TestSync(t *testing.T) {
"Normal CertificateIssued Certificate fetched from issuer successfully",
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificaterequests"),
"status",
gen.DefaultTestNamespace,
gen.CertificateRequestFrom(baseCR,
gen.SetCertificateRequestCertificate(certECPEM),
@@ -479,8 +486,9 @@ func TestSync(t *testing.T) {
"Normal CertificateIssued Certificate fetched from issuer successfully",
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificaterequests"),
"status",
gen.DefaultTestNamespace,
gen.CertificateRequestFrom(baseCR,
gen.SetCertificateRequestCertificate(certECPEMExpired),
@@ -156,8 +156,9 @@ func TestSign(t *testing.T) {
"Normal VaultInitError Failed to initialise vault client for signing: error initializing Vault client: tokenSecretRef, appRoleSecretRef, or Kubernetes auth role not set",
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificaterequests"),
"status",
gen.DefaultTestNamespace,
gen.CertificateRequestFrom(baseCR,
gen.SetCertificateRequestStatusCondition(cmapi.CertificateRequestCondition{
@@ -192,8 +193,9 @@ func TestSign(t *testing.T) {
`Normal SecretMissing Required secret resource not found: secret "non-existing-secret" not found`,
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificaterequests"),
"status",
gen.DefaultTestNamespace,
gen.CertificateRequestFrom(baseCR,
gen.SetCertificateRequestStatusCondition(cmapi.CertificateRequestCondition{
@@ -231,8 +233,9 @@ func TestSign(t *testing.T) {
`Normal SecretMissing Required secret resource not found: secret "non-existing-secret" not found`,
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificaterequests"),
"status",
gen.DefaultTestNamespace,
gen.CertificateRequestFrom(baseCR,
gen.SetCertificateRequestStatusCondition(cmapi.CertificateRequestCondition{
@@ -267,8 +270,9 @@ func TestSign(t *testing.T) {
"Warning SigningError Vault failed to sign certificate: failed to sign",
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificaterequests"),
"status",
gen.DefaultTestNamespace,
gen.CertificateRequestFrom(baseCR,
gen.SetCertificateRequestStatusCondition(cmapi.CertificateRequestCondition{
@@ -308,8 +312,9 @@ func TestSign(t *testing.T) {
`Warning SigningError Vault failed to sign certificate: failed to sign`,
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificaterequests"),
"status",
gen.DefaultTestNamespace,
gen.CertificateRequestFrom(baseCR,
gen.SetCertificateRequestStatusCondition(cmapi.CertificateRequestCondition{
@@ -346,8 +351,9 @@ func TestSign(t *testing.T) {
"Normal CertificateIssued Certificate fetched from issuer successfully",
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificaterequests"),
"status",
gen.DefaultTestNamespace,
gen.CertificateRequestFrom(baseCR,
gen.SetCertificateRequestCertificate(rsaPEMCert),
@@ -388,8 +394,9 @@ func TestSign(t *testing.T) {
"Normal CertificateIssued Certificate fetched from issuer successfully",
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificaterequests"),
"status",
gen.DefaultTestNamespace,
gen.CertificateRequestFrom(baseCR,
gen.SetCertificateRequestCertificate(rsaPEMCert),
@@ -208,8 +208,9 @@ func TestSign(t *testing.T) {
`Normal SecretMissing Required secret resource not found: secret "test-tpp-secret" not found`,
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificaterequests"),
"status",
gen.DefaultTestNamespace,
gen.CertificateRequestFrom(tppCR,
gen.SetCertificateRequestStatusCondition(cmapi.CertificateRequestCondition{
@@ -233,8 +234,9 @@ func TestSign(t *testing.T) {
`Normal VenafiInitError Failed to initialise venafi client for signing: this is a network error`,
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificaterequests"),
"status",
gen.DefaultTestNamespace,
gen.CertificateRequestFrom(tppCR,
gen.SetCertificateRequestStatusCondition(cmapi.CertificateRequestCondition{
@@ -260,8 +262,9 @@ func TestSign(t *testing.T) {
`Normal SecretMissing Required secret resource not found: secret "test-cloud-secret" not found`,
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificaterequests"),
"status",
gen.DefaultTestNamespace,
gen.CertificateRequestFrom(cloudCR,
gen.SetCertificateRequestStatusCondition(cmapi.CertificateRequestCondition{
@@ -284,8 +287,9 @@ func TestSign(t *testing.T) {
`Normal VenafiInitError Failed to initialise venafi client for signing: this is a network error`,
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificaterequests"),
"status",
gen.DefaultTestNamespace,
gen.CertificateRequestFrom(cloudCR,
gen.SetCertificateRequestStatusCondition(cmapi.CertificateRequestCondition{
@@ -311,8 +315,9 @@ func TestSign(t *testing.T) {
"Normal IssuancePending Venafi certificate still in a pending state, the request will be retried: Issuance is pending. You may try retrieving the certificate later using Pickup ID: test-cert-id\n\tStatus: test-status-pending",
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificaterequests"),
"status",
gen.DefaultTestNamespace,
gen.CertificateRequestFrom(tppCR,
gen.SetCertificateRequestStatusCondition(cmapi.CertificateRequestCondition{
@@ -339,8 +344,9 @@ func TestSign(t *testing.T) {
"Normal IssuancePending Venafi certificate still in a pending state, the request will be retried: Issuance is pending. You may try retrieving the certificate later using Pickup ID: test-cert-id\n\tStatus: test-status-pending",
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificaterequests"),
"status",
gen.DefaultTestNamespace,
gen.CertificateRequestFrom(cloudCR,
gen.SetCertificateRequestStatusCondition(cmapi.CertificateRequestCondition{
@@ -367,8 +373,9 @@ func TestSign(t *testing.T) {
"Warning Timeout Timed out waiting for venafi certificate, the request will be retried: Operation timed out. You may try retrieving the certificate later using Pickup ID: test-cert-id",
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificaterequests"),
"status",
gen.DefaultTestNamespace,
gen.CertificateRequestFrom(tppCR,
gen.SetCertificateRequestStatusCondition(cmapi.CertificateRequestCondition{
@@ -395,8 +402,9 @@ func TestSign(t *testing.T) {
"Warning Timeout Timed out waiting for venafi certificate, the request will be retried: Operation timed out. You may try retrieving the certificate later using Pickup ID: test-cert-id",
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificaterequests"),
"status",
gen.DefaultTestNamespace,
gen.CertificateRequestFrom(cloudCR,
gen.SetCertificateRequestStatusCondition(cmapi.CertificateRequestCondition{
@@ -423,8 +431,9 @@ func TestSign(t *testing.T) {
"Warning RetrieveError Failed to obtain venafi certificate: this is an error",
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificaterequests"),
"status",
gen.DefaultTestNamespace,
gen.CertificateRequestFrom(tppCR,
gen.SetCertificateRequestStatusCondition(cmapi.CertificateRequestCondition{
@@ -452,8 +461,9 @@ func TestSign(t *testing.T) {
"Warning RetrieveError Failed to obtain venafi certificate: this is an error",
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificaterequests"),
"status",
gen.DefaultTestNamespace,
gen.CertificateRequestFrom(cloudCR,
gen.SetCertificateRequestStatusCondition(cmapi.CertificateRequestCondition{
@@ -481,8 +491,9 @@ func TestSign(t *testing.T) {
"Normal CertificateIssued Certificate fetched from issuer successfully",
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificaterequests"),
"status",
gen.DefaultTestNamespace,
gen.CertificateRequestFrom(tppCR,
gen.SetCertificateRequestStatusCondition(cmapi.CertificateRequestCondition{
@@ -509,8 +520,9 @@ func TestSign(t *testing.T) {
"Normal CertificateIssued Certificate fetched from issuer successfully",
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificaterequests"),
"status",
gen.DefaultTestNamespace,
gen.CertificateRequestFrom(cloudCR,
gen.SetCertificateRequestStatusCondition(cmapi.CertificateRequestCondition{
+1
View File
@@ -30,6 +30,7 @@ go_library(
"@io_k8s_apimachinery//pkg/api/errors:go_default_library",
"@io_k8s_apimachinery//pkg/apis/meta/v1:go_default_library",
"@io_k8s_apimachinery//pkg/labels:go_default_library",
"@io_k8s_apimachinery//pkg/util/errors:go_default_library",
"@io_k8s_client_go//kubernetes:go_default_library",
"@io_k8s_client_go//listers/core/v1:go_default_library",
"@io_k8s_client_go//tools/cache:go_default_library",
+7 -13
View File
@@ -28,6 +28,12 @@ import (
"time"
"github.com/go-logr/logr"
corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
utilerrors "k8s.io/apimachinery/pkg/util/errors"
apiutil "github.com/jetstack/cert-manager/pkg/api/util"
cmapi "github.com/jetstack/cert-manager/pkg/apis/certmanager/v1alpha2"
cmmeta "github.com/jetstack/cert-manager/pkg/apis/meta/v1"
@@ -37,10 +43,6 @@ import (
"github.com/jetstack/cert-manager/pkg/util/errors"
"github.com/jetstack/cert-manager/pkg/util/kube"
"github.com/jetstack/cert-manager/pkg/util/pki"
corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
)
func (c *certificateRequestManager) ProcessItem(ctx context.Context, key string) error {
@@ -66,15 +68,7 @@ func (c *certificateRequestManager) ProcessItem(ctx context.Context, key string)
err = c.processCertificate(ctx, updatedCert)
log.V(logf.DebugLevel).Info("check if certificate status update is required")
updateStatusErr := c.updateCertificateStatus(ctx, crt, updatedCert)
// TODO: combine errors
if err != nil {
return err
}
if updateStatusErr != nil {
return err
}
return nil
return utilerrors.NewAggregate([]error{err, updateStatusErr})
}
func (c *certificateRequestManager) updateCertificateStatus(ctx context.Context, old, crt *cmapi.Certificate) error {
+26 -13
View File
@@ -1603,8 +1603,9 @@ func TestUpdateStatus(t *testing.T) {
exampleBundle1.certificate,
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificates"),
"status",
gen.DefaultTestNamespace,
gen.CertificateFrom(exampleBundle1.certificate,
gen.SetCertificateStatusCondition(cmapi.CertificateCondition{
@@ -1635,8 +1636,9 @@ func TestUpdateStatus(t *testing.T) {
exampleBundle1.certificate,
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificates"),
"status",
gen.DefaultTestNamespace,
gen.CertificateFrom(exampleBundle1.certificate,
gen.SetCertificateStatusCondition(cmapi.CertificateCondition{
@@ -1669,8 +1671,9 @@ func TestUpdateStatus(t *testing.T) {
exampleBundle1.certificate,
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificates"),
"status",
gen.DefaultTestNamespace,
gen.CertificateFrom(exampleBundle1.certificate,
gen.SetCertificateStatusCondition(cmapi.CertificateCondition{
@@ -1704,8 +1707,9 @@ func TestUpdateStatus(t *testing.T) {
exampleBundle1.certificateRequest,
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificates"),
"status",
gen.DefaultTestNamespace,
gen.CertificateFrom(exampleBundle1.certificate,
gen.SetCertificateStatusCondition(cmapi.CertificateCondition{
@@ -1743,8 +1747,9 @@ func TestUpdateStatus(t *testing.T) {
exampleBundle1.certificate,
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificates"),
"status",
gen.DefaultTestNamespace,
gen.CertificateFrom(exampleBundle1.certificate,
gen.SetCertificateStatusCondition(cmapi.CertificateCondition{
@@ -1784,8 +1789,9 @@ func TestUpdateStatus(t *testing.T) {
exampleBundle1.certificateRequest,
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificates"),
"status",
gen.DefaultTestNamespace,
gen.CertificateFrom(exampleBundle1.certificate,
gen.SetCertificateStatusCondition(cmapi.CertificateCondition{
@@ -1824,8 +1830,9 @@ func TestUpdateStatus(t *testing.T) {
exampleBundle1.certificate,
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificates"),
"status",
gen.DefaultTestNamespace,
gen.CertificateFrom(exampleBundle1.certificate,
gen.SetCertificateStatusCondition(cmapi.CertificateCondition{
@@ -1865,8 +1872,9 @@ func TestUpdateStatus(t *testing.T) {
exampleBundle1.certificateRequest,
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificates"),
"status",
gen.DefaultTestNamespace,
gen.CertificateFrom(exampleBundle1.certificate,
gen.SetCertificateStatusCondition(cmapi.CertificateCondition{
@@ -1906,8 +1914,9 @@ func TestUpdateStatus(t *testing.T) {
exampleBundle1.certificateRequestReady,
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificates"),
"status",
gen.DefaultTestNamespace,
gen.CertificateFrom(exampleBundle1.certificate,
gen.SetCertificateStatusCondition(cmapi.CertificateCondition{
@@ -1950,8 +1959,9 @@ func TestUpdateStatus(t *testing.T) {
exampleBundle1.certificate,
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificates"),
"status",
gen.DefaultTestNamespace,
gen.CertificateFrom(exampleBundle1.certificate,
gen.SetCertificateStatusCondition(cmapi.CertificateCondition{
@@ -1994,8 +2004,9 @@ func TestUpdateStatus(t *testing.T) {
exampleBundle1.certificateRequest,
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificates"),
"status",
gen.DefaultTestNamespace,
gen.CertificateFrom(exampleBundle1.certificate,
gen.SetCertificateStatusCondition(cmapi.CertificateCondition{
@@ -2033,8 +2044,9 @@ func TestUpdateStatus(t *testing.T) {
exampleBundle1.certificate,
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificates"),
"status",
gen.DefaultTestNamespace,
gen.CertificateFrom(exampleBundle1.certificate,
gen.SetCertificateStatusCondition(cmapi.CertificateCondition{
@@ -2073,8 +2085,9 @@ func TestUpdateStatus(t *testing.T) {
exampleBundle1.certificateRequest,
},
ExpectedActions: []testpkg.Action{
testpkg.NewAction(coretesting.NewUpdateAction(
testpkg.NewAction(coretesting.NewUpdateSubresourceAction(
cmapi.SchemeGroupVersion.WithResource("certificates"),
"status",
gen.DefaultTestNamespace,
gen.CertificateFrom(exampleBundle1.certificate,
gen.SetCertificateStatusCondition(cmapi.CertificateCondition{
+1 -4
View File
@@ -222,10 +222,7 @@ func updateCertificateStatus(ctx context.Context, m *metrics.Metrics, cmClient c
return nil, nil
}
log.V(logf.DebugLevel).Info("updating resource due to change in status", "diff", pretty.Diff(string(oldBytes), string(newBytes)))
// TODO: replace Update call with UpdateStatus. This requires a custom API
// server with the /status subresource enabled and/or subresource support
// for CRDs (https://github.com/kubernetes/kubernetes/issues/38113)
return cmClient.CertmanagerV1alpha2().Certificates(new.Namespace).Update(new)
return cmClient.CertmanagerV1alpha2().Certificates(new.Namespace).UpdateStatus(new)
}
func certificateHasTemporaryCertificateAnnotation(crt *v1alpha2.Certificate) bool {
+1 -4
View File
@@ -89,8 +89,5 @@ func (c *controller) updateIssuerStatus(old, new *v1alpha2.ClusterIssuer) (*v1al
if reflect.DeepEqual(old.Status, new.Status) {
return nil, nil
}
// TODO: replace Update call with UpdateStatus. This requires a custom API
// server with the /status subresource enabled and/or subresource support
// for CRDs (https://github.com/kubernetes/kubernetes/issues/38113)
return c.cmClient.CertmanagerV1alpha2().ClusterIssuers().Update(new)
return c.cmClient.CertmanagerV1alpha2().ClusterIssuers().UpdateStatus(new)
}
+1 -4
View File
@@ -89,8 +89,5 @@ func (c *controller) updateIssuerStatus(old, new *v1alpha2.Issuer) (*v1alpha2.Is
if reflect.DeepEqual(old.Status, new.Status) {
return nil, nil
}
// TODO: replace Update call with UpdateStatus. This requires a custom API
// server with the /status subresource enabled and/or subresource support
// for CRDs (https://github.com/kubernetes/kubernetes/issues/38113)
return c.cmClient.CertmanagerV1alpha2().Issuers(new.Namespace).Update(new)
return c.cmClient.CertmanagerV1alpha2().Issuers(new.Namespace).UpdateStatus(new)
}