-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add FieldRef support #8126
Conversation
There was a problem hiding this 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
(inconfig-features
)- When that flag is enabled, a Knative Service can specify
spec.template.spec.containers[].env[].valueFrom.fieldRef
andspec.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 tokubernetes
. Should the flag in the code also be scoped? Right now it is calledKubernetesFieldRef
but since the code is specific to the implementation, wouldn't justFieldRef
be cleaner?Next
- Add E2E tests
- Add documentation
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.
/ping |
There was a problem hiding this 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 { |
There was a problem hiding this comment.
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) != "" { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
There was a problem hiding this 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?
The following is the coverage report on the affected files.
|
There was a problem hiding this 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 { |
There was a problem hiding this comment.
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
There was a problem hiding this 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", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FieldPath: "status.IP", | |
FieldPath: "status.hostIP", |
Name: "NODE_IP", | ||
ValueFrom: &corev1.EnvVarSource{ | ||
FieldRef: &corev1.ObjectFieldSelector{ | ||
FieldPath: "status.IP", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FieldPath: "status.IP", | |
FieldPath: "status.hostIP", |
[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 |
/hold cancel |
Addresses part of #4190
Proposed Changes
kubernetes/field-ref
(inconfig-features
)spec.template.spec.containers[].env[].valueFrom.fieldRef
andspec.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 tokubernetes
. Should the flag in the code also be scoped? Right now it is calledKubernetesFieldRef
but since the code is specific to the implementation, wouldn't justFieldRef
be cleaner?Next
/assign @dprotaso @mattmoor