forked from gardener/gardener
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extend health/progressing checks of
gardener-resource-manager
by `c…
…ert-management` resources (gardener#9326) * Add Cert APIs to resource-manager target scheme * Prefactor: Add section about `health` controller * Add `certificate` health check to GRM * Add `certificate` progressing check to GRM * Abandon `controller-manager-library` dependency * Add `issuer` health check to GRM * Add `issuer` progressing check to GRM * Drop `metadata.generation` from integration test The generation field is disregarded when creating an object with a real client in integration tests. * Address review feedback * Address review feedback II
- Loading branch information
Showing
20 changed files
with
1,338 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Copyright 2024 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package health | ||
|
||
import ( | ||
"fmt" | ||
|
||
certv1alpha1 "github.com/gardener/cert-management/pkg/apis/cert/v1alpha1" | ||
corev1 "k8s.io/api/core/v1" | ||
) | ||
|
||
// CheckCertificate checks whether the given certificate object is healthy. | ||
func CheckCertificate(cert *certv1alpha1.Certificate) error { | ||
for _, condition := range cert.Status.Conditions { | ||
if condition.Type == certv1alpha1.CertificateConditionReady { | ||
if err := checkConditionState(condition.Type, string(corev1.ConditionTrue), string(condition.Status), condition.Reason, condition.Message); err != nil { | ||
return err | ||
} | ||
break | ||
} | ||
} | ||
|
||
if certState := cert.Status.State; certState != certv1alpha1.StateReady { | ||
return fmt.Errorf("certificate state is %q (%q expected)", certState, certv1alpha1.StateReady) | ||
} | ||
return nil | ||
} | ||
|
||
// IsCertificateProgressing returns false if the Certificate's generation matches the observed generation. | ||
func IsCertificateProgressing(cert *certv1alpha1.Certificate) (bool, string) { | ||
if cert.Status.ObservedGeneration < cert.Generation { | ||
return true, fmt.Sprintf("observed generation outdated (%d/%d)", cert.Status.ObservedGeneration, cert.Generation) | ||
} | ||
|
||
return false, "Certificate is fully rolled out" | ||
} | ||
|
||
// CheckCertificateIssuer checks whether the given issuer object is healthy. | ||
func CheckCertificateIssuer(issuer *certv1alpha1.Issuer) error { | ||
if issuerState := issuer.Status.State; issuerState != certv1alpha1.StateReady { | ||
return fmt.Errorf("issuer state is %q (%q expected)", issuerState, certv1alpha1.StateReady) | ||
} | ||
|
||
return nil | ||
} | ||
|
||
// IsCertificateIssuerProgressing returns false if the Issuer's generation matches the observed generation. | ||
func IsCertificateIssuerProgressing(issuer *certv1alpha1.Issuer) (bool, string) { | ||
if issuer.Status.ObservedGeneration < issuer.Generation { | ||
return true, fmt.Sprintf("observed generation outdated (%d/%d)", issuer.Status.ObservedGeneration, issuer.Generation) | ||
} | ||
|
||
return false, "Issuer is fully rolled out" | ||
} |
Oops, something went wrong.