mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-05 23:47:50 +00:00
Apply to use contextual logging for all loggers in statefulSet
Signed-off-by: kerthcet <kerthcet@gmail.com>
This commit is contained in:
@@ -22,7 +22,7 @@ import (
|
||||
"strings"
|
||||
|
||||
apps "k8s.io/api/apps/v1"
|
||||
"k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
errorutils "k8s.io/apimachinery/pkg/util/errors"
|
||||
@@ -208,6 +208,7 @@ func (spc *StatefulPodControl) DeleteStatefulPod(set *apps.StatefulSet, pod *v1.
|
||||
// An error is returned if something is not consistent. This is expected if the pod is being otherwise updated,
|
||||
// but a problem otherwise (see usage of this method in UpdateStatefulPod).
|
||||
func (spc *StatefulPodControl) ClaimsMatchRetentionPolicy(ctx context.Context, set *apps.StatefulSet, pod *v1.Pod) (bool, error) {
|
||||
logger := klog.FromContext(ctx)
|
||||
ordinal := getOrdinal(pod)
|
||||
templates := set.Spec.VolumeClaimTemplates
|
||||
for i := range templates {
|
||||
@@ -219,7 +220,7 @@ func (spc *StatefulPodControl) ClaimsMatchRetentionPolicy(ctx context.Context, s
|
||||
case err != nil:
|
||||
return false, fmt.Errorf("Could not retrieve claim %s for %s when checking PVC deletion policy", claimName, pod.Name)
|
||||
default:
|
||||
if !claimOwnerMatchesSetAndPod(claim, set, pod) {
|
||||
if !claimOwnerMatchesSetAndPod(logger, claim, set, pod) {
|
||||
return false, nil
|
||||
}
|
||||
}
|
||||
@@ -241,9 +242,9 @@ func (spc *StatefulPodControl) UpdatePodClaimForRetentionPolicy(ctx context.Cont
|
||||
case err != nil:
|
||||
return fmt.Errorf("Could not retrieve claim %s not found for %s when checking PVC deletion policy: %w", claimName, pod.Name, err)
|
||||
default:
|
||||
if !claimOwnerMatchesSetAndPod(claim, set, pod) {
|
||||
if !claimOwnerMatchesSetAndPod(logger, claim, set, pod) {
|
||||
claim = claim.DeepCopy() // Make a copy so we don't mutate the shared cache.
|
||||
needsUpdate := updateClaimOwnerRefForSetAndPod(claim, set, pod)
|
||||
needsUpdate := updateClaimOwnerRefForSetAndPod(logger, claim, set, pod)
|
||||
if needsUpdate {
|
||||
err := spc.objectMgr.UpdateClaim(claim)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user