Skip to content

Commit

Permalink
MTL-2000 Needs top-level Zypper key (#333)
Browse files Browse the repository at this point in the history
* MTL-2000 Needs top-level `Zypper` key

The `repos` key is actually nested under `zypper`, cloud-init
specifically looks for the parent key `zypper` for determining to run
the `zypper_add_repos` module.

This is compatible with the existing format of the `cloud-init.yaml`
file, which currently does not house anything under a `zypper` key.
Since this function won't be used after CSM 1.6, it's fine to leave this
way.

* Fix help message

The help message for `csi patch packages` is confusing, it is hard to
differentiate between `--config` and `--config-file`. Instead of
changing the names, this just makes it more clear which one is the CSI
config file.

* `https://packages/` is hit during MTL

During a fresh install (before CSM), we will be calling the `zypper_add_repos` module
before `net-init.sh` runs when only `mtl` resolves in DNS.

During upgrades when CSM is installed, `packages` will resolve properly
to the 10.92 address.
  • Loading branch information
rustydb authored Aug 17, 2023
1 parent ab51ed2 commit fdf99cb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
23 changes: 20 additions & 3 deletions cmd/patch/patch-packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,20 @@ type Repo struct {
// Packages is a list of packages to install on the client node.
type Packages []string

// Zypper is a map for Zypper cloud-init data.
type Zypper struct {
Repos []Repo `json:"repos"`
}

// ConfigFileData matches the current “cloud-init“ file in the CSM tarball.
type ConfigFileData struct {
Repos []Repo `json:"repos"`
Packages Packages `json:"packages"`
}

// UserData is the cloud-init structure/representation of the new data.
type UserData struct {
Repos []Repo `json:"repos"`
Zypper Zypper `json:"zypper"`
Packages Packages `json:"packages"`
}

Expand Down Expand Up @@ -106,19 +117,25 @@ func init() {
patchPackages.MarkFlagRequired("config-file")
}

// loadPackagesConfig reads the a configFile, returning its contents as unmarshalled YAML.
// loadPackagesConfig reads a configFile, returning its contents as unmarshalled YAML.
func loadPackagesConfig(filePath string) (UserData, error) {

var configData ConfigFileData
var data UserData
config, err := os.ReadFile(filePath)
if err != nil {
return data, err
}

if err := yaml.Unmarshal(config, &data); err != nil {
if err := yaml.Unmarshal(config, &configData); err != nil {
return data, err
}

data.Zypper = Zypper{
Repos: configData.Repos,
}
data.Packages = configData.Packages

return data, err
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,5 @@ func init() {
// Add a global '--config' option, so someone can pass in their own
// config file if desired, overriding the one in the current dir when
// we initialize this cobra program
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file")
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "CSI config file")
}
2 changes: 2 additions & 0 deletions pkg/pit/dnsmasq.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ domain=mtl,{{.CIDR.IP}},{{.DHCPEnd}},local
dhcp-option=interface:bond0,option:domain-search,mtl
interface=bond0
interface-name=pit.mtl,bond0
cname=packages.mtl,pit.mtl
cname=registry.mtl,pit.mtl
# This needs to point to the liveCD IP for provisioning in bare-metal environments.
dhcp-option=interface:bond0,option:dns-server,{{.PITServer}}
dhcp-option=interface:bond0,option:ntp-server,{{.PITServer}}
Expand Down

0 comments on commit fdf99cb

Please sign in to comment.