Skip to content

Commit

Permalink
Make caas-image-repo immutable after bootstrap for now to avoid rolli…
Browse files Browse the repository at this point in the history
…ng updating all operators;
  • Loading branch information
ycliuhw committed Aug 10, 2021
1 parent 77f994c commit b094765
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 12 deletions.
7 changes: 4 additions & 3 deletions cloudconfig/podcfg/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ func (cfg *ControllerPodConfig) GetControllerImagePath() (string, error) {

// GetJujuDbOCIImagePath returns the juju-db oci image path.
func (cfg *ControllerPodConfig) GetJujuDbOCIImagePath() (string, error) {
imageRepo := cfg.Controller.Config.CAASImageRepo()
imageRepoDetails := cfg.Controller.Config.CAASImageRepo()
imageRepo := imageRepoDetails.Repository
if imageRepo == "" {
imageRepo = JujudOCINamespace
}
Expand All @@ -47,7 +48,7 @@ func GetJujuOCIImagePath(controllerCfg controller.Config, ver version.Number, bu
// First check the deprecated "caas-operator-image-path" config.
ver.Build = build
imagePath, err := RebuildOldOperatorImagePath(
controllerCfg.CAASOperatorImagePath(), ver,
controllerCfg.CAASOperatorImagePath().Repository, ver,
)
if imagePath != "" || err != nil {
return imagePath, err
Expand All @@ -56,7 +57,7 @@ func GetJujuOCIImagePath(controllerCfg controller.Config, ver version.Number, bu
if ver != version.Zero {
tag = ver.String()
}
return imageRepoToPath(controllerCfg.CAASImageRepo(), tag)
return imageRepoToPath(controllerCfg.CAASImageRepo().Repository, tag)
}

// RebuildOldOperatorImagePath returns a updated image path for the specified juju version.
Expand Down
37 changes: 28 additions & 9 deletions controller/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import (
"github.com/juju/utils/v2"
"gopkg.in/juju/environschema.v1"

"github.com/juju/juju/core/resources"
// "github.com/juju/juju/core/resources"
"github.com/juju/juju/docker"
"github.com/juju/juju/pki"
)

Expand Down Expand Up @@ -424,8 +425,8 @@ var (
PublicDNSAddress,
JujuHASpace,
JujuManagementSpace,
CAASOperatorImagePath,
CAASImageRepo,
// CAASOperatorImagePath,
// CAASImageRepo,
Features,
MaxCharmStateSize,
MaxAgentStateSize,
Expand Down Expand Up @@ -832,14 +833,18 @@ func (c Config) JujuManagementSpace() string {

// CAASOperatorImagePath sets the url of the docker image
// used for the application operator.
func (c Config) CAASOperatorImagePath() string {
return c.asString(CAASOperatorImagePath)
func (c Config) CAASOperatorImagePath() *docker.ImageRepoDetails {
o, _ := docker.NewImageRepoDetails(c.asString(CAASOperatorImagePath))
return o
// return c.asString(CAASOperatorImagePath)
}

// CAASImageRepo sets the url of the docker repo
// used for the jujud operator and mongo images.
func (c Config) CAASImageRepo() string {
return c.asString(CAASImageRepo)
func (c Config) CAASImageRepo() *docker.ImageRepoDetails {
o, _ := docker.NewImageRepoDetails(c.asString(CAASImageRepo))
return o
// return c.asString(CAASImageRepo)
}

// MeteringURL returns the URL to use for metering api calls.
Expand Down Expand Up @@ -1001,15 +1006,29 @@ func Validate(c Config) error {
}

if v, ok := c[CAASOperatorImagePath].(string); ok && v != "" {
if err := resources.ValidateDockerRegistryPath(v); err != nil {
// if err := resources.ValidateDockerRegistryPath(v); err != nil {
imageDetails, err := docker.NewImageRepoDetails(v)
if err != nil {
return errors.Trace(err)
}
if err = imageDetails.Validate(); err != nil {
return errors.Trace(err)
}
c[CAASOperatorImagePath] = imageDetails.String()
fmt.Printf("c[CAASOperatorImagePath] -> %q", c[CAASOperatorImagePath])
}

if v, ok := c[CAASImageRepo].(string); ok && v != "" {
if err := resources.ValidateDockerRegistryPath(v); err != nil {
// if err := resources.ValidateDockerRegistryPath(v); err != nil {
imageDetails, err := docker.NewImageRepoDetails(v)
if err != nil {
return errors.Trace(err)
}
if err = imageDetails.Validate(); err != nil {
return errors.Trace(err)
}
c[CAASImageRepo] = imageDetails.String()
fmt.Printf("c[CAASImageRepo] -> %q", c[CAASImageRepo])
}

var auditLogMaxSize int
Expand Down

0 comments on commit b094765

Please sign in to comment.