Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: inventory builder overwrites the already existing nodes specified in the host.yaml #7577

Closed
VladMasarik opened this issue Apr 30, 2021 · 2 comments · Fixed by #7583
Closed
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@VladMasarik
Copy link
Contributor

Environment:

  • Version of Python (python --version):
  • Python 3.8.5

Kubespray version (commit) (git rev-parse --short HEAD):
5ea2d1e

Expected behavior:
With the following file I execute

KUBE_MASTERS_MASTERS=1 CONFIG_FILE=inventory/mycluster/hosts.yaml python contrib/inventory_builder/inventory.py 10.0.0.8

hosts.yaml file. (I think this should show that there is a bug as well, but I accidentally deleted my previous file which worked. In case you need it, I can try replicating it.)

all:
  hosts:
    main:
      ansible_host: 40.114.118.34
      ip: 10.0.1.6
      access_ip: 40.114.118.34
    node1:
      ansible_host: 10.0.0.9
      ip: 10.0.0.9
      access_ip: 10.0.0.9
  children:
    kube-master:
      hosts:
        main:
    kube_node:
      hosts:
        main:
        node1:
    etcd:
      hosts:
        main:
    k8s_cluster:
      children:
        kube_control_plane:
        kube_node:
    calico_rr:
      hosts: {}
    kube_control_plane:
      hosts:
        main:
        node1:

I expect the inventory.py script to add new entry while keeping the old ones:

all:
  hosts:
    main:
      ansible_host: 40.114.118.34
      ip: 10.0.1.6
      access_ip: 40.114.118.34
    node1:
      ansible_host: 10.0.0.9
      ip: 10.0.0.9
      access_ip: 10.0.0.9
    node2:
      ansible_host: 10.0.0.8
      ip: 10.0.0.8
      access_ip: 10.0.0.8

Actual behavior:
All hosts are deleted, except for the newly specified one:

all:
  hosts:
    node1:
      ansible_host: 10.0.0.8
      ip: 10.0.0.8
      access_ip: 10.0.0.8

I believe I have also found the bug+fix, but I got no response on Slack yet. When I wanted to submit a PR you mentioned I should create an issue, and I also think I found other bugs, with which I am not sure how to deal with. So my questions are:

  1. Is this an actual issue or I am just doing something wrong?
  2. How should I proceed if I think I have a fix, but I encountered other bugs, with which I am not sure how to deal with?
@VladMasarik VladMasarik added the kind/bug Categorizes issue or PR as related to a bug. label Apr 30, 2021
VladMasarik added a commit to VladMasarik/kubespray that referenced this issue May 2, 2021
@k8s-triage-robot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jul 29, 2021
@VladMasarik
Copy link
Contributor Author

/remove-lifecycle stale
PR exists, but it is not merged in yet

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Aug 18, 2021
k8s-ci-robot pushed a commit that referenced this issue Sep 10, 2021
* Fix: adding new ips with inventory builder (#7577)

* moved conflig loading logic
to after checking whether the config
should be loaded, and added check for
whether the config should be loaded

* added check for removing nodes from config
if the user wants to remove a node, we
need to load the config

* Fix tox errors
LuckySB pushed a commit to southbridgeio/kubespray that referenced this issue Oct 23, 2021
…bernetes-sigs#7583)

* Fix: adding new ips with inventory builder (kubernetes-sigs#7577)

* moved conflig loading logic
to after checking whether the config
should be loaded, and added check for
whether the config should be loaded

* added check for removing nodes from config
if the user wants to remove a node, we
need to load the config

* Fix tox errors
sakuraiyuta pushed a commit to sakuraiyuta/kubespray that referenced this issue Apr 16, 2022
…bernetes-sigs#7583)

* Fix: adding new ips with inventory builder (kubernetes-sigs#7577)

* moved conflig loading logic
to after checking whether the config
should be loaded, and added check for
whether the config should be loaded

* added check for removing nodes from config
if the user wants to remove a node, we
need to load the config

* Fix tox errors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants