Skip to content
This repository has been archived by the owner on Jun 29, 2022. It is now read-only.

baremetal: sets hostname controller_names/worker_names #1488

Merged
merged 2 commits into from
Jun 17, 2021

Conversation

ipochi
Copy link
Member

@ipochi ipochi commented Jun 9, 2021

Sets the hostname from the <cluster_name>-worker-<count_index> which
is set when set_standard_hostname is true, to
controller_names<count_index> for controllers and
worker_names<count_index> for workers

@pothos
Copy link
Member

pothos commented Jun 9, 2021

To add, the hostname change got introduced by #1477 where it was set from the template variable domain_name coming from var.controller_domains[count.index].

pothos
pothos previously approved these changes Jun 9, 2021
@pothos
Copy link
Member

pothos commented Jun 9, 2021

Can you add my comment to the commit message?

@ipochi ipochi requested review from invidian and surajssd June 9, 2021 13:23
Copy link
Member

@invidian invidian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could have some tests for this.

In general, I'd like #441 to be resolved in the first place, as it seems to me recently done changes more unify things, rather then retain old behavior, so I'm not sure about this PR. Perhaps someone more involved should decide.

set_standard_hostname = false
clc_snippets = concat(lookup(var.clc_snippets, var.controller_names[count.index], []), [
<<EOF
storage:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should make sure user can still override that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean the user would use a different name for the machine when defining it in the configuration and setting up a domain name than the hostname would be? I think it's good to check first what the behavior of CLC snippets is when the same file gets specified by the user again and if it doesn't work, document that the user has to set the hostname through a one-time service unit.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is a bug fix and does not change something related to how the user could overwrite the hostname, I think we should merge.

@ipochi ipochi force-pushed the imran/baremetal-set-hostname branch from 147040b to ca0837e Compare June 10, 2021 07:24
pothos
pothos previously approved these changes Jun 14, 2021
Copy link
Member

@pothos pothos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mercury-controller-0 name in Test_Baremetal_NodeSpecificLabels is mismatching because the K8s node name is node1 based on the hostname. I gues the K8s node name used to be overwritten and now isn't anymore, or this node-specific label test was implemented after the accidental name change. I think it's good to just use the user-provided name and later change the CI node naming to be more specific than node1, node2, node3`.

Sets the hostname from the `<cluster_name>-worker-<count_index>` which
is set when `set_standard_hostname` is true, to
`controller_names<count_index>` for controllers and
`worker_names<count_index>` for workers

The hostname change got introduced by #1477 where it was set from the
template variable `domain_name` coming from
var.controller_domains[count.index]
@ipochi ipochi force-pushed the imran/baremetal-set-hostname branch from 40074e4 to 6f44918 Compare June 17, 2021 11:16
Copy link
Member

@pothos pothos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test error message is not specific enough:

                if len(nodes.Items) == 1 && nodes.Items[0].Name != nodeName {
                        t.Errorf("expected node %q to have the labels %s", nodes.Items[0].Name, labels)
                }

I think it should be

                if len(nodes.Items) == 1 {
                                if nodes.Items[0].Name != nodeName  {
                                        t.Errorf("expected node %q but found %q to have the labels %s", nodeName, nodes.Items[0].Name, labels)
                                }
                } else {
                        t.Errorf("expected a single node, got %d", len(nodes.Items))
                }

@invidian
Copy link
Member

                if len(nodes.Items) == 1 {
                                if nodes.Items[0].Name != nodeName  {
                                        t.Errorf("expected node %q but found %q to have the labels %s", nodeName, nodes.Items[0].Name, labels)
                                }
                } else {
                        t.Errorf("expected a single node, got %d", len(nodes.Items))
                }

I'd make that two independent asserts with t.Fatal.

Signed-off-by: Imran Pochi <imran@kinvolk.io>
@ipochi ipochi force-pushed the imran/baremetal-set-hostname branch from 6f44918 to 53d1cb9 Compare June 17, 2021 12:21
@pothos
Copy link
Member

pothos commented Jun 17, 2021

Will merge now and start a new PR based on this

@pothos pothos merged commit 6a8001d into master Jun 17, 2021
@pothos pothos deleted the imran/baremetal-set-hostname branch June 17, 2021 15:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants