Skip to content

Commit 8a6b773

Browse files
authored
fix: only execute cloud-init-status-check.sh when it exists on the node (#7456)
1 parent debfb48 commit 8a6b773

File tree

59 files changed

+462
-61
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+462
-61
lines changed

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,6 @@
7575
],
7676
"files.trimTrailingWhitespace": true,
7777
"files.trimTrailingWhitespaceInRegexAndStrings": true,
78-
"files.insertFinalNewline": true
78+
"files.insertFinalNewline": true,
79+
"go.testTimeout": "30m"
7980
}
Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
echo $(date),$(hostname) > ${PROVISION_OUTPUT};
22
{{if not .GetDisableCustomData}}
3-
cloud-init status --wait > /dev/null 2>&1;
4-
[ "$?" -ne 0 ] && echo 'cloud-init failed' >> ${PROVISION_OUTPUT} && exit 1;
5-
echo "cloud-init succeeded" >> ${PROVISION_OUTPUT};
3+
CLOUD_INIT_STATUS_SCRIPT="/opt/azure/containers/cloud-init-status-check.sh";
4+
cloudInitExitCode=0;
5+
if [ -f "${CLOUD_INIT_STATUS_SCRIPT}" ]; then
6+
/bin/bash -c "source ${CLOUD_INIT_STATUS_SCRIPT}; handleCloudInitStatus \"${PROVISION_OUTPUT}\"; returnStatus=\$?; echo \"Cloud init status check exit code: \$returnStatus\" >> ${PROVISION_OUTPUT}; exit \$returnStatus" >> ${PROVISION_OUTPUT} 2>&1;
7+
else
8+
cloud-init status --wait > /dev/null 2>&1;
9+
fi;
10+
cloudInitExitCode=$?;
11+
if [ "$cloudInitExitCode" -eq 0 ]; then
12+
echo "cloud-init succeeded" >> ${PROVISION_OUTPUT};
13+
else
14+
echo "cloud-init failed with exit code ${cloudInitExitCode}" >> ${PROVISION_OUTPUT};
15+
exit ${cloudInitExitCode};
16+
fi;
617
{{end}}
718
{{if getIsAksCustomCloud .CustomCloudConfig}}
819
REPO_DEPOT_ENDPOINT="{{.CustomCloudConfig.RepoDepotEndpoint}}"
920
{{getInitAKSCustomCloudFilepath}} >> /var/log/azure/cluster-provision.log 2>&1;
1021
{{end}}
11-
/usr/bin/nohup /bin/bash -c "/bin/bash /opt/azure/containers/provision_start.sh"
22+
/usr/bin/nohup /bin/bash -c "/bin/bash /opt/azure/containers/provision_start.sh"

parts/linux/cloud-init/artifacts/cse_cmd.sh

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
PROVISION_OUTPUT="/var/log/azure/cluster-provision-cse-output.log";
22
echo $(date),$(hostname) > ${PROVISION_OUTPUT};
33
{{if ShouldEnableCustomData}}
4-
/bin/bash -c "source /opt/azure/containers/cloud-init-status-check.sh; handleCloudInitStatus \"${PROVISION_OUTPUT}\"; returnStatus=\$?; echo \"Cloud init status check exit code: \$returnStatus\" >> ${PROVISION_OUTPUT}; exit \$returnStatus" >> ${PROVISION_OUTPUT} 2>&1;
4+
CLOUD_INIT_STATUS_SCRIPT="/opt/azure/containers/cloud-init-status-check.sh";
5+
cloudInitExitCode=0;
6+
if [ -f "${CLOUD_INIT_STATUS_SCRIPT}" ]; then
7+
/bin/bash -c "source ${CLOUD_INIT_STATUS_SCRIPT}; handleCloudInitStatus \"${PROVISION_OUTPUT}\"; returnStatus=\$?; echo \"Cloud init status check exit code: \$returnStatus\" >> ${PROVISION_OUTPUT}; exit \$returnStatus" >> ${PROVISION_OUTPUT} 2>&1;
8+
else
9+
cloud-init status --wait > /dev/null 2>&1;
10+
fi;
511
cloudInitExitCode=$?;
6-
[ "$cloudInitExitCode" -ne 0 ] && echo "cloud-init failed with exit code ${cloudInitExitCode}" >> ${PROVISION_OUTPUT} && exit ${cloudInitExitCode};
12+
if [ "$cloudInitExitCode" -eq 0 ]; then
13+
echo "cloud-init succeeded" >> ${PROVISION_OUTPUT};
14+
else
15+
echo "cloud-init failed with exit code ${cloudInitExitCode}" >> ${PROVISION_OUTPUT};
16+
exit ${cloudInitExitCode};
17+
fi;
718
{{end}}
819
{{if IsAKSCustomCloud}}
920
REPO_DEPOT_ENDPOINT="{{AKSCustomCloudRepoDepotEndpoint}}"

pkg/agent/baker.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,9 @@ func getContainerServiceFuncMap(config *datamodel.NodeBootstrappingConfiguration
774774
return datamodel.AzureADIdentitySystem
775775
},
776776
"GetPodInfraContainerSpec": func() string {
777+
if config.K8sComponents == nil {
778+
return ""
779+
}
777780
return config.K8sComponents.PodInfraContainerImageURL
778781
},
779782
"IsKubenet": func() bool {
@@ -838,9 +841,15 @@ func getContainerServiceFuncMap(config *datamodel.NodeBootstrappingConfiguration
838841
return cs.Properties.HasDCSeriesSKU()
839842
},
840843
"GetHyperkubeImageReference": func() string {
844+
if config.K8sComponents == nil {
845+
return ""
846+
}
841847
return config.K8sComponents.HyperkubeImageURL
842848
},
843849
"GetLinuxPrivatePackageURL": func() string {
850+
if config.K8sComponents == nil {
851+
return ""
852+
}
844853
return config.K8sComponents.LinuxPrivatePackageURL
845854
},
846855
"GetTargetEnvironment": func() string {

0 commit comments

Comments
 (0)