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

Bug 1880902: automatically set the dnsPolicy with ClusterFirstWithHostNet when endpoint publishing strategy type is set to hostnetwork #492

Merged
merged 1 commit into from Nov 30, 2020

Conversation

miheer
Copy link
Contributor

@miheer miheer commented Nov 17, 2020

Bug 1880902 - If the endpoint publishing strategy type is set to hostnetwork then
we should automatically set the dnsPolicy with ClusterFirstWithHostNet.

@miheer miheer changed the title Bug 1880902 : automatically set the dnsPolicy with ClusterFirstWithHostNet when endpoint publishing strategy type is set to hostnetwork [WIP] Bug 1880902 : automatically set the dnsPolicy with ClusterFirstWithHostNet when endpoint publishing strategy type is set to hostnetwork Nov 17, 2020
@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 17, 2020
@Miciah
Copy link
Contributor

Miciah commented Nov 17, 2020

We should add a unit test in TestDeploymentConfigChanged. Also, we probably should add deployment.Spec.Template.Spec.DNSPolicy = corev1.DNSClusterFirst for the non-HostNetworking case so we always set an explicit policy, which will prevent the comparison in deploymentConfigChanged from getting confused when the API sets a default value.

@miheer miheer force-pushed the dnsPolicy branch 5 times, most recently from 5ea5f77 to 8a80513 Compare November 18, 2020 03:33
@miheer miheer changed the title [WIP] Bug 1880902 : automatically set the dnsPolicy with ClusterFirstWithHostNet when endpoint publishing strategy type is set to hostnetwork Bug 1880902 : automatically set the dnsPolicy with ClusterFirstWithHostNet when endpoint publishing strategy type is set to hostnetwork Nov 18, 2020
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 18, 2020
@miheer
Copy link
Contributor Author

miheer commented Nov 18, 2020

@Miciah PTAL

Copy link
Contributor

@sgreene570 sgreene570 left a comment

Choose a reason for hiding this comment

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

some small comments

@@ -38,6 +38,8 @@ func checkDeploymentHasEnvVar(t *testing.T, deployment *appsv1.Deployment, name
actualValue string
foundValue bool
)
//dnsPolicy := deployment.Spec.Template.Spec.DNSPolicy
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this comment necessary?

@@ -229,6 +231,10 @@ func TestDesiredRouterDeployment(t *testing.T) {
t.Error("expected host network to be false")
}

if deployment.Spec.Template.Spec.DNSPolicy != corev1.DNSClusterFirst {
t.Errorf("expected dnsPolicy to be #{corev1.DNSClusterFirst}")
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's make the new t.Errorf(...) calls more verbose somehow.
ie:

Suggested change
t.Errorf("expected dnsPolicy to be #{corev1.DNSClusterFirst}")
t.Errorf("expected dnsPolicy to be %q, got %q", corev1.DNSClusterFirst, deployment.Spec.Template.Spec.DNSPolicy)

@@ -901,6 +930,7 @@ func TestDeploymentConfigChanged(t *testing.T) {
},
},
Spec: corev1.PodSpec{
DNSPolicy: corev1.DNSClusterFirstWithHostNet,
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make more sense to set the test deployment's DNSPolicy to corev1.DNSClusterFirst since that's the API defaulted value (and then mutate that value to corev1.DNSClusterFirstWithHostNet in the new test cases)?

@miheer
Copy link
Contributor Author

miheer commented Nov 23, 2020

After the changes -> Unit tests are passing

[miheer@miheer cluster-ingress-operator]$ GO111MODULE=on go test -v -run TestDesiredRouterDeployment ./pkg/operator/controller/ingress/
=== RUN TestDesiredRouterDeployment
--- PASS: TestDesiredRouterDeployment (0.01s)
PASS
ok github.com/openshift/cluster-ingress-operator/pkg/operator/controller/ingress 0.017s
[miheer@miheer cluster-ingress-operator]$ GO111MODULE=on go test -v -run TestDeploymentConfigChanged ./pkg/operator/controller/ingress/
=== RUN TestDeploymentConfigChanged
--- PASS: TestDeploymentConfigChanged (0.01s)
PASS
ok github.com/openshift/cluster-ingress-operator/pkg/operator/controller/ingress (cached)
[miheer@miheer cluster-ingress-operator]$

},

{
description: "if dnsPolicy is not changed",
Copy link
Contributor

Choose a reason for hiding this comment

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

the descriptions for the 2 test cases you added are inaccurate, I believe

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh yes I will add them...just switched the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -229,6 +229,10 @@ func TestDesiredRouterDeployment(t *testing.T) {
t.Error("expected host network to be false")
}

if deployment.Spec.Template.Spec.DNSPolicy != corev1.DNSClusterFirst {
t.Errorf("expected dnsPolicy to be %q, got %q", corev1.DNSClusterFirst, deployment.Spec.Template.Spec.DNSPolicy)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
t.Errorf("expected dnsPolicy to be %q, got %q", corev1.DNSClusterFirst, deployment.Spec.Template.Spec.DNSPolicy)
t.Errorf("expected dnsPolicy to be %s, got %s", corev1.DNSClusterFirst, deployment.Spec.Template.Spec.DNSPolicy)

@@ -307,6 +311,9 @@ func TestDesiredRouterDeployment(t *testing.T) {
if deployment.Spec.Template.Spec.HostNetwork != false {
t.Error("expected host network to be false")
}
if deployment.Spec.Template.Spec.DNSPolicy != corev1.DNSClusterFirst {
t.Errorf("expected dnsPolicy to be #{corev1.DNSClusterFirst}")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
t.Errorf("expected dnsPolicy to be #{corev1.DNSClusterFirst}")
t.Errorf("expected dnsPolicy to be %s, got %s", corev1.DNSClusterFirst, deployment.Spec.Template.Spec.DNSPolicy)

@@ -459,6 +466,11 @@ func TestDesiredRouterDeployment(t *testing.T) {
if deployment.Spec.Template.Spec.HostNetwork != true {
t.Error("expected host network to be true")
}

if deployment.Spec.Template.Spec.DNSPolicy != corev1.DNSClusterFirstWithHostNet {
t.Errorf("expected dnsPolicy to be #{corev1.DNSClusterFirstWithHostNet}")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
t.Errorf("expected dnsPolicy to be #{corev1.DNSClusterFirstWithHostNet}")
t.Errorf("expected dnsPolicy to be %s, got %s", corev1.DNSClusterFirstWithHostNet, deployment.Spec.Template.Spec.DNSPolicy)

@@ -875,6 +887,21 @@ func TestDeploymentConfigChanged(t *testing.T) {
},
expect: true,
},
{
description: "if dnsPolicy is not changed",
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually I think this case is covered by the "if nothing changes" test.

Comment on lines 308 to 312
t.Error("expected host network to be false")
t.Errorf("expected dnsPolicy to be %s, got %s", corev1.DNSClusterFirst, deployment.Spec.Template.Spec.DNSPolicy)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please revert this change.

… network then

we should automatically set the dnsPolicy with ClusterFirstWithHostNet.
@Miciah
Copy link
Contributor

Miciah commented Nov 30, 2020

/retitle Bug 1880902: automatically set the dnsPolicy with ClusterFirstWithHostNet when endpoint publishing strategy type is set to hostnetwork
/lgtm
Thanks!

@openshift-ci-robot openshift-ci-robot changed the title Bug 1880902 : automatically set the dnsPolicy with ClusterFirstWithHostNet when endpoint publishing strategy type is set to hostnetwork Bug 1880902: automatically set the dnsPolicy with ClusterFirstWithHostNet when endpoint publishing strategy type is set to hostnetwork Nov 30, 2020
@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Nov 30, 2020
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Miciah, miheer

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

@openshift-ci-robot openshift-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. bugzilla/severity-high Referenced Bugzilla bug's severity is high for the branch this PR is targeting. labels Nov 30, 2020
@openshift-ci-robot
Copy link
Contributor

@miheer: This pull request references Bugzilla bug 1880902, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.7.0) matches configured target release for branch (4.7.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

Bug 1880902: automatically set the dnsPolicy with ClusterFirstWithHostNet when endpoint publishing strategy type is set to hostnetwork

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.

@openshift-ci-robot openshift-ci-robot added the bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. label Nov 30, 2020
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

1 similar comment
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot openshift-merge-robot merged commit 86adacb into openshift:master Nov 30, 2020
@openshift-ci-robot
Copy link
Contributor

@miheer: All pull requests linked via external trackers have merged:

Bugzilla bug 1880902 has been moved to the MODIFIED state.

In response to this:

Bug 1880902: automatically set the dnsPolicy with ClusterFirstWithHostNet when endpoint publishing strategy type is set to hostnetwork

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.

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. bugzilla/severity-high Referenced Bugzilla bug's severity is high for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants