Change:
migrated_packages+=("$KUBE_ROOT/$line") done < <(cat "${migrated_packages_file}") <ins> echo "Running structured logging static check on migrated packages" </ins> ret=0 GOOS=linux    logcheck "${migrated_packages[@]}" || ret=$? GOOS=windows  logcheck "${migrated_packages[@]}" || ret=$? if [ $ret -eq 0 ]; then <del> echo "Structured logging static check is passed :)." </del> <ins> echo "Structured logging static check passed on migrated packages :)" </ins> else echo "Please fix above failures. You can locally test via:" echo "hack/verify-structured-logging.sh" fi <ins> # Ignore migrated packages as they are already tested # Trim the trailing /... from given packages ignore_packages=$(grep -oE '^[a-zA-Z0-9/]+[^/.]' < "${KUBE_ROOT}"/hack/.structured_logging) all_packages=() # shellcheck disable=SC2010 for i in $(ls -d ./*/ | grep -v 'staging' | grep -v 'vendor' | grep -v 'hack') do all_packages+=("$(go list ./"$i"/... 2> /dev/null | sed 's/k8s.io/kubernetes///g')") all_packages+=(" ") done # We exclude vendor/ except vendor/k8s.io # This is because vendor/k8s.io is symlinked to staging # and needs to be checked all_packages+=("vendor/k8s.io") # Packages to test = all_packages - ignored_packages packages=() while IFS='' read -r line; do if [ -z "$line" ]; then continue; fi packages+=("$KUBE_ROOT/$line/...") done < <(echo "${all_packages[@]}" | tr " " "n" | grep -v "$ignore_packages") echo -e "nRunning structured logging static check on all other packages" GOOS=linux    logcheck -allow-unstructured "${packages[@]}" || ret=$? GOOS=windows  logcheck -allow-unstructured "${packages[@]}" || ret=$? if [ $ret -eq 0 ]; then echo "Structured logging static check passed on all packages :)" else echo "Please fix above failures. You can locally test via:" echo "hack/verify-structured-logging.sh" fi </ins> exit $ret

Discussion:
For structured logging migration we have developed a tool to klog invocations For a given directory logcheck validates two things: directory is fully migrated - check if there are non-structured logging calls like usage of and is correct - check if key values passed are paired. We run logcheck as part of Kubernetes verify scripts on directories listed in Directories listed in are marked as migrated to avoid regressions from organized migration, however there are also other code locations that already use new functions that are not yet ready to be marked as migrated (components that are not part of organized migrations are done as best effort). We should split checking if directory was migrated from correctness of new functions and scan whole codebase for correctness. Plan: Add a flag to logcheck for requiring that directory was migrated. Add to verify-strucured- running logcheck of whole k/k codebase to check correctness This will ensure higher quality of migration PRs by validating correctness of directories that were not yet in .structuredlogging /wg structured-logging /cc
I'd like to pick this up. Do I need to wait till it is triage/accepted?
/triage accepted
Feel free to pick it up :P Usually I don't want to self triage, but this issue is purely Structured Logging WG related.
/assign
[Case 2: Correct usage] If the directory is not marked as migrated, we check that it's usage of is correct and don't care about usage of . By default, CI will test for correctness of whole k/k codebase instead of testing for complete migration (which is the current behavior). And to test for migration, a new flag must be passed explicitly. is this the expectation?
To clarify, let me rephrase. Current state is What we want: [Case 2: Correct usage] tested on whole repository
If this is the case, I can start implementing it.
SG, thanks for the help.
/milestone v1.22 Part of work go graduate Structured Logging KEP to beta.
I don't think work here has finished. We still need to implement those changes in k/k repo: Cut new klog Bump klog in k/k Update the script ./hack/verify-structured- /reopen
Reopened this issue. <detailsIn response to : I don't think work here has finished.

We still need to implement those changes in k/k repo: Update the script /reopen </details
Why do we need to cut a new klog and bump in k/k? Can't we make latest logcheck available to k/k without it? I don't know the process.
Hmm, We could try without updating to update. Please send PR that will update ./hack/verify-structured- If updating klog is nesesery feel free to contact for help
If we do both, we'd have to run logcheck twice (with and without flag) which means test time will increase.
This depends on implementation, increasing running time is ok as long it's reasonable, for example x1.5, but not x10.
Due to v1.22 code freeze, I'm moving this issue to the next release. /milestone v1.23
We would like to have static analysis setup before we start migrating logs in 1.23. will you be able to work on it this week? Do you need any help?
Yes, I can. PR kubernetes/kubernetes/pull/ is up for enabling static analysis. It has some unresolved conversations. It'd be helpful if I could get another round of review on that PR. Before we merge that we'd need to fix existing logging issues which are listed here: If I could get help fixing those it'd be great. Else I can fix it too.
I see two issues that need to be addressed: Fix handling of in klog code, this should be done by creating an issue to klog () Fix remaining errors Upgrade klog version to pick up fix for Exit