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

default resolution rule policy to the imagepolicy default #19766

Merged
merged 1 commit into from
Jul 17, 2018

Conversation

bparees
Copy link
Contributor

@bparees bparees commented May 18, 2018

fixes #19775

@openshift-ci-robot openshift-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels May 18, 2018
@bparees
Copy link
Contributor Author

bparees commented May 18, 2018

/hold

@smarterclayton i'm sure you had a good reason for doing this as you did but since the godoc says:

	// Policy controls whether resolution will happen if the rule doesn't match local names. This value
	// overrides the global image policy for all target resources.
	Policy ImageResolutionType

there seems to a a conflict between what as implemented (resolutionrule inherits the global default only if an execution rule covers it) and what the doc claims (resolutionrule inherits the global default).

So either we need to fix the doc or fix the behavior, can you help me understand the intent here?

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 18, 2018
@bparees
Copy link
Contributor Author

bparees commented May 19, 2018

actually there are two issues/questions w/ the original code:

  1. the policy defaulting was only being applied if no resolution rules were explicitly defined by the user
  2. the policy defaulting is only being applied to resolution rules that are covered by an execution rule

this PR changes both of those (defaults all resolution rules, does not look at execution rule coverage), but perhaps the right solution is to just fix (1) (apply defaulting to all resolution rules, but only if an execution rule covers them). @smarterclayton I need the reasoning behind the covering logic.

@bparees
Copy link
Contributor Author

bparees commented May 19, 2018

@GrahamDumpleton fyi

@liggitt
Copy link
Contributor

liggitt commented May 19, 2018

I think the current behavior stemmed from this: #15868 (comment)

@smarterclayton
Copy link
Contributor

smarterclayton commented May 19, 2018 via email

@bparees
Copy link
Contributor Author

bparees commented May 19, 2018

This was to preserve back compat with 3.6. It is very possible any changes here could break running applications.

Can we agree that if, after applying the existing defaulting logic (which is only applied to the default resolution rules), there is a resolution rule w/ no policy set(that would be one explicitly defined by the user), we should set that resolution rule's policy to the global default?

If we do not do that, the configuration is invalid and the cluster fails to start, so there should be no risk of changing existing behavior for a working cluster, it just ensures that someone who, in the future, writes a configuration that relies on the documented defaulting behavior, will get a working cluster and not a validation error.

@openshift-ci-robot openshift-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels May 19, 2018
@bparees
Copy link
Contributor Author

bparees commented May 19, 2018

(i've updated the PR to reflect that proposal)

@bparees
Copy link
Contributor Author

bparees commented May 22, 2018

@smarterclayton bump

@openshift-ci-robot openshift-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels May 22, 2018
@smarterclayton
Copy link
Contributor

I can't see anything wrong with this but all of this is in a tape backup in my mind. Are you confident this can't accidentally regress deployed 3.9 clusters when they upgrade?

@bparees
Copy link
Contributor Author

bparees commented May 29, 2018

Are you confident this can't accidentally regress deployed 3.9 clusters when they upgrade?

From what i understand (which is worth sanity checking), if someone manually defined a resolution rule and did not define a policy for it, it will fail validation (policy is a required field). So any configurations this would affect are already invalid/failing to start. The intent here is just to help people who write a new config going forward.

@bparees bparees added this to the v3.11 milestone Jun 4, 2018
@bparees
Copy link
Contributor Author

bparees commented Jun 19, 2018

@smarterclayton beginning of 3.11 feels like a good time to merge this...

@bparees
Copy link
Contributor Author

bparees commented Jul 5, 2018

/hold cancel

@smarterclayton @liggitt i'm feeling pretty good about this, have i convinced you?

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 5, 2018
@bparees
Copy link
Contributor Author

bparees commented Jul 7, 2018

/refresh

@bparees
Copy link
Contributor Author

bparees commented Jul 7, 2018

/retest all

@bparees
Copy link
Contributor Author

bparees commented Jul 7, 2018

/test all

@liggitt
Copy link
Contributor

liggitt commented Jul 10, 2018

From what i understand (which is worth sanity checking), if someone manually defined a resolution rule and did not define a policy for it, it will fail validation (policy is a required field). So any configurations this would affect are already invalid/failing to start. The intent here is just to help people who write a new config going forward.

and we want to default the half they didn't specify? is that going to cause us problems if those defaults change in the future, and the changes don't mesh with the resolution rule they provided?

@bparees
Copy link
Contributor Author

bparees commented Jul 11, 2018

and we want to default the half they didn't specify? is that going to cause us problems if those defaults change in the future, and the changes don't mesh with the resolution rule they provided?

The api docs indicate that if the rule itself doesn't specify a value, the default value is pulled from the global policy setting(which is set by them). However the implementation didn't actually do that.
(instead you'd get an error indicating the value was required).

The sole purpose of this PR is to bring the behavior in line w/ the api doc. If we think the api doc behavior is not what we want, we can change the api docs and require that you always specify a policy for every rule, instead of allowing there to be a global policy that the rules inherit, but the global policy that is inherited by the rules by default seemed like a reasonable behavior to me.

I wouldn't think we'd be allowed to change the defaults (which in this case would be the default global policy, I guess).

@liggitt
Copy link
Contributor

liggitt commented Jul 11, 2018

The api docs indicate that if the rule itself doesn't specify a value, the default value is pulled from the global policy setting(which is set by them). However the implementation didn't actually do that.
(instead you'd get an error indicating the value was required).

The sole purpose of this PR is to bring the behavior in line w/ the api doc.

Ok.

I wouldn't think we'd be allowed to change the defaults (which in this case would be the default global policy, I guess).

Clayton will have to refresh my memory… I thought new types could get default rules added for them

@bparees
Copy link
Contributor Author

bparees commented Jul 11, 2018

for reference this is the current api doc:

// Policy controls whether resolution will happen if the rule doesn't match local names. This value
// overrides the global image policy for all target resources.
Policy ImageResolutionType

@bparees
Copy link
Contributor Author

bparees commented Jul 11, 2018

technically i guess it doesn't say it inherits the global default if not specified, but the claim that it "overrides it" would imply that it's optional/uses the global value normally.

@bparees
Copy link
Contributor Author

bparees commented Jul 11, 2018

Clayton will have to refresh my memory… I thought new types could get default rules added for them

@liggitt new types of what? this change only affects resolutionrules (e.g. not executionrules and not necessarily a new type of rule if we introduced one).

@liggitt
Copy link
Contributor

liggitt commented Jul 11, 2018

@liggitt new types of what? this change only affects resolutionrules (e.g. not executionrules and not necessarily a new type of rule if we introduced one).

I misread the defaulting... if they specify any resolution rules, we don't contribute any of the default ones, which might expand to include rules for new resource types in the future.

However the implementation didn't actually do that. (instead you'd get an error indicating the value was required).

does that mean that someone that doesn't specify any resolution rules gets an error? the defaults here don't set a policy value:

obj.ResolutionRules = []ImageResolutionPolicyRule{
{TargetResource: GroupResource{Resource: "pods"}, LocalNames: true},
{TargetResource: GroupResource{Group: "build.openshift.io", Resource: "builds"}, LocalNames: true},
{TargetResource: GroupResource{Group: "batch", Resource: "jobs"}, LocalNames: true},
{TargetResource: GroupResource{Group: "extensions", Resource: "replicasets"}, LocalNames: true},
{TargetResource: GroupResource{Resource: "replicationcontrollers"}, LocalNames: true},
{TargetResource: GroupResource{Group: "apps", Resource: "deployments"}, LocalNames: true},
{TargetResource: GroupResource{Group: "extensions", Resource: "deployments"}, LocalNames: true},
{TargetResource: GroupResource{Group: "apps", Resource: "statefulsets"}, LocalNames: true},
{TargetResource: GroupResource{Group: "extensions", Resource: "daemonsets"}, LocalNames: true},
}

@bparees
Copy link
Contributor Author

bparees commented Jul 12, 2018

does that mean that someone that doesn't specify any resolution rules gets an error? the defaults here don't set a policy value:

yes they do:

// default the resolution policy to the global default
for i := range obj.ResolutionRules {
if len(obj.ResolutionRules[i].Policy) != 0 {
continue
}
obj.ResolutionRules[i].Policy = DoNotAttempt
for _, rule := range obj.ExecutionRules {
if executionRuleCoversResource(rule, obj.ResolutionRules[i].TargetResource) {
obj.ResolutionRules[i].Policy = obj.ResolveImages
break
}
}
}

@bparees
Copy link
Contributor Author

bparees commented Jul 13, 2018

/retest

@liggitt
Copy link
Contributor

liggitt commented Jul 17, 2018

/lgtm

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bparees, liggitt

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

@bparees
Copy link
Contributor Author

bparees commented Jul 17, 2018

/retest

@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 bd5ef9d into openshift:master Jul 17, 2018
@bparees bparees deleted the imagepolicy branch August 6, 2018 16:45
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. lgtm Indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

openshift.io/ImagePolicy.resolutionRules[1].policy: Required value
6 participants