Skip to content
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
31 changes: 30 additions & 1 deletion cmd/generate-config/config/config-openapi-spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"kubelet",
"manifests",
"network",
"node"
"node",
"storage"
],
"properties": {
"apiServer": {
Expand Down Expand Up @@ -267,6 +268,34 @@
"type": "string"
}
}
},
"storage": {
"description": "Storage represents a subfield of the MicroShift config data structure. Its purpose to provide a user\nfacing interface to control whether MicroShift should deploy LVMS on startup.",
"type": "object",
"properties": {
"driver": {
"description": "Driver is a user defined string value matching one of the above CSIStorageDriver values. MicroShift uses this\nvalue to decide whether to deploy the LVMS operator. An unset field defaults to \"\" during yaml parsing, and thus\ncould mean that the cluster has been upgraded. In order to support the existing out-of-box behavior, MicroShift\nassumes an empty string to mean the storage driver should be deployed.\nAllowed values are: unset or one of [\"\", \"lvms\", \"none\"]",
"type": "string",
"enum": [
"",
"none",
"lvms"
]
},
"optionalCsiComponents": {
"description": "OptionalCSIComponents is a user defined slice of CSIComponent values. These value tell MicroShift which\nadditional, non-driver, CSI controllers to deploy on start. MicroShift will deploy snapshot controller\nand webhook when no components are specified. This preserves the current deployment behavior of existing\nclusters. Users must set `.storage.optionalCsiComponents: []` to explicitly tell MicroShift not to deploy any CSI\ncomponents. The CSI Driver is excluded as it is typically deployed via the same manifest as the accompanying\nstorage driver. Like CSIStorageDriver, uninstallation is not supported as this can lead to orphaned storage\nobjects.\nAllowed values are: unset, [], or one or more of [\"snapshot-controller\", \"snapshot-webhook\"]",
"type": "array",
"items": {
"description": "OptionalCsiComponent values determine which CSI components MicroShift should deploy. Currently only csi snapshot components\nare supported.",
"type": "string",
"enum": [
"none",
"snapshot-controller",
"snapshot-webhook"
]
}
}
}
}
}
}
8 changes: 8 additions & 0 deletions docs/user/howto_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ node:
hostnameOverride: ""
nodeIP: ""
nodeIPv6: ""
storage:
driver: ""
optionalCsiComponents:
- ""

```
<!---
Expand Down Expand Up @@ -110,6 +114,10 @@ node:
hostnameOverride: ""
nodeIP: ""
nodeIPv6: ""
storage:
driver: ""
optionalCsiComponents:
- ""

```
<!---
Expand Down
11 changes: 10 additions & 1 deletion etcd/vendor/github.com/openshift/microshift/pkg/config/config.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

116 changes: 116 additions & 0 deletions etcd/vendor/github.com/openshift/microshift/pkg/config/storage.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

92 changes: 92 additions & 0 deletions packaging/greenboot/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -294,3 +294,95 @@ function log_script_exit() {
echo "FINISHED"
fi
}

# lvmsDriverShouldExist shallowly wraps some python yaml parsing to determine if the LVMS-Operator is expected to be
# deployed.
# args:
# none
# return:
# 0: "true", expect the driver to be running
# 1: "false", do not expect the driver to be running
function lvmsDriverShouldExist() {
# The python script checks the config's .storage.driver value. Parsing errors are ignored, these will be caught
# by MicroShift during startup, before this greenboot script is run. The script favors verbosity over simplified
# code.
# args:
# None
# return:
# None
# exit code:
# 0: The lvms components should be checked for. This case occurs for any one of:
# - .storage.driver == one of ["", "lvms"]
# - .storage.driver is unset (indicates default config)
# - .storage is unset (indicates default config)
# - the file cannot be opened (indicates default config)
# 1: The lvms components should not be checked for. This case occurs for:
# - .storage.driver == "none"
if python -c \
'import yaml, sys
Comment thread
copejon marked this conversation as resolved.
Outdated
try:
with open("/etc/microshift/config.yaml") as stream:
try:
config = yaml.safe_load(stream)
if config["storage"]["driver"] == "none":
sys.exit(1)
elif config["storage"]["driver"] == "lvms":
sys.exit(0)
elif config["storage"]["driver"] == "":
sys.exit(0)
else:
sys.exit(1)
except KeyError as e:
sys.exit(0)
finally:
stream.close()
except Exception as e:
print(f"error opening config: {e}", file=sys.Stderr)
'; then
return 0
fi
return 1
}
Comment thread
copejon marked this conversation as resolved.
Outdated

# csiComponentsShouldBeDeployed checks for a given csi component string identifier in the config's
# .storage.optionalCsiComponents array.
# args:
# $1 "some-csi-component"
# return:
# 0: the component should be checked for. This case occurs for any one of:
# - .storage is unset
# - .storage.optionalCsiComponents is unset
# - "some-csi-component" matches an element in .storage.optionalCsiComponents
# 1: the component should not be checked for. This case occurs for:
# - .storage.optionalCsiComponents is set and does not contain "some-csi-component"
# - .storage.optionalCsiComponents is set and len(.storage.optionalCsiComponents) == 0
function csiComponentShouldBeDeployed() {
local -r component="${1?csiComponentsShouldBeDeployed expects a single string argument, got none}"

if python -c \
'import sys
import yaml
try:
with open("/etc/microshift/config.yaml") as stream:
try:
config = yaml.safe_load(stream)
if len(config["storage"]["optionalCsiComponents"]) == 0:
sys.exit(0)
elif "none" in config["storage"]["optionalCsiComponents"]:
sys.exit(1)
elif sys.argv[1] in config["storage"]["optionalCsiComponents"]:
sys.exit(0)
else:
sys.exit(1)
except KeyError as e:
sys.exit(0)
finally:
stream.close()
except Exception as e:
print(f"error opening config: {e}", file=sys.Stderr)
' "${component}";
then
return 0
fi
return 1
}
31 changes: 22 additions & 9 deletions packaging/greenboot/microshift-running-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ set -e

SCRIPT_NAME=$(basename "$0")
SCRIPT_PID=$$
PODS_NS_LIST=(openshift-ovn-kubernetes openshift-service-ca openshift-ingress openshift-dns kube-system)
PODS_CT_LIST=(2 1 1 2 2)
PODS_NS_LIST=(openshift-ovn-kubernetes openshift-service-ca openshift-ingress openshift-dns)
PODS_CT_LIST=(2 1 1 2)
LOG_POD_EVENTS=false

# Source the MicroShift health check functions library
Expand All @@ -25,19 +25,21 @@ function forced_termination() {
exit 1
}

# Check preconditions for existence of topolvm deployment.
# Check preconditions for existence of lvms deployment.
# Adapted from MicroShift code.
#
# args: None
# return: 0 if topolvm readiness should be checked, 1 otherwise
function topolvmShouldBeDeployed() {
# return: 0 if lvms readiness should be checked, 1 otherwise
function lvmsShouldBeDeployed() {
if ! hash vgs 2>/dev/null; then
return 1
fi

if [ -f /etc/microshift/lvmd.yaml ]; then
return 0
fi
if ! lvmsDriverShouldExist; then
return 1
fi

local -r volume_groups=$(vgs --readonly --options=name --noheadings)
local -r volume_groups_count=$(echo "${volume_groups}" | wc -w)
Expand Down Expand Up @@ -139,10 +141,21 @@ if ! wait_for "${WAIT_TIMEOUT_SECS}" microshift_health_endpoints_ok ; then
exit 1
fi

if topolvmShouldBeDeployed; then
if lvmsShouldBeDeployed; then
PODS_NS_LIST+=(openshift-storage)
PODS_CT_LIST+=(2)
fi
declare -a csi_components=('csi-snapshot-controller' 'csi-snapshot-webhook')
csi_pods_ct=0
for csi_c in "${csi_components[@]}"; do
if csiComponentShouldBeDeployed "${csi_c}"; then
(( csi_pods_ct += 1 ))
fi
done
if [ ${csi_pods_ct} -gt 0 ]; then
PODS_NS_LIST+=(kube-system)
PODS_CT_LIST+=("${csi_pods_ct}")
fi

# Starting pod-specific checks
# Log list of pods and their events on failure
Expand All @@ -160,7 +173,7 @@ for i in "${!PODS_NS_LIST[@]}"; do
CHECK_PODS_NS=${PODS_NS_LIST[${i}]}

echo "Waiting ${WAIT_TIMEOUT_SECS}s for pod image(s) from the '${CHECK_PODS_NS}' namespace to be downloaded"
if ! wait_for "${WAIT_TIMEOUT_SECS}" namespace_images_downloaded ; then
if ! wait_for "${WAIT_TIMEOUT_SECS}" namespace_images_downloaded; then
echo "Error: Timed out waiting for pod image(s) from the '${CHECK_PODS_NS}' namespace to be downloaded"
exit 1
fi
Expand All @@ -172,7 +185,7 @@ for i in "${!PODS_NS_LIST[@]}"; do
CHECK_PODS_CT=${PODS_CT_LIST[${i}]}

echo "Waiting ${WAIT_TIMEOUT_SECS}s for ${CHECK_PODS_CT} pod(s) from the '${CHECK_PODS_NS}' namespace to be in 'Ready' state"
if ! wait_for "${WAIT_TIMEOUT_SECS}" namespace_pods_ready ; then
if ! wait_for "${WAIT_TIMEOUT_SECS}" namespace_pods_ready; then
echo "Error: Timed out waiting for ${CHECK_PODS_CT} pod(s) in the '${CHECK_PODS_NS}' namespace to be in 'Ready' state"
exit 1
fi
Expand Down
Loading