Skip to content

Commit fb30ceb

Browse files
committed
Add docs for bind perms
1 parent b655a47 commit fb30ceb

2 files changed

Lines changed: 42 additions & 7 deletions

File tree

docs/content/docs/Applications/ServiceBindings.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,38 @@ openrun app update bindings /apps/reporting-read /apps/metrics-read /reporting
192192

193193
This updates staging. Add `--promote` to update prod in the same command.
194194

195+
## Binding Source Permissions
196+
197+
Apps can only use bindings whose source is allowed by the app metadata (or at the system level in `openrun.toml`). The `--bind-perm` option records the allowed binding sources for an app. If `--approve` is also used, the requested binding source permissions are copied into the approved list.
198+
199+
```shell
200+
openrun app create \
201+
--bind-perm postgres/main \
202+
--approve \
203+
github.com/example/reporting-app \
204+
/reporting
205+
206+
openrun app update bind-perm --approve postgres/main /reporting
207+
```
208+
209+
By default at the system level, bindings are allowed to the default postgres and mysql services. This can be configured by updating `openrun.toml`:
210+
211+
```toml {filename="openrun.toml"}
212+
[permissions]
213+
binding_source_perms = ["postgres", "mysql"] # default postgres and mysql binding sources are allowed by default
214+
```
215+
216+
For declarative apply files, use `bind_perm` in the app definition:
217+
218+
```python {filename="apps.ace"}
219+
app(
220+
"/reporting",
221+
"github.com/example/reporting-app",
222+
bindings=["/apps/reporting-db"],
223+
bind_perm=["postgres/main"],
224+
)
225+
```
226+
195227
## Auto Bindings
196228

197229
When the value passed to `--bind` starts with `/`, OpenRun treats it as an existing binding path. When it does not start with `/`, OpenRun treats it as a service source and creates a base binding automatically.

internal/app/container_handler.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -330,13 +330,16 @@ func (h *ContainerHandler) healthChecker(ctx context.Context) {
330330

331331
time.Sleep(60 * time.Second) // wait for 1 minute to let the app start up
332332
h.Debug().Msgf("Health checker started for app %s", h.app.Id)
333-
fullHash, err := h.getAppHash()
334-
if err != nil {
335-
h.Error().Err(err).Msgf("Error getting app hash for %s", h.app.Id)
336-
return
337-
}
338-
containerName := container.GenContainerName(h.app.Id, h.manager, fullHash, h.manager.SupportsInPlaceUpdate())
339333
for range h.healthCheckTicker.C {
334+
h.stateLock.RLock()
335+
containerName := h.activeContainerName
336+
running := h.currentState == ContainerStateRunning && containerName != ""
337+
h.stateLock.RUnlock()
338+
if !running {
339+
h.Trace().Msgf("Health checker waiting for app %s to start", h.app.Id)
340+
continue
341+
}
342+
340343
err := h.WaitForHealth(h.containerConfig.StatusHealthAttempts, containerName, "")
341344
if err == nil {
342345
continue
@@ -351,7 +354,7 @@ func (h *ContainerHandler) healthChecker(ctx context.Context) {
351354
h.stateLock.Lock()
352355
h.currentState = ContainerStateHealthFailure
353356

354-
err = h.manager.StopContainer(ctx, container.GenContainerName(h.app.Id, h.manager, fullHash, h.manager.SupportsInPlaceUpdate()))
357+
err = h.manager.StopContainer(ctx, containerName)
355358
if err != nil {
356359
h.Error().Err(err).Msgf("Error stopping app %s after health failure", h.app.Id)
357360
}

0 commit comments

Comments
 (0)