rawfile-localpv/rawfile.py
Mehran Kholdi 0095c0e83a Implement metadata schema migration
Summary: Trying to add custom `fsType`s, new metadata fields need to be stored. We need a mechanism to migrate existing volume metadata.

Test Plan:
- Install the chart using an older image tag like `36fc480`
- Create and use a pvc
- Verify that the volume's metadata file, located at `/var/csi/rawfile/pvc-.../disk.meta` does not contain the `schema_version` field
- Upgrade the chart to use the image tag `feature-schema-migration`
- Wait until all node pods are upgraded
- Verify that the volume's metadata file contains the new `schema_version` field

Reviewers: bghadiri, h.marvi, mhyousefi, sina_rad

Reviewed By: bghadiri, h.marvi, mhyousefi

Differential Revision: https://phab.hamravesh.ir/D832
2020-07-18 09:41:24 +04:30

49 lines
1.4 KiB
Python
Executable File

#!/usr/bin/env python3
import logging
from concurrent import futures
import click
import grpc
import rawfile_servicer
from consts import CONFIG
from csi import csi_pb2_grpc
from metrics import expose_metrics
from rawfile_util import migrate_all_volume_schemas
@click.group()
@click.option("--image-repository", envvar="IMAGE_REPOSITORY")
@click.option("--image-tag", envvar="IMAGE_TAG")
def cli(image_repository, image_tag):
CONFIG["image_repository"] = image_repository
CONFIG["image_tag"] = image_tag
@cli.command()
@click.option("--endpoint", envvar="CSI_ENDPOINT", default="0.0.0.0:5000")
@click.option("--nodeid", envvar="NODE_ID")
@click.option("--enable-metrics/--disable-metrics", default=True)
def csi_driver(endpoint, nodeid, enable_metrics):
migrate_all_volume_schemas()
if enable_metrics:
expose_metrics()
server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
csi_pb2_grpc.add_IdentityServicer_to_server(
rawfile_servicer.RawFileIdentityServicer(), server
)
csi_pb2_grpc.add_NodeServicer_to_server(
rawfile_servicer.RawFileNodeServicer(node_name=nodeid), server
)
csi_pb2_grpc.add_ControllerServicer_to_server(
rawfile_servicer.RawFileControllerServicer(), server
)
server.add_insecure_port(endpoint)
server.start()
server.wait_for_termination()
if __name__ == "__main__":
logging.basicConfig()
cli()