Skip to content

Remove the EnvFactory class from the CTS code#4107

Open
clumens wants to merge 10 commits intoClusterLabs:mainfrom
clumens:no-env-factory
Open

Remove the EnvFactory class from the CTS code#4107
clumens wants to merge 10 commits intoClusterLabs:mainfrom
clumens:no-env-factory

Conversation

@clumens
Copy link
Copy Markdown
Contributor

@clumens clumens commented May 7, 2026

This is it.

clumens added 5 commits May 7, 2026 09:03
It was always provided, so remove the option for it to be None.

Ref T680
It's not an Environment instance, even though it acts an awful lot like
one.  It's actually a CtsLab instance.

Ref T680
The Corosync class is only used by cts-attrd, cts-exec, and cts-fencing
which are all standalone programs.  Nothing in the wider cts python
module uses it.  Thus we can make this change without having to modify
anything anywhere else.

Ref T680
@clumens clumens requested a review from nrwahl2 May 7, 2026 17:26
Comment thread cts/cts-lab.in
Comment thread cts/cts-lab.in
Comment thread cts/cts-lab.in
# Create the Cluster Manager object.
# Currently Corosync2 is the only available cluster manager.
cm = Corosync2()
cm = Corosync2(env)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The Corosync2 constructor needs to take this and use it instead of creating its own instance.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Github seems to be on a quest to make comments harder to see in the context of the code they're commenting on, so I might have missed something. But it's already doing that. A Corosync2 is a ClusterManager, and its __init__ method takes the same env instance and sets that as an attribute that gets used everywhere.

clumens added 5 commits May 8, 2026 09:14
Nothing uses this yet, which will cause a pylint warning, but the patch
to make use of it is going to be pretty large so I wanted to split this
out separately.

Ref T680
Instead of instantiating it through the EnvFactory class, pass through
the one that we got in test_list.  This also allows eliminating a ton of
pylint warnings.

Ref T680
Instead of using the EnvFactory class, we can just instantiate an
Environment and pass it around everywhere.  We still want there to only
be one instance of this class first because it does a lot of argument
processing which takes time, and second because each instance will get
its own random number.

Ref T680
And with this, there are no more factory classes in our python code.

Fixes T680
These don't do anything besides wrap functions in the logging module.
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