Skip to content

Commit 77300a7

Browse files
committed
Fix some naming
1 parent fbd13a5 commit 77300a7

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

internal/controller/nginx/agent/command.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ func (cs *commandService) Subscribe(in pb.CommandService_SubscribeServer) error
203203
// Only broadcast operations should signal ResponseCh for coordination.
204204
pendingBroadcastRequest = &msg
205205
case err = <-msgr.Errors():
206-
cs.logger.Error(err, "connection error", "deployment", conn.ParentName, "uuid", gi.UUID)
206+
cs.logger.Error(err, "connection error", conn.ParentType, conn.ParentName, "uuid", gi.UUID)
207207
deployment.SetPodErrorStatus(gi.UUID, err)
208208
select {
209209
case channels.ResponseCh <- struct{}{}:
@@ -248,7 +248,7 @@ func (cs *commandService) Subscribe(in pb.CommandService_SubscribeServer) error
248248

249249
func (cs *commandService) waitForConnection(
250250
ctx context.Context,
251-
gi grpcContext.GrpcInfo,
251+
grpcInfo grpcContext.GrpcInfo,
252252
) (*agentgrpc.Connection, *Deployment, error) {
253253
ticker := time.NewTicker(time.Second)
254254
defer ticker.Stop()
@@ -267,7 +267,7 @@ func (cs *commandService) waitForConnection(
267267
case <-timer.C:
268268
return nil, nil, err
269269
case <-ticker.C:
270-
if conn := cs.connTracker.GetConnection(gi.UUID); conn.Ready() {
270+
if conn := cs.connTracker.GetConnection(grpcInfo.UUID); conn.Ready() {
271271
// connection has been established, now ensure that the deployment exists in the store
272272
if deployment := cs.nginxDeployments.Get(conn.ParentName); deployment != nil {
273273
return &conn, deployment, nil
@@ -283,7 +283,7 @@ func (cs *commandService) waitForConnection(
283283
// setInitialConfig gets the initial configuration for this connection and applies it.
284284
func (cs *commandService) setInitialConfig(
285285
ctx context.Context,
286-
gi *grpcContext.GrpcInfo,
286+
grpcInfo *grpcContext.GrpcInfo,
287287
deployment *Deployment,
288288
conn *agentgrpc.Connection,
289289
msgr messenger.Messenger,
@@ -292,7 +292,7 @@ func (cs *commandService) setInitialConfig(
292292
defer deployment.FileLock.Unlock()
293293

294294
if err := cs.validatePodImageVersion(conn.ParentName, conn.ParentType, deployment.imageVersion); err != nil {
295-
cs.logAndSendErrorStatus(gi, deployment, conn, err)
295+
cs.logAndSendErrorStatus(grpcInfo, deployment, conn, err)
296296
return grpcStatus.Errorf(codes.FailedPrecondition, "nginx image version validation failed: %s", err.Error())
297297
}
298298

@@ -301,12 +301,12 @@ func (cs *commandService) setInitialConfig(
301301
cs.logger.Info(
302302
"Sending initial configuration to agent",
303303
conn.ParentType, conn.ParentName,
304-
"uuid", gi.UUID,
304+
"uuid", grpcInfo.UUID,
305305
"configVersion", configVersion,
306306
)
307307

308308
if err := msgr.Send(ctx, buildRequest(fileOverviews, conn.InstanceID, configVersion)); err != nil {
309-
cs.logAndSendErrorStatus(gi, deployment, conn, err)
309+
cs.logAndSendErrorStatus(grpcInfo, deployment, conn, err)
310310

311311
return grpcStatus.Error(codes.Internal, err.Error())
312312
}
@@ -330,7 +330,7 @@ func (cs *commandService) setInitialConfig(
330330
true, // poll immediately
331331
func(ctx context.Context) (bool, error) {
332332
if err := msgr.Send(ctx, buildPlusAPIRequest(action, conn.InstanceID)); err != nil {
333-
cs.logAndSendErrorStatus(gi, deployment, conn, err)
333+
cs.logAndSendErrorStatus(grpcInfo, deployment, conn, err)
334334

335335
return false, grpcStatus.Error(codes.Internal, err.Error())
336336
}
@@ -359,7 +359,7 @@ func (cs *commandService) setInitialConfig(
359359
cancel()
360360
}
361361
// send the status (error or nil) to the status queue
362-
cs.logAndSendErrorStatus(gi, deployment, conn, errors.Join(errs...))
362+
cs.logAndSendErrorStatus(grpcInfo, deployment, conn, errors.Join(errs...))
363363

364364
return nil
365365
}
@@ -403,7 +403,7 @@ func (cs *commandService) waitForInitialConfigApply(
403403
// exist on the Deployment are not overwritten.
404404
// If the error is nil, then we just enqueue the nil value and don't log it, which indicates success.
405405
func (cs *commandService) logAndSendErrorStatus(
406-
gi *grpcContext.GrpcInfo,
406+
grpcInfo *grpcContext.GrpcInfo,
407407
deployment *Deployment,
408408
conn *agentgrpc.Connection,
409409
err error,
@@ -414,10 +414,10 @@ func (cs *commandService) logAndSendErrorStatus(
414414
cs.logger.Info(
415415
"Successfully configured nginx for new subscription",
416416
conn.ParentType, conn.ParentName,
417-
"uuid", gi.UUID,
417+
"uuid", grpcInfo.UUID,
418418
)
419419
}
420-
deployment.SetPodErrorStatus(gi.UUID, err)
420+
deployment.SetPodErrorStatus(grpcInfo.UUID, err)
421421

422422
queueObj := &status.QueueObject{
423423
Deployment: conn.ParentName,

internal/controller/nginx/agent/grpc/interceptor/interceptor.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,11 @@ func getGrpcInfo(ctx context.Context) (*grpcContext.GrpcInfo, error) {
114114
}, nil
115115
}
116116

117-
func (c ContextSetter) validateToken(ctx context.Context, gi *grpcContext.GrpcInfo) (context.Context, error) {
117+
func (c ContextSetter) validateToken(ctx context.Context, grpcInfo *grpcContext.GrpcInfo) (context.Context, error) {
118118
tokenReview := &authv1.TokenReview{
119119
Spec: authv1.TokenReviewSpec{
120120
Audiences: []string{c.audience},
121-
Token: gi.Token,
121+
Token: grpcInfo.Token,
122122
},
123123
}
124124

@@ -169,5 +169,5 @@ func (c ContextSetter) validateToken(ctx context.Context, gi *grpcContext.GrpcIn
169169
return nil, status.Error(codes.Unauthenticated, msg)
170170
}
171171

172-
return grpcContext.NewGrpcContext(ctx, *gi), nil
172+
return grpcContext.NewGrpcContext(ctx, *grpcInfo), nil
173173
}

internal/controller/nginx/agent/grpc/interceptor/interceptor_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ func TestValidateToken_PodListOptions(t *testing.T) {
253253

254254
testCases := []struct {
255255
pod *corev1.Pod
256-
gi *grpcContext.GrpcInfo
256+
grpcInfo *grpcContext.GrpcInfo
257257
name string
258258
shouldErr bool
259259
}{
@@ -269,7 +269,7 @@ func TestValidateToken_PodListOptions(t *testing.T) {
269269
},
270270
Status: corev1.PodStatus{Phase: corev1.PodRunning},
271271
},
272-
gi: &grpcContext.GrpcInfo{Token: "dummy-token"},
272+
grpcInfo: &grpcContext.GrpcInfo{Token: "dummy-token"},
273273
shouldErr: false,
274274
},
275275
{
@@ -284,7 +284,7 @@ func TestValidateToken_PodListOptions(t *testing.T) {
284284
},
285285
Status: corev1.PodStatus{Phase: corev1.PodRunning},
286286
},
287-
gi: &grpcContext.GrpcInfo{Token: "dummy-token"},
287+
grpcInfo: &grpcContext.GrpcInfo{Token: "dummy-token"},
288288
shouldErr: true,
289289
},
290290
{
@@ -299,7 +299,7 @@ func TestValidateToken_PodListOptions(t *testing.T) {
299299
},
300300
Status: corev1.PodStatus{Phase: corev1.PodRunning},
301301
},
302-
gi: &grpcContext.GrpcInfo{Token: "dummy-token"},
302+
grpcInfo: &grpcContext.GrpcInfo{Token: "dummy-token"},
303303
shouldErr: true,
304304
},
305305
{
@@ -312,7 +312,7 @@ func TestValidateToken_PodListOptions(t *testing.T) {
312312
},
313313
Status: corev1.PodStatus{Phase: corev1.PodRunning},
314314
},
315-
gi: &grpcContext.GrpcInfo{Token: "dummy-token"},
315+
grpcInfo: &grpcContext.GrpcInfo{Token: "dummy-token"},
316316
shouldErr: true,
317317
},
318318
{
@@ -327,7 +327,7 @@ func TestValidateToken_PodListOptions(t *testing.T) {
327327
},
328328
Status: corev1.PodStatus{Phase: corev1.PodPending},
329329
},
330-
gi: &grpcContext.GrpcInfo{Token: "dummy-token"},
330+
grpcInfo: &grpcContext.GrpcInfo{Token: "dummy-token"},
331331
shouldErr: true,
332332
},
333333
}
@@ -352,7 +352,7 @@ func TestValidateToken_PodListOptions(t *testing.T) {
352352
patchedClient := &patchClient{fakeClient}
353353
csPatched := NewContextSetter(patchedClient, "ngf-audience")
354354

355-
resultCtx, err := csPatched.validateToken(t.Context(), tc.gi)
355+
resultCtx, err := csPatched.validateToken(t.Context(), tc.grpcInfo)
356356
if tc.shouldErr {
357357
g.Expect(err).To(HaveOccurred())
358358
g.Expect(err.Error()).To(ContainSubstring("no running pods"))

0 commit comments

Comments
 (0)