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

Manager Flag Error: flag provided but not defined: -config #2918

Closed
nikfot opened this issue Sep 9, 2022 · 5 comments
Closed

Manager Flag Error: flag provided but not defined: -config #2918

nikfot opened this issue Sep 9, 2022 · 5 comments
Labels
kind/bug Categorizes issue or PR as related to a bug. triage/needs-information Indicates an issue needs more information in order to work on it.

Comments

@nikfot
Copy link

nikfot commented Sep 9, 2022

What broke? What's expected?

The flag --config is applied in manager config patch but does not exist in the flag declaration inside main.go.

Reproducing this issue

If you leave this uncommented in config/default/kustomization.yaml :

# Mount the controller config file for loading manager configurations
# through a ComponentConfig type
- manager_config_patch.yaml

and it gets patched, then when deploying

make deploy IMG=mycontroller-image:latest

The pod stays in crashloopbackoff state with this log:

kubectl logs -f test-controller-manager-6cd4b6966b-kw245                                                                                                          
flag provided but not defined: -config
Usage of /manager:
  -health-probe-bind-address string
    	The address the probe endpoint binds to. (default ":8081")
  -kubeconfig string
    	Paths to a kubeconfig. Only required if out-of-cluster.
  -leader-elect
    	Enable leader election for controller manager. Enabling this will ensure there is only one active controller manager.
  -metrics-bind-address string
    	The address the metric endpoint binds to. (default ":8080")
  -zap-devel
    	Development Mode defaults(encoder=consoleEncoder,logLevel=Debug,stackTraceLevel=Warn). Production Mode defaults(encoder=jsonEncoder,logLevel=Info,stackTraceLevel=Error) (default true)
  -zap-encoder value
    	Zap log encoding (one of 'json' or 'console')
  -zap-log-level value
    	Zap Level to configure the verbosity of logging. Can be one of 'debug', 'info', 'error', or any integer value > 0 which corresponds to custom debug levels of increasing verbosity
  -zap-stacktrace-level value
    	Zap Level at and above which stacktraces are captured (one of 'info', 'error', 'panic').
  -zap-time-encoding value
    	Zap time encoding (one of 'epoch', 'millis', 'nano', 'iso8601', 'rfc3339' or 'rfc3339nano'). Defaults to 'epoch'.

By taking a look into main, I can see those flags get parsed:

	flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
	flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
	flag.BoolVar(&enableLeaderElection, "leader-elect", false,
		"Enable leader election for controller manager. "+
			"Enabling this will ensure there is only one active controller manager.")
	opts := zap.Options{
		Development: true,
	}
	opts.BindFlags(flag.CommandLine)
	flag.Parse()

But no --config flag.

It can be easily resolved by commenting out the patch. But I am opening the issue in case it causes confusion to someone.

KubeBuilder (CLI) Version

Version: main.version{KubeBuilderVersion:"v3.6.0", KubernetesVendor:"unknown", GitCommit:"f20414648f1851ae97997f4a5f8eb4329f450f6d", BuildDate:"2022-08-24T11:13:19Z", GoOs:"linux", GoArch:"amd64"}

PROJECT version

3

Plugin versions

layout:
- go.kubebuilder.io/v3

Other versions

Go Version

go version                                                                                                                                                        [~]
go version go1.19 linux/amd64

go mod:

go 1.18

require (
	github.com/onsi/ginkgo v1.16.5
	github.com/onsi/gomega v1.18.1
	k8s.io/api v0.24.0
	k8s.io/apimachinery v0.24.0
	k8s.io/client-go v0.24.0
	sigs.k8s.io/controller-runtime v0.12.1
)

Kubectl Version

kubectl version                                                                                                                                                 ⏎ [~]
Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.5", GitCommit:"e6503f8d8f769ace2f338794c914a96fc335df0f", GitTreeState:"clean", BuildDate:"2020-06-26T03:47:41Z", GoVersion:"go1.13.9", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"24", GitVersion:"v1.24.3", GitCommit:"aef86a93758dc3cb2c658dd9657ab4ad4afc21cb", GitTreeState:"clean", BuildDate:"2022-07-13T14:23:26Z", GoVersion:"go1.18.3", Compiler:"gc", Platform:"linux/amd64"}

Extra Labels

No response

@nikfot nikfot added the kind/bug Categorizes issue or PR as related to a bug. label Sep 9, 2022
@camilamacedo86
Copy link
Member

Hi @nikfot,

Did you follow the tutorial and enable the component config (https://book.kubebuilder.io/component-config-tutorial/tutorial.html) to be able to use it?

Also, you probably did not scaffold the project with version 3.6.0. Am I right? Note that the we had a bug fix to not scaffold the component config manifest without use the flag to properly init the project with, see: operator-framework/operator-sdk#5884

@camilamacedo86 camilamacedo86 added the triage/needs-information Indicates an issue needs more information in order to work on it. label Sep 10, 2022
@nikfot
Copy link
Author

nikfot commented Sep 12, 2022

Hi @camilamacedo86 ,
you're right in the first one. In the second one, I now use version 3.6.0. I am not sure if I updated the version during the process and in between commits. I would say I didn't.

@camilamacedo86
Copy link
Member

camilamacedo86 commented Sep 12, 2022

HI @nikfot,

You need to follow the tutorial and change your scaffold to work with.
Note that the bug here is that the tool was scaffolding filles that should not because by default this option is NOT enabled.

Then, if you scaffold the project with previous versions or 3.6.0 you must follow the tutorial to enable this feature in your project. (https://book.kubebuilder.io/component-config-tutorial/tutorial.html), If you create the project with old versions then you have scaffold files related to it but you might not have all of them. So, just check the tutorial and ensure that you properly enable the feature + have the scaffolds update as described in the steps to do that manually.

On top of that, please ensure that you check the fix as well: #2778

@camilamacedo86
Copy link
Member

I am closing this one as sorted out.
If you see that you are still unable to achieve the goal, please open a new issue and provide the link for your project/repo as the steps are done so we are able to reproduce and check out how can we help you with.

Thank you.

@nikfot
Copy link
Author

nikfot commented Sep 12, 2022

Thanks @camilamacedo86 for the quick answers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. triage/needs-information Indicates an issue needs more information in order to work on it.
Projects
None yet
Development

No branches or pull requests

2 participants