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 FieldRef support #8126

Merged
merged 1 commit into from
Jun 11, 2020
Merged

Conversation

JRBANCEL
Copy link
Contributor

Addresses part of #4190

Proposed Changes

  • Introduce a Feature Flag kubernetes/field-ref (in config-features)
  • When that flag is enabled, a Knative Service can specify spec.template.spec.containers[].env[].valueFrom.fieldRef and spec.template.spec.containers[].env[].valueFrom.resourceFieldRef

Open questions

I am not 100% happy with the naming and scoping. I think it makes sense to scope features to the specific platform: e.g. multi-container is not platform specific, therefore not scoped, kubernetes/field-ref is specific to Kubernetes, so scoped to kubernetes. Should the flag in the code also be scoped? Right now it is called KubernetesFieldRef but since the code is specific to the implementation, wouldn't just FieldRef be cleaner?

Next

  • Add E2E tests
  • Add documentation

/assign @dprotaso @mattmoor

@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label May 29, 2020
@knative-prow-robot knative-prow-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label May 29, 2020
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.

@JRBANCEL: 0 warnings.

In response to this:

Addresses part of #4190

Proposed Changes

  • Introduce a Feature Flag kubernetes/field-ref (in config-features)
  • When that flag is enabled, a Knative Service can specify spec.template.spec.containers[].env[].valueFrom.fieldRef and spec.template.spec.containers[].env[].valueFrom.resourceFieldRef

Open questions

I am not 100% happy with the naming and scoping. I think it makes sense to scope features to the specific platform: e.g. multi-container is not platform specific, therefore not scoped, kubernetes/field-ref is specific to Kubernetes, so scoped to kubernetes. Should the flag in the code also be scoped? Right now it is called KubernetesFieldRef but since the code is specific to the implementation, wouldn't just FieldRef be cleaner?

Next

  • Add E2E tests
  • Add documentation

/assign @dprotaso @mattmoor

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 area/API API objects and controllers label May 29, 2020
@evankanderson evankanderson removed their request for review June 2, 2020 17:04
@JRBANCEL
Copy link
Contributor Author

JRBANCEL commented Jun 3, 2020

/ping

Copy link
Contributor

@vagababov vagababov left a comment

Choose a reason for hiding this comment

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

/lint
Mostly looks good to me.

@@ -91,3 +128,16 @@ func TestFeaturesConfiguration(t *testing.T) {
})
}
}

// defaultWith returns the default *Feature patched with the provided *Features.
func defaultWith(p *Features) *Features {
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 pure evil
😈

pType := reflect.ValueOf(p).Elem()
fType := reflect.ValueOf(f).Elem()
for i := 0; i < pType.NumField(); i++ {
if pType.Field(i).Interface().(Flag) != "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we sure no other types of values will be added? This is test, so 🤷 , but stil.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can check the type assertion and fail but that doesn't help much compared to failing directly with a panic. It is for test only, I don't think we care.

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.

@vagababov: 0 warnings.

In response to this:

/lint
Mostly looks good to me.

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.

@JRBANCEL
Copy link
Contributor Author

JRBANCEL commented Jun 8, 2020

/ping @dprotaso @mattmoor

Copy link
Member

@mattmoor mattmoor left a comment

Choose a reason for hiding this comment

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

This generally LGTM. It needs a rebase, and not sure if @dprotaso has comments?

@knative-metrics-robot
Copy link

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

File Old Coverage New Coverage Delta
pkg/apis/serving/fieldmask.go 97.9% 97.9% 0.0
pkg/apis/serving/k8s_validation.go 99.2% 99.2% 0.0

Copy link
Member

@dprotaso dprotaso 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

Not going to block on the config map field formatting - hopefully we can come to a consensus before the release

if err := cm.Parse(data, asFlag("multi-container", &nc.MultiContainer)); err != nil {
if err := cm.Parse(data,
asFlag("multi-container", &nc.MultiContainer),
asFlag("kubernetes/field-ref", &nc.KubernetesFieldRef)); 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.

note: there's a discussion about the format of these fields

https://knative.slack.com/archives/CU9DGL4FM/p1591710914146300

@knative-prow-robot knative-prow-robot added lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jun 11, 2020
Copy link
Member

@dprotaso dprotaso left a comment

Choose a reason for hiding this comment

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

/hold
minor nit - drop if you want to do it in a later PR

Name: "NODE_IP",
ValueFrom: &corev1.EnvVarSource{
FieldRef: &corev1.ObjectFieldSelector{
FieldPath: "status.IP",
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
FieldPath: "status.IP",
FieldPath: "status.hostIP",

Name: "NODE_IP",
ValueFrom: &corev1.EnvVarSource{
FieldRef: &corev1.ObjectFieldSelector{
FieldPath: "status.IP",
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
FieldPath: "status.IP",
FieldPath: "status.hostIP",

@knative-prow-robot knative-prow-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 11, 2020
@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dprotaso, JRBANCEL

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

@dprotaso
Copy link
Member

/hold cancel

@knative-prow-robot knative-prow-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 11, 2020
@knative-prow-robot knative-prow-robot merged commit 7a6a278 into knative:master Jun 11, 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. area/API API objects and controllers cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants