Skip to content

Commit 598c51c

Browse files
committed
Fix review comments to
1. Undo changes to the charts and deploy directories 2. Add boilerplate to pkg/constants/constants.go 3. Changed logging to entire VolumeContext to just the FSGroup 4. Updated the way empty string is checked 5. changed Infof to InfoS 6. Removed un-necessary/redundant logs
1 parent 50f04b9 commit 598c51c

File tree

7 files changed

+26
-17
lines changed

7 files changed

+26
-17
lines changed

charts/secrets-store-csi-driver/crds/secrets-store.csi.x-k8s.io_secretproviderclasspodstatuses.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ spec:
4141
description: SecretProviderClassPodStatusStatus defines the observed state
4242
of SecretProviderClassPodStatus
4343
properties:
44-
fsGroup:
45-
type: string
4644
mounted:
4745
type: boolean
4846
objects:

deploy/secrets-store.csi.x-k8s.io_secretproviderclasspodstatuses.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ spec:
4141
description: SecretProviderClassPodStatusStatus defines the observed state
4242
of SecretProviderClassPodStatus
4343
properties:
44-
fsGroup:
45-
type: string
4644
mounted:
4745
type: boolean
4846
objects:

pkg/constants/constants.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/*
2+
Copyright 2025 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
116
package constants
217

318
const (

pkg/rotation/reconciler.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -401,16 +401,16 @@ func (r *Reconciler) reconcile(ctx context.Context, spcps *secretsstorev1.Secret
401401
return fmt.Errorf("failed to lookup provider client: %q", providerName)
402402
}
403403
gid := constants.NoGID
404-
if spcps.Status.FSGroup != "" {
404+
if len(spcps.Status.FSGroup) > 0 {
405405
gid, err = strconv.ParseInt(spcps.Status.FSGroup, 10, 64)
406406
if err != nil {
407407
errorReason = internalerrors.FailedToParseFSGroup
408-
errStr := fmt.Sprintf("failed to rotate objects for pod %s/%s, err: %v, invalid FSGroup:%s", spcps.Namespace, spcps.Status.PodName, err, spcps.Status.FSGroup)
408+
errStr := fmt.Sprintf("failed to rotate objects for pod %s/%s, invalid FSGroup:%s, err: %w ", spcps.Namespace, spcps.Status.PodName, spcps.Status.FSGroup, err)
409409
r.generateEvent(pod, corev1.EventTypeWarning, mountRotationFailedReason, errStr)
410410
return fmt.Errorf("%s", errStr)
411411
}
412412
}
413-
klog.V(5).Infof("Reconciling pod %s/%s with fsGroup: %v\n", spcps.Namespace, spcps.Status.PodName, gid)
413+
klog.V(5).InfoS("updating the secret content", "pod", klog.ObjectRef{Namespace: spcps.Namespace, Name: spcps.Status.PodName}, "FSGroup", gid)
414414
newObjectVersions, errorReason, err := secretsstore.MountContent(ctx, providerClient, string(paramsJSON), string(secretsJSON), spcps.Status.TargetPath, string(permissionJSON), oldObjectVersions, gid)
415415
if err != nil {
416416
r.generateEvent(pod, corev1.EventTypeWarning, mountRotationFailedReason, fmt.Sprintf("provider mount err: %+v", err))

pkg/secrets-store/nodeserver.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,21 +142,21 @@ func (ns *nodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis
142142
return &csi.NodePublishVolumeResponse{}, nil
143143
}
144144

145-
klog.V(2).InfoS("node publish volume", "target", targetPath, "volumeId", volumeID, "mount flags", mountFlags)
145+
klog.V(2).InfoS("node publish volume", "target", targetPath, "volumeId", volumeID, "mount flags", mountFlags, "volumeCapabilities", req.VolumeCapability.String())
146146

147-
klog.V(5).InfoS("volume mounted with", "volumeContext", req.VolumeContext, "volumeCapabilities", req.VolumeCapability.String())
148147
gid := constants.NoGID // Group ID to Chown the volume contents to
149-
if req.VolumeCapability != nil && req.VolumeCapability.GetMount() != nil && req.VolumeCapability.GetMount().GetVolumeMountGroup() != "" {
150-
fsGroupStr := req.VolumeCapability.GetMount().GetVolumeMountGroup()
148+
mountVol := req.VolumeCapability.GetMount()
149+
if len(mountVol.GetVolumeMountGroup()) > 0 {
150+
fsGroupStr := mountVol.GetVolumeMountGroup()
151151
klog.V(5).Info("fsGroupStr: %v\n", fsGroupStr)
152152
gid, err = strconv.ParseInt(fsGroupStr, 10, 64)
153153
klog.V(5).Info("converted gid: %v\n", gid)
154154
if err != nil {
155-
klog.ErrorS(err, "failed to mount secrets store object content", "pod", klog.ObjectRef{Namespace: podNamespace, Name: podName}, "invalid FSGroup: ", fsGroupStr)
155+
klog.ErrorS(err, "failed to mount secrets store object content", "pod", klog.ObjectRef{Namespace: podNamespace, Name: podName}, "FSGroup: ", fsGroupStr)
156156
return nil, status.Error(codes.InvalidArgument, "Error parsing FSGroup")
157157
}
158158
} else {
159-
klog.V(5).Info("mount group not set")
159+
klog.V(5).InfoS("mount group not set", "targetPath", targetPath, "pod", klog.ObjectRef{Namespace: podNamespace, Name: podName})
160160
}
161161

162162
if isMockProvider(providerName) {

pkg/secrets-store/utils.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,10 @@ func createOrUpdateSecretProviderClassPodStatus(ctx context.Context, c client.Cl
102102
}
103103
o = spcpsutil.OrderSecretProviderClassObjectByID(o)
104104
fsGroup := ""
105-
klog.V(5).Infof("gid: %v for pod: %v/%v", gid, namespace, podname)
106105
if gid != constants.NoGID {
107106
fsGroup = strconv.FormatInt(gid, 10)
108107
}
109-
klog.V(5).Infof("gid string: %v for pod: %v/%v", fsGroup, namespace, podname)
108+
klog.V(5).InfoS("setting gid in spcps", "pod", klog.ObjectRef{Namespace: namespace, Name: podname}, "gid", gid, "gidStr", fsGroup)
110109
spcPodStatus := &secretsstorev1.SecretProviderClassPodStatus{
111110
ObjectMeta: metav1.ObjectMeta{
112111
Name: spcpsName,
@@ -133,7 +132,6 @@ func createOrUpdateSecretProviderClassPodStatus(ctx context.Context, c client.Cl
133132
UID: types.UID(podUID),
134133
},
135134
})
136-
klog.V(5).InfoS("creating", "spcPodStatus", spcPodStatus)
137135
if err = c.Create(ctx, spcPodStatus); err == nil || !apierrors.IsAlreadyExists(err) {
138136
return err
139137
}

test/e2eprovider/server/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ func (s *Server) Mount(ctx context.Context, req *v1alpha1.MountRequest) (*v1alph
167167
}
168168

169169
klog.InfoS("Secret Object with", "name", mockSecretsStoreObject.ObjectName, "permission", mockSecretsStoreObject.FilePermission)
170-
if mockSecretsStoreObject.FilePermission != "" {
170+
if len(mockSecretsStoreObject.FilePermission) > 0 {
171171
mode, err := strconv.ParseUint(mockSecretsStoreObject.FilePermission, 8, 32)
172172
if err != nil || mode > 511 {
173173
return nil, fmt.Errorf("invalid filePermission: %s, error: %w for file: %s", mockSecretsStoreObject.FilePermission, err, mockSecretsStoreObject.ObjectName)

0 commit comments

Comments
 (0)