-
Notifications
You must be signed in to change notification settings - Fork 129
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
PMM-12573 Update podman via UI. #3128
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
41c0323
PMM-12573 Update UI podman.
BupycHuk c47aa2c
PMM-12573 Fix tests and linters.
BupycHuk b198056
PMM-12573 Added empty line at end of file.
BupycHuk e095a8c
PMM-12573 Simplify update logic.
BupycHuk 36dfcc9
PMM-12573 don't expose watchtower.
BupycHuk 7cf938f
PMM-12573 change path of env file.
BupycHuk 95e9f3b
Merge branch 'v3' into PMM-12573-update-ui-podman
BupycHuk ecfeadc
PMM-12573 Revert unnecessary changes.
BupycHuk 5b2c6bf
PMM-12573 Refactoring.
BupycHuk 47c925c
PMM-12573 update watchtower config.
BupycHuk 4c3e6f8
PMM-212573 fix path to watchtower env file.
BupycHuk 17312aa
Merge branch 'v3' into PMM-12573-update-ui-podman
BupycHuk 27105d2
Merge branch 'v3' into PMM-12573-update-ui-podman
BupycHuk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
build/packer/ansible/roles/podman-setup/templates/pmm-server.env
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
PMM_WATCHTOWER_HOST=http://watchtower:8080 | ||
PMM_WATCHTOWER_TOKEN=123 | ||
PMM_SERVER_UPDATE_VERSION=docker.io/perconalab/pmm-server:3-dev-container | ||
PMM_DEV_UPDATE_DOCKER_IMAGE=docker.io/perconalab/pmm-server:3-dev-container | ||
PMM_IMAGE={{ pmm_server_image_name }} | ||
PMM_DISTRIBUTION_METHOD={{ pmm_distribution_method }} | ||
PMM_DISTRIBUTION_METHOD={{ pmm_distribution_method }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
build/packer/ansible/roles/podman-setup/templates/watchtower.env
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
WATCHTOWER_HTTP_API_UPDATE=1 | ||
WATCHTOWER_HTTP_API_TOKEN=123 | ||
WATCHTOWER_NO_RESTART=1 | ||
WATCHTOWER_DEBUG=1 | ||
WATCHTOWER_CLEANUP=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,6 +46,7 @@ const ( | |
updateCheckInterval = 24 * time.Hour | ||
updateCheckResultFresh = updateCheckInterval + 10*time.Minute | ||
updateDefaultTimeout = 30 * time.Second | ||
envfilePath = "/home/pmm/update/pmm-server.env" | ||
) | ||
|
||
var fileName = "/etc/pmm-server-update-version.json" | ||
|
@@ -173,6 +174,19 @@ func (up *Updater) StartUpdate(ctx context.Context, newImageName string) error { | |
return grpcstatus.Errorf(codes.FailedPrecondition, "failed to check watchtower host") | ||
} | ||
|
||
if _, e := os.Stat(envfilePath); e == nil { | ||
err := up.updatePodmanEnvironmentVariables(envfilePath, newImageName) | ||
if err != nil { | ||
up.running = false | ||
up.l.WithError(err).Error("Failed to update environment variables file") | ||
return errors.Wrap(err, "failed to update environment variables file") | ||
} | ||
} else if !os.IsNotExist(e) { | ||
up.running = false | ||
up.l.WithError(e).Error("Failed to check environment variables file") | ||
return errors.Wrap(e, "failed to check environment variables file") | ||
} | ||
|
||
if err := up.sendRequestToWatchtower(ctx, newImageName); err != nil { | ||
up.running = false | ||
up.l.WithError(err).Error("Failed to trigger update") | ||
|
@@ -475,6 +489,27 @@ func (up *Updater) checkWatchtowerHost() error { | |
return nil | ||
} | ||
|
||
func (up *Updater) updatePodmanEnvironmentVariables(filename string, name string) error { | ||
if len(strings.Split(name, "/")) < 3 { | ||
name = "docker.io/" + name | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. podman requires full name to update. |
||
} | ||
file, err := os.ReadFile(filename) | ||
if err != nil { | ||
return errors.Wrap(err, "failed to read file") | ||
} | ||
lines := strings.Split(string(file), "\n") | ||
for i, line := range lines { | ||
if strings.Contains(line, "PMM_IMAGE") { | ||
lines[i] = fmt.Sprintf("PMM_IMAGE=%s", name) | ||
} | ||
} | ||
err = os.WriteFile(filename, []byte(strings.Join(lines, "\n")), 0o644) | ||
if err != nil { | ||
return errors.Wrap(err, "failed to write file") | ||
} | ||
return nil | ||
} | ||
|
||
func isHostAvailable(host string, port string, timeout time.Duration) bool { | ||
conn, err := net.DialTimeout("tcp", net.JoinHostPort(host, port), timeout) | ||
if err != nil { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
PMM_WATCHTOWER_HOST=http://watchtower:8080 | ||
PMM_WATCHTOWER_TOKEN=123 | ||
PMM_IMAGE=docker.io/perconalab/pmm-server:3-dev-latest | ||
PMM_DISTRIBUTION_METHOD=ami |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it will be dropped before GA