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

[RHCLOUD-30604] return ansible_host with the high level connection status response #371

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

tahmidefaz
Copy link
Member

@tahmidefaz tahmidefaz commented Jul 16, 2024

What?

Explain what the change is linking any relevant JIRAs or Issues.

Why?

Consider what business or engineering goal does this PR achieves.

How?

Describe how the change is implemented. Any noteable new libaries, APIs, or features.

Testing

Did you add any tests for the change?

Anything Else?

Any other notes about the PR that would be useful for the reviewer.

Secure Coding Practices Checklist Link

Secure Coding Checklist

  • Input Validation
  • Output Encoding
  • Authentication and Password Management
  • Session Management
  • Access Control
  • Cryptographic Practices
  • Error Handling and Logging
  • Data Protection
  • Communication Security
  • System Configuration
  • Database Security
  • File Management
  • Memory Management
  • General Coding Practices

@tahmidefaz tahmidefaz requested a review from dehort July 16, 2024 16:48
@tahmidefaz tahmidefaz force-pushed the return-ansible-host-highlevel branch from 93549e0 to fb67c0e Compare July 16, 2024 16:49
Copy link
Contributor

@dehort dehort left a comment

Choose a reason for hiding this comment

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

Hey Tahmid,
I talked with Rex about this a while back. He mentioned that the ansible_host field needs to be along side the host id. More info in this comment in the jira.

At this point, I think the best thing to do is to add a new field along side the existing systems field that contains the host id and ansible_host field. Maybe we call call this new field systems_details (naming things is difficult)?

It feels kind of gross to add a new field to contain this info, but we would break existing clients if we changed the existing systems field from an array of strings to an array of objects. :(

Let me know if you have any questions. I'll try to look into this a bit more closely shortly.

@tahmidefaz
Copy link
Member Author

Hey Tahmid, I talked with Rex about this a while back. He mentioned that the ansible_host field needs to be along side the host id. More info in this comment in the jira.

At this point, I think the best thing to do is to add a new field along side the existing systems field that contains the host id and ansible_host field. Maybe we call call this new field systems_details (naming things is difficult)?

It feels kind of gross to add a new field to contain this info, but we would break existing clients if we changed the existing systems field from an array of strings to an array of objects. :(

Let me know if you have any questions. I'll try to look into this a bit more closely shortly.

I just moved the ansible_host under a new systems_info object. For example:

"systems_info": [
            {
                "ansible_host": "test-ansible-host",
                "host_id": "fe30b997-c15a-44a9-89df-c236c3b5c540"
            }
        ]

@tahmidefaz tahmidefaz requested a review from dehort July 19, 2024 18:55
@dehort
Copy link
Contributor

dehort commented Jul 22, 2024

/retest

Copy link
Contributor

@dehort dehort left a comment

Choose a reason for hiding this comment

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

This is looking good.

I think there is an issue where the satellite connected hosts always have an empty string for their ansible_host even if they have a valid ansible_host in inventory.

This can be seen by modifying the inventory mock to add the ansible_host to the satellite connected host.

diff --git internal/api/connectors/inventory/inventory_mock.go internal/api/connectors/inventory/inventory_mock.go
index 7113f73..161dad8 100644
--- internal/api/connectors/inventory/inventory_mock.go
+++ internal/api/connectors/inventory/inventory_mock.go
@@ -38,6 +38,7 @@ func (this *inventoryConnectorMock) GetHostConnectionDetails(
                SatelliteInstanceID: &satelliteInstanceID,
                SatelliteVersion:    &satelliteVersion,
                SatelliteOrgID:      &satelliteOrgID,
+               AnsibleHost: &ansibleHost,
        }
 
        directConnectDetails := HostDetails{

The way I see to fix it would be to stop passing the ansibleHost parameter to the formatConnectionResponse() method and instead add the ansiblehost data to host array that is passed to that method. Of course, each method that calls the formatConnectionResponse() method will need to be modified to build that list so that it contains the host id and ansible_host.

I hope that makes sense.

This is complicated. :) Ping me if you need more details, etc.

@tahmidefaz
Copy link
Member Author

This is looking good.

I think there is an issue where the satellite connected hosts always have an empty string for their ansible_host even if they have a valid ansible_host in inventory.

This can be seen by modifying the inventory mock to add the ansible_host to the satellite connected host.

diff --git internal/api/connectors/inventory/inventory_mock.go internal/api/connectors/inventory/inventory_mock.go
index 7113f73..161dad8 100644
--- internal/api/connectors/inventory/inventory_mock.go
+++ internal/api/connectors/inventory/inventory_mock.go
@@ -38,6 +38,7 @@ func (this *inventoryConnectorMock) GetHostConnectionDetails(
                SatelliteInstanceID: &satelliteInstanceID,
                SatelliteVersion:    &satelliteVersion,
                SatelliteOrgID:      &satelliteOrgID,
+               AnsibleHost: &ansibleHost,
        }
 
        directConnectDetails := HostDetails{

The way I see to fix it would be to stop passing the ansibleHost parameter to the formatConnectionResponse() method and instead add the ansiblehost data to host array that is passed to that method. Of course, each method that calls the formatConnectionResponse() method will need to be modified to build that list so that it contains the host id and ansible_host.

I hope that makes sense.

This is complicated. :) Ping me if you need more details, etc.

@dehort I was initially thinking that ansible_host is only present with direct connect host, so did not pay much attention to satellite. Anyhow, ansible_host values should get return correctly for all connection types. 👍

@tahmidefaz tahmidefaz requested a review from dehort July 25, 2024 15:12
Copy link
Contributor

@dehort dehort left a comment

Choose a reason for hiding this comment

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

Looking good.

I left one (kind of) nit-picky comment.

@@ -356,6 +356,18 @@ components:
type: string
minLength: 1

HostIdWithAnsibleHost:
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this be renamed to something like HostDetails or something a bit more generic?

Its possible that we will need to add more info about the hosts later on and then this name makes less sense.

Naming is hard :(

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 changed this to HostAtribute. Unfortunately, HostDetails is used quite extensively thoughout the codebase to mean a different thing, so didn't want to add to the confusion here.

@tahmidefaz tahmidefaz requested a review from dehort July 29, 2024 14:09
@tahmidefaz
Copy link
Member Author

@dehort I am occupied with the PlatEx stuff. If you or someone from the integrations team can take over this task, that'd be great!

@dehort
Copy link
Contributor

dehort commented Sep 11, 2024

Hey @tahmidefaz, yep, I'll take it from here. Thank you!

@dehort
Copy link
Contributor

dehort commented Sep 11, 2024

/retest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants