Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,13 @@ deps:
#
# So we only use the commit id as the version for the binaries built from master branch,
# and use the tag as the version for any release branches.
ifeq ($(shell git rev-parse --abbrev-ref HEAD), master)
VERSION := $(shell git log -1 --format=%h)
else
VERSION := $(shell git describe --dirty --always 2>/dev/null)
endif
VERSION ?= $(shell \
if [ "$$(git rev-parse --abbrev-ref HEAD)" = "master" ]; then \
git log -1 --format=%h; \
else \
git describe --dirty --always 2>/dev/null; \
fi)
export VERSION

.PHONY: version
version:
Expand Down Expand Up @@ -400,6 +402,13 @@ vet:
################################################################################
## BUILD IMAGES ##
################################################################################
ifdef CSI_IMAGE_NAME
export CSI_IMAGE_NAME
endif
ifdef SYNCER_IMAGE_NAME
export SYNCER_IMAGE_NAME
endif

.PHONY: images
images: | $(DOCKER_SOCK)
hack/release.sh
Expand Down
4 changes: 4 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ require (
sigs.k8s.io/yaml v1.6.0 // indirect
)

// Local govmomi with CnsUnregisterVolumeEx / AcknowledgeUnregister / QueryPendingUnregisters APIs.
// TODO: Remove once govmomi upstream merges vmware/govmomi#4027.
replace github.com/vmware/govmomi => github.com/deepakkinni/govmomi v0.24.1-0.20260531062728-bccc2167ced2

// k8s.io/kubernetes declares staging module deps as v0.0.0 with local
// replace directives. Consumers must supply their own replaces to real
// published versions.
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/deepakkinni/govmomi v0.24.1-0.20260531062728-bccc2167ced2 h1:2IE3oF3HC+sJt/iJbulu8ye0axee0UHraLWu8IIW6OQ=
github.com/deepakkinni/govmomi v0.24.1-0.20260531062728-bccc2167ced2/go.mod h1:/1lqYPsCaC3Rf+WTgMcuvs+TqJVEvLX1O4oJ51pIw4E=
github.com/dougm/pretty v0.0.0-20160325215624-add1dbc86daf h1:A2XbJkAuMMFy/9EftoubSKBUIyiOm6Z8+X5G7QpS6so=
github.com/dougm/pretty v0.0.0-20160325215624-add1dbc86daf/go.mod h1:7NQ3kWOx2cZOSjtcveTa5nqupVr2s6/83sG+rTlI7uA=
github.com/emicklei/go-restful/v3 v3.13.0 h1:C4Bl2xDndpU6nJ4bc1jXd+uTmYPVUwkD6bFY/oTyCes=
Expand Down Expand Up @@ -203,8 +205,6 @@ github.com/vmware-tanzu/vm-operator/api v1.9.1-0.20260423003402-51227659e236 h1:
github.com/vmware-tanzu/vm-operator/api v1.9.1-0.20260423003402-51227659e236/go.mod h1:nWTPpxfe4gHuuYuFcrs86+NMxfkqPk3a3IlvI8TCWak=
github.com/vmware-tanzu/vm-operator/external/byok v0.0.0-20260423003402-51227659e236 h1:2aWSkcY11sUh/s1ZTeJrH17UOUN1mtuc+UKZyMItXGo=
github.com/vmware-tanzu/vm-operator/external/byok v0.0.0-20260423003402-51227659e236/go.mod h1:8tiuyYslzjLIUmOlXZuGKQdQP2ZgWGCVhVeyptmZYnk=
github.com/vmware/govmomi v0.53.0-alpha.0.0.20260418033738-262be50854f2 h1:uZyUn9ASbYtzL3oWA/bEKQYyO2Mm2+9qNg++Nv3XQCI=
github.com/vmware/govmomi v0.53.0-alpha.0.0.20260418033738-262be50854f2/go.mod h1:0F3hChqXDrSQQnjfSiCqRE5lPD4aZlbOtKG4uroq2a4=
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
Expand Down
66 changes: 48 additions & 18 deletions hack/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,12 @@ readonly SYNCER_IMAGE_CI=${BASE_IMAGE_REPO}/syncer

PUSH=
LATEST=
# These can be set via env vars, -i/-s/-v flags, or left empty for defaults.
CUSTOM_CSI_IMAGE_NAME="${CSI_IMAGE_NAME:-}"
CUSTOM_SYNCER_IMAGE_NAME="${SYNCER_IMAGE_NAME:-}"
CSI_IMAGE_NAME=
SYNCER_IMAGE_NAME=
if [[ "$(git rev-parse --abbrev-ref HEAD)" =~ "master" ]]; then
VERSION="$(git log -1 --format=%h)"
else
VERSION="$(git describe --always 2>/dev/null)"
fi
VERSION="${VERSION:-}"
GIT_COMMIT="$(git log -1 --format=%H)"
GCR_KEY_FILE="${GCR_KEY_FILE:-}"
GOPROXY="${GOPROXY:-https://proxy.golang.org}"
Expand Down Expand Up @@ -75,15 +74,21 @@ usage: ${0} [FLAGS]
Honored environment variables:
GCR_KEY_FILE
GOPROXY
VERSION image tag to use (overridden by -v flag)
CSI_IMAGE_NAME CSI driver image name (overridden by -i flag)
SYNCER_IMAGE_NAME syncer image name (overridden by -s flag)

FLAGS
-h show this help and exit
-i CSI driver image name (e.g. myrepo/driver); overrides CSI_IMAGE_NAME env var
-k path to GCR key file. Used to login to registry if specified
(defaults to: ${GCR_KEY_FILE})
-l tag the images as \"latest\" in addition to their version
when used with -p, both tags will be pushed
-p push the images to the public container registry
-r push the image to custom registry, specify the registry to be used
-s syncer image name (e.g. myrepo/syncer); overrides SYNCER_IMAGE_NAME env var
-v image tag/version to use (e.g. mytestv1); overrides VERSION env var and git
"


Expand Down Expand Up @@ -130,7 +135,12 @@ function build_driver_images_windows() {
function build_driver_images_linux() {
echo "building ${CSI_IMAGE_NAME}:${VERSION} for linux"
docker buildx rm vsphere-csi-builder-win || echo "builder instance not found, safe to proceed"
tag="${CSI_IMAGE_NAME}-linux-${ARCH}:${VERSION}"
# If a custom image name was provided, use it as-is; otherwise append -linux-${ARCH}
if [ -n "${CUSTOM_CSI_IMAGE_NAME}" ]; then
tag="${CSI_IMAGE_NAME}:${VERSION}"
else
tag="${CSI_IMAGE_NAME}-linux-${ARCH}:${VERSION}"
fi
docker buildx build \
--platform "linux/$ARCH" \
--output "${LINUX_IMAGE_OUTPUT}" \
Expand Down Expand Up @@ -164,8 +174,8 @@ function build_syncer_image_linux() {
}

function build_images() {
CSI_IMAGE_NAME=${CSI_IMAGE_CI}
SYNCER_IMAGE_NAME=${SYNCER_IMAGE_CI}
CSI_IMAGE_NAME="${CUSTOM_CSI_IMAGE_NAME:-${CSI_IMAGE_CI}}"
SYNCER_IMAGE_NAME="${CUSTOM_SYNCER_IMAGE_NAME:-${SYNCER_IMAGE_CI}}"
LATEST="latest"

# build images for linux platform
Expand Down Expand Up @@ -258,11 +268,14 @@ function push_syncer_images() {
}

# Start of main script
while getopts ":hk:lpr:" opt; do
while getopts ":hi:k:lpr:s:v:" opt; do
case ${opt} in
h)
error "${USAGE}" && exit 1
;;
i)
CUSTOM_CSI_IMAGE_NAME="${OPTARG}"
;;
k)
GCR_KEY_FILE="${OPTARG}"
;;
Expand All @@ -275,6 +288,12 @@ while getopts ":hk:lpr:" opt; do
r)
REGISTRY="${OPTARG}"
;;
s)
CUSTOM_SYNCER_IMAGE_NAME="${OPTARG}"
;;
v)
VERSION="${OPTARG}"
;;
\?)
error "invalid option: -${OPTARG} ${USAGE}" && exit 1
;;
Expand All @@ -283,22 +302,33 @@ while getopts ":hk:lpr:" opt; do
;;
esac
done

# Resolve VERSION: -v flag or env var wins; fall back to git.
if [ -z "${VERSION}" ]; then
if [[ "$(git rev-parse --abbrev-ref HEAD)" =~ "master" ]]; then
VERSION="$(git log -1 --format=%h)"
else
VERSION="$(git describe --always 2>/dev/null)"
fi
fi
shift $((OPTIND-1))

# Verify the GCR_KEY_FILE exists if defined
if [ "${GCR_KEY_FILE}" ]; then
[ -e "${GCR_KEY_FILE}" ] || fatal "key file ${GCR_KEY_FILE} does not exist"
fi

# Validate build/release type.
case "${BUILD_RELEASE_TYPE}" in
ci|pr|release)
# do nothing
;;
*)
fatal "invalid BUILD_RELEASE_TYPE: ${BUILD_RELEASE_TYPE}"
;;
esac
# Validate build/release type when set.
if [ -n "${BUILD_RELEASE_TYPE}" ]; then
case "${BUILD_RELEASE_TYPE}" in
ci|pr|release)
# do nothing
;;
*)
fatal "invalid BUILD_RELEASE_TYPE: ${BUILD_RELEASE_TYPE}"
;;
esac
fi

mkdir -p .build

Expand Down
9 changes: 9 additions & 0 deletions manifests/supervisorcluster/1.33/cns-csi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ rules:
- apiGroups: ["cns.vmware.com"]
resources: ["cnsvolumeinfoes/status"]
verbs: ["patch"]
- apiGroups: ["cns.vmware.com"]
resources: ["csivolumeinfos"]
verbs: ["create", "get", "list", "watch", "delete", "patch", "update"]
- apiGroups: ["cns.vmware.com"]
resources: ["csivolumeinfos/status"]
verbs: ["update", "patch"]
- apiGroups: ["crd.nsx.vmware.com"]
resources: ["networkinfos"]
verbs: ["get", "watch", "list"]
Expand Down Expand Up @@ -791,6 +797,9 @@ rules:
- apiGroups: ["vmoperator.vmware.com"]
resources: ["virtualmachines"]
verbs: ["get", "list"]
- apiGroups: ["cns.vmware.com"]
resources: ["csivolumeinfos"]
verbs: ["get", "list"]
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
Expand Down
9 changes: 9 additions & 0 deletions manifests/supervisorcluster/1.34/cns-csi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ rules:
- apiGroups: ["cns.vmware.com"]
resources: ["cnsvolumeinfoes/status"]
verbs: ["patch"]
- apiGroups: ["cns.vmware.com"]
resources: ["csivolumeinfos"]
verbs: ["create", "get", "list", "watch", "delete", "patch", "update"]
- apiGroups: ["cns.vmware.com"]
resources: ["csivolumeinfos/status"]
verbs: ["update", "patch"]
- apiGroups: ["crd.nsx.vmware.com"]
resources: ["networkinfos"]
verbs: ["get", "watch", "list"]
Expand Down Expand Up @@ -791,6 +797,9 @@ rules:
- apiGroups: ["vmoperator.vmware.com"]
resources: ["virtualmachines"]
verbs: ["get", "list"]
- apiGroups: ["cns.vmware.com"]
resources: ["csivolumeinfos"]
verbs: ["get", "list"]
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
Expand Down
9 changes: 9 additions & 0 deletions manifests/supervisorcluster/1.35/cns-csi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ rules:
- apiGroups: ["cns.vmware.com"]
resources: ["cnsvolumeinfoes/status"]
verbs: ["patch"]
- apiGroups: ["cns.vmware.com"]
resources: ["csivolumeinfos"]
verbs: ["create", "get", "list", "watch", "delete", "patch", "update"]
- apiGroups: ["cns.vmware.com"]
resources: ["csivolumeinfos/status"]
verbs: ["update", "patch"]
- apiGroups: ["crd.nsx.vmware.com"]
resources: ["networkinfos"]
verbs: ["get", "watch", "list"]
Expand Down Expand Up @@ -791,6 +797,9 @@ rules:
- apiGroups: ["vmoperator.vmware.com"]
resources: ["virtualmachines"]
verbs: ["get", "list"]
- apiGroups: ["cns.vmware.com"]
resources: ["csivolumeinfos"]
verbs: ["get", "list"]
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,27 @@ const (
ReasonDetachFailed = "DetachFailed"
// ReasonFailed reflects that the CR instance is not yet ready.
ReasonFailed = "Failed"
// ReasonDroppedBySnapshotRevert reflects that the volume was removed from the VM
// as part of a snapshot revert operation. vSphere has already removed the disk;
// no ReconfigVM call is needed.
ReasonDroppedBySnapshotRevert = "DroppedBySnapshotRevert"
// ReasonDetachBlocked reflects that a ReconfigVM remove was blocked, typically
// because a vSphere snapshot still retains the disk.
ReasonDetachBlocked = "DetachBlocked"

// ConditionAttachMethod is the condition type set by CSI on a per-volume basis
// to communicate to vm-operator which attach mechanism was used.
// "Reconfig" means CSI unregistered the FCD and vm-operator should use
// ReconfigVM_Task with a file-backed disk. "CnsAttach" means CSI used the
// legacy CNS attach path.
ConditionAttachMethod = "AttachMethod"
// ReasonReconfig is the condition reason for ConditionAttachMethod when CSI
// has unregistered the FCD and placed diskPath + diskUUID on the volume
// status for vm-operator to use in ReconfigVM_Task.
ReasonReconfig = "Reconfig"
// ReasonCnsAttach is the condition reason for ConditionAttachMethod when CSI
// followed the legacy BatchAttachVolumes path (brownfield or FSS disabled).
ReasonCnsAttach = "CnsAttach"
)

// SharingMode is the sharing mode of the virtual disk.
Expand Down Expand Up @@ -145,10 +166,17 @@ type PersistentVolumeClaimStatus struct {
CnsVolumeID string `json:"cnsVolumeId,omitempty"`
// +optional

// DiskUUID is the ID obtained when volume is attached to a VM.
// DiskUUID is the stable identifier for the virtual disk
// (VirtualDisk.Backing.Uuid). Populated by CSI on greenfield attach so
// that vm-operator can verify the disk matches after ReconfigVM_Task.
DiskUUID string `json:"diskUUID,omitempty"`
// +optional

// DiskPath is the datastore path for the VMDK (populated by CSI on
// greenfield attach for vm-operator to use in ReconfigVM_Task).
DiskPath string `json:"diskPath,omitempty"`
// +optional

// Conditions describes any conditions associated with this volume.
Conditions []metav1.Condition `json:"conditions,omitempty"`
}
Expand Down
Loading