Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop depending on default StorageClass' presence for ScyllaClusters in our manifests, examples, scripts and tests #2009

Merged
merged 4 commits into from
Jul 12, 2024
Merged
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
1 change: 1 addition & 0 deletions deploy/manager-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ spec:
members: 1
storage:
capacity: 5Gi
storageClassName: scylladb-local-xfs
resources:
limits:
cpu: 200m
Expand Down
1 change: 1 addition & 0 deletions deploy/manager-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ spec:
members: 1
storage:
capacity: 5Gi
storageClassName: scylladb-local-xfs
resources:
limits:
cpu: 1
Expand Down
1 change: 1 addition & 0 deletions deploy/manager/dev/50_scyllacluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ spec:
members: 1
storage:
capacity: 5Gi
storageClassName: scylladb-local-xfs
resources:
limits:
cpu: 200m
Expand Down
1 change: 1 addition & 0 deletions deploy/manager/prod/50_scyllacluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ spec:
members: 1
storage:
capacity: 5Gi
storageClassName: scylladb-local-xfs
resources:
limits:
cpu: 1
Expand Down
1 change: 1 addition & 0 deletions examples/helm/values.cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ racks:
members: 2
storage:
capacity: 5Gi
storageClassName: scylladb-local-xfs
resources:
limits:
cpu: 1
Expand Down
1 change: 1 addition & 0 deletions examples/helm/values.manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ scylla:
members: 1
storage:
capacity: 5Gi
storageClassName: scylladb-local-xfs
resources:
limits:
cpu: 1
Expand Down
1 change: 1 addition & 0 deletions examples/scylladb/scylla.scyllacluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ spec:
members: 1
storage:
capacity: 1Gi
storageClassName: scylladb-local-xfs
resources:
requests:
cpu: 10m
Expand Down
14 changes: 6 additions & 8 deletions hack/.ci/lib/e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,6 @@ function gather-artifacts-on-exit {
done
}

function unset-default-storageclass {
for f in "${KUBECONFIGS[@]}"; do
for r in $( KUBECONFIG="${f}" kubectl get storageclasses -o name ); do
KUBECONFIG="${f}" kubectl patch "${r}" -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"false"}}}'
done
done
}

function apply-e2e-workarounds {
if [ -z "${SO_IMAGE+x}" ]; then
echo "SO_IMAGE can't be empty" > /dev/stderr
Expand Down Expand Up @@ -191,6 +183,11 @@ function run-e2e {
exit 2
fi

if [ -z "${SO_SCYLLACLUSTER_STORAGECLASS_NAME+x}" ]; then
echo "SO_SCYLLACLUSTER_STORAGECLASS_NAME can't be empty" > /dev/stderr
exit 2
fi
tnozicka marked this conversation as resolved.
Show resolved Hide resolved

if [ -z "${ARTIFACTS+x}" ]; then
echo "ARTIFACTS can't be empty" > /dev/stderr
exit 2
Expand Down Expand Up @@ -262,6 +259,7 @@ spec:
- "--scyllacluster-node-service-type=${SO_SCYLLACLUSTER_NODE_SERVICE_TYPE}"
- "--scyllacluster-nodes-broadcast-address-type=${SO_SCYLLACLUSTER_NODES_BROADCAST_ADDRESS_TYPE}"
- "--scyllacluster-clients-broadcast-address-type=${SO_SCYLLACLUSTER_CLIENTS_BROADCAST_ADDRESS_TYPE}"
- "--scyllacluster-storageclass-name=${SO_SCYLLACLUSTER_STORAGECLASS_NAME}"
- "--object-storage-bucket=${SO_BUCKET_NAME}"
- "--gcs-service-account-key-path=${gcs_sa_in_container_path}"
image: "${SO_IMAGE}"
Expand Down
4 changes: 2 additions & 2 deletions hack/.ci/run-e2e-gke-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ trap gather-artifacts-on-exit EXIT
SO_NODECONFIG_PATH="${SO_NODECONFIG_PATH=${parent_dir}/manifests/cluster/nodeconfig.yaml}"
export SO_NODECONFIG_PATH

# Make sure there is no default storage class before we create our own so we always use our own provisioner from the release.
unset-default-storageclass
SO_SCYLLACLUSTER_STORAGECLASS_NAME="${SO_SCYLLACLUSTER_STORAGECLASS_NAME=scylladb-local-xfs}"
export SO_SCYLLACLUSTER_STORAGECLASS_NAME

SCYLLA_OPERATOR_FEATURE_GATES="${SCYLLA_OPERATOR_FEATURE_GATES:-AllAlpha=true,AllBeta=true}"
export SCYLLA_OPERATOR_FEATURE_GATES
Expand Down
5 changes: 2 additions & 3 deletions hack/.ci/run-e2e-gke.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@ SO_NODECONFIG_PATH="${SO_NODECONFIG_PATH=./hack/.ci/manifests/cluster/nodeconfig
export SO_NODECONFIG_PATH
SO_CSI_DRIVER_PATH="${parent_dir}/manifests/namespaces/local-csi-driver/"
export SO_CSI_DRIVER_PATH
SO_SCYLLACLUSTER_STORAGECLASS_NAME="${SO_SCYLLACLUSTER_STORAGECLASS_NAME=scylladb-local-xfs}"
export SO_SCYLLACLUSTER_STORAGECLASS_NAME

# Backwards compatibility. Remove when release repo stops using SO_DISABLE_NODECONFIG.
if [[ "${SO_DISABLE_NODECONFIG:-false}" == "true" ]]; then
SO_NODECONFIG_PATH=""
SO_CSI_DRIVER_PATH=""
else
# Make sure there is no default storage class before we create our own.
unset-default-storageclass
fi

SCYLLA_OPERATOR_FEATURE_GATES="${SCYLLA_OPERATOR_FEATURE_GATES:-AllAlpha=true,AllBeta=true}"
Expand Down
28 changes: 24 additions & 4 deletions hack/ci-deploy-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,11 @@ else
echo "Skipping CSI driver creation"
fi

mkdir "${ARTIFACTS}/manager"
cat > "${ARTIFACTS}/manager/kustomization.yaml" << EOF
if [[ -z "${SO_SCYLLACLUSTER_STORAGECLASS_NAME+x}" ]]; then
kubectl_create -n=scylla-manager -f="${source_url}/${revision}/deploy/manager-prod.yaml"
elif [[ -n "${SO_SCYLLACLUSTER_STORAGECLASS_NAME}" ]]; then
mkdir "${ARTIFACTS}/manager"
cat > "${ARTIFACTS}/manager/kustomization.yaml" << EOF
resources:
- ${source_url}/${revision}/deploy/manager-prod.yaml
patches:
Expand All @@ -101,9 +104,26 @@ patches:
patch: |
- op: replace
path: /spec/datacenter/racks/0/storage/storageClassName
value: scylladb-local-xfs
value: "${SO_SCYLLACLUSTER_STORAGECLASS_NAME}"
EOF
kubectl kustomize "${ARTIFACTS}/manager" | kubectl_create -n=scylla-manager -f=-
kubectl kustomize "${ARTIFACTS}/manager" | kubectl_create -n=scylla-manager -f=-
else
mkdir "${ARTIFACTS}/manager"
cat > "${ARTIFACTS}/manager/kustomization.yaml" << EOF
resources:
- ${source_url}/${revision}/deploy/manager-prod.yaml
patches:
- target:
group: scylla.scylladb.com
version: v1
kind: ScyllaCluster
name: scylla-manager-cluster
patch: |
- op: remove
path: /spec/datacenter/racks/0/storage/storageClassName
EOF
kubectl kustomize "${ARTIFACTS}/manager" | kubectl_create -n=scylla-manager -f=-
fi

kubectl -n=scylla-manager wait --timeout=5m --for='condition=Progressing=False' scyllaclusters.scylla.scylladb.com/scylla-manager-cluster
kubectl -n=scylla-manager wait --timeout=5m --for='condition=Degraded=False' scyllaclusters.scylla.scylladb.com/scylla-manager-cluster
Expand Down
5 changes: 5 additions & 0 deletions hack/ci-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ else
kubectl_create -n=local-csi-driver -f="${SO_CSI_DRIVER_PATH}"
fi

if [[ -n "${SO_SCYLLACLUSTER_STORAGECLASS_NAME}" ]]; then
yq e --inplace '.spec.datacenter.racks[0].storage.storageClassName = env(SO_SCYLLACLUSTER_STORAGECLASS_NAME)' "${DEPLOY_DIR}/manager/50_scyllacluster.yaml"
elif [[ -n "${SO_SCYLLACLUSTER_STORAGECLASS_NAME+x}" ]]; then
yq e --inplace 'del(.spec.datacenter.racks[0].storage.storageClassName)' "${DEPLOY_DIR}/manager/50_scyllacluster.yaml"
fi
kubectl_create -f "${DEPLOY_DIR}"/manager

kubectl -n=scylla-manager wait --timeout=5m --for='condition=Progressing=False' scyllaclusters.scylla.scylladb.com/scylla-manager-cluster
Expand Down
1 change: 1 addition & 0 deletions helm/deploy/manager_prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ scylla:
members: 1
storage:
capacity: 5Gi
storageClassName: scylladb-local-xfs
resources:
limits:
cpu: 1
Expand Down
1 change: 1 addition & 0 deletions helm/scylla-manager/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ scylla:
members: 1
storage:
capacity: 5Gi
storageClassName: scylladb-local-xfs
resources:
limits:
cpu: 1
Expand Down
1 change: 1 addition & 0 deletions helm/scylla/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ racks:
members: 3
# Storage definition
storage:
storageClassName: scylladb-local-xfs
capacity: 10Gi
# Scylla container resource definition
resources:
Expand Down
4 changes: 4 additions & 0 deletions pkg/cmd/tests/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type ScyllaClusterOptions struct {
NodeServiceType string
NodesBroadcastAddressType string
ClientsBroadcastAddressType string
StorageClassName string
}

var supportedNodeServiceTypes = []scyllav1.NodeServiceType{
Expand Down Expand Up @@ -63,6 +64,7 @@ func NewTestFrameworkOptions(streams genericclioptions.IOStreams, userAgent stri
NodeServiceType: string(scyllav1.NodeServiceTypeHeadless),
NodesBroadcastAddressType: string(scyllav1.BroadcastAddressTypePodIP),
ClientsBroadcastAddressType: string(scyllav1.BroadcastAddressTypePodIP),
StorageClassName: "",
},
ObjectStorageBucket: "",
GCSServiceAccountKeyPath: "",
Expand Down Expand Up @@ -98,6 +100,7 @@ func (o *TestFrameworkOptions) AddFlags(cmd *cobra.Command) {
slices.ConvertSlice(supportedBroadcastAddressTypes, slices.ToString[scyllav1.BroadcastAddressType]),
", ",
)))
cmd.PersistentFlags().StringVarP(&o.ScyllaClusterOptionsUntyped.StorageClassName, "scyllacluster-storageclass-name", "", o.ScyllaClusterOptionsUntyped.StorageClassName, fmt.Sprintf("Name of the StorageClass to request for ScyllaCluster storage."))
cmd.PersistentFlags().StringVarP(&o.ObjectStorageBucket, "object-storage-bucket", "", o.ObjectStorageBucket, "Name of the object storage bucket.")
cmd.PersistentFlags().StringVarP(&o.GCSServiceAccountKeyPath, "gcs-service-account-key-path", "", o.GCSServiceAccountKeyPath, "Path to a file containing a GCS service account key.")
}
Expand Down Expand Up @@ -158,6 +161,7 @@ func (o *TestFrameworkOptions) Complete(args []string) error {
NodesBroadcastAddressType: scyllav1.BroadcastAddressType(o.ScyllaClusterOptionsUntyped.NodesBroadcastAddressType),
ClientsBroadcastAddressType: scyllav1.BroadcastAddressType(o.ScyllaClusterOptionsUntyped.ClientsBroadcastAddressType),
},
StorageClassName: o.ScyllaClusterOptionsUntyped.StorageClassName,
}

if len(o.GCSServiceAccountKeyPath) > 0 {
Expand Down
3 changes: 3 additions & 0 deletions test/e2e/fixture/scylla/scyllacluster.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ spec:
members: 1
storage:
capacity: 1Gi
{{- if .storageClassName }}
storageClassName: {{ .storageClassName }}
{{- end }}
resources:
requests:
cpu: 10m
Expand Down
3 changes: 3 additions & 0 deletions test/e2e/fixture/scylla/zonal.scyllacluster.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ spec:
members: 1
storage:
capacity: 1Gi
{{- if $.storageClassName }}
storageClassName: {{ $.storageClassName }}
{{- end }}
resources:
requests:
cpu: 10m
Expand Down
2 changes: 2 additions & 0 deletions test/e2e/framework/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ func (f *Framework) GetDefaultScyllaCluster() *scyllav1.ScyllaCluster {
"nodeServiceType": TestContext.ScyllaClusterOptions.ExposeOptions.NodeServiceType,
"nodesBroadcastAddressType": TestContext.ScyllaClusterOptions.ExposeOptions.NodesBroadcastAddressType,
"clientsBroadcastAddressType": TestContext.ScyllaClusterOptions.ExposeOptions.ClientsBroadcastAddressType,
"storageClassName": TestContext.ScyllaClusterOptions.StorageClassName,
}

sc, _, err := scyllafixture.ScyllaClusterTemplate.RenderObject(renderArgs)
Expand All @@ -119,6 +120,7 @@ func (f *Framework) GetDefaultZonalScyllaClusterWithThreeRacks() *scyllav1.Scyll
"nodeServiceType": TestContext.ScyllaClusterOptions.ExposeOptions.NodeServiceType,
"nodesBroadcastAddressType": TestContext.ScyllaClusterOptions.ExposeOptions.NodesBroadcastAddressType,
"clientsBroadcastAddressType": TestContext.ScyllaClusterOptions.ExposeOptions.ClientsBroadcastAddressType,
"storageClassName": TestContext.ScyllaClusterOptions.StorageClassName,
"rackNames": []string{"a", "b", "c"},
}

Expand Down
3 changes: 2 additions & 1 deletion test/e2e/framework/testcontext.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ type IngressController struct {
}

type ScyllaClusterOptions struct {
ExposeOptions ExposeOptions
ExposeOptions ExposeOptions
StorageClassName string
}

type ExposeOptions struct {
Expand Down