Skip to content

Commit 7afdfa7

Browse files
committed
more logging
1 parent e044ef1 commit 7afdfa7

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

internal/file/file_manager_service.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,12 @@ func (fms *FileManagerService) UpdateManifestFile(ctx context.Context,
442442
slog.DebugContext(ctx, "Updating manifest file", "current_files", currentFiles, "referenced", referenced)
443443
currentManifestFiles, _, readError := fms.manifestFile()
444444

445+
slog.DebugContext(ctx, "Current manifest file")
446+
for _, file := range currentManifestFiles {
447+
slog.DebugContext(ctx, "Manifest File: ", "file", file.ManifestFileMeta.Name, "hash",
448+
file.ManifestFileMeta.Hash, "unmanaged", file.ManifestFileMeta.Unmanaged)
449+
}
450+
445451
// When agent is first started the manifest is updated when an NGINX instance is found, but the manifest file
446452
// will be empty leading to previousManifestFiles being empty. This was causing issues if the first config
447453
// apply failed leading to the manifest file being rolled back to an empty file.
@@ -462,10 +468,17 @@ func (fms *FileManagerService) UpdateManifestFile(ctx context.Context,
462468
updatedFiles := make(map[string]*model.ManifestFile)
463469

464470
manifestFiles := fms.convertToManifestFileMap(currentFiles, referenced)
471+
slog.DebugContext(ctx, "Files being updated")
472+
for _, file := range currentFiles {
473+
slog.DebugContext(ctx, "Updated File: ", "file", file.GetFileMeta().GetName(), "hash",
474+
file.GetFileMeta().GetHash(), "unmanaged", file.GetUnmanaged())
475+
}
476+
465477
// During a config apply every file is set to unreferenced
466478
// When a new NGINX config context is detected
467479
// we update the files in the manifest by setting the referenced bool to true
468480
if currentManifestFiles != nil && referenced {
481+
slog.DebugContext(ctx, "Referenced set to ture, add current files to updated files ")
469482
for _, currentManifestFile := range currentManifestFiles {
470483
// if file from manifest file is unreferenced add it to updatedFiles map
471484
if !currentManifestFile.ManifestFileMeta.Referenced {

internal/file/file_operator.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,6 @@ func (fo *FileOperator) WriteManifestFile(
157157
ctx context.Context, updatedFiles map[string]*model.ManifestFile, manifestDir, manifestPath string,
158158
) (writeError error) {
159159
slog.DebugContext(ctx, "Writing manifest file", "updated_files", updatedFiles)
160-
for _, file := range updatedFiles {
161-
slog.DebugContext(ctx, "Updated File: ", "file", file.ManifestFileMeta.Name, "hash",
162-
file.ManifestFileMeta.Hash, "referenced", file.ManifestFileMeta.Referenced)
163-
}
164160
manifestJSON, err := json.MarshalIndent(updatedFiles, "", " ")
165161
if err != nil {
166162
return fmt.Errorf("unable to marshal manifest file json: %w", err)

0 commit comments

Comments
 (0)