From b078978b00cfc99f4f9e2631fab298a6c71f2cbe Mon Sep 17 00:00:00 2001 From: kpcraig <3031348+kpcraig@users.noreply.github.com> Date: Wed, 26 Feb 2025 16:13:46 -0500 Subject: [PATCH] Update GRPC functions to send rotation window and period as seconds explicitly (#29721) --- sdk/plugin/grpc_system.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/sdk/plugin/grpc_system.go b/sdk/plugin/grpc_system.go index c80d6229ad..d85e29f9e6 100644 --- a/sdk/plugin/grpc_system.go +++ b/sdk/plugin/grpc_system.go @@ -234,8 +234,10 @@ func (s *gRPCSystemViewClient) RegisterRotationJob(ctx context.Context, req *rot MountPoint: req.MountPoint, Path: req.ReqPath, RotationSchedule: req.RotationSchedule, - RotationWindow: int64(req.RotationWindow), - RotationPeriod: int64(req.RotationPeriod), + + // on the side outbound from the plugin, we convert duration to seconds, so seconds get sent over the wire + RotationWindow: int64(req.RotationWindow.Seconds()), + RotationPeriod: int64(req.RotationPeriod.Seconds()), }, } resp, err := s.client.RegisterRotationJob(ctx, cfgReq) @@ -472,8 +474,11 @@ func (s *gRPCSystemViewServer) RegisterRotationJob(ctx context.Context, req *pb. MountPoint: req.Job.MountPoint, ReqPath: req.Job.Path, RotationSchedule: req.Job.RotationSchedule, - RotationWindow: time.Duration(req.Job.RotationWindow) * time.Second, - RotationPeriod: time.Duration(req.Job.RotationPeriod) * time.Second, + // on the side inbound to vault, we convert seconds back to time.Duration + // Note: this value is seconds (as per the outbound client call, despite being int64) + // The field is int64 because of gRPC reasons, not time.Duration reasons + RotationWindow: time.Duration(req.Job.RotationWindow) * time.Second, + RotationPeriod: time.Duration(req.Job.RotationPeriod) * time.Second, } rotationID, err := s.impl.RegisterRotationJob(ctx, cfgReq)