question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug

Although no garden CLI commands are hanging, multiple processes are causing high CPU usage. image

No garden dev commands were executed, only garden deploy using the kubernetes provider (cluster on GKE). .gardenignore files are also used to ignore folders like node_modules. Is there a way to check how many/which files are watched, as this might be the cause of the high CPU usage?

Some garden deploy executions seem to be stuck in the beginning on the provider step, before starting the deployment. After canceling the command, the process probably keeps on running.

Your environment

  • OS: MacOS Big Sur 11.6
  • How I’m running Kubernetes: GKE

garden version 0.12.29

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10

github_iconTop GitHub Comments

1reaction
tbl-harmoneycommented, Apr 13, 2022

We’ve built a custom version of Garden with extra logging and came to the following conclusion:

Our project.garden.yaml file contained the following config:

dotIgnoreFiles:
  - .gitignore
  - .gardenignore

We started with .gitignore but needed some extra excludes as we also have sub (module) .gitignore files. We added some of these more specific ignores to a .gardenignore file.

However, this causes the function getFiles() in core/src/vcs/git.ts to behave differently, due to this if-condition: https://github.com/garden-io/garden/blob/master/core/src/vcs/git.ts#L272

if (this.ignoreFiles.length > 1) {

Some “intersection” logic is executed, calling a comparison function: https://github.com/garden-io/garden/blob/master/core/src/vcs/git.ts#L294

// Note: The comparison function needs to account for git first returning untracked files, so we prefix with
// a zero or one to indicate whether it's a tracked file or not, and then do a simple string comparison
const intersection = new SortedStreamIntersection(
  streams.map(({ output }) => output),
  (a: VcsFile, b: VcsFile) => {
    log.debug(`HARMONEY ${identifier}: comparing ${a.path} and ${b.path}`) // added custom log to debug
    const cmpA = (a.hash ? "1" : "0") + a.path
    const cmpB = (b.hash ? "1" : "0") + b.path
    return <any>(cmpA > cmpB) - <any>(cmpA < cmpB)
  }
)

When adding logs, an infinite loop seemed to be present:

HARMONEY 152: comparing .DS_Store and .dockerignore
HARMONEY 152: comparing .dockerignore and .dockerignore
HARMONEY 152: comparing .dockerignore and .DS_Store
HARMONEY 152: comparing undefined and undefined
HARMONEY 152: comparing .dockerignore and .DS_Store
HARMONEY 152: comparing .dockerignore and .dockerignore
HARMONEY 152: comparing .dockerignore and .DS_Store
HARMONEY 152: comparing undefined and undefined
HARMONEY 152: comparing .dockerignore and .DS_Store
HARMONEY 152: comparing .dockerignore and .dockerignore
HARMONEY 152: comparing .dockerignore and .DS_Store
HARMONEY 152: comparing undefined and undefined
HARMONEY 152: comparing .dockerignore and .DS_Store
HARMONEY 152: comparing .dockerignore and .dockerignore
...

As multiple ignore files in the garden config clearly complicate the execution, we just eliminated the .gardenignore file again:

dotIgnoreFiles:
  - .gitignore

FYI, contents of the deleted .gardenignore file were:

dist
node_modules
target
acceptance/reports

Which explains why .dockerignore and .DS_Store files were listed in the logs, although our .gitignore file does ignore them. This “multiple ignore file” and intersection logic can be tricky for an end user. It feels like adding an extra ignore file should just be an extra safety, whereas an extra ignore file with only few ignored lines can cause a heavy comparison.

As a conclusion: we have a valid workaround by just specifying 1 ignore file. However, the infinite loop could still be solved to improve the “multiple ignore file” setup.

0reactions
stale[bot]commented, Jul 31, 2022

This issue has been automatically marked as stale because it hasn’t had any activity in 90 days. It will be closed in 14 days if no further activity occurs (e.g. changing labels, comments, commits, etc.). Please feel free to tag a maintainer and ask them to remove the label if you think it doesn’t apply. Thank you for submitting this issue and helping make Garden a better product!

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is CPU usage, and how to fix high CPU usage
High CPU usage is often the cause of bad performance. Your computer may be affected by this problem if you're experiencing long loading ......
Read more >
How to Fix High CPU Usage (with Pictures) - wikiHow
1. Press .Ctrl+ Shift+Esc to open the Task Manager. This is a utility that monitors and reports on all of the processes and...
Read more >
How to Lower CPU Usage - NinjaOne
What are common fixes for high CPU use? How to lower CPU usage in Windows 10; How to lower CPU usage when gaming...
Read more >
How to Lower CPU Usage: Common Causes & Tips - N-able
The symptoms of high CPU usage are familiar: the cursor moves jerkily and slowly, and applications begin to lag or shut down.
Read more >
Guidance for troubleshooting high CPU usage - Windows Server
Keep in mind that you can expect CPU usage to increase as a process or an application serves requests. However, if you consistently...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found