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

MGMT-17365: Add support for setting agent labels in BMH as annotations #6124

Merged
merged 1 commit into from Apr 18, 2024

Conversation

ori-amizur
Copy link
Contributor

@ori-amizur ori-amizur commented Mar 28, 2024

BMH is the custom resource that is used to add a new host. Agent on the other hand is created automatically when a host registers. Since there is a need to control agent labels the following agent label support was added:

In order to add an entry that controls agent label, a new BMH annotation needs to be added.
The annotation key is prefixed with the string
'bmac.agent-install.openshift.io.agent-label.'. The remainder of the annotation is considered the label key.
The value of the annotation is a JSON dictionary with 2 possible keys. The key 'operation' can contain one of the values ["add","delete"] which mean that the label can either added , or deleted. The dictionary key 'value' contains the label value.
The value of the annotation is identical to the agent label value.

Note: agent labels cannot be deleted by usage of BMH annotations.

List all the issues related to this PR

  • New Feature
  • Enhancement
  • Bug fix
  • Tests
  • Documentation
  • CI/CD

What environments does this code impact?

  • Automation (CI, tools, etc)
  • Cloud
  • Operator Managed Deployments
  • None

How was this code tested?

  • assisted-test-infra environment
  • dev-scripts environment
  • Reviewer's test appreciated
  • Waiting for CI to do a full test run
  • Manual (Elaborate on how it was tested)
  • No tests needed

Checklist

  • Title and description added to both, commit and PR.
  • Relevant issues have been associated (see CONTRIBUTING guide)
  • This change does not require a documentation update (docstring, docs, README, etc)
  • Does this change include unit-tests (note that code changes require unit-tests)

Reviewers Checklist

  • Are the title and description (in both PR and commit) meaningful and clear?
  • Is there a bug required (and linked) for this change?
  • Should this PR be backported?

/cc @carbonin

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Mar 28, 2024
@openshift-ci-robot
Copy link

openshift-ci-robot commented Mar 28, 2024

@ori-amizur: This pull request references MGMT-17365 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "4.16.0" version, but no target version was set.

In response to this:

BMH is the custom resource that is used to add a new host. Agent on the other hand is created automatically when a host registers. Since there is a need to control agent labels the following agent label support was added:

In order to add an entry that controls agent label, a new BMH annotation needs to be added.
The annotation key is prefixed with the string
'bmac.agent-install.openshift.io.agent-label.'. The remainder of the annotation is considered the label key.
The value of the annotation is a JSON dictionary with 2 possible keys. The key 'operation' can contain one of the values ["add","delete"] which mean that the label can either added , or deleted. The dictionary key 'value' contains the label value.

List all the issues related to this PR

  • New Feature
  • Enhancement
  • Bug fix
  • Tests
  • Documentation
  • CI/CD

What environments does this code impact?

  • Automation (CI, tools, etc)
  • Cloud
  • Operator Managed Deployments
  • None

How was this code tested?

  • assisted-test-infra environment
  • dev-scripts environment
  • Reviewer's test appreciated
  • Waiting for CI to do a full test run
  • Manual (Elaborate on how it was tested)
  • No tests needed

Checklist

  • Title and description added to both, commit and PR.
  • Relevant issues have been associated (see CONTRIBUTING guide)
  • This change does not require a documentation update (docstring, docs, README, etc)
  • Does this change include unit-tests (note that code changes require unit-tests)

Reviewers Checklist

  • Are the title and description (in both PR and commit) meaningful and clear?
  • Is there a bug required (and linked) for this change?
  • Should this PR be backported?

/cc @carbonin

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 openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci bot requested a review from carbonin March 28, 2024 14:28
@openshift-ci openshift-ci bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Mar 28, 2024
Copy link

codecov bot commented Mar 28, 2024

Codecov Report

Attention: Patch coverage is 80.76923% with 5 lines in your changes are missing coverage. Please review.

Project coverage is 68.75%. Comparing base (1795995) to head (32623ef).
Report is 16 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6124      +/-   ##
==========================================
+ Coverage   68.31%   68.75%   +0.43%     
==========================================
  Files         242      243       +1     
  Lines       35817    37357    +1540     
==========================================
+ Hits        24470    25684    +1214     
- Misses       9221     9454     +233     
- Partials     2126     2219      +93     
Files Coverage Δ
internal/controller/controllers/crd_utils.go 70.37% <60.00%> (-0.51%) ⬇️
...nal/controller/controllers/bmh_agent_controller.go 79.42% <85.71%> (+3.61%) ⬆️

... and 14 files with indirect coverage changes

@ori-amizur
Copy link
Contributor Author

/retest

@ori-amizur
Copy link
Contributor Author

/test edge-e2e-ai-operator-disconnected-capi

Copy link
Member

@carbonin carbonin left a comment

Choose a reason for hiding this comment

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

I don't particularly like the json API and the imperitive nature of the annotation values.

This is targeted toward users of ZTP and I don't think those users are going to be tweaking these annotations to add and remove things after initial deployment.

I'm reminded of @mhrivnak's reasoning in #5893 (comment) and rereading that comment in the scope of this PR makes me think we should stick with a simpler solution:

If the annotation exists on the BMH, the corresponding label should exist on the agent.

internal/controller/controllers/bmh_agent_controller.go Outdated Show resolved Hide resolved
internal/controller/controllers/crd_utils.go Outdated Show resolved Hide resolved
@ori-amizur
Copy link
Contributor Author

If the annotation exists on the BMH, the corresponding label should exist on the agent.

And if the annotation doesn't exist in BMH, should it be deleted from the Agent ?

@mhrivnak
Copy link
Member

mhrivnak commented Apr 2, 2024

Please find an appropriate location inside this repository to document this feature before merging it.

@romfreiman
Copy link
Contributor

I don't particularly like the json API and the imperitive nature of the annotation values.

I 100% agree. So what's the plan then? I dont think this is an acceptable solution for a supported code

@carbonin
Copy link
Member

carbonin commented Apr 2, 2024

I 100% agree. So what's the plan then? I dont think this is an acceptable solution for a supported code

Not sure what the "this" is here, but my idea was that adding an annotation on the BMH would push that as a label to the agent and removing it would do nothing. The justification is that users adding things on the BMH are not doing this as an interactive process so simply replicating over should be enough.

Another option would be to enfoce a naming scheme for the label on the agent that would allow our controller (BMAC) to know if a label on the agent was added from the BMH, but is also not in the annotations in the BMH currently (and thus should be removed). This should be okay because nothing external cares about the agent label name (as opposed to node labels).

@ori-amizur
Copy link
Contributor Author

Since deletion is not required, the annotation value will be identical agent label value.
So only addition will be supported

@openshift-ci-robot
Copy link

openshift-ci-robot commented Apr 3, 2024

@ori-amizur: This pull request references MGMT-17365 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "4.16.0" version, but no target version was set.

In response to this:

BMH is the custom resource that is used to add a new host. Agent on the other hand is created automatically when a host registers. Since there is a need to control agent labels the following agent label support was added:

In order to add an entry that controls agent label, a new BMH annotation needs to be added.
The annotation key is prefixed with the string
'bmac.agent-install.openshift.io.agent-label.'. The remainder of the annotation is considered the label key.
The value of the annotation is a JSON dictionary with 2 possible keys. The key 'operation' can contain one of the values ["add","delete"] which mean that the label can either added , or deleted. The dictionary key 'value' contains the label value.
The value of the annotation is identical to the agent label value.

Note: agent labels cannot be deleted by usage of BMH annotations.

List all the issues related to this PR

  • New Feature
  • Enhancement
  • Bug fix
  • Tests
  • Documentation
  • CI/CD

What environments does this code impact?

  • Automation (CI, tools, etc)
  • Cloud
  • Operator Managed Deployments
  • None

How was this code tested?

  • assisted-test-infra environment
  • dev-scripts environment
  • Reviewer's test appreciated
  • Waiting for CI to do a full test run
  • Manual (Elaborate on how it was tested)
  • No tests needed

Checklist

  • Title and description added to both, commit and PR.
  • Relevant issues have been associated (see CONTRIBUTING guide)
  • This change does not require a documentation update (docstring, docs, README, etc)
  • Does this change include unit-tests (note that code changes require unit-tests)

Reviewers Checklist

  • Are the title and description (in both PR and commit) meaningful and clear?
  • Is there a bug required (and linked) for this change?
  • Should this PR be backported?

/cc @carbonin

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 openshift-eng/jira-lifecycle-plugin repository.

@ori-amizur ori-amizur requested a review from mhrivnak April 3, 2024 15:37
Copy link
Member

@carbonin carbonin left a comment

Choose a reason for hiding this comment

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

Can you update the PR description to match the current behavior?

Please find an appropriate location inside this repository to document this feature before merging it.

Specifically this should be added to the existing list of BMH annotation info in https://github.com/openshift/assisted-service/tree/master/docs/hive-integration#bare-metal-operator-integration

internal/controller/controllers/crd_utils.go Show resolved Hide resolved
BMH is the custom resource that is used to add a new host. Agent on the
other hand is created automatically when a host registers. Since there
is a need to control agent labels the following agent label support was
added:

In order to add an entry that controls agent label, a new BMH annotation
needs to be added.
The annotation key is prefixed with the string
'bmac.agent-install.openshift.io.agent-label.'.  The remainder of the
annotation is considered the label key.
The value of the annotation is identical to the agent label value.

Note: agent labels cannot be deleted by usage of BMH annotations.
@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Apr 10, 2024
Copy link

openshift-ci bot commented Apr 10, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: carbonin, ori-amizur

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:
  • OWNERS [carbonin,ori-amizur]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot
Copy link

/retest-required

Remaining retests: 0 against base HEAD 7080d0d and 2 for PR HEAD 32623ef in total

@ori-amizur
Copy link
Contributor Author

/retest

1 similar comment
@ori-amizur
Copy link
Contributor Author

/retest

@openshift-ci-robot
Copy link

/retest-required

Remaining retests: 0 against base HEAD 4c9b414 and 1 for PR HEAD 32623ef in total

@openshift-ci-robot
Copy link

/retest-required

Remaining retests: 0 against base HEAD b3b43c2 and 0 for PR HEAD 32623ef in total

@openshift-ci-robot
Copy link

/hold

Revision 32623ef was retested 3 times: holding

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 16, 2024
@ori-amizur
Copy link
Contributor Author

/unhold
/retest

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 17, 2024
@openshift-ci-robot
Copy link

/retest-required

Remaining retests: 0 against base HEAD 29e748f and 2 for PR HEAD 32623ef in total

@openshift-ci-robot
Copy link

/retest-required

Remaining retests: 0 against base HEAD 4f44cb4 and 1 for PR HEAD 32623ef in total

@openshift-ci-robot
Copy link

/retest-required

Remaining retests: 0 against base HEAD 0d3e7fb and 0 for PR HEAD 32623ef in total

Copy link

openshift-ci bot commented Apr 18, 2024

@ori-amizur: all tests passed!

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

@openshift-merge-bot openshift-merge-bot bot merged commit 8f268e7 into openshift:master Apr 18, 2024
16 checks passed
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. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. 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.

None yet

5 participants