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

added condition for the case when user try to enable addons without kubernetes #13508

Closed
wants to merge 1 commit into from

Conversation

NikhilSharmaWe
Copy link
Member

@NikhilSharmaWe NikhilSharmaWe commented Jan 28, 2022

Fixes #13487

  • When user try to enable addons with --no-kubernetes=true an output should be logged informing that it is not possible to enable addons with --no-kubernetes passed. This PR works on logging that output.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jan 28, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: NikhilSharmaWe
To complete the pull request process, please assign medyagh after the PR has been reviewed.
You can assign the PR to them by writing /assign @medyagh in a comment when ready.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@minikube-bot
Copy link
Collaborator

Can one of the admins verify this patch?

@NikhilSharmaWe
Copy link
Member Author

NikhilSharmaWe commented Jan 28, 2022

@spowelljr and @SilkeDH is my thinking correct here for adding the improvement.

If yes,

  • An error Error: cmd/minikube/cmd/start.go:1134:1: cyclomatic complexity 31 of func validateFlags is high (> 30) (gocyclo) is occuring. How can we increase the cyclomatic complexity or what is correct way to deal with it ?

@spowelljr
Copy link
Member

You have to move the logic you added out to a function to keep the cyclomatic complexity low.

Also, this PR is not catching the case if the user starts minikube and then run minikube addons enable <addon>.

Copy link
Member

@medyagh medyagh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for this PR just a lint comment
and plz paste the output the PR before and after this PR

@@ -1236,6 +1236,10 @@ func validateFlags(cmd *cobra.Command, drvName string) {
exit.Message(reason.Usage, "Sorry, please set the --output flag to one of the following valid options: [text,json]")
}

if viper.GetStringSlice(config.AddonListFlag) != nil && viper.GetBool(noKubernetes) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider adding it to a helper func to fix the lint error "cyclomatic complexity 31"

helper could be caled
validateNoAddonsForNoKubernetes(config...)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@medyagh

  • Is the function validateNoAddonsForNoKubernetes() correctly added ?
  • I have called func validateNoAddonsForNoKubernetes() inside the func provisionWithDriver(), func validateFlags() was also called here, so is it a correct place to call it ?

@NikhilSharmaWe
Copy link
Member Author

NikhilSharmaWe commented Jan 29, 2022

@spowelljr I am not able to understand your point when you say :

  • Also, this PR is not catching the case if the user starts minikube and then run minikube addons enable <addon>.

Could you explain me that what case actually we have tackled in this PR till now and how can we deal with the other case you have mentioned in this comment ?

@spowelljr
Copy link
Member

@spowelljr I am not able to understand your point when you say :

  • Also, this PR is not catching the case if the user starts minikube and then run minikube addons enable <addon>.

Could you explain me that what case actually we have tackled in this PR till now and how can we deal with the other case you have mentioned in this comment ?

Right now you're checking the case where the user runs:

minikube start --addons metallb

But also need to check for the case where user starts minikube and then enables the addon after:

minikube start
minikube addons enable metallb

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Feb 1, 2022
@NikhilSharmaWe
Copy link
Member Author

@spowelljr

  • You suggested in this comment of yours that use function config.Load() to find out that --no-kubernetes has been set or not. Function config.Load() return value of type ClusterConfig and in this type I am not able to find out how to figure out whether --no-kubernetes has been set or not.

  • I have done something different here, could you please review the method I have followed.

@@ -40,6 +40,9 @@ var addonsEnableCmd = &cobra.Command{
if len(args) != 1 {
exit.Message(reason.Usage, "usage: minikube addons enable ADDON_NAME")
}
if ClusterFlagValue() == constants.NoKubernetesVersion {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ClusterFlagValue() returns the profile, so it doesn't make any sense to compare that against a Kubernetes version.

@@ -1652,3 +1653,9 @@ func exitGuestProvision(err error) {
}
exit.Error(reason.GuestProvision, "error provisioning guest", err)
}

func validateNoAddonsForNoKubernetes() {
if viper.GetStringSlice(config.AddonListFlag) != nil && viper.GetBool(noKubernetes) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

viper.GetStringSlice(config.AddonListFlag) isn't nil when no addons flag is passed, try running minikube start --no-kubernetes yourself.

@spowelljr
Copy link
Member

@spowelljr

  • You suggested in this comment of yours that use function config.Load() to find out that --no-kubernetes has been set or not. Function config.Load() return value of type ClusterConfig and in this type I am not able to find out how to figure out whether --no-kubernetes has been set or not.
  • I have done something different here, could you please review the method I have followed.

ClusterConfig.KubernetesConfig.KubernetesVersion is set to constants.NoKubernetesVersion to indicate that --no-kubernetes is set.

@NikhilSharmaWe
Copy link
Member Author

NikhilSharmaWe commented Feb 5, 2022

@spowelljr and @medyagh

Do these changes solves the issue occurring before ? Please inform.

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/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 May 8, 2022
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/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 Jun 7, 2022
@@ -40,6 +40,11 @@ var addonsEnableCmd = &cobra.Command{
if len(args) != 1 {
exit.Message(reason.Usage, "usage: minikube addons enable ADDON_NAME")
}
if ClusterConfig, err := config.Load(ClusterFlagValue()); err == nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ClusterConfig, err := config.Load(ClusterFlagValue()); err == nil {
if clusterConfig, err := config.Load(ClusterFlagValue()); err == nil {

As per Go naming conventions

@@ -40,6 +40,11 @@ var addonsEnableCmd = &cobra.Command{
if len(args) != 1 {
exit.Message(reason.Usage, "usage: minikube addons enable ADDON_NAME")
}
if ClusterConfig, err := config.Load(ClusterFlagValue()); err == nil {
if ClusterConfig.KubernetesConfig.KubernetesVersion == constants.NoKubernetesVersion {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ClusterConfig.KubernetesConfig.KubernetesVersion == constants.NoKubernetesVersion {
if clusterConfig.KubernetesConfig.KubernetesVersion == constants.NoKubernetesVersion {

@@ -1652,3 +1653,11 @@ func exitGuestProvision(err error) {
}
exit.Error(reason.GuestProvision, "error provisioning guest", err)
}

func validateNoAddonsForNoKubernetes() {
if ClusterConfig, err := config.Load(ClusterFlagValue()); err == nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ClusterConfig, err := config.Load(ClusterFlagValue()); err == nil {
if clusterConfig, err := config.Load(ClusterFlagValue()); err == nil {


func validateNoAddonsForNoKubernetes() {
if ClusterConfig, err := config.Load(ClusterFlagValue()); err == nil {
if ClusterConfig.KubernetesConfig.KubernetesVersion == constants.NoKubernetesVersion {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ClusterConfig.KubernetesConfig.KubernetesVersion == constants.NoKubernetesVersion {
if clusterConfig.KubernetesConfig.KubernetesVersion == constants.NoKubernetesVersion {

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue or PR with /reopen
  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close

@k8s-ci-robot
Copy link
Contributor

@k8s-triage-robot: Closed this PR.

In response to this:

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue or PR with /reopen
  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/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
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Output message if user tries to enable addons with --no-kubernetes
6 participants