github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/upgrades/steps_22.go (about)

     1  // Copyright 2017 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package upgrades
     5  
     6  import (
     7  	"os"
     8  	"path/filepath"
     9  )
    10  
    11  // stateStepsFor22 returns upgrade steps for Juju 2.2 that manipulate state directly.
    12  func stateStepsFor22() []Step {
    13  	return []Step{
    14  		&upgradeStep{
    15  			description: "add machineid to non-detachable storage docs",
    16  			targets:     []Target{DatabaseMaster},
    17  			run: func(context Context) error {
    18  				return context.State().AddNonDetachableStorageMachineId()
    19  			},
    20  		},
    21  		&upgradeStep{
    22  			description: "remove application config settings with nil value",
    23  			targets:     []Target{DatabaseMaster},
    24  			run: func(context Context) error {
    25  				return context.State().RemoveNilValueApplicationSettings()
    26  			},
    27  		},
    28  		&upgradeStep{
    29  			description: "add controller log collection sizing config settings",
    30  			targets:     []Target{DatabaseMaster},
    31  			run: func(context Context) error {
    32  				return context.State().AddControllerLogCollectionsSizeSettings()
    33  			},
    34  		},
    35  		&upgradeStep{
    36  			description: "add status history pruning config settings",
    37  			targets:     []Target{DatabaseMaster},
    38  			run: func(context Context) error {
    39  				return context.State().AddStatusHistoryPruneSettings()
    40  			},
    41  		},
    42  		&upgradeStep{
    43  			description: "add storage constraints to storage instance docs",
    44  			targets:     []Target{DatabaseMaster},
    45  			run: func(context Context) error {
    46  				return context.State().AddStorageInstanceConstraints()
    47  			},
    48  		},
    49  		&upgradeStep{
    50  			description: "split log collections",
    51  			targets:     []Target{DatabaseMaster},
    52  			run: func(context Context) error {
    53  				return context.State().SplitLogCollections()
    54  			},
    55  		},
    56  	}
    57  }
    58  
    59  // stepsFor22 returns upgrade steps for Juju 2.2 that only need the API.
    60  func stepsFor22() []Step {
    61  	return []Step{
    62  		&upgradeStep{
    63  			description: "remove meter status file",
    64  			targets:     []Target{AllMachines},
    65  			run:         removeMeterStatusFile,
    66  		},
    67  	}
    68  }
    69  
    70  // removeMeterStatusFile removes the meter status file from the agent data directory.
    71  func removeMeterStatusFile(context Context) error {
    72  	dataDir := context.AgentConfig().DataDir()
    73  	meterStatusFile := filepath.Join(dataDir, "meter-status.yaml")
    74  	return os.RemoveAll(meterStatusFile)
    75  }