Repository: knative-sandbox/eventing-kafka
Pull request #242 (2020-11-30 19:26:54)

Fix label consistency

<!-- Please include the 'why' behind your changes if no issue exists -->

## Proposed Changes

- Label source name has a different spelling in [eventing repo](https://github.com/knative/eventing/blob/241af67e1844c9363869ca4141b910d0bc9819c6/pkg/reconciler/apiserversource/resources/labels.go#L28)
- We should keep things consistent because tooling may rely on these labels etc. In my case this makes hard to parse metric labels.
- Ping source btw seems to have its [own special label](https://github.com/knative/eventing/blob/241af67e1844c9363869ca4141b910d0bc9819c6/pkg/reconciler/pingsource/resources/labels.go#L28).
<!--
If this change has user-visible impact, follow the instructions below.
Examples include:

- 🎁 Add new feature
- 🐛 Fix bug
- 🧽 Update or clean up current behavior
- 🗑️ Remove feature or internal logic

Otherwise delete the rest of this template.
-->

**Release Note**

<!--
🗒️ If this change has user-visible impact, write a release note in the block
below. Include the string "action required" if additional action is required of
users switching to the new release, for example in case of a breaking change.

Write as if you are speaking to users, not other Knative contributors. If this
change has no user-visible impact, no release-note is needed.
-->

```release-note
NONE
```



knative-prow-robot: [APPROVALNOTIFIER] This PR is **NOT APPROVED**

This pull-request has been approved by: *<a href="https://github.com/knative-sandbox/eventing-kafka/pull/242#" title="Author self-approved">skonto</a>*
To complete the [pull request process](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process), please assign **matzew** after the PR has been reviewed.
You can assign the PR to them by writing `/assign @matzew` in a comment when ready.

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=knative-sandbox%2Feventing-kafka).

<details open>
Needs approval from an approver in each of these files:

- **[OWNERS](https://github.com/knative-sandbox/eventing-kafka/blob/master/OWNERS)**

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":["matzew"]} -->
knative-prow-robot: Hi @skonto. Thanks for your PR.

I'm waiting for a [knative-sandbox](https://github.com/orgs/knative-sandbox/people) member to verify that this patch is reasonable to test. If it is, they should reply with `/ok-to-test` on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should [join the org](https://github.com/orgs/knative-sandbox/people) to skip this step.

Once the patch is verified, the new status will be reflected by the `ok-to-test` label.

I understand the commands that are listed [here](https://go.k8s.io/bot-commands?repo=knative-sandbox%2Feventing-kafka).

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
</details>

codecov[bot]: # [Codecov](https://codecov.io/gh/knative-sandbox/eventing-kafka/pull/242?src=pr&el=h1) Report
> Merging [#242](https://codecov.io/gh/knative-sandbox/eventing-kafka/pull/242?src=pr&el=desc) (ca77ea5) into [master](https://codecov.io/gh/knative-sandbox/eventing-kafka/commit/c026e323c4e3fadd2decfa18d02ee9d0a206593d?el=desc) (c026e32) will **decrease** coverage by `0.04%`.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/knative-sandbox/eventing-kafka/pull/242/graphs/tree.svg?width=650&height=150&src=pr&token=W765CT93QC)](https://codecov.io/gh/knative-sandbox/eventing-kafka/pull/242?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master     #242      +/-   ##
==========================================
- Coverage   75.79%   75.74%   -0.05%     
==========================================
  Files         112      112              
  Lines        4309     4309              
==========================================
- Hits         3266     3264       -2     
- Misses        848      850       +2     
  Partials      195      195              
```


| [Impacted Files](https://codecov.io/gh/knative-sandbox/eventing-kafka/pull/242?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pkg/source/reconciler/source/resources/labels.go](https://codecov.io/gh/knative-sandbox/eventing-kafka/pull/242/diff?src=pr&el=tree#diff-cGtnL3NvdXJjZS9yZWNvbmNpbGVyL3NvdXJjZS9yZXNvdXJjZXMvbGFiZWxzLmdv) | `100.00% <100.00%> (ø)` | |
| [...tributed/common/kafka/admin/eventhubcache/cache.go](https://codecov.io/gh/knative-sandbox/eventing-kafka/pull/242/diff?src=pr&el=tree#diff-cGtnL2NoYW5uZWwvZGlzdHJpYnV0ZWQvY29tbW9uL2thZmthL2FkbWluL2V2ZW50aHViY2FjaGUvY2FjaGUuZ28=) | `65.06% <0.00%> (-2.41%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/knative-sandbox/eventing-kafka/pull/242?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/knative-sandbox/eventing-kafka/pull/242?src=pr&el=footer). Last update [c026e32...6c1d9fe](https://codecov.io/gh/knative-sandbox/eventing-kafka/pull/242?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

lionelvillard: The pingsource labels are not used anymore. Instead the labels are directly set on the deployment config: https://github.com/knative/eventing/blob/master/config/core/deployments/pingsource-mt-adapter.yaml

/ok-to-test
/lgtm

knative-prow-robot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/knative-sandbox/eventing-kafka/pull/242#pullrequestreview-541503623" title="Approved">matzew</a>*, *<a href="https://github.com/knative-sandbox/eventing-kafka/pull/242#" title="Author self-approved">skonto</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=knative-sandbox%2Feventing-kafka).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com/knative-sandbox/eventing-kafka/blob/master/OWNERS)~~ [matzew]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->

Patch:
diff --git a/pkg/source/reconciler/source/resources/labels.go b/pkg/source/reconciler/source/resources/labels.go
index b0658d674..048b91850 100644
--- a/pkg/source/reconciler/source/resources/labels.go
+++ b/pkg/source/reconciler/source/resources/labels.go
@@ -25,6 +25,6 @@ const (
 func GetLabels(name string) map[string]string {
 	return map[string]string{
 		"eventing.knative.dev/source":     controllerAgentName,
-		"eventing.knative.dev/SourceName": name,
+		"eventing.knative.dev/sourceName": name,
 	}
 }


Test patch:
diff --git a/pkg/source/reconciler/source/resources/labels_test.go b/pkg/source/reconciler/source/resources/labels_test.go
index 0f7b4bc21..d2d302878 100644
--- a/pkg/source/reconciler/source/resources/labels_test.go
+++ b/pkg/source/reconciler/source/resources/labels_test.go
@@ -28,7 +28,7 @@ func TestGetLabels(t *testing.T) {
 
 	wantLabels := map[string]string{
 		"eventing.knative.dev/source":     "kafka-source-controller",
-		"eventing.knative.dev/SourceName": "testSourceName",
+		"eventing.knative.dev/sourceName": "testSourceName",
 	}
 
 	eq := cmp.Equal(testLabels, wantLabels)
diff --git a/test/e2e/helpers/kafka_helper.go b/test/e2e/helpers/kafka_helper.go
index 2d36acf1b..012eaa01b 100644
--- a/test/e2e/helpers/kafka_helper.go
+++ b/test/e2e/helpers/kafka_helper.go
@@ -269,7 +269,7 @@ func CheckKafkaSourceState(ctx context.Context, c *testlib.Client, name string,
 //On timeout reports error
 func CheckRADeployment(ctx context.Context, c *testlib.Client, name string, inState func(deps *appsv1.DeploymentList) (bool, error)) error {
 	listOptions := metav1.ListOptions{
-		LabelSelector: fmt.Sprintf("%s=%s", "eventing.knative.dev/SourceName", name),
+		LabelSelector: fmt.Sprintf("%s=%s", "eventing.knative.dev/sourceName", name),
 	}
 	kDeps := c.Kube.AppsV1().Deployments(c.Namespace)
 	var lastState *appsv1.DeploymentList