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

Only update crawler tags if present in config dict #32331

Merged
merged 2 commits into from Jul 6, 2023

Conversation

luos-fc
Copy link
Contributor

@luos-fc luos-fc commented Jul 3, 2023

Closes: #32330

This PR modifies the GlueCrawlerHook to only update the crawlers tags if the Tags key is present in the config dict. This prevent situations where tags that are set by external processes are overwritten whenever the crawler is run from Airflow.

Copy link
Contributor

@Adaverse Adaverse left a comment

Choose a reason for hiding this comment

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

The changes and corresponding test coverage LGTM.

mock_config_missing_tags.pop("Tags")
mock_get_conn.return_value.get_crawler.return_value = {"Crawler": mock_config_missing_tags}

assert self.hook.update_crawler(**mock_config_missing_tags) is False
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we also add a testcase for when Tags key is in the config? Not sure if it's already covered.

Copy link
Contributor

Choose a reason for hiding this comment

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

i think test_replace_tag function is testing the above case.

Copy link
Member

Choose a reason for hiding this comment

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

yeah. Can you double check it @utkarsharma2 ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ya, they are covered. I got confused by these lines, it seems like they don't add any value to the test. Test seems to work even after removing them.

mock_config_two = deepcopy(mock_config)
mock_config_two.pop("Tags")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed those two lines

@Adaverse
Copy link
Contributor

Adaverse commented Jul 4, 2023

Can we also do this cleanup i.e in test test_replace_tag, it seems like the below code snippet is just laying there -

        mock_config_two = deepcopy(mock_config)
        mock_config_two.pop("Tags")

@potiuk
Copy link
Member

potiuk commented Jul 4, 2023

Can we also do this cleanup i.e in test test_replace_tag, it seems like the below code snippet is just lying there -

        mock_config_two = deepcopy(mock_config)
        mock_config_two.pop("Tags")

what do you mean by lying :) ?

@Adaverse
Copy link
Contributor

Adaverse commented Jul 4, 2023

Can we also do this cleanup i.e in test test_replace_tag, it seems like the below code snippet is just lying there -

        mock_config_two = deepcopy(mock_config)
        mock_config_two.pop("Tags")

what do you mean by lying :) ?

The variable mock_config_two isn't being used just defined. Pardon for the typo lying :).

Copy link
Contributor

@Adaverse Adaverse left a comment

Choose a reason for hiding this comment

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

LGTM

@potiuk potiuk merged commit 7a3bc8d into apache:main Jul 6, 2023
42 checks passed
@luos-fc luos-fc deleted the glue-tags branch July 6, 2023 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:providers provider:amazon-aws AWS/Amazon - related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AWS GlueCrawlerOperator deletes existing tags on run
5 participants