Skip to content

Use PATCH when updating a Configuration's Route label - #1704

Merged
google-prow-robot merged 2 commits into
knative:masterfrom
dprotaso:patch
Jul 27, 2018
Merged

google-prow-robot merged 2 commits into
knative:masterfrom
dprotaso:patch

Conversation

@dprotaso

Copy link
Copy Markdown
Member

Addresses: #1127

@google-prow-robot google-prow-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 26, 2018
@mattmoor mattmoor self-assigned this Jul 26, 2018
@dprotaso

Copy link
Copy Markdown
Member Author

/hold

@google-prow-robot google-prow-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 26, 2018
Addresses: knative#1127

Use json merge patching given that vanilla json patch will fail
if a configuration doesn't have any prior labels
@dprotaso

Copy link
Copy Markdown
Member Author

/hold cancel

@google-prow-robot google-prow-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 26, 2018

@mattmoor mattmoor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

/lgtm
/approve
/hold

This is awesome, thanks so much for doing this. One nit inline, and a (likely infeasible) idea for generalizing this.

mergePatch := map[string]interface{}{
"metadata": map[string]interface{}{
"labels": map[string]interface{}{
serving.RouteLabelKey: routeName,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

seems weird to make this *string instead of just passing the string and taking the &routeName here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

You need to be able to have null in the json so that it deletes the keyed entry from the object

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Comment thread pkg/controller/route/labels.go Outdated
return nil
}

func setRouteLabelForConfiguration(configClient servingv1alpha1.ConfigurationInterface, configName string, routeName *string) error {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In principle, we should be able to generalize this into a helper in pkg/controller as something that takes:

type Patcher interface {
    Patch(name string, pt types.PatchType(?), patch map[string]interface{})
}

You might also want this function to take the map[string]interface{} of "labels"...

REVISIT: As I realized I omitted the return type, I realized that the signature variance would likely be our downfall. :(

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I realized that the signature variance would likely be our downfall. :(

der untergang

@google-prow-robot google-prow-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jul 26, 2018
@google-prow-robot google-prow-robot removed the lgtm Indicates that a PR is ready to be merged. label Jul 27, 2018

@mattmoor mattmoor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

/lgtm
/approve

@google-prow-robot google-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 27, 2018
@google-prow-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dprotaso, mattmoor

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details 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

@mattmoor

Copy link
Copy Markdown
Contributor

/hold cancel

@google-prow-robot google-prow-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 27, 2018
@knative-metrics-robot

Copy link
Copy Markdown

The following is the coverage report on pkg/.
Say /test pull-knative-serving-go-coverage to run the coverage report again

File Old Coverage New Coverage Delta
pkg/controller/route/labels.go 93.5% 92.3% -1.2

@dprotaso

Copy link
Copy Markdown
Member Author

/test pull-knative-serving-unit-tests

@google-prow-robot
google-prow-robot merged commit 32dba09 into knative:master Jul 27, 2018
mattmoor pushed a commit to mattmoor/serving that referenced this pull request Jul 27, 2018
* Use PATCH when updating a Configuration's Route label

Addresses: knative#1127

Use json merge patching given that vanilla json patch will fail
if a configuration doesn't have any prior labels

* Provide a comment to point out how a route label can be removed
ZhiminXiang pushed a commit to ZhiminXiang/serving-1 that referenced this pull request Aug 2, 2018
* Use PATCH when updating a Configuration's Route label

Addresses: knative#1127

Use json merge patching given that vanilla json patch will fail
if a configuration doesn't have any prior labels

* Provide a comment to point out how a route label can be removed
@dprotaso
dprotaso deleted the patch branch September 11, 2018 23:16
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/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.

4 participants