kontena / pharos-cluster

Pharos - The Kubernetes Distribution
https://k8spharos.dev/
Apache License 2.0
311 stars 43 forks source link

1.2 -> 1.3 ugprade assumes that ~/.pharos/* kubeconfigs already exist #534

Closed SpComb closed 6 years ago

SpComb commented 6 years ago

The UpgradeMaster phase uses the kube_client for the dns_patch_thread: https://github.com/kontena/pharos-cluster/blob/master/lib/pharos/phases/upgrade_master.rb#L53

This assumes that the ~/.pharos/* kubeconfig for the master already exists prior to running pharos-cluster up, because the ConfigureClient phase that writes that file only runs after the UpgradeMaster phase.

The upgrade will fail if the pharos-cluster up command is run on a different host than what was used to pharos-cluster up the cluster before the upgrade.

kke commented 6 years ago

502 could be slightly changed to fix this

SpComb commented 6 years ago

With #502 the Pharos::Phase.new(master: ...) is mostly irrelevant now, normally only the cluster_context['kubeconfig'] is used... except for Pharos::Addon#kube_client, which relies on the @kube_client[host] getting cached by the phases invoking it with a config.

The usages of Pharos::Kube.client need some cleanup, it's rather misleading now.

SpComb commented 6 years ago

This is still broken on 1.3.0-rc.2 if you first rm ~/.pharos/* before running the pharos-cluster up for the upgrade:

==> Upgrade master @ terom-pharos-master terom-xenial-test
...
    [terom-pharos-master] Upgrading control plane ...
...

No such file or directory @ rb_sysopen - /root/.pharos/master.terom-pharos-dev.kontena.works
/usr/local/lib/ruby/2.4.0/psych.rb:472:in `initialize'
/usr/local/lib/ruby/2.4.0/psych.rb:472:in `open'
/usr/local/lib/ruby/2.4.0/psych.rb:472:in `load_file'
/usr/local/bundle/gems/k8s-client-0.3.2/lib/k8s/config.rb:81:in `load_file'
/app/lib/pharos/kube.rb:62:in `host_config'
/app/lib/pharos/kube.rb:48:in `client'
/app/lib/pharos/phase.rb:83:in `kube_client'
/app/lib/pharos/phases/upgrade_master.rb:53:in `create_dns_patch_thread'
/app/lib/pharos/phases/upgrade_master.rb:39:in `upgrade'
/app/lib/pharos/phases/upgrade_master.rb:23:in `call'
/app/lib/pharos/phase_manager.rb:92:in `block in apply'
/app/lib/pharos/phase_manager.rb:53:in `yield_phase_with_retry'
/app/lib/pharos/phase_manager.rb:44:in `block in run_serial'
/app/lib/pharos/phase_manager.rb:43:in `map'
/app/lib/pharos/phase_manager.rb:43:in `run_serial'
/app/lib/pharos/phase_manager.rb:73:in `run'
/app/lib/pharos/phase_manager.rb:89:in `apply'
/app/lib/pharos/cluster_manager.rb:120:in `apply_phase'
/app/lib/pharos/cluster_manager.rb:87:in `apply_phases'
/app/lib/pharos/up_command.rb:105:in `configure'
/app/lib/pharos/up_command.rb:44:in `block in execute'
/app/lib/pharos/up_command.rb:43:in `chdir'
/app/lib/pharos/up_command.rb:43:in `execute'
/usr/local/bundle/gems/clamp-1.2.1/lib/clamp/command.rb:63:in `run'
/usr/local/bundle/gems/clamp-1.2.1/lib/clamp/subcommand/execution.rb:11:in `execute'
/usr/local/bundle/gems/clamp-1.2.1/lib/clamp/command.rb:63:in `run'
/usr/local/bundle/gems/clamp-1.2.1/lib/clamp/command.rb:132:in `run'
/app/lib/pharos/root_command.rb:18:in `run'
bin/pharos-cluster:12:in `<main>'