Skip to content

Migrate to V2 and reuse provided token - #66

Merged
Gerrit91 merged 63 commits into
masterfrom
reuse-provided-token
Sep 9, 2026
Merged

Migrate to V2 and reuse provided token#66
Gerrit91 merged 63 commits into
masterfrom
reuse-provided-token

Conversation

@majst01

@majst01 majst01 commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Description

This is a major refactoring of #61 to reuse the provided token instead of using a admin token to fetch machines

Depends on:

replaces #61

Noteworthy

`metalctlv2` is now also supported with metal-console. Users of `metalctl` are advised to update as the `--admin` was removed, admins are now detected implicitly by the server.

Used AI-Tools ✨

  • Deepseek used for test generation

@majst01
majst01 marked this pull request as ready for review September 3, 2026 10:42
@majst01
majst01 requested a review from a team as a code owner September 3, 2026 10:42
@vknabel vknabel moved this to In Progress in Development Sep 7, 2026

@Gerrit91 Gerrit91 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Really good. Nice to see that this seems to work!

Comment thread internal/console/server.go Outdated
cs.log.Info("checking if machine is still owned by the same user", "machineID", machineID)

m, err := cs.client.Machine().FindMachine(machine.NewFindMachineParams().WithID(machineID), nil)
// we must use adminv2 because otherwise project must be passed which is not known here

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Comment is misleading because adminv2 is not always used? The project was passed and is stored in the metalv2 struct.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

removed

Comment thread internal/console/metalv2.go Outdated
Uuid: machineID,
})
if err != nil {
return nil, fmt.Errorf("failed to fetch requested machine %s %w", machineID, err)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
return nil, fmt.Errorf("failed to fetch requested machine %s %w", machineID, err)
return nil, fmt.Errorf("failed to fetch requested machine %s: %w", machineID, err)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread internal/console/metalv2.go Outdated
Project: m.project,
})
if err != nil {
return nil, fmt.Errorf("failed to fetch requested machine %s %w", machineID, err)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
return nil, fmt.Errorf("failed to fetch requested machine %s %w", machineID, err)
return nil, fmt.Errorf("failed to fetch requested machine %s: %w", machineID, err)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread internal/console/metalv1.go Outdated
func (m *metalv1) getMachine(ctx context.Context, machineID string) (*machine, error) {
resp, err := m.client.Machine().FindMachine(metalmachine.NewFindMachineParams().WithID(machineID).WithContext(ctx), nil)
if err != nil {
return nil, fmt.Errorf("failed to fetch requested machine %s %w", machineID, err)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
return nil, fmt.Errorf("failed to fetch requested machine %s %w", machineID, err)
return nil, fmt.Errorf("failed to fetch requested machine %s: %w", machineID, err)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread internal/console/server.go Outdated
Comment thread internal/console/server.go
Comment thread internal/console/server.go Outdated

func (cs *consoleServer) connectSSH(tcpConn *tls.Conn, mgmtServiceAddress, machineID string) (gossh.Conn, *gossh.Client, *gossh.Session, error) {
pubHostKey, err := loadPublicHostKey()
bb, err := os.ReadFile(cs.spec.PublicKeyFile)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should read all these files on program init in the constructor. Same for loading the certs for the metal-bmc connection.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes ! done for all key files on startup

@majst01
majst01 force-pushed the reuse-provided-token branch from 75ec3d1 to 27c10a2 Compare September 9, 2026 09:59
@Gerrit91
Gerrit91 merged commit 1708ff7 into master Sep 9, 2026
4 checks passed
@Gerrit91
Gerrit91 deleted the reuse-provided-token branch September 9, 2026 12:19
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Development Sep 9, 2026
@Gerrit91 Gerrit91 mentioned this pull request Sep 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: control-plane Affects the metal-stack control-plane area.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants