Skip to content

Commit

Permalink
Fix initlialize-port-resources flag and change default to True an…
Browse files Browse the repository at this point in the history
…d catch failures in ONCE resync (#202)
  • Loading branch information
Tankilevitch authored Nov 3, 2023
1 parent 712bc4b commit b3afb28
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 6 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

<!-- towncrier release notes start -->

## 0.4.1 (2023-11-03)

### Bug Fixes

- Fixed the `initialize-port-resources` option in `ocean sail` to not be a flag.
- Changed default of `initialize-port-resources` to `true`.
- Catch all exceptions in the resync of ONCE event listener,to make sure the application will exit gracefully


## 0.4.0 (2023-10-31)

### Features
Expand Down
6 changes: 3 additions & 3 deletions port_ocean/cli/commands/sail.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
"--initialize-port-resources",
"initialize_port_resources",
type=bool,
is_flag=True,
help="""Set to true to create default resources on installation.
If not specified, the default value is false.""",
help="""Set to False to not create default resources on installation.
If not specified, will use the environment variable `OCEAN__INITIALIZE_PORT_RESOURCES` to determine whether
to initialize resources, and if not set, will default to True.""",
)
@click.option(
"-O",
Expand Down
2 changes: 1 addition & 1 deletion port_ocean/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class IntegrationSettings(BaseModel, extra=Extra.allow):


class IntegrationConfiguration(BaseOceanSettings, extra=Extra.allow):
initialize_port_resources: bool = False
initialize_port_resources: bool = True
scheduled_resync_interval: int | None = None
port: PortSettings
event_listener: EventListenerSettingsType
Expand Down
6 changes: 5 additions & 1 deletion port_ocean/core/event_listener/once.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ async def start(self) -> None:
@repeat_every(seconds=0, max_repetitions=1)
async def resync_and_exit() -> None:
logger.info("Once event listener started")
await self.events["on_resync"]({})
try:
await self.events["on_resync"]({})
except Exception:
# we catch all exceptions here to make sure the application will exit gracefully
logger.exception("Error occurred while resyncing")
logger.info("Once event listener finished")
logger.info("Exiting application")
signal.raise_signal(signal.SIGINT)
Expand Down
1 change: 1 addition & 0 deletions port_ocean/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def run(
# Override config with arguments
if initialize_port_resources is not None:
app.config.initialize_port_resources = initialize_port_resources

if app.config.initialize_port_resources:
initialize_defaults(
app.integration.AppConfigHandlerClass.CONFIG_CLASS, app.config
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "port-ocean"
version = "0.4.0"
version = "0.4.1"
description = "Port Ocean is a CLI tool for managing your Port projects."
readme = "README.md"
homepage = "https://app.getport.io"
Expand Down

0 comments on commit b3afb28

Please sign in to comment.