Skip to content
Open
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
1 change: 1 addition & 0 deletions apis/v1/secretproviderclasspodstatus_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type SecretProviderClassPodStatusStatus struct {
Mounted bool `json:"mounted,omitempty"`
TargetPath string `json:"targetPath,omitempty"`
Objects []SecretProviderClassObject `json:"objects,omitempty"`
FSGroup string `json:"fsGroup,omitempty"`
}

// SecretProviderClassObject defines the object fetched from external secrets store
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ spec:
description: SecretProviderClassPodStatusStatus defines the observed state
of SecretProviderClassPodStatus
properties:
fsGroup:
type: string
mounted:
type: boolean
objects:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ spec:
description: SecretProviderClassPodStatusStatus defines the observed state
of SecretProviderClassPodStatus
properties:
fsGroup:
type: string
mounted:
type: boolean
objects:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ spec:
description: SecretProviderClassPodStatusStatus defines the observed state
of SecretProviderClassPodStatus
properties:
fsGroup:
type: string
mounted:
type: boolean
objects:
Expand Down
22 changes: 22 additions & 0 deletions pkg/constants/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
Copyright 2025 The Kubernetes Authors.

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.
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
*/
*/

nit: new line

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


package constants

const (
// NoGID is the default gid -1 to indicate no change in FSGroup
NoGID = int64(-1)
)
3 changes: 2 additions & 1 deletion pkg/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@ const (
// PodVolumeNotFound error
PodVolumeNotFound = "PodVolumeNotFound"
// FileWriteError error
FileWriteError = "FileWriteError"
FileWriteError = "FileWriteError"
FailedToParseFSGroup = "FailedToParseFSGroup"
)
10 changes: 9 additions & 1 deletion pkg/rotation/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,15 @@ func (r *Reconciler) reconcile(ctx context.Context, spcps *secretsstorev1.Secret
r.generateEvent(pod, corev1.EventTypeWarning, mountRotationFailedReason, fmt.Sprintf("failed to lookup provider client: %q", providerName))
return fmt.Errorf("failed to lookup provider client: %q", providerName)
}
newObjectVersions, errorReason, err := secretsstore.MountContent(ctx, providerClient, string(paramsJSON), string(secretsJSON), spcps.Status.TargetPath, string(permissionJSON), oldObjectVersions)
gid, err := fileutil.ParseFSGroup(spcps.Status.FSGroup)
if err != nil {
errorReason = internalerrors.FailedToParseFSGroup
errStr := fmt.Sprintf("failed to rotate objects for pod %s/%s, invalid FSGroup:%s", spcps.Namespace, spcps.Status.PodName, spcps.Status.FSGroup)
r.generateEvent(pod, corev1.EventTypeWarning, mountRotationFailedReason, fmt.Sprintf("%s, err: %v", errStr, err))
return fmt.Errorf("%s, err: %w", errStr, err)
}
klog.V(5).InfoS("updating the secret content", "pod", klog.ObjectRef{Namespace: spcps.Namespace, Name: spcps.Status.PodName}, "FSGroup", gid)
newObjectVersions, errorReason, err := secretsstore.MountContent(ctx, providerClient, string(paramsJSON), string(secretsJSON), spcps.Status.TargetPath, string(permissionJSON), oldObjectVersions, gid)
if err != nil {
r.generateEvent(pod, corev1.EventTypeWarning, mountRotationFailedReason, fmt.Sprintf("provider mount err: %+v", err))
return fmt.Errorf("failed to rotate objects for pod %s/%s, err: %w", spcps.Namespace, spcps.Status.PodName, err)
Expand Down
Loading