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

Refactor check to support different versions easily #3929

Merged
merged 3 commits into from
Jun 18, 2019
Merged

Refactor check to support different versions easily #3929

merged 3 commits into from
Jun 18, 2019

Conversation

ofek
Copy link
Contributor

@ofek ofek commented Jun 18, 2019

Additional Notes

The post_0_10_2 flag will be used in a subsequent PR

Copy link
Contributor

@therve therve left a comment

Choose a reason for hiding this comment

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

Some minor comments. I'm not necessarily a fan of python OO tricks, but it does the job in this case.

partition,
)
topic_partitions_without_a_leader.append((topic, partition))
def __init__(self, name, init_config, instances):
Copy link
Contributor

Choose a reason for hiding this comment

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

You can remove this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, I just thought I'd have it already there for the next PR

consumer_offsets = {}
if coord_id is not None and coord_id >= 0:
broker_ids = [coord_id]
if is_affirmative(instance.get('mode-0.10.2', False)):
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not use a flag from init_config instead? That would make more sense to me, as all instances are going to be impacted.

Arguing about naming, but I think we should make it like mode_0_10_2, if we don't find a friendlier name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Instances may use different versions of Kafka

Copy link
Contributor

Choose a reason for hiding this comment

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

Are we creating a class for every instance?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup! (in A6+)


return highwater_offsets, topic_partitions_without_a_leader
def __new__(cls, name, init_config, instances):
instance = instances[0]
Copy link
Contributor

Choose a reason for hiding this comment

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

Could there be a case where different instances use different modes?
If yes then the split should happen on the check method rather than the constructor, if not it should be a init config

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. Yes
  2. No need b/c each config instance is given its own AgentCheck instance

Copy link
Contributor

Choose a reason for hiding this comment

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

But aren't we always using the first instance to check the mode?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is only ever one instance in that list

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, we have a confusing interface for checks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A5 was different is why :(

consumer_offsets = {}
if coord_id is not None and coord_id >= 0:
broker_ids = [coord_id]
if is_affirmative(instance.get('mode-0.10.2', False)):
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe the issue is naming here but I'm reading this if like:

if 0.10.2:
    something
else:
    0.10.2

which does not make a lot of sense

)


class LegacyKafkaCheck_0_10_2(AgentCheck):
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume this is pretty much a copypaste of old kafka_consumer.py

@codecov
Copy link

codecov bot commented Jun 18, 2019

Codecov Report

Merging #3929 into master will decrease coverage by 5.55%.
The diff coverage is 69.56%.

@@            Coverage Diff             @@
##           master    #3929      +/-   ##
==========================================
- Coverage   86.31%   80.76%   -5.56%     
==========================================
  Files         763       10     -753     
  Lines       40116      551   -39565     
  Branches     4709      114    -4595     
==========================================
- Hits        34628      445   -34183     
+ Misses       4196       74    -4122     
+ Partials     1292       32    -1260

@ofek ofek merged commit 2833c79 into master Jun 18, 2019
@ofek ofek deleted the ofek/kcr branch June 18, 2019 23:40
@glasser
Copy link
Contributor

glasser commented Aug 23, 2019

Did the post_0_10_2 flag ever get added?

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.

None yet

4 participants