-
Notifications
You must be signed in to change notification settings - Fork 54
Add CalcOnlyRunning option to ProxMox scheduler #432
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
base: main
Are you sure you want to change the base?
Conversation
External PRTest runs on external PRs require manual approval. |
🚀 e2e tests runWe add labels to the PRs to control the e2e test runs by running specific tests and skipping some test contexts,
ℹ️ Ask a |
) | ||
opts := []any{proxmox.WithHTTPClient(httpClient), proxmox.WithAPIToken(ProxmoxTokenID, ProxmoxSecret)} | ||
if strings.ToLower(ProxmoxReserveOnlyRunning) == "true" { | ||
opts = append(opts, goproxmox.WithCalcOnlyRunning()) |
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.
Wouldn't be better to set it as field in the cluster/machine spec?
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.
I agree.
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.
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)
What's the context for this change? |
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.
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 |
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.
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" { |
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.
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", "") |
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.
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) { |
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.
Definitely not ...any
.
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) | ||
} | ||
} |
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.
This should've been a type.
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.
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?
return &APIClient{ | ||
ac := &APIClient{ | ||
Client: upstreamClient, | ||
logger: logger, | ||
}, nil | ||
} | ||
for _, o := range apiOpts { | ||
o(ac) | ||
} | ||
return ac, nil |
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.
Ditto.
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