• Rostislav M. Georgiev's avatar
    kubeadm: config migrate handles more valid configs · 037fb610
    Rostislav M. Georgiev authored
    kubeadm config migrate uses AnyConfigFileAndDefaultsToInternal, which can
    unmarshal config from file only if InitConfiguration or JoinConfiguration are
    present. Even with that in mind, it can only return a singlie config object,
    with InitConfiguration taking precendence over JoinConfiguration. Thus, the
    following cases were not handled properly, while they were perfectly valid for
    kubeadm init/join:
    
    - ClusterConfiguration only file caused kubeadm config migrate to exit with
      error.
    - Init + Join configurations in the same file caused Init + Cluster
      configuration to be produced (ignoring JoinConfiguration). The same is valid
      when the combo is Init + Cluster + Join configurations.
    - Cluster + Join configuration ignores ClusterConfiguration and only
      JoinConfiguration gets migrated.
    
    To fix this, the following is done:
    - Introduce MigrateOldConfigFromFile which migrates old config from a file,
      while ensuring that all kubeadm originated input config kinds are taken care
      of. Add comprehensive unit tests for this.
    - Replace the use of AnyConfigFileAndDefaultsToInternal in
      kubeadm config migrate with MigrateOldConfigFromFile.
    - Remove the no longer used and error prone AnyConfigFileAndDefaultsToInternal.
    Signed-off-by: 's avatarRostislav M. Georgiev <rostislavg@vmware.com>
    037fb610
common.go 8.13 KB