k8s storage not attached until after pod is spun up

Bug #1818507 reported by Stuart Bishop
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Canonical Juju
Triaged
Low
Unassigned

Bug Description

storage-attached hooks do not run for k8s charms until after pod-spec-set has been called and the pod is spun up. Until then, juju storage shows 'pending' with no further feedback.

This means that charms cannot wait until required storage is available before spinning up the pod, such as this failing example:

@hook("pgdata-storage-attached")
def pgdata_storage_attached():
    reactive.set_flag("postgresql.pgdata.attached")
    status.maintenance("pgdata storage attached")

@when_not("postgresql.pgdata.attached")
def require_pgdata():
    status.waiting("pgdata not attached")

@when_not('postgresql.configured')
@when('postgresql.storage.attached')
def config_container():
    status.maintenance('configuring container')
    caas_base.pod_spec_set(make_pod_spec()):

The storage section of my metadata.yaml:

storage:
  pgdata:
    type: filesystem
    description: >
      Database data files (ie. $PGDATA). Stores all of your data and
      indexes. Mainly random access reads and writes.
    minimum-size: 5M
    location: /srv/pgdata
    multiple:
      range: "1"

Spinning up the pod before required resources are not available takes care, as we need to ensure clients cannot actually use it and risk losing data when the pod is reset into the final state.

Revision history for this message
John A Meinel (jameinel) wrote :

Its an interesting chicken-and-egg problem where we don't know what pods you're going to start until you tell us, but you need to know how to configure those pods before you start them.

What storage information would be useful to help you get started with a pod that would consume storage?

Changed in juju:
status: New → Incomplete
Revision history for this message
Stuart Bishop (stub) wrote :

For my needs, the charm needs to know that the named storage has been attached (normally signalled by the foo-storage-attached hook), and will be mounted at the location defined in metadata.yaml when the pod is spun up.

A k8s charm may be able to assume that mandatory storage will be there, in which case the storage hooks are completely unnecessary. If storage is optional, however, the charm needs to know if it has been attached, or if alternative steps taken (such as setting the workload status to blocked).

Changed in juju:
status: Incomplete → New
Revision history for this message
Richard Harding (rharding) wrote :

Putting this down as a feature request for when/if we do storage on k8s where things like the hooks would come into play.

Changed in juju:
status: New → Triaged
importance: Undecided → Wishlist
Revision history for this message
Ian Booth (wallyworld) wrote :

I don't understand comment #3. We do run storage hooks.

To clarify, the storage-attached hook is run as soon as storage is provisioned to the pod, but this can only possibly happen after pod-spec-set is called since the pod and its storage attachment(s) are part of the pod spec template handed off to the statefulset. The charm needs to wait until any required resources such as storage are available if that's how it needs to operate.

Revision history for this message
Canonical Juju QA Bot (juju-qa-bot) wrote :

This bug has not been updated in 2 years, so we're marking it Low importance. If you believe this is incorrect, please update the importance.

Changed in juju:
importance: Wishlist → Low
tags: added: expirebugs-bot
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.