Skip to content

Conversation

@arjunanan6
Copy link
Contributor

@arjunanan6 arjunanan6 commented Oct 4, 2023

This change intends on adding the PowerShell remoting protocol (PSRP) type connection along with a test function.

related: #19739


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in newsfragments.

Copy link
Member

@hussein-awala hussein-awala left a comment

Choose a reason for hiding this comment

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

Some tips for better contribution:

  • Use a good/clear title for your PR
  • Add a description for your change even if you add the related issue
  • Keep your PR as draft while it is not ready

@hussein-awala hussein-awala marked this pull request as draft October 4, 2023 20:11
@Taragolis
Copy link
Contributor

related: #19739

Are you sure that this correct issue? Issue related to apache-airflow-providers-microsoft-winrm but changes made in apache-airflow-providers-microsoft-psrp

@Taragolis
Copy link
Contributor

If this changes are correct, than I guess it more related to

@arjunanan6
Copy link
Contributor Author

@hussein-awala I didn't even know you could do a draft, so thanks for pointing that out. My final version will have a better title, details, etc.

@Taragolis It is kind-of related, I guess it can take down two stones at a time.

@arjunanan6
Copy link
Contributor Author

@hussein-awala or @Taragolis do you see what I am doing wrong here? I added the connection-type in provider.yaml which appears to be where the provider info and conns are looked up from for the UI, but it does not show up.

@Taragolis
Copy link
Contributor

Taragolis commented Oct 7, 2023

do you see what I am doing wrong here? I added the connection-type in provider.yaml which appears to be where the provider info and conns are looked up from for the UI, but it does not show up.

Problem with incorrect path to the PsrpHook, this could be found in case of running Static Code Checks

Finished check: Found 0 errors in 1 checked items

Found 1 error in providers
Error: The `airflow.providers.microsoft.psrp.hooks.PsrpHook` object in connection-types list in airflow/providers/microsoft/psrp/provider.yaml does not exist or is not a class: module 'airflow.providers.microsoft.psrp.hooks' has no attribute 'PsrpHook'

After changes it appear in to the Connection UI
image

as well as by run airflow providers hooks


Some other useful links for which might help you for contribution to Airflow

arjunanan6 and others added 2 commits October 7, 2023 16:08
Co-authored-by: Andrey Anshin <Andrey.Anshin@taragol.is>
Co-authored-by: Andrey Anshin <Andrey.Anshin@taragol.is>
@arjunanan6
Copy link
Contributor Author

@Taragolis Yikes, what a terrible oversight. I saw the static checks but did not check it properly enough. Thank you!

@uranusjr uranusjr changed the title Initial commit PSRP connection type support Oct 13, 2023
@github-actions
Copy link

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale Stale PRs per the .github/workflows/stale.yml policy file label Nov 28, 2023
@malthe
Copy link
Contributor

malthe commented Nov 28, 2023

@arjunanan6 any progress on this – seems like you've found the issue and just need to rebase this?

@arjunanan6
Copy link
Contributor Author

@malthe Haven't had any time of late, but let me see if I can finish it up this week.

@arjunanan6
Copy link
Contributor Author

@Taragolis @malthe what do you think about the test I've just added?

@malthe
Copy link
Contributor

malthe commented Nov 28, 2023

@arjunanan6 you don't need to actually invoke any command; instead, simply enter into the hook context:

with PsrpHook(psrp_conn_id=self.conn_id):
    pass

This will raise an exception if there is a connection error.

It works because entering the hook will in turn enter into the runspace pool context, which automatically connects it to the remote machine, establishing a connection.

@arjunanan6
Copy link
Contributor Author

@arjunanan6 you don't need to actually invoke any command; instead, simply enter into the hook context:

with PsrpHook(psrp_conn_id=self.conn_id):
    pass

This will raise an exception if there is a connection error.

It works because entering the hook will in turn enter into the runspace pool context, which automatically connects it to the remote machine, establishing a connection.

Ah interesting, so I overdid it then. I'll make a change shortly and push it.

@arjunanan6 arjunanan6 marked this pull request as ready for review November 28, 2023 11:48
@github-actions github-actions bot removed the stale Stale PRs per the .github/workflows/stale.yml policy file label Nov 29, 2023
@malthe
Copy link
Contributor

malthe commented Nov 30, 2023

@arjunanan6 now, to test this, you would build on the existing suite:

class TestPsrpHook:
    ....
    def test_test_connection(self, runspace_pool, *mocks):
        with PsrpHook(CONNECTION_ID):
            # Assert that the `runspace_pool` has been entered into, i.e. opened.

Something along the lines of

assert runspace_pool.return_value.__enter__.mock_calls == [call()]

@arjunanan6
Copy link
Contributor Author

@malthe Awesome, thanks for that! I'll get on it.

@arjunanan6
Copy link
Contributor Author

I'm aware of the failing tests, I will look into it asap!

@eladkal eladkal changed the title PSRP connection type support Add PSRP connection type Dec 6, 2023
@arjunanan6 arjunanan6 marked this pull request as draft January 16, 2024 14:53
@arjunanan6 arjunanan6 marked this pull request as ready for review February 7, 2024 13:20
@arjunanan6
Copy link
Contributor Author

@Taragolis Sorry about the extreme delay, I had some stuff going on. I think this is now ready for a review. Could you take a look when you have time? Thank you.

Copy link
Contributor

@malthe malthe left a comment

Choose a reason for hiding this comment

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

Looks good to me

@malthe malthe merged commit bcf2673 into apache:main Feb 16, 2024
@arjunanan6 arjunanan6 deleted the arjunanan6/psrp-conn branch November 19, 2025 06:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants