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

Getting fails to load: plugin: not implemented when using custom generator plugin #1641

Closed
arthurgustin opened this issue Oct 16, 2019 · 6 comments
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.

Comments

@arthurgustin
Copy link
Contributor

arthurgustin commented Oct 16, 2019

Version: {Version:kustomize/v3.2.3 GitCommit:f8412aa3d39f32151525aff97a351288f5a7470b BuildDate:2019-10-08T23:30:25Z GoOs:linux GoArch:amd64}

Hi, I had to write a custom generator for my use-case (generating N times the same resource with a different name,namespace and a lot of custom properties). I simplified my plugin for the issue tracker.

This plugin is located inside my kustomize folder at

myProject/k8s/kustomize/plugin/someteam.example.com/v1/processgenerator/ProcessGenerator.go

and I use

XDG_CONFIG_HOME=myProject/k8s kustomize build --enable_alpha_plugins

for rendering

package main

import (
	"bytes"
	"sigs.k8s.io/kustomize/v3/pkg/ifc"
	"text/template"

	"sigs.k8s.io/kustomize/v3/pkg/resmap"
	"sigs.k8s.io/kustomize/v3/pkg/types"
	"sigs.k8s.io/yaml"
)

type plugin struct {
	rf               *resmap.Factory
	types.ObjectMeta `json:"metadata,omitempty" yaml:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` // INCLUDE NAME AND NAMESPACE ALREADY

	ProcessName             string `json:"processName,omitempty" yaml:"processName,omitempty"`
	# + 30 properties
}

//nolint: golint
//noinspection GoUnusedGlobalVariable
var KustomizePlugin plugin

func (p *plugin) Config(ldr ifc.Loader, rf *resmap.Factory, c []byte) error {
	p.rf = rf
	return yaml.Unmarshal(c, p)
}

func (p *plugin) Generate() (resmap.ResMap, error) {
	var buf bytes.Buffer
	temp := template.Must(template.New("tmpl").Parse(CpuProcess))
	err := temp.Execute(&buf, p)
	if err != nil {
		return nil, err
	}
	return p.rf.NewResMapFromBytes(buf.Bytes())
}

func (p *plugin) Transform(m resmap.ResMap) error {
	return nil
}

// language=YAML
const CpuProcess = `
apiVersion: v1
kind: ServiceAccount
metadata:
  name: {{.ProcessName}}-autoscaler-sa
  namespace: processing

---

# + several other resources
`

The error I get:

Error: accumulating resources: recursed accumulation of path '../base': accumulating resources: recursed accumulation of path 'processes': accumulating resources: recursed accumulation of path 'cars': plugin myProject/k8s/kustomize/plugin/someteam.example.com/v1/processgenerator/ProcessGenerator fails to load: plugin: not implemented

I tried to created the .so file, did not help.

Can you provide a full working example of a custom Go plugin and a project that use it ?
I found this PR which seems to be related #1508

@oboukili
Copy link

I think the problem is that you specify the version (gvk) in your 3 levels path, you should get rid of the v1 and try again
(also I think it was a typo, but you need to have the compiled ProcessGenerator.so shared object within that path)

your path should be: myProject/k8s/kustomize/plugin/someteam.example.com/processgenerator/ProcessGenerator.so

Within your generator instanciation file:

apiVersion: someteam.example.com
kind: ProcessGenerator
...

@snarlysodboxer
Copy link

@oboukili I'm having the same problem since upgrading to kustomize API version 3.3.1 (CLI version 3.2.3), and removing the v1 in the gvk does not fix or change the problem. Also, having v1 worked just fine as of kustomize version 3.2.0. Of course this requires a generator config like:

apiVersion: someteam.example.com/v1
kind: ProcessGenerator
...

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 21, 2020
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Feb 20, 2020
@fejta-bot
Copy link

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

@k8s-ci-robot
Copy link
Contributor

@fejta-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.
Projects
None yet
Development

No branches or pull requests

5 participants