Updates to how we handle Machine Configurations on edit of Cluster YAML

- This change basically reverts https://github.com/rancher/dashboard/pull/9678
  and instead shows a warning
- That PR spawned the issue https://github.com/rancher/dashboard/issues/9724
- That issue created some interest
- Efforts to fix that issue described in https://github.com/rancher/dashboard/issues/9724#issuecomment-1738959640
- For 2.8.0 we're going back to how we were pre-2.8.0 and fix post-2.8.0
This commit is contained in:
Richard Cox 2023-09-28 15:07:55 +01:00
parent 022cfe2c5a
commit 211222c0cf
3 changed files with 32 additions and 6 deletions

View File

@ -653,6 +653,10 @@ asyncButton:
action: Save
success: Saved
waiting: Saving…
editAndContinue:
action: Save and Continue
success: Saved
waiting: Saving…
enable:
action: Enable
success: Enabled
@ -1840,6 +1844,9 @@ cluster:
pspChange:
title: Pod Security Policy deprecation
body: <p>Kubernetes has removed support for Pod Security Policies (PSPs) starting with version 1.25. If your cluster has PodSecurityPolicy admission controller enabled via "kube-apiserver-arg.enable-admission-plugins" in Cluster YAML, it has to be <i>manually</i> removed before proceeding with the upgrade. Additionally, any PSPs that may be present in the cluster will no longer be available/enforced. Do you want to proceed?</p>
editYamlMachinePool:
title: Save Machine Configuration
body: Machine Configurations define how Pool machines are deployed<br><br> They will be saved upfront to ensure Cluster YAML can be saved.
snapshots:
suffix: Snapshots per node
systemService:

View File

@ -327,10 +327,13 @@ export default {
async showPreviewYaml() {
if ( this.applyHooks ) {
await this.applyHooks(
BEFORE_SAVE_HOOKS,
CONTEXT_HOOK_EDIT_YAML,
);
try {
await this.applyHooks(BEFORE_SAVE_HOOKS, CONTEXT_HOOK_EDIT_YAML);
} catch (e) {
console.warn('Unablet to show yaml: ', e); // eslint-disable-line no-console
return;
}
}
const resourceYaml = this.createResourceYaml(this.yamlModifiers);

View File

@ -864,7 +864,7 @@ export default {
},
created() {
this.registerBeforeHook(this.saveMachinePools, 'save-machine-pools');
this.registerBeforeHook(this.saveMachinePools, 'save-machine-pools', 1);
this.registerBeforeHook(this.setRegistryConfig, 'set-registry-config');
this.registerAfterHook(this.cleanupMachinePools, 'cleanup-machine-pools');
this.registerAfterHook(this.saveRoleBindings, 'save-role-bindings');
@ -1235,7 +1235,23 @@ export default {
async saveMachinePools(hookContext) {
if (hookContext === CONTEXT_HOOK_EDIT_YAML) {
return;
await new Promise((resolve, reject) => {
this.$store.dispatch('cluster/promptModal', {
component: 'GenericPrompt',
componentProps: {
title: this.t('cluster.rke2.modal.editYamlMachinePool.title'),
body: this.t('cluster.rke2.modal.editYamlMachinePool.body'),
applyMode: 'editAndContinue',
confirm: (confirmed) => {
if (confirmed) {
resolve();
} else {
reject(new Error('User Cancelled'));
}
}
},
});
});
}
const finalPools = [];