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

ExtraPortMapping Validation #3302

Closed

Conversation

aroradaman
Copy link
Member

Using random host ports for validating extra port mapping defined without host ports (default behaviour for provider docker and podman)

Fixes #3301

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jul 9, 2023
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 9, 2023
Comment on lines 161 to 169
// using default listen address
if portMapping.ListenAddress == "" {
portMapping.ListenAddress = wildcardAddrIPv4.String()
}

// using default protool
if portMapping.Protocol == "" {
portMapping.Protocol = PortMappingProtocolTCP
}
Copy link
Contributor

Choose a reason for hiding this comment

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

we have a default stage in pkg/internal/apis/config/default.go

Copy link
Contributor

Choose a reason for hiding this comment

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

point is we should default things in defaulting stage, not here in validation

Copy link
Member Author

Choose a reason for hiding this comment

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

should I remove defaults from pkg/cluster/internal/providers/<provider>/provision.go then and add it as part of SetDefaultsCluster in default stage .. defaulting with respect to provider ?

// do provider internal defaulting
// in a future API revision we will handle this at the API level and remove this
if pm.ListenAddress == "" {
switch clusterIPFamily {
case config.IPv4Family, config.DualStackFamily:
pm.ListenAddress = "0.0.0.0" // this is the docker default anyhow
case config.IPv6Family:
pm.ListenAddress = "::"
default:
return nil, errors.Errorf("unknown cluster IP family: %v", clusterIPFamily)
}
}
if string(pm.Protocol) == "" {
pm.Protocol = config.PortMappingProtocolTCP // TCP is the default
}

// do provider internal defaulting
// in a future API revision we will handle this at the API level and remove this
if pm.ListenAddress == "" {
switch clusterIPFamily {
case config.IPv4Family, config.DualStackFamily:
pm.ListenAddress = "0.0.0.0"
case config.IPv6Family:
pm.ListenAddress = "::"
default:
return nil, errors.Errorf("unknown cluster IP family: %v", clusterIPFamily)
}
}
if string(pm.Protocol) == "" {
pm.Protocol = config.PortMappingProtocolTCP // TCP is the default
}

@aojea
Copy link
Contributor

aojea commented Jul 14, 2023

/lgtm
/assign @BenTheElder

for final approval

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 14, 2023
@aojea
Copy link
Contributor

aojea commented Jul 14, 2023

/lgtm cancel

don't we need to modify ./pkg/internal/apis/config/default.go too?

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 14, 2023
@aroradaman
Copy link
Member Author

@aojea Is ./pkg/internal/apis/config/default.go generated by code-generator ?
If yes, can you point me to documentation for the same ?

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: aroradaman
Once this PR has been reviewed and has the lgtm label, please ask for approval from aojea. For more information see the Kubernetes Code Review Process.

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

@aroradaman aroradaman force-pushed the fix/extra-port-mapping branch 2 times, most recently from fb8fe10 to c5bc252 Compare July 14, 2023 15:28
Copy link
Member

@BenTheElder BenTheElder left a comment

Choose a reason for hiding this comment

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

I've been out sick and I'm going to need some more time to think about how to better structure this, but I don't think exporting all of these values is the answer.

Thanks for working on this problem!

@prahaladramji
Copy link

I've been out sick and I'm going to need some more time to think about how to better structure this, but I don't think exporting all of these values is the answer.

Thanks for working on this problem!

Just following up to find out what's the current thoughts on this PR, I'm looking for a resolution to #3301.

@BenTheElder Is the feedback more around the implementation details of this PR or is the above mentioned issue the desired behaviour of kind moving forward post v0.18.0?

@BenTheElder
Copy link
Member

I was hoping for a response to the existing comments before reviewing further.

Signed-off-by: Daman Arora <aroradaman@gmail.com>
Signed-off-by: Daman Arora <aroradaman@gmail.com>
@aroradaman
Copy link
Member Author

/retest

@prahaladramji
Copy link

@aroradaman is there anything I can help with here? Or is this a test that could pass with a retest?

@aroradaman
Copy link
Member Author

@prahaladramji I don't think retest would help here, and also the error is not related to this PR.

@BenTheElder do we still need pull-kind-e2e-kubernetes-1-24 given that it has already reached EOL. I also see pull-kind-e2e-kubernetes-1-28 to be missing.

@k8s-ci-robot
Copy link
Contributor

k8s-ci-robot commented Dec 26, 2023

@aroradaman: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-kind-e2e-kubernetes-1-24 6fa6758 link true /test pull-kind-e2e-kubernetes-1-24

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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. I understand the commands that are listed here.

@aroradaman
Copy link
Member Author

/test pull-kind-e2e-kubernetes-1-29

@aroradaman
Copy link
Member Author

ping @BenTheElder

@prahaladramji
Copy link

The 1 failing check seemes to be related to vagrant as part of the ci step and not related to this change.

A general look at that error seems like it could just be flakey vagrant step (potentially a retry may work). But if not, I'm happy to try and help look at fixing that step.

@k8s-ci-robot
Copy link
Contributor

PR needs rebase.

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.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 10, 2024
@aroradaman
Copy link
Member Author

/close in favor of #3513
cc. @prahaladramji

@aojea aojea closed this Feb 10, 2024
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/provider/docker Issues or PRs related to docker area/provider/podman Issues or PRs related to podman cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. 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.

A unique hostPort is not generated when using extraPortMappings without specifying hostPort.
5 participants