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

Add Dev and Project labeling / refactoring labeling and annotations #5551

Merged
merged 3 commits into from
Mar 17, 2022

Conversation

cdrage
Copy link
Member

@cdrage cdrage commented Mar 14, 2022

What type of PR is this:

/kind feature
/kind cleanup

What does this PR do / why we need it:

In this PR we:

  • Correctly name all the labels in a more concise manner (ex. Project Type
    is an annotation)
  • Add Dev and Deploy mode labels to both odo dev and odo deploy
    commands so that we can intuitively retrieve what components are in
    deploy or dev mode
  • Somewhat refactors how we do labeling

Which issue(s) this PR fixes:

1/2 of PR's for #5405

PR acceptance criteria:

  • Unit test

  • Integration test

  • Documentation

How to test changes / Special notes to the reviewer:

N/A

Signed-off-by: Charlie Drage charlie@charliedrage.com

@netlify
Copy link

netlify bot commented Mar 14, 2022

✔️ Deploy Preview for odo-docusaurus-preview canceled.

🔨 Explore the source changes: 6e42019

🔍 Inspect the deploy log: https://app.netlify.com/sites/odo-docusaurus-preview/deploys/6231e96af8aa1f0007ed8fbe

@openshift-ci openshift-ci bot added the kind/feature Categorizes issue as a feature request. For PRs, that means that the PR is the implementation label Mar 14, 2022
@openshift-ci
Copy link

openshift-ci bot commented Mar 14, 2022

@cdrage: The label(s) kind/cleanup cannot be applied, because the repository doesn't have them.

In response to this:

What type of PR is this:

/kind feature
/kind cleanup

What does this PR do / why we need it:

In this PR we:

  • Correctly name all the labels in a more concise manner (ex. Project Type
    is an annotation)
  • Add Dev and Deploy mode labels to both odo dev and odo deploy
    commands so that we can intuitively retrieve what components are in
    deploy or dev mode
  • Somewhat refactors how we do labeling

Which issue(s) this PR fixes:

1/2 of PR's for #5405

PR acceptance criteria:

  • Unit test

  • Integration test

  • Documentation

How to test changes / Special notes to the reviewer:

N/A

Signed-off-by: Charlie Drage charlie@charliedrage.com

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.

@odo-robot
Copy link

odo-robot bot commented Mar 14, 2022

Unit Tests on commit 4ec08b6 finished successfully.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Mar 14, 2022

Validate Tests on commit 4ec08b6 finished successfully.
View logs: TXT HTML

<!--
Thank you for opening a PR! Here are some things you need to know before submitting:

1. Please read our developer guideline: https://github.com/redhat-developer/odo/wiki/Dev:-odo-Dev-Guidelines
2. Label this PR accordingly with the '/kind' line
3. Ensure you have written and ran the appropriate tests: https://github.com/redhat-developer/odo/wiki/Dev:-Writing-and-running-tests
4. Read how we approve and LGTM each PR: https://github.com/redhat-developer/odo/wiki/Pull-Requests:-Review-guideline

Documentation:

If you are pushing a change to documentation, please read: https://github.com/redhat-developer/odo/wiki/Documentation:-Contributing
-->

**What type of PR is this:**

<!--
Add one of the following kinds:
/kind bug
/kind tests
/kind documentation

Feel free to use other [labels](https://github.com/redhat-developer/odo/labels) as needed. However one of the above labels must be present or the PR will not be reviewed. This instruction is for reviewers as well.
-->
/kind feature
/kind cleanup

**What does this PR do / why we need it:**

In this PR we:
  * Correctly name all the labels in a more concise manner (ex. Project Type
    is an annotation)
  * Add Dev and Deploy mode labels to both `odo dev` and `odo deploy`
    commands so that we can intuitively retrieve what components are in
    deploy or dev mode
  * Somewhat refactors how we do labeling

**Which issue(s) this PR fixes:**
<!--
Specifying the issue will automatically close it when this PR is merged
-->

1/2 of PR's for redhat-developer#5405

**PR acceptance criteria:**

- [X] Unit test

- [X] Integration test

- [X] Documentation

**How to test changes / Special notes to the reviewer:**

N/A

Signed-off-by: Charlie Drage <charlie@charliedrage.com>
@odo-robot
Copy link

odo-robot bot commented Mar 14, 2022

Kubernetes Tests on commit 4ec08b6 finished successfully.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Mar 14, 2022

Windows Tests (OCP) on commit 4ec08b6 finished with errors.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Mar 14, 2022

OpenShift Tests on commit 4ec08b6 finished with errors.
View logs: TXT HTML

Copy link
Contributor

@feloy feloy left a comment

Choose a reason for hiding this comment

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

I note that this PR does not fix #5546, that's ok for me (I prefer that it is fixed as part of another PR)

pkg/component/labels/labels.go Show resolved Hide resolved
pkg/component/labels/labels.go Outdated Show resolved Hide resolved
@valaparthvi
Copy link
Member

valaparthvi commented Mar 15, 2022

@cdrage Can you try to get this PR in as soon as possible? I think it will be helpful for the odo delete PR that I am working on.

@feloy
Copy link
Contributor

feloy commented Mar 15, 2022

You will need to run go fmt ./... to format files correctly:

gofmt ERROR - These files are not formated by gofmt:
./pkg/component/component_test.go
./pkg/component/labels/labels_test.go
./pkg/devfile/adapters/kubernetes/component/adapter_test.go
./pkg/kclient/fake/ingress.go
./pkg/storage/labels/labels_test.go
./pkg/testingutil/deployments.go
./pkg/testingutil/routes.go
./pkg/url/labels/labels_test.go

// ComponentDeployLabel ...
const ComponentDeployLabel = "Deploy"
// ComponentUnknownLabel is the label that is used to display something we do not know
const ComponentUnknownLabel = "<unknown>"
Copy link
Member

Choose a reason for hiding this comment

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

This is not used anywhere.

const ComponentDeployName = "Deploy"

// ComponentNoneName ...
const ComponentNoneName = "None"
Copy link
Member

Choose a reason for hiding this comment

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

This is not used anywhere.

@@ -413,13 +415,14 @@ func getRemoteComponentMetadata(client kclient.ClientInterface, componentName st
// Annotations
component.Annotations = fromCluster.GetAnnotations()

// Mark the component status as pushed
component.Status.State = componentlabels.ComponentPushedName
Copy link
Member

Choose a reason for hiding this comment

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

This should probably use StateTypePushed from types.go

const ComponentNoneName = "None"

// ComponentPushedName ...
const ComponentPushedName = "Pushed"
Copy link
Member

Choose a reason for hiding this comment

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

This is not used as a label or its value it should not be in this file.

Similar constant is already defined in pkg/component/types.go

"github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
"github.com/devfile/api/v2/pkg/devfile"
"github.com/devfile/library/pkg/devfile/parser"
parsercommon "github.com/devfile/library/pkg/devfile/parser/data/v2/common"
dfutil "github.com/devfile/library/pkg/util"

applabels "github.com/redhat-developer/odo/pkg/application/labels"
Copy link
Member

Choose a reason for hiding this comment

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

can we keep the import grouping as it were?

Signed-off-by: Charlie Drage <charlie@charliedrage.com>
pkg/component/component.go Outdated Show resolved Hide resolved
// Since `odo deploy` can theoretically deploy a deployment as well with the same instance name
// we make sure that we are retrieving the deployment with the Dev mode, NOT Deploy.
selectorLabels := componentlabels.GetLabels(a.ComponentName, a.AppName, false)
selectorLabels[componentlabels.OdoModeLabel] = componentlabels.ComponentDevName
Copy link
Member

Choose a reason for hiding this comment

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

wouldn't it be better to include OdoModeLabel in componentlabels.GetLabels?
It will be safer and it it will be automatically used everywhere where it is needed.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think so unless there is a refactor with the GetLabels and how we do it elsewhere (it'd break odo push tests).

I did think of your solution, but found I was changing WAYYY too many places where the GetLabels code is. Especially in parts of the code where you would have to modify multiple functions just to pass in "Dev" or "Deploy" from the pkg/cli layer.

@valaparthvi
Copy link
Member

@cdrage I'm no longer blocked on this, so take your time.

@cdrage
Copy link
Member Author

cdrage commented Mar 16, 2022

/retest

…labels

Signed-off-by: Charlie Drage <charlie@charliedrage.com>
@sonarcloud
Copy link

sonarcloud bot commented Mar 16, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
1.0% 1.0% Duplication

@feloy
Copy link
Contributor

feloy commented Mar 16, 2022

/retest

@feloy
Copy link
Contributor

feloy commented Mar 16, 2022

/retest

 failed to pull stack java-openliberty from registry.stage.devfile.io/devfile-catalog/java-openliberty:0.8.1 with allowed media types [application/vnd.devfileio.devfile.layer.v1 image/png image/svg+xml application/vnd.devfileio.vsx.layer.v1.tar application/x-tar]: failed to copy: httpReaderSeeker: failed open: unexpected status code https://registry.stage.devfile.io/v2/devfile-catalog/java-openliberty/blobs/sha256:99c7dfff0973a1f1a036ad5c7c8c0d87d05f97d161ac9d49881d6fc152f5baf0: 502 Bad Gateway

@feloy
Copy link
Contributor

feloy commented Mar 16, 2022

/test v4.9-integration-e2e

@feloy
Copy link
Contributor

feloy commented Mar 17, 2022

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Mar 17, 2022
@@ -254,7 +266,7 @@ func (a Adapter) Push(parameters common.PushParameters) (err error) {

a.deployment, err = a.Client.WaitForDeploymentRollout(a.deployment.Name)
if err != nil {
return errors.Wrap(err, "error while waiting for deployment rollout")
return errors.Wrapf(err, "Failed to update config to component deployed.")
Copy link
Member

Choose a reason for hiding this comment

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

There's a separate PR for removing the occurrences of errors.Wrapf, but wherever you are modifying things, can you make sure to use fmt.Errorf? Otherwise, I think, we will end up having errors.Wrapf occurrences if that PR goes in before yours.

Copy link
Member

Choose a reason for hiding this comment

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

@feloy WDYT? I see you already lgtm'd this PR. Since you are working on the other PR, I am OK by adding LGTM back to this PR if you would prefer this one to go in first.

Copy link
Contributor

@feloy feloy Mar 17, 2022

Choose a reason for hiding this comment

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

We will turn @cdrage into a weather vane (is this phrase existing in english?), as he already changed this back and forth several times depending on different reviews :(
I created the PR #5557 to resolve the misunderstanding, let's keep it as is here, I will handle it in my PR after rebasing

Copy link
Member

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added lgtm Indicates that a PR is ready to be merged. Required by Prow. and removed lgtm Indicates that a PR is ready to be merged. Required by Prow. labels Mar 17, 2022
@feloy
Copy link
Contributor

feloy commented Mar 17, 2022

/approve

@openshift-ci
Copy link

openshift-ci bot commented Mar 17, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: feloy

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 openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. Required by Prow. label Mar 17, 2022
@openshift-merge-robot openshift-merge-robot merged commit d48a607 into redhat-developer:main Mar 17, 2022
cdrage added a commit to cdrage/odo that referenced this pull request Aug 31, 2022
…edhat-developer#5551)

* Add Dev and Project labeling / refactoring labeling and annotations

<!--
Thank you for opening a PR! Here are some things you need to know before submitting:

1. Please read our developer guideline: https://github.com/redhat-developer/odo/wiki/Dev:-odo-Dev-Guidelines
2. Label this PR accordingly with the '/kind' line
3. Ensure you have written and ran the appropriate tests: https://github.com/redhat-developer/odo/wiki/Dev:-Writing-and-running-tests
4. Read how we approve and LGTM each PR: https://github.com/redhat-developer/odo/wiki/Pull-Requests:-Review-guideline

Documentation:

If you are pushing a change to documentation, please read: https://github.com/redhat-developer/odo/wiki/Documentation:-Contributing
-->

**What type of PR is this:**

<!--
Add one of the following kinds:
/kind bug
/kind tests
/kind documentation

Feel free to use other [labels](https://github.com/redhat-developer/odo/labels) as needed. However one of the above labels must be present or the PR will not be reviewed. This instruction is for reviewers as well.
-->
/kind feature
/kind cleanup

**What does this PR do / why we need it:**

In this PR we:
  * Correctly name all the labels in a more concise manner (ex. Project Type
    is an annotation)
  * Add Dev and Deploy mode labels to both `odo dev` and `odo deploy`
    commands so that we can intuitively retrieve what components are in
    deploy or dev mode
  * Somewhat refactors how we do labeling

**Which issue(s) this PR fixes:**
<!--
Specifying the issue will automatically close it when this PR is merged
-->

1/2 of PR's for redhat-developer#5405

**PR acceptance criteria:**

- [X] Unit test

- [X] Integration test

- [X] Documentation

**How to test changes / Special notes to the reviewer:**

N/A

Signed-off-by: Charlie Drage <charlie@charliedrage.com>

* Review update / renaming

Signed-off-by: Charlie Drage <charlie@charliedrage.com>

* Review changes. Adds tests for generateDeploymentObjectMeta. Changes labels

Signed-off-by: Charlie Drage <charlie@charliedrage.com>
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. Required by Prow. kind/feature Categorizes issue as a feature request. For PRs, that means that the PR is the implementation lgtm Indicates that a PR is ready to be merged. Required by Prow.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants