Skip to content

Conversation

deepdivenow
Copy link

Issue #, if available:

Description of changes:
Add CalcOnlyRunning option to ProxMox scheduler.
Add Scheduler feature ignore VMs in Not Running State for test environments.
Refactor goproxmox options for support new local options

Testing performed:
Testing on local env with proxmox 8.3.3

Copy link

github-actions bot commented Mar 2, 2025

External PR

Test runs on external PRs require manual approval.

Copy link

github-actions bot commented Mar 2, 2025

🚀 e2e tests run

We add labels to the PRs to control the e2e test runs by running specific tests and skipping some test contexts,
please follow this guide:

Label Behaviour
none Run Generic tests
e2e/none skip all e2e tests (documentation etc) - overrides all e2e/* labels Do not run any tests (overrides all e2e/ flags)
e2e/flatcar run Flatcar e2e tests Add Flatcar tests to the run

ℹ️ Ask a Member to add the requested labels if you don't have enough permissions.

)
opts := []any{proxmox.WithHTTPClient(httpClient), proxmox.WithAPIToken(ProxmoxTokenID, ProxmoxSecret)}
if strings.ToLower(ProxmoxReserveOnlyRunning) == "true" {
opts = append(opts, goproxmox.WithCalcOnlyRunning())
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't be better to set it as field in the cluster/machine spec?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree.

Copy link
Author

@deepdivenow deepdivenow Mar 26, 2025

Choose a reason for hiding this comment

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

Wouldn't be better to set it as field in the cluster/machine spec?

Maybe on Cluster scope, on mashine scope need special config structure for each physical node in physical proxmox Cluster.
proxmoxmachines.infrastructure.cluster.x-k8s.io is virtualMashine and very strange set this option here (not For Physical mashine|node)

@wikkyk
Copy link
Collaborator

wikkyk commented Mar 6, 2025

What's the context for this change?

Copy link
Collaborator

@wikkyk wikkyk left a comment

Choose a reason for hiding this comment

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

I don't like this change. I think I get the use case but you need to elaborate on the problem being solved here.
Besides, the naming is inconsistent and it's a user interface change so it needs user documentation.

// ProxmoxSecret env variable that defines the Proxmox secret for the given token id.
ProxmoxSecret string
ProxmoxSecret string
ProxmoxReserveOnlyRunning string
Copy link
Collaborator

Choose a reason for hiding this comment

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

The name of this variable isn't particularly descriptive and it's missing a comment.
The type should be bool.

proxmox.WithAPIToken(ProxmoxTokenID, ProxmoxSecret),
)
opts := []any{proxmox.WithHTTPClient(httpClient), proxmox.WithAPIToken(ProxmoxTokenID, ProxmoxSecret)}
if strings.ToLower(ProxmoxReserveOnlyRunning) == "true" {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use a bool.

ProxmoxURL = env.GetString("PROXMOX_URL", "")
ProxmoxTokenID = env.GetString("PROXMOX_TOKEN", "")
ProxmoxSecret = env.GetString("PROXMOX_SECRET", "")
ProxmoxReserveOnlyRunning = env.GetString("PROXMOX_RESERVE_ONLY_RUNNING", "")
Copy link
Collaborator

Choose a reason for hiding this comment

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

A new environment variable needs user documentation.

// NewAPIClient initializes a Proxmox API client. If the client is misconfigured, an error is returned.
func NewAPIClient(ctx context.Context, logger logr.Logger, baseURL string, options ...proxmox.Option) (*APIClient, error) {
// options can be goproxmox.Option or proxmox.Option
func NewAPIClient(ctx context.Context, logger logr.Logger, baseURL string, options ...any) (*APIClient, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Definitely not ...any.

Comment on lines +57 to +68
var pOpts []proxmox.Option
var apiOpts []Option
for _, option := range options {
switch o := option.(type) {
case proxmox.Option:
pOpts = append(pOpts, o)
case Option:
apiOpts = append(apiOpts, o)
default:
return nil, fmt.Errorf("invalid option %T", option)
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should've been a type.

Copy link
Author

@deepdivenow deepdivenow Mar 26, 2025

Choose a reason for hiding this comment

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

Can you get example
How to not use "any", if we have type from upstream library "proxmox.Option", and we need local type in this library?

Comment on lines -61 to +90
return &APIClient{
ac := &APIClient{
Client: upstreamClient,
logger: logger,
}, nil
}
for _, o := range apiOpts {
o(ac)
}
return ac, nil
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ditto.

@deepdivenow
Copy link
Author

What's the context for this change?

For example my test environment have a lot VMs, but most of the time these machines are not working.
Now scheduler calc RAM of this mashines as USED, but physical node have a lot of free memory for run new VMs.
изображение

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants