@@ -590,15 +590,15 @@ func (d *common) restartCommon(inst instance.Instance, timeout time.Duration) er
590590 Snapshot : inst .IsSnapshot (),
591591 }
592592
593- err := inst .Update (args , false )
593+ err := inst .Update (args , instance . UpdateActionInternal )
594594 if err != nil {
595595 return err
596596 }
597597
598598 // On function return, set the flag back on
599599 defer func () {
600600 args .Ephemeral = ephemeral
601- _ = inst .Update (args , false )
601+ _ = inst .Update (args , instance . UpdateActionInternal )
602602 }()
603603 }
604604
@@ -1188,7 +1188,7 @@ func (d *common) restoreCommon(inst instance.Instance, source instance.Instance,
11881188 Snapshot : d .IsSnapshot (),
11891189 }
11901190
1191- err := inst .Update (args , false )
1191+ err := inst .Update (args , instance . UpdateActionInternal )
11921192 if err != nil {
11931193 op .Done (err )
11941194 return false , nil , err
@@ -1197,7 +1197,7 @@ func (d *common) restoreCommon(inst instance.Instance, source instance.Instance,
11971197 // On function return, set the flag back on.
11981198 defer func () {
11991199 args .Ephemeral = ephemeral
1200- err = inst .Update (args , false )
1200+ err = inst .Update (args , instance . UpdateActionInternal )
12011201 if err != nil {
12021202 d .logger .Error ("Failed restoring ephemeral flag after restore" , logger.Ctx {"err" : err })
12031203 }
@@ -1236,7 +1236,7 @@ func (d *common) restoreCommon(inst instance.Instance, source instance.Instance,
12361236
12371237 // Don't pass as user-requested as there's no way to fix a bad config.
12381238 // This will call d.UpdateBackupFile() to ensure snapshot list is up to date.
1239- err = inst .Update (args , false )
1239+ err = inst .Update (args , instance . UpdateActionInternal )
12401240 if err != nil {
12411241 op .Done (err )
12421242 return false , nil , err
@@ -1400,6 +1400,11 @@ func (d *common) isStartableStatusCode(statusCode api.StatusCode) error {
14001400 return nil
14011401}
14021402
1403+ // isUserRequested returns whether the update action is user-requested.
1404+ func (d * common ) isUserRequested (actionType instance.UpdateAction ) bool {
1405+ return actionType == instance .UpdateActionUser || actionType == instance .UpdateActionUserRefresh
1406+ }
1407+
14031408// getStartupSnapNameAndExpiry returns the name and expiry for a snapshot to be taken at startup.
14041409func (d * common ) getStartupSnapNameAndExpiry (inst instance.Instance ) (string , * time.Time , error ) {
14051410 schedule := strings .ToLower (d .expandedConfig ["snapshots.schedule" ])
@@ -2235,7 +2240,7 @@ func (d *common) removeDiskDevices() error {
22352240}
22362241
22372242// validateConfig validates the configuration.
2238- func (d * common ) validateConfig (allUpdatedDeviceKeys []string , addDevices deviceConfig.Devices , removeDevices deviceConfig.Devices , oldExpandedDevices deviceConfig.Devices , changedConfigKeys []string , oldExpandedConfig map [string ]string , userRequested bool ) error {
2243+ func (d * common ) validateConfig (allUpdatedDeviceKeys []string , addDevices deviceConfig.Devices , removeDevices deviceConfig.Devices , oldExpandedDevices deviceConfig.Devices , changedConfigKeys []string , oldExpandedConfig map [string ]string , actionType instance. UpdateAction ) error {
22392244 if shared .StringPrefixInSlice (deviceConfig .ConfigInitialPrefix , allUpdatedDeviceKeys ) {
22402245 for devName , newDev := range addDevices {
22412246 for k , newVal := range newDev {
@@ -2248,8 +2253,8 @@ func (d *common) validateConfig(allUpdatedDeviceKeys []string, addDevices device
22482253 return fmt .Errorf ("New device %q with initial configuration %q cannot be added once the instance is created" , devName , k )
22492254 }
22502255
2251- if k == deviceConfig .ConfigInitialPrefix + "zfs.promote" {
2252- // Allow zfs.promote to be added as this is needed for volume promotion.
2256+ if actionType == instance . UpdateActionUserRefresh && k == deviceConfig .ConfigInitialPrefix + "zfs.promote" {
2257+ // Allow zfs.promote to be added only during refresh as this is needed for volume promotion.
22532258 continue
22542259 }
22552260
@@ -2266,6 +2271,8 @@ func (d *common) validateConfig(allUpdatedDeviceKeys []string, addDevices device
22662271 }
22672272 }
22682273
2274+ userRequested := d .isUserRequested (actionType )
2275+
22692276 if userRequested {
22702277 // Look for deleted protected keys.
22712278 protectedKeys := map [string ]struct {}{
0 commit comments