Skip to content
This repository has been archived by the owner on Mar 31, 2023. It is now read-only.

Get dynamic latest CAPEI release #331

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ spec:
operator: Exists
containers:
- name: controller
image: weaveworks/cluster-api-existinginfra-controller:v0.2.4
image: weaveworks/cluster-api-existinginfra-controller:latest
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think it's safe to use latest here. That would mean that any wk binary someone used after CAPEI got updated would end up pulling the new manifest (which could easily be inconsistent w/ the binary in some way) 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jrryjcksn You're right. I'll revert this.

args:
- --verbose
resources:
Expand Down
34 changes: 32 additions & 2 deletions test/integration/container/multimaster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,34 @@ func init() {
rootDir = dir
}

func getLatestCAPEIRelease() (string, error) {
url := "https://api.github.com/repos/weaveworks/wksctl/releases"

req, err := http.NewRequest("GET", url, nil)
if err != nil {
return "", err
}

res, err := http.DefaultClient.Do(req)
if err != nil {
return "", err
}

var response []struct {
Name string `json:"name"`
}

if err := json.NewDecoder(res.Body).Decode(&response); err != nil {
return "", err
}

if len(response) == 0 {
return "", fmt.Errorf("no releases found")
}

return response[0].Name, nil
}

func TestMultimasterSetup(t *testing.T) {
// Set env var NODE_OS to either "centos" or "ubuntu" to choose a node running that OS
// e.g. NODE_OS=centos go test -v test/integration/container/...
Expand All @@ -376,8 +404,10 @@ func TestMultimasterSetup(t *testing.T) {
if shouldRetagPush(t, registryPort) {
run(t, filepath.Join(rootDir, "environments/local-docker-registry/retag_push.sh"), "-p", strconv.Itoa(registryPort))
}
// FIXME: look this value up more dynamically.
const capeiImage = "weaveworks/cluster-api-existinginfra-controller:v0.2.4"
release, err := getLatestCAPEIRelease()
Copy link
Contributor

Choose a reason for hiding this comment

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

Here, though, it seems great! :-)

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we want the version that matches the go.mod file - otherwise there is the potential to create the seed node with one version and the remaining nodes with a different version.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That seems interesting. I'm curious in how that could happen. Would getLatestCAPEIRelease() be called many times? It seems just to be called once. 🙂

assert.NoError(t, err)

var capeiImage = fmt.Sprintf("weaveworks/cluster-api-existinginfra-controller:%s", release)
run(t, "docker", "pull", capeiImage)
run(t, "docker", "tag", capeiImage, fmt.Sprintf("localhost:%d/%s", registryPort, capeiImage))
run(t, "docker", "push", fmt.Sprintf("localhost:%d/%s", registryPort, capeiImage))
Expand Down