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

Add support for envFrom and volumeMounts #393

Merged
merged 21 commits into from
Nov 6, 2019

Conversation

igsong
Copy link
Contributor

@igsong igsong commented Aug 28, 2019

Proposed Changes

To use NOT-YET supported expressions of ksvc, following flags, which can be set in service create or service update, are added.

  • Support envFrom expression. By giving the flag --env-from (config-map | secret):CONFIG_MAP_OR_SECRET_NAME, a config map or secret is embedded using envFrom. To unset, a - suffix can be used like --env or --label.
  • Support volumeMount expression. By giving the flag --volume-mount VOLUME_NAME=(config-map|secret):CONFIG_MAP_OR_SECRET_NAME@/mount/here, a config map or secret is mounted on the user-container. To unset, a - suffix can be used like --env or --label.

Unlike initial proposal, the support for serviceAccountName will be shown another PR and imagePullPolicy has removed because Knative Serving does not support the feature.

Release Note

NONE

/lint

@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Aug 28, 2019
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.

@igsong: 5 warnings.

In response to this:

Proposed Changes

To use NOT-YET supported expressions of ksvc, following flags, which can be set in service create or service update, are added.

  • Support envFrom expression. By giving the flag --env-from (config-map | secret):CONFIG_MAP_OR_SECRET_NAME, a config map or secret is embedded using envFrom. To unset, a - suffix can be used like --env or --label.
  • Support volumeMount expression. By giving the flag --volume-mount VOLUME_NAME=(config-map|secret):CONFIG_MAP_OR_SECRET_NAME@/mount/here, a config map or secret is mounted on the user-container. To unset, a - suffix can be used like --env or --label.
  • Support serviceAccountName expression. By giving the flag --service-account-name=SERVICE_ACCOUNT_NAME, a user can set a service account for a ksvc.
  • Support imagePullPolicy expression. By giving the flag --image-pull-policy=POLICY, a user can set a image pull policy for a ksvc. POLICY should be one of always, if-not-present, never or - which can be used for unsetting imagePullPolicy.

Release Note

NONE

/lint

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.

pkg/serving/config_changes.go Outdated Show resolved Hide resolved
pkg/serving/config_changes.go Outdated Show resolved Hide resolved
pkg/serving/config_changes.go Show resolved Hide resolved
pkg/serving/config_changes.go Outdated Show resolved Hide resolved
pkg/util/parsing_helper.go Outdated Show resolved Hide resolved
@knative-prow-robot knative-prow-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Aug 28, 2019
@knative-prow-robot
Copy link
Contributor

Hi @igsong. 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.

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 knative-prow-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Aug 28, 2019
@igsong
Copy link
Contributor Author

igsong commented Aug 28, 2019

/lint

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.

@igsong: 0 warnings.

In response to this:

/lint

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 knative-prow-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 29, 2019
Copy link
Contributor

@maximilien maximilien left a comment

Choose a reason for hiding this comment

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

/ok-to-test

@knative-prow-robot knative-prow-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Aug 29, 2019
@igsong
Copy link
Contributor Author

igsong commented Aug 29, 2019

/test pull-knative-client-build-tests

@navidshaikh
Copy link
Collaborator

Support imagePullPolicy expression. By giving the flag --image-pull-policy=POLICY, a user can set a image pull policy for a ksvc. POLICY should be one of always, if-not-present, never or - which can be used for unsetting imagePullPolicy.

We have lock-to-digest and no-lock-to-digest flags, which users can use to achieve desired state.

@igsong
Copy link
Contributor Author

igsong commented Aug 30, 2019

We have lock-to-digest and no-lock-to-digest flags, which users can use to achieve desired state.

Thank you for comments. But, I think that the lock-to-digest and no-lock-to-digest flags are different from image-pull-policy because image-pull-policy is a kind of caching policy of the docker image on each k8s worker node, while the lock-to-digest flag automatically alternates image to a digest form of image URL previously used when there is no image flag. Of course, when a user is using a static tag or a digest to specify an image, or lock-to-digest flag is set, image-pull-policy may be not so useful, but when using a dynamic tag with no-lock-to-digest, setting imagePullPolicy may be needed.

pkg/kn/commands/service/configuration_edit_flags.go Outdated Show resolved Hide resolved
pkg/serving/config_changes.go Outdated Show resolved Hide resolved
pkg/kn/commands/service/configuration_edit_flags.go Outdated Show resolved Hide resolved
pkg/serving/config_changes.go Outdated Show resolved Hide resolved
pkg/serving/config_changes.go Show resolved Hide resolved
pkg/serving/config_changes.go Outdated Show resolved Hide resolved
pkg/serving/config_changes.go Outdated Show resolved Hide resolved
}
}

for i := range volumeMounts {
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems like this code may not handle mounting the same secret (or whatever volume) at two different paths, or handling a message where the same secret (or whatever volume) was already mounted at two different paths. There are a lot of corner cases here.

I agree with the decision not to make the user handle all the minutae of the difference between volume mounts and volumes if they do not have to, though.

Copy link
Contributor Author

@igsong igsong Sep 4, 2019

Choose a reason for hiding this comment

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

OK, then I think that it would be better to have two flags instead of current one, like --volume-mount /mount/here=VOLUME_NAME and --volume VOLUME_NAME=(config-map|secret):CONFIG_MAP_OR_SECRET_NAME. How do you think of it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I split up the flag --volume-mount into --volume and --volume-mount to cope with the case that @sixolet mentioned

@igsong igsong requested a review from sixolet September 17, 2019 15:38
Copy link
Contributor

@maximilien maximilien left a comment

Choose a reason for hiding this comment

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

Wondering if there is a way to also include an integration test? Perhaps a modification to other tests that uses these features?

@maximilien
Copy link
Contributor

maximilien commented Sep 19, 2019

You might need to rebase:

pkg/kn/commands/service/service_create_test.go
pkg/kn/commands/service/service_update_test.go 

@navidshaikh
Copy link
Collaborator

@igsong : ping! let's rebase and get this in queue.

@igsong
Copy link
Contributor Author

igsong commented Oct 4, 2019

@igsong : ping! let's rebase and get this in queue.

I've rebased.

@maximilien
Copy link
Contributor

You might need to make sure and include the newly generated docs.

@igsong
Copy link
Contributor Author

igsong commented Nov 3, 2019

I've done to apply all the suggested and discussed changes.

One thing I want to notice is that OrderedMap is newly adopted to make behaviors caused by --volume and --mount deterministic.

@igsong igsong requested a review from rhuss November 3, 2019 18:44
Copy link
Contributor

@rhuss rhuss left a comment

Choose a reason for hiding this comment

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

Thanks a tons, looks really, really good !

I just started the review, but not yet finished. However there is one serious error which always occur for auto generated volume names (see below, ie.. a name must not contain a /). If you could sanitize the name before using as a volume name, that would be a good fix.

I will continue later, but wanted to already give you that partial review feedback.

docs/cmd/kn_service_create.md Outdated Show resolved Hide resolved
}

func generateVolumeName(path string) string {
return fmt.Sprintf("kn-managed-volume:%s", path)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is too simplistic, as you have to sanitize the path that it's a well-formed kubernetes identifier. As the path has to start with / (as you can only mount absolute paths) you will always get an invalid name here. Unfortunately, such things can be only detected in integration tests, not unit tests, as unit tests don't do any validation.

Also, I would either don't use a prefix or, if required e.g. when for auto-deleting volumes, then just use kn:, which is just shorter and easier to read when examing the k8s files.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've changed the part to use a sanitized path string + checksum of original path string without any prefix.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks, works for me now !

I'm going to go over the rest of the PR quickly and lets get it merged today so that we get it into 0.10.0 (to be released today). We can then fix any outstanding issues (or add some real integrations tests) later.

@knative-metrics-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-knative-client-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/kn/commands/service/configuration_edit_flags.go 83.9% 84.7% 0.9
pkg/serving/config_changes.go 82.3% 79.3% -3.0
pkg/util/orderedmap.go Do not exist 73.0%
pkg/util/parsing_helper.go 100.0% 95.7% -4.3

Copy link
Contributor

@rhuss rhuss left a comment

Choose a reason for hiding this comment

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

Thanks a lot for all your work (and especially for the comprehensive unit tests) and also for your patience with us reviewing it !

The PR looks good to merge and will be included in 0.10.0 (which by accident is released today ;-)

/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Nov 6, 2019
@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: igsong, rhuss

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

The pull request process is described 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

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 6, 2019
@rhuss
Copy link
Contributor

rhuss commented Nov 6, 2019

/retest

@rhuss
Copy link
Contributor

rhuss commented Nov 6, 2019

The CI test error is a strange beast. See slack channel for the discussion about it. Hopefully its only a hickup.

@navidshaikh
Copy link
Collaborator

/test pull-knative-client-integration-tests

@knative-prow-robot knative-prow-robot merged commit 9d759ca into knative:master Nov 6, 2019
coryrc pushed a commit to coryrc/client that referenced this pull request May 14, 2020
* Add more functions to shared gcs package

These functions are needed for flaky tests reporting, which will need to list n number of latest finished builds, generate some files and upload to gcs to be consumed by testgrid

* separate out prow, testgrid, and junit related functions
navidshaikh added a commit to navidshaikh/client that referenced this pull request Aug 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants