---
title: Charmhub | Deploy MongoDB using Charmhub - The Open Operator Collection
description: Deploy the latest version of MongoDB on any cloud.
url: https://charmhub.io/mongodb/libraries/set_status
---

# MongoDB

[Canonical](https://charmhub.io/publisher/data-platform "View all packages from Canonical")

* [Canonical](https://charmhub.io/publisher/data-platform "View all packages from Canonical")
* [Databases](https://charmhub.io/?filter=databases)

Platform:

24.04

22.04

6/stable 265

```
juju deploy mongodb --channel 6/stable
```

[Learn to deploy on juju >](https://juju.is/docs/juju/manage-applications)

[Toggle side navigation](https://charmhub.io/mongodb/libraries/set_status#drawer)

## charms.mongodb.v0.set\_status

* [*Docstrings*Docstrings](https://charmhub.io/mongodb/libraries/set_status)
  [*Code*Source code](https://charmhub.io/mongodb/libraries/set_status/source-code)
* + Download

    Fetch library

    ```
    charmcraft fetch-lib charms.mongodb.v0.set_status
    ```

    [Download set\_status.py](https://charmhub.io/mongodb/libraries/set_status/download)
  + *Last updated* 16 Sep 2024
  + *Revision* Library version 0.6

Code for handing statuses in the app and unit.

---

Index

* [class MongoDBStatusHandler](https://charmhub.io/mongodb/libraries/set_status#mongodbstatushandler)
* + [def \_\_init\_\_(
    self,
    charm)](https://charmhub.io/mongodb/libraries/set_status#mongodbstatushandler-__init__)
* + [def set\_and\_share\_status(
    self,
    status)](https://charmhub.io/mongodb/libraries/set_status#mongodbstatushandler-set_and_share_status)
* + [def set\_app\_status(
    self)](https://charmhub.io/mongodb/libraries/set_status#mongodbstatushandler-set_app_status)
* + [def is\_current\_unit\_ready(
    self,
    ignore\_unhealthy\_upgrade)](https://charmhub.io/mongodb/libraries/set_status#mongodbstatushandler-is_current_unit_ready)
* + [def is\_status\_related\_to\_mismatched\_revision(
    self,
    status\_type)](https://charmhub.io/mongodb/libraries/set_status#mongodbstatushandler-is_status_related_to_mismatched_revision)
* + [def are\_all\_units\_ready\_for\_upgrade(
    self,
    unit\_to\_ignore)](https://charmhub.io/mongodb/libraries/set_status#mongodbstatushandler-are_all_units_ready_for_upgrade)
* + [def are\_shards\_status\_ready\_for\_upgrade(
    self)](https://charmhub.io/mongodb/libraries/set_status#mongodbstatushandler-are_shards_status_ready_for_upgrade)
* + [def share\_status\_to\_config\_server(
    self)](https://charmhub.io/mongodb/libraries/set_status#mongodbstatushandler-share_status_to_config_server)
* + [def is\_unit\_status\_ready\_for\_upgrade(
    self)](https://charmhub.io/mongodb/libraries/set_status#mongodbstatushandler-is_unit_status_ready_for_upgrade)
* + [def process\_statuses(
    self)](https://charmhub.io/mongodb/libraries/set_status#mongodbstatushandler-process_statuses)
* + [def get\_statuses(
    self)](https://charmhub.io/mongodb/libraries/set_status#mongodbstatushandler-get_statuses)
* + [def prioritize\_statuses(
    self,
    statuses)](https://charmhub.io/mongodb/libraries/set_status#mongodbstatushandler-prioritize_statuses)
* + [def get\_invalid\_integration\_status(
    self)](https://charmhub.io/mongodb/libraries/set_status#mongodbstatushandler-get_invalid_integration_status)
* + [def get\_cluster\_mismatched\_revision\_status(
    self)](https://charmhub.io/mongodb/libraries/set_status#mongodbstatushandler-get_cluster_mismatched_revision_status)
* [def build\_unit\_status(
  mongodb\_config,
  unit\_host
  )](https://charmhub.io/mongodb/libraries/set_status#build_unit_status)

#### class MongoDBStatusHandler

Description

Verifies versions across multiple integrated applications. None

Methods

MongoDBStatusHandler.
\_\_init\_\_(

*self*

,
charm: CharmBase
)

Constructor for CrossAppVersionChecker.

Arguments

charm

charm to inherit from.

MongoDBStatusHandler.
set\_and\_share\_status(

*self*

,
status: StatusBase
)

Description

Sets the charm status and shares to app status and config-server if applicable. None

MongoDBStatusHandler.
set\_app\_status(

*self*
)

Description

TODO Future Feature/Epic: parse statuses and set a status for the entire app. None

MongoDBStatusHandler.
is\_current\_unit\_ready(

*self*

,
ignore\_unhealthy\_upgrade: bool
)

Returns True if the current unit status shows that the unit is ready.

Description

Note: we allow the use of ignore\_unhealthy\_upgrade, to avoid infinite loops due to this
function returning False and preventing the status from being reset.

MongoDBStatusHandler.
is\_status\_related\_to\_mismatched\_revision(

*self*

,
status\_type: str
)

Returns True if the current status is related to a mimsatch in revision.

Description

Note: A few functions calling this method receive states differently. One receives them by
"goal state" which processes data differently and the other via the ".status" property.
Hence we have to be flexible to handle each.

MongoDBStatusHandler.
are\_all\_units\_ready\_for\_upgrade(

*self*

,
unit\_to\_ignore: str
)

Description

Returns True if all charm units status's show that they are ready for upgrade. None

MongoDBStatusHandler.
are\_shards\_status\_ready\_for\_upgrade(

*self*
)

Returns True if all integrated shards status's show that they are ready for upgrade.

Description

A shard is ready for upgrade if it is either in the waiting for upgrade status or active
status.

MongoDBStatusHandler.
share\_status\_to\_config\_server(

*self*
)

Description

Shares this shards status info to the config server. None

MongoDBStatusHandler.
is\_unit\_status\_ready\_for\_upgrade(

*self*
)

Description

Returns True if the status of the current unit reflects that it is ready for upgrade. None

MongoDBStatusHandler.
process\_statuses(

*self*
)

Retrieves statuses from processes inside charm and returns the highest priority status.

Description

When a non-fatal error occurs while processing statuses, the error is processed and
returned as a statuses.

TODO: add more status handling here for other cases: i.e. TLS, or resetting a status that
should not be reset

MongoDBStatusHandler.
get\_statuses(

*self*
)

Description

Retrieves statuses for the different processes running inside the unit. None

MongoDBStatusHandler.
prioritize\_statuses(

*self*

,
statuses: Tuple
)

Description

Returns the status with the highest priority from backups, sharding, and mongod. None

MongoDBStatusHandler.
get\_invalid\_integration\_status(

*self*
)

Description

Returns a status if an invalid integration is present. None

MongoDBStatusHandler.
get\_cluster\_mismatched\_revision\_status(

*self*
)

Description

Returns a Status if the cluster has mismatched revisions. None

#### def build\_unit\_status(     mongodb\_config: MongoConfiguration,     unit\_host: str )

Description

Generates the status of a unit based on its status reported by mongod. None
