@@ -17,6 +17,7 @@ import (
1717 mpi "github.com/nginx/agent/v3/api/grpc/mpi/v1"
1818 "github.com/nginx/agent/v3/internal/config"
1919 "github.com/nginx/agent/v3/pkg/id"
20+ "google.golang.org/protobuf/proto"
2021)
2122
2223var (
@@ -268,19 +269,28 @@ func (w *NginxAppProtectInstanceWatcher) updateInstance(ctx context.Context) {
268269 w .instanceMutex .Lock ()
269270 defer w .instanceMutex .Unlock ()
270271
271- w .nginxAppProtectInstance .GetInstanceMeta ().Version = w .version
272- runtimeInfo := w .nginxAppProtectInstance .GetInstanceRuntime ().GetNginxAppProtectRuntimeInfo ()
273- if runtimeInfo == nil {
274- slog .ErrorContext (ctx , "Error updating NGINX App Protect instance runtimeInfo, instance no longer exists" )
275- return
276- }
272+ instanceCopy , ok := proto .Clone (w .nginxAppProtectInstance ).(* mpi.Instance )
273+
274+ if ok {
275+ instanceCopy .GetInstanceMeta ().Version = w .version
276+ runtimeInfo := instanceCopy .GetInstanceRuntime ().GetNginxAppProtectRuntimeInfo ()
277+ if runtimeInfo == nil {
278+ slog .ErrorContext (ctx , "Error updating NGINX App Protect instance runtimeInfo, instance no longer exists" )
279+ return
280+ }
277281
278- runtimeInfo .Release = w .release
279- runtimeInfo .AttackSignatureVersion = w .attackSignatureVersion
280- runtimeInfo .ThreatCampaignVersion = w .threatCampaignVersion
281- runtimeInfo .EnforcerEngineVersion = w .enforcerEngineVersion
282+ runtimeInfo .Release = w .release
283+ runtimeInfo .AttackSignatureVersion = w .attackSignatureVersion
284+ runtimeInfo .ThreatCampaignVersion = w .threatCampaignVersion
285+ runtimeInfo .EnforcerEngineVersion = w .enforcerEngineVersion
282286
283- slog .InfoContext (ctx , "NGINX App Protect instance updated" )
287+ w .nginxAppProtectInstance = instanceCopy
288+
289+ slog .InfoContext (ctx , "NGINX App Protect instance updated" )
290+ } else {
291+ slog .WarnContext (ctx , "Unable to clone instance while updating instance" , "instance" ,
292+ w .NginxAppProtectInstance ())
293+ }
284294}
285295
286296func (w * NginxAppProtectInstanceWatcher ) haveVersionsChanged () bool {
0 commit comments