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

Bug: not enough arguments in call to restmapper.NewShortcutExpander #319

Closed
very-doge-wow opened this issue Dec 19, 2023 · 7 comments
Closed

Comments

@very-doge-wow
Copy link

very-doge-wow commented Dec 19, 2023

I'm trying to use the library as specified in: https://github.com/werf/kubedog/blob/main/doc/usage.md#examples-of-using-trackers

However I always receive this error:

/go/pkg/mod/github.com/werf/[email protected]/pkg/kube/kube.go:402:48: not enough arguments in call to restmapper.NewShortcutExpander
have (*restmapper.DeferredDiscoveryRESTMapper, discovery.CachedDiscoveryInterface)
want (meta.RESTMapper, discovery.DiscoveryInterface, func(string))
/go/pkg/mod/github.com/werf/[email protected]/pkg/kube/kube_config_getter.go:134:53: not enough arguments in call to restmapper.NewShortcutExpander
have (*restmapper.DeferredDiscoveryRESTMapper, discovery.CachedDiscoveryInterface)
want (meta.RESTMapper, discovery.DiscoveryInterface, func(string)

This is my code:

// init kubedog to watch resources
err = kube.Init(kube.InitOptions{})
if err != nil {
	fmt.Fprintf(os.Stderr, "Unable to initialize kube: %s\n", err)
	os.Exit(1)
}

err = multitrack.Multitrack(
	kube.Kubernetes,
	multitrack.MultitrackSpecs{
		Deployments: []multitrack.MultitrackSpec{
			multitrack.MultitrackSpec{
				ResourceName: h.Configuration.ApplicationName,
				Namespace:    h.Configuration.Namespace,
			},
		},
	},
	multitrack.MultitrackOptions{},
)

if err != nil {
	log.Errorf("ERROR: resources have not reached ready state: %s", err)
	return err
}

I am using the most current version v0.11.0. Any help would be appreciated.

@very-doge-wow
Copy link
Author

very-doge-wow commented Dec 20, 2023

Seems to be because we use v0.29.0 of client-go and kubedog uses v0.26.2, so the signature of the function has changed. How often do you integrate updates of dependencies here?

@distorhead
Copy link
Member

Hi, thanks for the report!

I think we can arrange client-go upgrade asap during this week.

@distorhead
Copy link
Member

@very-doge-wow Hi!

Just updated client-go to 1.29 #320, check it out!

@very-doge-wow
Copy link
Author

Thanks, will try it after the holidays.

@very-doge-wow
Copy link
Author

Have tested and it works now, thanks. Still the question, how often do you integrate updates?

@very-doge-wow
Copy link
Author

I am also receiving the following warning, not sure how to fix this:

W0102 12:29:23.926279 59 reflector.go:462] pkg/mod/k8s.io/[email protected]/tools/cache/reflector.go:229: watch of *v1.Event ended with: an error on the server ("unable to decode an event from the watch stream: context canceled") has prevented the request from succeeding

Any advice? 🤔

@distorhead
Copy link
Member

how often do you integrate updates

@very-doge-wow Hi! As for your question: we are about to setup our periodical routine to update dependencies once in 3 or 4 weeks (security updates should be merged asap of course).

It is important to know that kubedog project being used by such projects as: werf/werf and werf/nelm, and sometimes some dependencies updates may be blocked by these projects, but we are currently on a way to cleanup some old stuff from werf and keep dependencies as fresh as possible.

W0102 12:29:23.926279 59 reflector.go:462] pkg/mod/k8s.io/[email protected]/tools/cache/reflector.go:229: watch of
*v1.Event ended with: an error on the server ("unable to decode an event from the watch stream: context canceled") has prevented the request from succeeding

This is just harmless warning from inside client-go internals, which is part of it normal operation. However if you want to suppress these messages see this logger initialization snippet:

func SilenceKlogV2(ctx context.Context) error {
	fs := flag.NewFlagSet("klog", flag.PanicOnError)
	klog_v2.InitFlags(fs)

	if err := fs.Set("logtostderr", "false"); err != nil {
		return err
	}
	if err := fs.Set("alsologtostderr", "false"); err != nil {
		return err
	}
	if err := fs.Set("stderrthreshold", "5"); err != nil {
		return err
	}

	// Suppress info and warnings from client-go reflector
	klog_v2.SetOutputBySeverity("INFO", ioutil.Discard)
	klog_v2.SetOutputBySeverity("WARNING", ioutil.Discard)
	klog_v2.SetOutputBySeverity("ERROR", ioutil.Discard)
	klog_v2.SetOutputBySeverity("FATAL", logboek.Context(ctx).ErrStream())

	return nil
}

func SilenceKlog(ctx context.Context) error {
	fs := flag.NewFlagSet("klog", flag.PanicOnError)
	klog.InitFlags(fs)

	if err := fs.Set("logtostderr", "false"); err != nil {
		return err
	}
	if err := fs.Set("alsologtostderr", "false"); err != nil {
		return err
	}
	if err := fs.Set("stderrthreshold", "5"); err != nil {
		return err
	}

	// Suppress info and warnings from client-go reflector
	klog.SetOutputBySeverity("INFO", ioutil.Discard)
	klog.SetOutputBySeverity("WARNING", ioutil.Discard)
	klog.SetOutputBySeverity("ERROR", ioutil.Discard)
	klog.SetOutputBySeverity("FATAL", logboek.Context(ctx).ErrStream())

	return nil
}

https://github.com/werf/kubedog/blob/main/cmd/kubedog/main.go#L72C13-L72C24

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

No branches or pull requests

2 participants