Skip to content
This repository was archived by the owner on Aug 4, 2020. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions deploy/bm-inventory-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ metadata:
labels:
app: bm-inventory
data:
INVENTORY_URL: REPLACE_URL
INVENTORY_PORT: REPLACE_PORT
INVENTORY_BASE_URL: REPLACE_BASE_URL
NAMESPACE: REPLACE_NAMESPACE
BASE_DNS_DOMAINS: REPLACE_DOMAINS # example: name1:id1/provider1,name2:id2/provider2
OPENSHIFT_INSTALL_RELEASE_IMAGE: "quay.io/openshift-release-dev/ocp-release@sha256:eab93b4591699a5a4ff50ad3517892653f04fb840127895bb3609b3cc68f98f3"
22 changes: 10 additions & 12 deletions internal/bminventory/inventory.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ type Config struct {
KubeconfigGenerator string `envconfig:"KUBECONFIG_GENERATE_IMAGE" default:"quay.io/ocpmetal/ignition-manifests-and-kubeconfig-generate:latest"` // TODO: update the latest once the repository has git workflow
//[TODO] - change the default of Releae image to "", once everyine wll update their environment
ReleaseImage string `envconfig:"OPENSHIFT_INSTALL_RELEASE_IMAGE" default:"quay.io/openshift-release-dev/ocp-release@sha256:eab93b4591699a5a4ff50ad3517892653f04fb840127895bb3609b3cc68f98f3"`
InventoryURL string `envconfig:"INVENTORY_URL" default:"10.35.59.36"`
InventoryPort string `envconfig:"INVENTORY_PORT" default:"30485"`
InventoryBaseURL string `envconfig:"INVENTORY_BASE_URL" default:"http://10.35.59.36:30485"`
Copy link
Owner

Choose a reason for hiding this comment

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

Default is not needed - it's incorrect anyway.

S3EndpointURL string `envconfig:"S3_ENDPOINT_URL" default:"http://10.35.59.36:30925"`
S3Bucket string `envconfig:"S3_BUCKET" default:"test"`
AwsAccessKeyID string `envconfig:"AWS_ACCESS_KEY_ID" default:"accessKey1"`
Expand Down Expand Up @@ -114,7 +113,7 @@ const ignitionConfigFormat = `{
"units": [{
"name": "agent.service",
"enabled": true,
"contents": "[Service]\nType=simple\nRestart=always\nRestartSec=3\nStartLimitIntervalSec=0\nEnvironment=HTTPS_PROXY={{.ProxyURL}}\nEnvironment=HTTP_PROXY={{.ProxyURL}}\nEnvironment=http_proxy={{.ProxyURL}}\nEnvironment=https_proxy={{.ProxyURL}}\nExecStartPre=podman run --privileged --rm -v /usr/local/bin:/hostbin {{.AgentDockerImg}} cp /usr/bin/agent /hostbin\nExecStart=/usr/local/bin/agent --host {{.InventoryURL}} --port {{.InventoryPort}} --cluster-id {{.clusterId}} --agent-version {{.AgentDockerImg}}\n\n[Install]\nWantedBy=multi-user.target"
"contents": "[Service]\nType=simple\nRestart=always\nRestartSec=3\nStartLimitIntervalSec=0\nEnvironment=HTTPS_PROXY={{.ProxyURL}}\nEnvironment=HTTP_PROXY={{.ProxyURL}}\nEnvironment=http_proxy={{.ProxyURL}}\nEnvironment=https_proxy={{.ProxyURL}}\nExecStartPre=podman run --privileged --rm -v /usr/local/bin:/hostbin {{.AgentDockerImg}} cp /usr/bin/agent /hostbin\nExecStart=/usr/local/bin/agent --url {{.InventoryBaseURL}} --cluster-id {{.clusterId}} --agent-version {{.AgentDockerImg}}\n\n[Install]\nWantedBy=multi-user.target"
}]
},
"storage": {
Expand Down Expand Up @@ -293,14 +292,13 @@ func (b *bareMetalInventory) createImageJob(jobName, imgName, ignitionConfig str

func (b *bareMetalInventory) formatIgnitionFile(cluster *common.Cluster, params installer.GenerateClusterISOParams) (string, error) {
var ignitionParams = map[string]string{
"userSshKey": b.getUserSshKey(params),
"AgentDockerImg": b.AgentDockerImg,
"InventoryURL": strings.TrimSpace(b.InventoryURL),
"InventoryPort": strings.TrimSpace(b.InventoryPort),
"clusterId": cluster.ID.String(),
"ProxyURL": params.ImageCreateParams.ProxyURL,
"PULL_SECRET": dataurl.EncodeBytes([]byte(cluster.PullSecret)),
"AGENT_MOTD": url.PathEscape(agentMessageOfTheDay),
"userSshKey": b.getUserSshKey(params),
"AgentDockerImg": b.AgentDockerImg,
"InventoryBaseURL": strings.TrimSpace(b.InventoryBaseURL),
"clusterId": cluster.ID.String(),
"ProxyURL": params.ImageCreateParams.ProxyURL,
"PULL_SECRET": dataurl.EncodeBytes([]byte(cluster.PullSecret)),
"AGENT_MOTD": url.PathEscape(agentMessageOfTheDay),
}
tmpl, err := template.New("ignitionConfig").Parse(ignitionConfigFormat)
if err != nil {
Expand Down Expand Up @@ -1598,7 +1596,7 @@ func (b *bareMetalInventory) createKubeconfigJob(cluster *common.Cluster, jobNam
},
{
Name: "INVENTORY_ENDPOINT",
Value: "http://" + strings.TrimSpace(b.InventoryURL) + ":" + strings.TrimSpace(b.InventoryPort) + "/api/assisted-install/v1",
Value: strings.TrimSpace(b.InventoryBaseURL) + "/api/assisted-install/v1",
},
{
Name: "IMAGE_NAME",
Expand Down
12 changes: 12 additions & 0 deletions internal/bminventory/inventory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,18 @@ var _ = Describe("GenerateClusterISO", func() {
})
Expect(generateReply).Should(BeAssignableToTypeOf(installer.NewGenerateClusterISOBadRequest()))
})

It("ignition_file_contains_url", func() {
cluster := registerCluster(false)

bm.InventoryBaseURL = "file://10.56.20.70:7878"
text, err := bm.formatIgnitionFile(cluster, installer.GenerateClusterISOParams{
ImageCreateParams: &models.ImageCreateParams{},
})

Expect(err).Should(BeNil())
Expect(text).Should(ContainSubstring(fmt.Sprintf("--url %s", bm.InventoryBaseURL)))
})
})

var _ = Describe("RegisterHost", func() {
Expand Down
9 changes: 4 additions & 5 deletions internal/host/installcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,12 @@ func (i *installCmd) GetStep(ctx context.Context, host *models.Host) (*models.St
}

cmdArgsTmpl := "sudo podman run -v /dev:/dev:rw -v /opt:/opt:rw --privileged --pid=host --net=host " +
"-v /var/log:/var/log:rw --name assisted-installer {{.INSTALLER}} --role {{.ROLE}} --cluster-id {{.CLUSTER_ID}} --host {{.HOST}} " +
"--port {{.PORT}} --boot-device {{.BOOT_DEVICE}} --host-id {{.HOST_ID}} --openshift-version {{.OPENSHIFT_VERSION}} " +
"--controller-image {{.CONTROLLER_IMAGE}}"
"-v /var/log:/var/log:rw --name assisted-installer {{.INSTALLER}} --role {{.ROLE}} --cluster-id {{.CLUSTER_ID}} " +
"--boot-device {{.BOOT_DEVICE}} --host-id {{.HOST_ID}} --openshift-version {{.OPENSHIFT_VERSION}} " +
"--controller-image {{.CONTROLLER_IMAGE}} --url {{.BASE_URL}}"

data := map[string]string{
"HOST": strings.TrimSpace(i.instructionConfig.InventoryURL),
"PORT": strings.TrimSpace(i.instructionConfig.InventoryPort),
"BASE_URL": strings.TrimSpace(i.instructionConfig.InventoryBaseUrl),
"CLUSTER_ID": string(host.ClusterID),
"HOST_ID": string(*host.ID),
"ROLE": string(role),
Expand Down
24 changes: 12 additions & 12 deletions internal/host/installcmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ import (
"github.com/pkg/errors"
)

const inventoryURL = "10.35.59.36"
const inventoryPort = "30485"

var defaultInstructionConfig = InstructionConfig{
InventoryURL: "10.35.59.36",
InventoryPort: "30485",
InstallerImage: "quay.io/ocpmetal/assisted-installer:latest",
ControllerImage: "quay.io/ocpmetal/assisted-installer-controller:latest",
InventoryBaseUrl: fmt.Sprintf("http://%s:%s", inventoryURL, inventoryPort),
InstallerImage: "quay.io/ocpmetal/assisted-installer:latest",
ControllerImage: "quay.io/ocpmetal/assisted-installer-controller:latest",
}

var _ = Describe("installcmd", func() {
Expand Down Expand Up @@ -151,22 +153,20 @@ func validateInstallCommand(reply *models.Step, role models.HostRole, clusterId
installCommand := "sudo podman run -v /dev:/dev:rw -v /opt:/opt:rw --privileged --pid=host " +
"--net=host -v /var/log:/var/log:rw " +
"--name assisted-installer quay.io/ocpmetal/assisted-installer:latest --role %s " +
"--cluster-id %s --host %s --port %s " +
"--cluster-id %s " +
"--boot-device /dev/sdb --host-id %s --openshift-version 4.5 " +
"--controller-image %s --host-name %s"
"--controller-image %s --url %s --host-name %s"
ExpectWithOffset(1, reply.Args[1]).Should(Equal(fmt.Sprintf(installCommand, role, clusterId,
defaultInstructionConfig.InventoryURL, defaultInstructionConfig.InventoryPort, hostId,
defaultInstructionConfig.ControllerImage, hostname)))
hostId, defaultInstructionConfig.ControllerImage, defaultInstructionConfig.InventoryBaseUrl, hostname)))
} else {
installCommand := "sudo podman run -v /dev:/dev:rw -v /opt:/opt:rw --privileged --pid=host " +
"--net=host -v /var/log:/var/log:rw " +
"--name assisted-installer quay.io/ocpmetal/assisted-installer:latest --role %s " +
"--cluster-id %s --host %s --port %s " +
"--cluster-id %s " +
"--boot-device /dev/sdb --host-id %s --openshift-version 4.5 " +
"--controller-image %s"
"--controller-image %s --url %s"
ExpectWithOffset(1, reply.Args[1]).Should(Equal(fmt.Sprintf(installCommand, role, clusterId,
defaultInstructionConfig.InventoryURL, defaultInstructionConfig.InventoryPort, hostId,
defaultInstructionConfig.ControllerImage)))
hostId, defaultInstructionConfig.ControllerImage, defaultInstructionConfig.InventoryBaseUrl)))
}
ExpectWithOffset(1, reply.StepType).To(Equal(models.StepTypeInstall))
}
3 changes: 1 addition & 2 deletions internal/host/instructionmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ type InstructionManager struct {
stateToSteps stateToStepsMap
}
type InstructionConfig struct {
InventoryURL string `envconfig:"INVENTORY_URL" default:"10.35.59.36"`
InventoryPort string `envconfig:"INVENTORY_PORT" default:"30485"`
InventoryBaseUrl string `envconfig:"INVENTORY_BASE_URL" default:"http://10.35.59.36:30485"`
Copy link
Owner

Choose a reason for hiding this comment

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

Default is not needed - it's incorrect anyway.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was trying to keep the existing functionality. Do you want me to remove it?

Copy link
Owner

Choose a reason for hiding this comment

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

i was talking about the default values, once the agent and test infra ready to this change you can remove those as well.

InstallerImage string `envconfig:"INSTALLER_IMAGE" default:"quay.io/ocpmetal/assisted-installer:latest"`
ControllerImage string `envconfig:"CONTROLLER_IMAGE" default:"quay.io/ocpmetal/assisted-installer-controller:latest"`
ConnectivityCheckImage string `envconfig:"CONNECTIVITY_CHECK_IMAGE" default:"quay.io/ocpmetal/connectivity_check:latest"`
Expand Down
3 changes: 1 addition & 2 deletions tools/deploy_assisted_installer_configmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ def main():
with open(SRC_FILE, "r") as src:
with open(DST_FILE, "w+") as dst:
data = src.read()
data = data.replace("REPLACE_URL", '"{}"'.format(service_host))
data = data.replace("REPLACE_PORT", '"{}"'.format(service_port))
data = data.replace("REPLACE_DOMAINS", '"{}"'.format(deploy_options.base_dns_domains))
data = data.replace("REPLACE_BASE_URL", f'http://{service_host}:{service_port}')
data = data.replace('REPLACE_NAMESPACE', deploy_options.namespace)
print("Deploying {}".format(DST_FILE))

Expand Down