Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: mutex protect krusty #53

Merged
merged 1 commit into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fmt:

.PHONY: test
test:
go test -coverprofile coverage.out -v ./...
go test -race -coverprofile coverage.out -v ./...

.PHONY: e2e-test
e2e-test: build
Expand Down
6 changes: 6 additions & 0 deletions internal/build/kustomize.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"os"
"path/filepath"
"sync"

"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/kustomize/api/konfig"
Expand All @@ -17,6 +18,8 @@ import (
"sigs.k8s.io/yaml"
)

var kustomizeBuildMutex sync.Mutex

type KustomizeOpts struct {
Path string
}
Expand Down Expand Up @@ -95,6 +98,9 @@ func (k *Kustomize) buildKustomization(path string) (resmap.ResMap, error) {
PluginConfig: krusty.MakeDefaultOptions().PluginConfig,
}

kustomizeBuildMutex.Lock()
defer kustomizeBuildMutex.Unlock()

kustomizer := krusty.MakeKustomizer(buildOptions)
return kustomizer.Run(fs, path)
}
Expand Down