-
Notifications
You must be signed in to change notification settings - Fork 44
DLPX-73229 iSCSI initiator name should be unique on each engine #300
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright (c) 2021 by Delphix. All rights reserved. | ||
# | ||
|
||
# | ||
# This script generates a unique initiator name based on the system-uuid | ||
# | ||
|
||
PATH=/bin:/usr/bin/ | ||
|
||
NAME_FILE="/etc/iscsi/initiatorname.iscsi" | ||
AUTHORITY="2008-07.com.delphix" | ||
|
||
if [[ -f $NAME_FILE ]]; then | ||
system_uuid=$(get-system-uuid) | ||
|
||
if [[ ${#system_uuid} -ne 36 ]]; then | ||
echo "Error: unexpected UUID -- $system_uuid" >&2 | ||
exit 1 | ||
fi | ||
|
||
name_entry="InitiatorName=iqn.$AUTHORITY:$system_uuid" | ||
|
||
# | ||
# Generate IQN for this Delphix Engine (if not already present) | ||
# | ||
if ! grep -Gq "^$name_entry" $NAME_FILE; then | ||
{ | ||
echo "## DO NOT EDIT OR REMOVE THIS FILE!" | ||
echo "## If you remove this file, the iSCSI daemon will not start." | ||
echo "## If you change the InitiatorName, existing access control lists" | ||
echo "## may reject this initiator. The InitiatorName must be unique" | ||
echo "## for each iSCSI initiator. Do NOT duplicate iSCSI InitiatorNames." | ||
printf '%s\n' "$name_entry" | ||
} >$NAME_FILE | ||
chmod 640 $NAME_FILE | ||
echo "Generating unique iSCSI name using UUID $system_uuid" | ||
fi | ||
fi | ||
|
||
exit 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# | ||
# Copyright 2021 Delphix | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
[Unit] | ||
Description=One time IQN configuration for iscsid.service | ||
Before=open-iscsi.service | ||
|
||
[Service] | ||
Type=oneshot | ||
RemainAfterExit=no | ||
ExecStart=/lib/open-iscsi/unique-name-check.sh | ||
|
||
[Install] | ||
WantedBy=open-iscsi.service |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright 2021 Delphix | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
PATH=/bin:/usr/bin/:/usr/sbin | ||
|
||
set -o pipefail | ||
|
||
function die() { | ||
echo "$(basename "$0"): $*" >&2 | ||
exit 1 | ||
} | ||
|
||
[[ "$EUID" -ne 0 ]] && die "must be run as root" | ||
|
||
if [[ $# -ne 0 ]]; then | ||
echo "Error: unexpected arguments" | ||
echo "Usage: $(basename "$0")" | ||
echo | ||
echo "Display the persistent system uuid for the appliance." | ||
exit 2 | ||
fi | ||
|
||
# | ||
# Extract the 'system-uuid' property. | ||
# | ||
# This property is used for an engine-uuid as well as to derive | ||
# a unique iSCSI initiator IQN. | ||
# | ||
# NOTE: | ||
# IBMcloud changes the system-uuid whenever the engine is | ||
# power-cycled but preserves the chassis-asset-tag-uuid. For that | ||
# cloud provider we use that property to obtain a UUID. | ||
# | ||
if [[ "$(dmidecode -s chassis-asset-tag)" == "ibmcloud" ]]; then | ||
DMI_KEYWORD="baseboard-asset-tag" | ||
else | ||
DMI_KEYWORD="system-uuid" | ||
fi | ||
|
||
system_uuid=$(dmidecode -s $DMI_KEYWORD | awk '{print tolower($0)}') | ||
|
||
echo -n "$system_uuid" | ||
exit 0 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of introducing a dependent service, could this have been done by adding an
ExecStartPre
to theopen-iscsi.service
unit via override?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried that initially but that service doesn't run on first boot.