Skip to content

fix: fix for unexpected token error#169

Merged
blue4209211 merged 8 commits into
mainfrom
fix-node-agent
Jan 12, 2026
Merged

fix: fix for unexpected token error#169
blue4209211 merged 8 commits into
mainfrom
fix-node-agent

Conversation

@mayankpande88

Copy link
Copy Markdown
Contributor

No description provided.

@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello @mayankpande88, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses an 'unexpected token error' by significantly improving the robustness of container ID parsing and workload resolution. It introduces conditional logic to correctly handle both Kubernetes and non-Kubernetes container ID formats, ensuring that the appropriate workload owner is identified. Furthermore, it enhances system stability by adding a filter to explicitly ignore certain control plane systemd services during container ID calculation.

Highlights

  • Container ID Parsing Refinement: The logic for parsing container IDs in NewContainer has been enhanced to differentiate between Kubernetes-managed containers and other container types (e.g., Docker, systemd, Swarm, Nomad).
  • Non-Kubernetes Workload Resolution: A new mechanism has been introduced to resolve workloads for non-Kubernetes containers, using the container's name as the primary identifier for the workload.
  • Control Plane Service Filtering: An additional check has been added in calcId to ignore systemd services that are identified as part of the control plane, preventing them from being processed as regular containers.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request addresses an unexpected token error by introducing more robust handling of different container ID formats, correctly distinguishing between Kubernetes and other container types like Docker or systemd. This prevents potential panics when encountering non-standard container IDs. Additionally, it enhances filtering by ignoring certain systemd services associated with the control plane. My review includes a suggestion to refactor a block of code in containers/container.go to align with idiomatic Go naming conventions and to simplify the logic, improving readability and maintainability. The changes are a positive step towards making the agent more resilient.

Comment thread containers/container.go
mayankpande88 and others added 7 commits January 10, 2026 16:55
…ystemd services

- Fix concurrent map read/write crash in updateDelays by using proper locking:
  - Get PIDs snapshot under read lock
  - Make syscalls without holding lock to avoid contention
  - Update delays under write lock

- Fix "unexpected container id" errors for systemd services:
  - Only resolve pod owner for k8s containers (/k8s/ or /k8s-cronjob/ prefixes)
  - Use container name as workload for non-k8s containers

- Skip systemd services that match IGNORE_CONTROL_PLANE list in calcId

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Increase l7_events perf buffer from 64 to 128 pages per CPU to reduce
  lost samples
- Add rate-limited logging for lost samples (aggregate and log every 10s
  instead of per-event)
- Include CPU info in lost samples log for better debugging

The duplicate log lines (4x) were caused by per-CPU lost sample records
being logged separately. Now they are aggregated and logged periodically.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Initialize klog flags properly to prevent duplicate log output.
The issue was that klog was outputting to both the custom writer
and stderr by default. Setting logtostderr=false, alsologtostderr=false,
and stderrthreshold=FATAL ensures only the custom output is used.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replace klog.Errorf with klog.ErrorS for lost samples logging.
klog.Errorf logs to ERROR, WARNING, and INFO levels causing 3x
duplicates. klog.ErrorS uses structured logging and only logs
once at the ERROR level.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Replace klog.ErrorS with log.Printf for lost samples logging.
Both klog.Errorf and klog.ErrorS output to multiple severity
levels (ERROR, WARNING, INFO) by design, causing 3x duplicates.

The standard log package writes once to the configured output
(our RateLimitedLogOutput) without duplication.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add read lock when iterating over activeConnections map in the
Collect function to prevent concurrent map iteration and map write
errors during Prometheus metric collection.

The race condition occurs when:
- Prometheus calls Collect() which iterates over activeConnections
- Concurrently, connection events modify activeConnections

Error:
  fatal error: concurrent map iteration and map write
  at containers/container.go:455

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Prevent agent crashes when receiving malformed or incomplete ClickHouse
protocol packets by adding defer/recover pattern to ParseClickhouse.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@blue4209211 blue4209211 merged commit 8755b83 into main Jan 12, 2026
2 checks passed
@blue4209211 blue4209211 deleted the fix-node-agent branch January 12, 2026 03:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants