miracle2k/k8s-snapshots

Error: No such backend

Closed this issue · 2 comments

When defining snapshot rules for PVCs on GKE I'm getting rule.invalid errors. Relevant config and outputs are below. I'm happy to troubleshoot this, but I could use some guidance on where to begin.

Deployment

kubectl describe deployments --namespace=kube-system k8s-snapshot
Name:                   k8s-snapshot
Namespace:              kube-system
CreationTimestamp:      Wed, 10 Oct 2018 09:23:01 -0700
Labels:                 app=k8s-snapshot
                        chart=k8s-snapshot-0.1.0
                        heritage=Tiller
                        release=k8s-snapshot
Annotations:            deployment.kubernetes.io/revision=1
Selector:               app=k8s-snapshot,release=k8s-snapshot
Replicas:               1 desired | 1 updated | 1 total | 1 available | 0 unavailable
StrategyType:           RollingUpdate
MinReadySeconds:        0
RollingUpdateStrategy:  25% max unavailable, 25% max surge
Pod Template:
  Labels:  app=k8s-snapshot
           release=k8s-snapshot
  Containers:
   k8s-snapshot:
    Image:  elsdoerfer/k8s-snapshots:v2.0
    Port:   <none>
    Environment:
      GCLOUD_JSON_KEYFILE_NAME:  /var/secrets/google-application-credentials/credentials.json
      USE_CLAIM_NAME:            true
      LOG_LEVEL:                 DEBUG
    Mounts:
      /var/secrets/google-application-credentials/ from google-application-credentials (ro)
  Volumes:
   google-application-credentials:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  google-application-credentials
    Optional:    false
Conditions:
  Type           Status  Reason
  ----           ------  ------
  Progressing    True    NewReplicaSetAvailable
  Available      True    MinimumReplicasAvailable
OldReplicaSets:  <none>
NewReplicaSet:   k8s-snapshot-558c758f86 (1/1 replicas created)
Events:
  Type    Reason             Age                From                   Message
  ----    ------             ----               ----                   -------
  Normal  ScalingReplicaSet  26m (x4 over 37m)  deployment-controller  Scaled down replica set k8s-snapshot-558c758f86 to 0
  Normal  ScalingReplicaSet  26m (x5 over 47m)  deployment-controller  Scaled up replica set k8s-snapshot-558c758f86 to 1

SnapshotRule Definition:

apiVersion: "k8s-snapshots.elsdoerfer.com/v1"
kind: SnapshotRule
metadata:
  name: gitlab-gitaly
spec:
  deltas: PT1H P1D P7D
  persistentVolumeClaim: repo-data-gitlab-gitaly-0

CRD definition

kubectl describe crd snapshotrules.k8s-snapshots.elsdoerfer.com
Name:         snapshotrules.k8s-snapshots.elsdoerfer.com
Namespace:
Labels:       <none>
Annotations:  <none>
API Version:  apiextensions.k8s.io/v1beta1
Kind:         CustomResourceDefinition
Metadata:
  Creation Timestamp:  2018-10-10T16:23:01Z
  Generation:          1
  Resource Version:    98171
  Self Link:           /apis/apiextensions.k8s.io/v1beta1/customresourcedefinitions/snapshotrules.k8s-snapshots.elsdoerfer.com
  UID:                 c1c7c450-cca8-11e8-8736-42010a8a0fd0
Spec:
  Group:  k8s-snapshots.elsdoerfer.com
  Names:
    Kind:       SnapshotRule
    List Kind:  SnapshotRuleList
    Plural:     snapshotrules
    Short Names:
      sr
    Singular:  snapshotrule
  Scope:       Namespaced
  Version:     v1
Status:
  Accepted Names:
    Kind:       SnapshotRule
    List Kind:  SnapshotRuleList
    Plural:     snapshotrules
    Short Names:
      sr
    Singular:  snapshotrule
  Conditions:
    Last Transition Time:  2018-10-10T16:23:01Z
    Message:               no conflicts found
    Reason:                NoConflicts
    Status:                True
    Type:                  NamesAccepted
    Last Transition Time:  2018-10-10T16:23:01Z
    Message:               the initial names have been accepted
    Reason:                InitialNamesAccepted
    Status:                True
    Type:                  Established
Events:                    <none>

PVC definition

kubectl describe pvc repo-data-gitlab-gitaly-0
Name:          repo-data-gitlab-gitaly-0
Namespace:     default
StorageClass:  standard
Status:        Bound
Volume:        pvc-754650ef-cc39-11e8-8736-42010a8a0fd0
Labels:        app=gitaly
               release=gitlab
Annotations:   pv.kubernetes.io/bind-completed=yes
               pv.kubernetes.io/bound-by-controller=yes
               volume.beta.kubernetes.io/storage-provisioner=kubernetes.io/gce-pd
Finalizers:    []
Capacity:      50Gi
Access Modes:  RWO
Events:        <none>

LOG output

[k8s_snapshots.core] backend=None message=No such backed: "None" resource=<SnapshotRule gitlab-gitaly> severity=ERROR structured_error=[{'type': 'ConfigurationError', 'message': 'No such backed: "None"', 'data': {'error': ModuleNotFoundError("No module named 'k8s_snapshots.backends.None'",)}, 'readable': ['Traceback (most recent call last):\n', '  File "/usr/local/lib/python3.6/site-packages/k8s_snapshots-0.0.0-py3.6.egg/k8s_snapshots/core.py", line 115, in rule_from_resource\n    backend = get_backend(backend_name)\n', '  File "/usr/local/lib/python3.6/site-packages/k8s_snapshots-0.0.0-py3.6.egg/k8s_snapshots/backends/__init__.py", line 22, in get_backend\n    raise ConfigurationError(f\'No such backed: "{name}"\', error=e)\n', 'k8s_snapshots.errors.ConfigurationError: ConfigurationError: No such backed: "None" {\'error\': ModuleNotFoundError("No module named \'k8s_snapshots.backends.None\'",)}\n']}]

It looks like this is just a case of the documentation being slightly out of date.
README.md has this example configuration

      containers:
      - name: k8s-snapshots
        image: elsdoerfer/k8s-snapshots:v2.0

However, the feature to specify PV and PVC doesn't exist in the v2.0 tag. Changing the spec to:

      containers:
      - name: k8s-snapshots
        image: elsdoerfer/k8s-snapshots:dev

fixes the issue.

The latest tag is now advertised.