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 1842741: Fix serviceChanged and daemonsetConfigChanged #174

Conversation

Miciah
Copy link
Contributor

@Miciah Miciah commented Jun 2, 2020

serviceChanged: Fix session affinity, type

When comparing services to determine whether an update is required, treat implicit and explicit default values as equal.

Before this commit, the update logic would keep trying to revert the default value that the API set for the service's session affinity or type.

  • pkg/operator/controller/controller_dns_service.go (serviceChanged): Use the new cmpServiceAffinity and cmpServiceType functions so that two services are considered equal if the only difference between them is that one does not specify the session affinity or type and the other service has the default values.
    (cmpServiceAffinity, cmpServiceType): New function.
  • pkg/operator/controller/controller_dns_service_test.go: (TestDNSServiceChanged): Verify that serviceChanged returns false if the only mutation is that the session affinity or type has been updated from empty to the default value.

daemonsetConfigChanged: Fix for volume default mode

When comparing daemonsets to determine whether an update is required, treat implicit and explicit default values as equal.

Before this commit, the update logic would keep trying to revert the default value that the API set for a volume's default mode.

  • pkg/operator/controller/controller_dns_daemonset.go (daemonsetConfigChanged): Use the new cmpConfigMapVolumeSource and cmpSecretVolumeSource functions so that two daemonsets are considered equal if the only difference between them is that one does not specify a default mode value and the other daemonset specifies the default value.
    (volumeDefaultMode): New constant with the default mode that the API uses for configmap and secret volume sources.
    (cmpConfigMapVolumeSource, cmpSecretVolumeSource): New functions.
  • pkg/operator/controller/controller_dns_daemonset_test.go: (TestDaemonsetConfigChanged): Verify that daemonsetConfigChanged returns false if the only mutation is that a volume's default mode value has been updated from empty to the default value.

@openshift-ci-robot openshift-ci-robot added the bugzilla/severity-medium Referenced Bugzilla bug's severity is medium for the branch this PR is targeting. label Jun 2, 2020
@openshift-ci-robot
Copy link
Contributor

@Miciah: This pull request references Bugzilla bug 1842741, 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.6.0) matches configured target release for branch (4.6.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 1842741: Fix serviceChanged and daemonsetConfigChanged

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 Jun 2, 2020
@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 2, 2020
@Miciah Miciah force-pushed the BZ1842741-serviceChanged-fix-session-affinity-and-type-daemonsetConfigChanged-fix-volume-default-mode branch from c74be28 to 266a252 Compare June 2, 2020 02:51
if !cmp.Equal(a.Optional, b.Optional, cmpopts.EquateEmpty()) {
return false
}
return true
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: could condense lines 253-256 to return cmp.Equal(a.Optional, b.Optional, cmpopts.EquateEmpty())

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Stylistically, I prefer to follow the pattern consistently:

	if thing1 doesn't match {
		return false
	}
	if thing2 doesn't match {
		return false
	}
	// ...
	if thingn doesn't match {
		return false
	}
	return true

There is nothing special about thingn (in concrete terms, the Optional field), so I prefer not to deviate from the established pattern. Does that seem reasonable?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, it does. I see what you mean now!

if !cmp.Equal(a.Items, b.Items, cmpopts.EquateEmpty()) {
return false
}
aDefaultMode := int32(420)
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 sense to define a defaultMode := int32(420) literal somewhere, in the event the default mode were to change?

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 think it is extremely unlikely that the default mode would change because that seems like it would be a breaking API change. I could introduce a constant though. Would using the same constant for both secret volume sources and configmap volume sources make sense?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, my mistake. I think using a constant as you mentioned would make sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated. Thanks!

@Miciah Miciah force-pushed the BZ1842741-serviceChanged-fix-session-affinity-and-type-daemonsetConfigChanged-fix-volume-default-mode branch from 266a252 to d7e886e Compare June 5, 2020 18:03
@openshift-ci-robot
Copy link
Contributor

@Miciah: This pull request references Bugzilla bug 1842741, which is valid.

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

In response to this:

Bug 1842741: Fix serviceChanged and daemonsetConfigChanged

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 needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 20, 2020
When comparing services to determine whether an update is required, treat
implicit and explicit default values as equal.

Before this commit, the update logic would keep trying to revert the
default value that the API set for the service's session affinity or type.

This commit fixes part of bug 1842741.

https://bugzilla.redhat.com/show_bug.cgi?id=1842741

* pkg/operator/controller/controller_dns_service.go (serviceChanged): Use
the new cmpServiceAffinity and cmpServiceType functions so that two
services are considered equal if the only difference between them is that
one does not specify the session affinity or type and the other service has
the default values.
(cmpServiceAffinity, cmpServiceType): New function.
* pkg/operator/controller/controller_dns_service_test.go
(TestDNSServiceChanged): Verify that serviceChanged returns false if the
only mutation is that the session affinity or type has been updated from
empty to the default value.
@Miciah
Copy link
Contributor Author

Miciah commented Jun 21, 2020

Rebased.

@Miciah Miciah force-pushed the BZ1842741-serviceChanged-fix-session-affinity-and-type-daemonsetConfigChanged-fix-volume-default-mode branch from d7e886e to eb482f6 Compare June 21, 2020 05:45
@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 21, 2020
newVal := int32(0)
daemonset.Spec.Template.Spec.Volumes[1].Secret.DefaultMode = &newVal
},
expect: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

These 2 test cases cover the cmpSecretVolumeSource(...) function. Perhaps there should be 2 similar test cases for cmpConfigMapVolumeSource(...)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added. I also noticed that the index was wrong (it should be 0 rather than 1 for the config-volume volume), so I fixed the index on the existing test and added a host-path volume to make the list of volumes consistent with the actual manifest. Thanks!

When comparing daemonsets to determine whether an update is required, treat
implicit and explicit default values as equal.

Before this commit, the update logic would keep trying to revert the
default value that the API set for a volume's default mode.

This commit fixes part of bug 1842741.

https://bugzilla.redhat.com/show_bug.cgi?id=1842741

* pkg/operator/controller/controller_dns_daemonset.go
(daemonsetConfigChanged): Use the new cmpConfigMapVolumeSource and
cmpSecretVolumeSource functions so that two daemonsets are considered equal
if the only difference between them is that one does not specify a default
mode value and the other daemonset specifies the default value.
(volumeDefaultMode): New constant with the default mode that the API uses
for configmap and secret volume sources.
(cmpConfigMapVolumeSource, cmpSecretVolumeSource): New functions.
* pkg/operator/controller/controller_dns_daemonset_test.go
(TestDaemonsetConfigChanged): Verify that daemonsetConfigChanged returns
false if the only mutation is that a volume's default mode value has been
updated from empty to the default value.
@Miciah Miciah force-pushed the BZ1842741-serviceChanged-fix-session-affinity-and-type-daemonsetConfigChanged-fix-volume-default-mode branch from eb482f6 to 147d79a Compare July 8, 2020 04:04
@Miciah
Copy link
Contributor Author

Miciah commented Jul 8, 2020

/test e2e-aws

@sgreene570
Copy link
Contributor

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 8, 2020
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

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

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-merge-robot openshift-merge-robot merged commit 8f6e321 into openshift:master Jul 8, 2020
@openshift-ci-robot
Copy link
Contributor

@Miciah: All pull requests linked via external trackers have merged: openshift/cluster-dns-operator#174. Bugzilla bug 1842741 has been moved to the MODIFIED state.

In response to this:

Bug 1842741: Fix serviceChanged and daemonsetConfigChanged

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-medium Referenced Bugzilla bug's severity is medium 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

4 participants