Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1487559 - [RFE] foreman-maintain maintenance-mode command
Summary: [RFE] foreman-maintain maintenance-mode command
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Satellite Maintain
Version: Unspecified
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: Unspecified
Assignee: Kavita
QA Contact: Jameer Pathan
URL:
Whiteboard:
: 1314742 1526749 (view as bug list)
Depends On:
Blocks: 1122832 1496794
TreeView+ depends on / blocked
 
Reported: 2017-09-01 09:27 UTC by Ivan Necas
Modified: 2023-09-07 18:56 UTC (History)
13 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-03-05 16:17:26 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 22198 0 High Closed foreman-maintain maintenance-mode command 2021-02-03 12:24:42 UTC
Red Hat Knowledge Base (Solution) 2760281 0 None None None 2017-11-02 16:54:03 UTC

Description Ivan Necas 2017-09-01 09:27:51 UTC
As part of the pre-migrations phase, we perform steps to temporary disable functionality to make sure the upgrades are run in isolation from outside, e.g.

* Disable enabled sync plans, stores information about the disabled sync plans to file to be able to restore it in SyncPlans::Enable

* Disable external traffic on port 443 to prevent the interference with the system while the uprade runs

The commands to work with the maintenance-mode:

1. foreman-maintain maintenance-mode status 
   Shows the status of the maintenance mode. Possible values:

   * off - the maintenance mode is off
   * on - the maintenance mode is on
   * partially on - there were some steps of the maintenance mode already set,  while some parts were not
   * not available - since foreman-maintain can run not only the satellite, on some installations (such as clients), this might not be avaiable

2. foreman-maintain maintenance-mode on
   Runs the steps to enable the maintenance mode

3. foreman-maintain maintenance-mode off
   Runs the steps to disable the maintenance mode


The exact steps to turn the maintenance mode on/off might differ from different versions and server vs proxy.

Comment 6 Bryan Kearney 2017-11-02 16:54:04 UTC
*** Bug 1314742 has been marked as a duplicate of this bug. ***

Comment 7 Ivan Necas 2018-01-09 15:09:15 UTC
Created redmine issue http://projects.theforeman.org/issues/22198 from this bug

Comment 8 Anurag Patel 2018-01-10 13:53:26 UTC
*** Bug 1526749 has been marked as a duplicate of this bug. ***

Comment 9 Satellite Program 2018-05-16 20:10:34 UTC
Upstream bug assigned to kgaikwad

Comment 10 Peter Vreman 2018-11-02 15:48:28 UTC
With Sat6.4 the system requirements are more reasonable now with 20GB memory and ~800GB disk space.

For me this BZ can be closed as delivered with Sat6.4

Comment 11 Bryan Kearney 2018-12-17 18:03:14 UTC
Ivan, how are you with comment 10?

Comment 12 Peter Vreman 2018-12-18 14:27:31 UTC
Looks like i typed a comment in the wrong BZ, https://bugzilla.redhat.com/show_bug.cgi?id=1487559#c10 was meant for BZ https://bugzilla.redhat.com/show_bug.cgi?id=1408380 and has nothing to do with maintenance mode.

Sorry for the confusion,
Peter

Comment 15 Bryan Kearney 2019-02-21 13:01:57 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue https://projects.theforeman.org/issues/22198 has been resolved.

Comment 21 Jameer Pathan 2019-07-02 11:37:11 UTC
Verified

-Satellite version: satellite-6.6.0-5.beta.el7sat.noarch
-foreman-maintain version: rubygem-foreman_maintain-0.4.3-2.el7sat.noarch

Steps:
1. "maintenance-mode" command
# foreman-maintain maintenance-mode --help
Usage:
    foreman-maintain maintenance-mode [OPTIONS] SUBCOMMAND [ARG] ...

Parameters:
    SUBCOMMAND                    subcommand
    [ARG] ...                     subcommand arguments

Subcommands:
    start                         Start maintenance-mode
    stop                          Stop maintenance-mode
    status                        Get maintenance-mode status
    is-enabled                    Get maintenance-mode status code

Options:
    -h, --help                    print help

2. "maintenance-mode status" command
# foreman-maintain maintenance-mode status
Running Status of maintenance-mode
================================================================================
Check of maintenance-mode consistency: 
/ Running status of maintenance-mode                                            

Status of maintenance-mode: Off
- Iptables chain: absent
- sync plans: empty data
- cron jobs: not managed                                              [OK]
--------------------------------------------------------------------------------

2. "maintenance-mode is-enabled" command
# foreman-maintain maintenance-mode is-enabled
Running Show only status code of maintenance-mode
================================================================================
Showing status code for maintenance_mode: 
Maintenance mode is Off                                               [OK]
--------------------------------------------------------------------------------

1

3. "maintenance-mode start" command
- Create few sync-plans and add ":manage_crond: true" in "/etc/foreman-maintain/foreman_maintain.yml" 
file to manage cron service.

# foreman-maintain maintenance-mode start
Running Start maintenance-mode
================================================================================
disable active sync plans: 
- Total 3 sync plans are now disabled.                                [OK]      
--------------------------------------------------------------------------------
Add maintenance_mode chain to iptables:                               [OK]
--------------------------------------------------------------------------------
Stop cron service: 
Stopping the following service(s):

crond
\ All services stopped                                                [OK]      
--------------------------------------------------------------------------------

- Information about the disabled sync plans is stored in "/var/lib/foreman-maintain/data.yml" file to be able to use it to re-enable sync plans.
# cat /var/lib/foreman-maintain/data.yml 
---
:default:
  :sync_plans:
    :enabled: []
    :disabled:
    - 1
    - 2
    - 3

4. Check status of maintenace-mode
# foreman-maintain maintenance-mode status
Running Status of maintenance-mode
================================================================================
Check of maintenance-mode consistency: 
/ Running status of maintenance-mode                                            

Status of maintenance-mode: On
- Iptables chain: present
- sync plans: disabled
- cron jobs: not running                                              [OK]
--------------------------------------------------------------------------------

# foreman-maintain maintenance-mode is-enabled
Running Show only status code of maintenance-mode
================================================================================
Showing status code for maintenance_mode: 
Maintenance mode is On                                                [OK]
--------------------------------------------------------------------------------

0

5. "maintenance-mode stop" command
# foreman-maintain maintenance-mode stop
Running Stop maintenance-mode
================================================================================
re-enable sync plans: 
\ Total 3 sync plans are now enabled.                                 [OK]      
--------------------------------------------------------------------------------
Remove maintenance_mode chain from iptables:                          [OK]
--------------------------------------------------------------------------------
Start cron service: 
Starting the following service(s):

crond
\ All services started                                                [OK]      
--------------------------------------------------------------------------------

# foreman-maintain maintenance-mode status
Running Status of maintenance-mode
================================================================================
Check of maintenance-mode consistency: 
/ Running status of maintenance-mode                                            

Status of maintenance-mode: Off
- Iptables chain: absent
- sync plans: enabled
- cron jobs: running                                                  [OK]
--------------------------------------------------------------------------------


Observation:
1. "maintenance-mode status" gives status of:
- maintenance-mode is On or Off.
- Sync-plans enabled/disabled.
- Whether maintenance_mode chain is added to iptables.
- state of cron service

2. "maintenance-mode is-enabled" gives maintenance-mode status code,
0 when maintenance-mode is On and 1 if it's Off.

3. "maintenance-mode start" command:
- Adds maintenance_mode chain to iptables.
- Disables active sync-plans
- stops cron service. (if manage_crond is set to true in "/etc/foreman-maintain/foreman_maintain.yml")

4. "maintenance-mode stop" command:
- Removes maintenance_mode chain from iptables.
- re-enables sync-plans which got disabled during "maintenance-mode start"
- starts cron service.

Additional info:
- maintenance-mode subcommand is also supported on capsule for backup scenario as cron start/stop and iptables chain rule for 443 will work on capsule.
Foreman Maintain won't run sync-plan procedures on capsule as it checks for feature katello. (Reference comment #20 )

Comment 22 Bryan Kearney 2020-03-05 16:17:26 UTC
The current version of foreman_maintain includes this fix.

Comment 23 Bryan Kearney 2020-03-05 16:17:49 UTC
The current version of foreman_maintain includes this fix.


Note You need to log in before you can comment on or make changes to this bug.