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

PCS state module: feature set for creating master slave resources #52374

Open
preussal opened this issue Apr 1, 2019 · 5 comments
Open

PCS state module: feature set for creating master slave resources #52374

preussal opened this issue Apr 1, 2019 · 5 comments
Labels
Feature new functionality including changes to functionality and code refactors, etc. State-Module
Milestone

Comments

@preussal
Copy link

preussal commented Apr 1, 2019

Description of Issue/Question

Change PCS modules/state module so, that it is possible to do

  • create a master slave resource

Setup

Requirements:
PCS is installed, pcs service is started.
there is a master / slave compatible resource. eg DRBD

pcs command:

pcs resource master --help

Usage: pcs resource master...
master [<master/slave id>] <resource id | group id> [options] [--wait[=n]]
Configure a resource or group as a multi-state (master/slave) resource.
If --wait is specified, pcs will wait up to 'n' seconds for the
operation to finish (including starting and promoting resource
instances if appropriate) and then return 0 on success or 1 on error.
If 'n' is not specified it defaults to 60 minutes.
Note: to remove a master you must remove the resource/group it contains.

adjust the Definition resource_present so that you can specify the create value in _item_present. "create = master"

def resource_present(name, resource_id, resource_type, resource_options=None, create=create cibname=None):
.
.
.

   return _item_present(name=name,
                         item='resource',
                         item_id=resource_id,
                         item_type=resource_type,
                         create=create,
                         extra_args=resource_options,
                         cibname=cibname)

or better write a separate Definition master_salve_present
Adaptation to the salt/states/pcs.py


def master_salve_present(name, resource_id, resource_type, resource_options=None, cibname=None):
    '''
    Ensure that a Master Slave resource is created

    Should be run on one cluster node only
    (there may be races)
    Can only be run on a node with a functional pacemaker/corosync

    name
        Irrelevant, not used (recommended: {{formulaname}}__resource_present_{{resource_id}})
    resource_id
        name for the resource
    resource_type
        resource type (other resouce_id)
    resource_options
        additional options for creating the resource
    cibname
        use a cached CIB-file named like cibname instead of the live CIB

    Example:

    .. code-block:: yaml

        drbd_pcs__master_slave_present_drbdname:
            pcs.master_salve_present:
                - resource_id: ms_drbdname
                - resource_type: drbdname
                - resource_options:
			- master-max=1 
			- master-node-max=1 
			- clone-max=2 
			- clone-node-max=1 
			- notify=true 
			- target-role=Started
         	- cibname: cib_for_drbdname
    '''
    return _item_present(name=name,
                         item='resource',
			 create='master',
                         item_id=resource_id,
                         item_type=resource_type,
                         extra_args=resource_options,
                         cibname=cibname)


Add master slave resources to your cluster from the resource drbdname and override the default create with master

        drbd_pcs__resource_present_drbdname:
            pcs.resource_present:
                - resource_id: ms_drbdname
                - resource_type: drbdname
                - create: master
                - resource_options:
			- master-max=1 
			- master-node-max=1 
			- clone-max=2 
			- clone-node-max=1 
			- notify=true 
			- target-role=Started

Or with seperate Definition master_salve_present

        drbd_pcs__master_salve_present_drbdname:
            pcs.master_salve_present:
                - resource_id: ms_drbdname
                - resource_type: drbdname
                - resource_options:
			- master-max=1 
			- master-node-max=1 
			- clone-max=2 
			- clone-node-max=1 
			- notify=true 
			- target-role=Started
@frogunder frogunder added this to the Approved milestone Apr 1, 2019
@frogunder frogunder added Feature new functionality including changes to functionality and code refactors, etc. State-Module labels Apr 1, 2019
@rnickle
Copy link

rnickle commented Jun 12, 2019

I ran into the same problem with PCS when I tried to do a more advanced configuration.

I put together a working solution, then thought to look and see if anybody else had raised this issue, which I thank you for filing.

As you pointed out, the 'resource_present' function can be easily repurposed to do this, with only a couple of minor changes. I named the new function 'master_present' in my solution for clarity. PCS uses the command 'master' to indicate the creation of a 'master/slave' resource, but this type of resource is also known as 'multi-state' or 'ms.'

The PCS resource command defines 4 types of resource that can be created:

'resource'
'group'
'master'
'clone'

So we should add corresponding 'group_present' and 'clone_present' functions as well as 'master_present'. I will take a look at that also.

@rnickle
Copy link

rnickle commented Jun 14, 2019

I fully tested a working pillar/state definition that builds a nested LVM DRBD resource and uses the master_present function.

I tried to hack in a 'group add' function and met with partial success, but the full functionality is not there, it will require more work.

@stale
Copy link

stale bot commented Jan 8, 2020

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

If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.

@stale stale bot added the stale label Jan 8, 2020
@rnickle
Copy link

rnickle commented Jan 8, 2020

Thanks for reminding me bot, I was hung up on a different DRBD issue and resolved that recently, I'll repull and reintegrate.

@stale
Copy link

stale bot commented Jan 8, 2020

Thank you for updating this issue. It is no longer marked as stale.

@stale stale bot removed the stale label Jan 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature new functionality including changes to functionality and code refactors, etc. State-Module
3 participants