pr feedback

cloud-runner-develop
Frostebite 2026-01-18 16:51:31 +00:00
parent 54adcbb959
commit dc7c16ce58
3 changed files with 88 additions and 1 deletions

38
dist/index.js vendored
View File

@ -4579,6 +4579,38 @@ class KubernetesStorage {
let checkCount = 0;
try {
cloud_runner_logger_1.default.log(`watch Until PVC Not Pending ${name} ${namespace}`);
// Check if storage class uses WaitForFirstConsumer binding mode
// If so, skip waiting - PVC will bind when pod is created
let shouldSkipWait = false;
try {
const pvcBody = (await kubeClient.readNamespacedPersistentVolumeClaim(name, namespace)).body;
const storageClassName = pvcBody.spec?.storageClassName;
if (storageClassName) {
const kubeConfig = new k8s.KubeConfig();
kubeConfig.loadFromDefault();
const storageV1Api = kubeConfig.makeApiClient(k8s.StorageV1Api);
try {
const sc = await storageV1Api.readStorageClass(storageClassName);
const volumeBindingMode = sc.body.volumeBindingMode;
if (volumeBindingMode === 'WaitForFirstConsumer') {
cloud_runner_logger_1.default.log(`StorageClass "${storageClassName}" uses WaitForFirstConsumer binding mode. PVC will bind when pod is created. Skipping wait.`);
shouldSkipWait = true;
}
}
catch (scError) {
// If we can't check the storage class, proceed with normal wait
cloud_runner_logger_1.default.log(`Could not check storage class binding mode: ${scError}. Proceeding with normal wait.`);
}
}
}
catch (pvcReadError) {
// If we can't read PVC, proceed with normal wait
cloud_runner_logger_1.default.log(`Could not read PVC to check storage class: ${pvcReadError}. Proceeding with normal wait.`);
}
if (shouldSkipWait) {
cloud_runner_logger_1.default.log(`Skipping PVC wait - will bind when pod is created`);
return;
}
const initialPhase = await this.getPVCPhase(kubeClient, name, namespace);
cloud_runner_logger_1.default.log(`Initial PVC phase: ${initialPhase}`);
// Wait until PVC is NOT Pending (i.e., Bound or Available)
@ -4602,6 +4634,12 @@ class KubernetesStorage {
.slice(-5); // Get last 5 events
if (pvcEvents.length > 0) {
cloud_runner_logger_1.default.log(`PVC Events: ${JSON.stringify(pvcEvents, undefined, 2)}`);
// Check if event indicates WaitForFirstConsumer
const waitForConsumerEvent = pvcEvents.find((e) => e.reason === 'WaitForFirstConsumer' || e.message?.includes('waiting for first consumer'));
if (waitForConsumerEvent) {
cloud_runner_logger_1.default.log(`PVC is waiting for first consumer. This is normal for WaitForFirstConsumer storage classes. Proceeding without waiting.`);
return true; // Exit wait loop - PVC will bind when pod is created
}
}
}
catch (eventError) {

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -50,6 +50,44 @@ class KubernetesStorage {
let checkCount = 0;
try {
CloudRunnerLogger.log(`watch Until PVC Not Pending ${name} ${namespace}`);
// Check if storage class uses WaitForFirstConsumer binding mode
// If so, skip waiting - PVC will bind when pod is created
let shouldSkipWait = false;
try {
const pvcBody = (await kubeClient.readNamespacedPersistentVolumeClaim(name, namespace)).body;
const storageClassName = pvcBody.spec?.storageClassName;
if (storageClassName) {
const kubeConfig = new k8s.KubeConfig();
kubeConfig.loadFromDefault();
const storageV1Api = kubeConfig.makeApiClient(k8s.StorageV1Api);
try {
const sc = await storageV1Api.readStorageClass(storageClassName);
const volumeBindingMode = sc.body.volumeBindingMode;
if (volumeBindingMode === 'WaitForFirstConsumer') {
CloudRunnerLogger.log(
`StorageClass "${storageClassName}" uses WaitForFirstConsumer binding mode. PVC will bind when pod is created. Skipping wait.`,
);
shouldSkipWait = true;
}
} catch (scError) {
// If we can't check the storage class, proceed with normal wait
CloudRunnerLogger.log(`Could not check storage class binding mode: ${scError}. Proceeding with normal wait.`);
}
}
} catch (pvcReadError) {
// If we can't read PVC, proceed with normal wait
CloudRunnerLogger.log(`Could not read PVC to check storage class: ${pvcReadError}. Proceeding with normal wait.`);
}
if (shouldSkipWait) {
CloudRunnerLogger.log(`Skipping PVC wait - will bind when pod is created`);
return;
}
const initialPhase = await this.getPVCPhase(kubeClient, name, namespace);
CloudRunnerLogger.log(`Initial PVC phase: ${initialPhase}`);
@ -78,6 +116,17 @@ class KubernetesStorage {
if (pvcEvents.length > 0) {
CloudRunnerLogger.log(`PVC Events: ${JSON.stringify(pvcEvents, undefined, 2)}`);
// Check if event indicates WaitForFirstConsumer
const waitForConsumerEvent = pvcEvents.find(
(e) => e.reason === 'WaitForFirstConsumer' || e.message?.includes('waiting for first consumer'),
);
if (waitForConsumerEvent) {
CloudRunnerLogger.log(
`PVC is waiting for first consumer. This is normal for WaitForFirstConsumer storage classes. Proceeding without waiting.`,
);
return true; // Exit wait loop - PVC will bind when pod is created
}
}
} catch (eventError) {
// Ignore event fetch errors