Skip to content

Commit

Permalink
chore: make select log messages more explicit (#652)
Browse files Browse the repository at this point in the history
## Description

No function changes -- just trying to make the controller logs easier to
follow.

## Type of change

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [x] Other (security config, docs update, etc)

## Checklist before merging

- [ ] Test, docs, adr added or updated as needed
- [ ] [Contributor Guide
Steps](https://github.com/defenseunicorns/pepr/blob/main/CONTRIBUTING.md#submitting-a-pull-request)
followed
  • Loading branch information
btlghrants committed Mar 14, 2024
1 parent ef780c4 commit 32973b6
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion journey/pepr-deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export function peprDeploy() {
await until(() => state.done)

// completes only if conditions are met, so... getting here means success!
}, 5000);
}, 10000);
});

describe("should display the UUIDs of the deployed modules", testUUID);
Expand Down
17 changes: 16 additions & 1 deletion src/lib/filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,22 @@ export function shouldSkipRequest(binding: Binding, req: AdmissionRequest, capab
(combinedNamespaces.length && !combinedNamespaces.includes(req.namespace || "")) ||
(!namespaces.includes(req.namespace || "") && capabilityNamespaces.length !== 0 && namespaces.length !== 0)
) {
logger.debug("Namespace does not match");
let type = "";
let label = "";

if (binding.isMutate) {
type = "Mutate";
label = binding.mutateCallback!.name;
} else if (binding.isValidate) {
type = "Validate";
label = binding.validateCallback!.name;
} else if (binding.isWatch) {
type = "Watch";
label = binding.watchCallback!.name;
}

logger.debug(`${type} binding (${label}) does not match request namespace "${req.namespace}"`);

return true;
}

Expand Down
4 changes: 2 additions & 2 deletions src/lib/mutate-processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export async function mutateProcessor(
}

const label = action.mutateCallback.name;
Log.info(actionMetadata, `Processing matched action ${label}`);
Log.info(actionMetadata, `Processing mutation action (${label})`);

matchedAction = true;

Expand All @@ -79,7 +79,7 @@ export async function mutateProcessor(
// Run the action
await action.mutateCallback(wrapped);

Log.info(actionMetadata, `Action succeeded`);
Log.info(actionMetadata, `Mutation action succeeded (${label})`);

// Add annotations to the request to indicate that the capability succeeded
updateStatus("succeeded");
Expand Down
4 changes: 2 additions & 2 deletions src/lib/validate-processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export async function validateProcessor(
}

const label = action.validateCallback.name;
Log.info(actionMetadata, `Processing matched action ${label}`);
Log.info(actionMetadata, `Processing validation action (${label})`);

try {
// Run the validation callback, if it fails set allowed to false
Expand All @@ -61,7 +61,7 @@ export async function validateProcessor(
};
}

Log.info(actionMetadata, `Validation Action completed: ${resp.allowed ? "allowed" : "denied"}`);
Log.info(actionMetadata, `Validation action complete (${label}): ${resp.allowed ? "allowed" : "denied"}`);
} catch (e) {
// If any validation throws an error, note the failure in the Response
Log.error(actionMetadata, `Action failed: ${JSON.stringify(e)}`);
Expand Down

0 comments on commit 32973b6

Please sign in to comment.