Skip to content
This repository was archived by the owner on Jun 24, 2020. It is now read-only.

Conversation

@aliok
Copy link
Member

@aliok aliok commented Feb 12, 2020

Fixes #292

Proposed Changes

  • Backwards compatible change
  • Only use KUBECONFIG if the command line argument is empty

Release Note

NONE

Same PR for eventing operator: knative/eventing-operator#100

@googlebot googlebot added the cla: yes Author(s) signed a CLA. label Feb 12, 2020
@aliok aliok requested a review from houshengbo February 12, 2020 10:57
Copy link
Contributor

@knative-prow-robot knative-prow-robot left a comment

Choose a reason for hiding this comment

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

@aliok: 0 warnings.

Details

In response to this:

Fixes #292

Proposed Changes

  • Backwards compatible change
  • Only use KUBECONFIG if the command line argument is empty

Release Note

NONE

Same PR for eventing operator: knative/eventing-operator#100

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.

@knative-prow-robot
Copy link
Contributor

Hi @aliok. Thanks for your PR.

I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

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.

recursive = flag.Bool("recursive", false, "If filename is a directory, process all manifests recursively")
MasterURL = flag.String("master", "", "The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.")
Kubeconfig = flag.String("kubeconfig", "", "Path to a kubeconfig. Only required if out-of-cluster.")
Kubeconfig = flag.String("kubeconfig", os.Getenv("KUBECONFIG"), "Path to a kubeconfig. Only required if out-of-cluster.")
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we actually remove these altogether? They should come via sharedmain anyway, I think? (modulo recursive)

Choose a reason for hiding this comment

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

How can we access these arguments from sharedmain?

config, err := mf.NewManifest(filepath.Join(koDataDir, "knative-serving/"), *recursive, cfg)

To create Manifest, we need the cfg. The cfg is created by

cfg, err := clientcmd.BuildConfigFromFlags(*MasterURL, *Kubeconfig)

so we need MasterURL and Kubeconfig. How can we access them in sharedmain?

Copy link
Contributor

Choose a reason for hiding this comment

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

You're right indeed, we can't reuse them cause they are captured in MainWithConfig.

I'd propose to make these flags package local (lowercase), use the plain Main function in our cmd/manager/main.go and reuse sharedmain.GetConfig(*masterURL, *kubeconfig) here locally. That function does all the defaulting needed by all controllers.

Choose a reason for hiding this comment

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

Is it sharedmain.GetConfig("", "")?

Copy link
Contributor

Choose a reason for hiding this comment

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

well, if you want to keep supporting the flags you gotta pass them in.

Copy link
Member Author

Choose a reason for hiding this comment

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

@markusthoemmes I made some changes.

Copy link
Contributor

@markusthoemmes markusthoemmes left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

/hold

for the nit. Feel free to unhold if you don't want to fix that.

MasterURL = flag.String("master", "", "The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.")
Kubeconfig = flag.String("kubeconfig", "", "Path to a kubeconfig. Only required if out-of-cluster.")
masterURL = flag.String("master", "", "The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.")
kubeconfig = flag.String("kubeconfig", os.Getenv("KUBECONFIG"), "Path to a kubeconfig. Only required if out-of-cluster.")
Copy link
Contributor

Choose a reason for hiding this comment

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

The Getenv call is no longer needed as the GetConfig call below does that defaulting already.

Copy link
Member Author

Choose a reason for hiding this comment

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

Right! Thanks for the heads up.

@aliok
Copy link
Member Author

aliok commented Feb 13, 2020

Squashed and ready for final review

@aliok
Copy link
Member Author

aliok commented Feb 13, 2020

for the nit. Feel free to unhold if you don't want to fix that.

I can't. I lack permissions :)

Copy link
Contributor

@markusthoemmes markusthoemmes left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve
/hold cancel

@aliok
Copy link
Member Author

aliok commented Feb 13, 2020

oh man this failed :(

flag redefined: master

Can't redefine a flag. We either need to make the flags in sharedmain exposed or do some hack around reading the same flag again in our controller.

@markusthoemmes wdyt?

@markusthoemmes
Copy link
Contributor

Dang. For this PR I'd roll back the change to the "normal" Main function and use the sharedmain.GetConfig helper in main.go as well. That'll land your initial reason to open the PR in the first place.

We can then discuss what to do with the rest.

@aliok
Copy link
Member Author

aliok commented Feb 13, 2020

/retest

@knative-prow-robot
Copy link
Contributor

@aliok: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

Details

In response to this:

/retest

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.

@aliok
Copy link
Member Author

aliok commented Feb 13, 2020

Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

oh boy.
cc @markusthoemmes

@markusthoemmes
Copy link
Contributor

/ok-to-test

Copy link
Contributor

@markusthoemmes markusthoemmes left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

Copy link

@houshengbo houshengbo left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aliok, houshengbo, markusthoemmes

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

The pull request process is described here

Details 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

@knative-prow-robot knative-prow-robot merged commit a4d4f70 into knative:master Feb 13, 2020
@aliok aliok deleted the read-kubeconfig-env-var branch February 14, 2020 07:14
houshengbo pushed a commit to houshengbo/serving-operator that referenced this pull request Feb 17, 2020
houshengbo pushed a commit to houshengbo/serving-operator that referenced this pull request Feb 17, 2020
knative-prow-robot pushed a commit that referenced this pull request Feb 18, 2020
* Support reading KubeConfig from KUBECONFIG env var (#293)

* Add upgrade tests into the e2e-tests-latest-serving (#286)

* Add upgrade tests into the e2e-tests-latest-serving

This PR adds the tests to verify the correct number and names of knative serving
deployments.

The test tag postupgrade is added, marking the tests to run after upgrade to the
latest HEAD of operator, with the latest generated manifest of knative serving.

* Install the latest release of the operator and then upgrade

* Split the long functions and rename the common package

* Refactor the PR based on the comments

* Update the library from jcrossley3/manifestival to manifestival

* Update pkg/reconciler/knativeserving/common/gateway.go

please fix

Co-Authored-By: Matt Moore <[email protected]>

Co-authored-by: Ali Ok <[email protected]>
Co-authored-by: Kenny Leung <[email protected]>
Co-authored-by: Matt Moore <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support reading KubeConfig from KUBECONFIG env var

5 participants