fix(kubernetes): better management of units (#3419)
This commit is contained in:
parent
09cc171a10
commit
f549e1afef
|
@ -210,7 +210,7 @@ sub manage_selection {
|
||||||
$self->{nodes}->{$node->{metadata}->{name}} = {
|
$self->{nodes}->{$node->{metadata}->{name}} = {
|
||||||
display => $node->{metadata}->{name},
|
display => $node->{metadata}->{name},
|
||||||
pods_allocatable => $node->{status}->{allocatable}->{pods},
|
pods_allocatable => $node->{status}->{allocatable}->{pods},
|
||||||
cpu_allocatable => $self->to_bytes(value => $node->{status}->{allocatable}->{cpu}),
|
cpu_allocatable => $self->to_core(value => $node->{status}->{allocatable}->{cpu}),
|
||||||
memory_allocatable => $self->to_bytes(value => $node->{status}->{capacity}->{memory}),
|
memory_allocatable => $self->to_bytes(value => $node->{status}->{capacity}->{memory}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -239,14 +239,18 @@ sub to_bytes {
|
||||||
|
|
||||||
my $value = $options{value};
|
my $value = $options{value};
|
||||||
|
|
||||||
if ($value =~ /(\d+)Ki$/) {
|
if ($value =~ /(\d+)m$/) {
|
||||||
|
$value = $1 / 1000;
|
||||||
|
} elsif ($value =~ /(\d+)Ki?$/) {
|
||||||
$value = $1 * 1024;
|
$value = $1 * 1024;
|
||||||
} elsif ($value =~ /(\d+)Mi$/) {
|
} elsif ($value =~ /(\d+)Mi?$/) {
|
||||||
$value = $1 * 1024 * 1024;
|
$value = $1 * 1024 * 1024;
|
||||||
} elsif ($value =~ /(\d+)Gi$/) {
|
} elsif ($value =~ /(\d+)Gi?$/) {
|
||||||
$value = $1 * 1024 * 1024 * 1024;
|
$value = $1 * 1024 * 1024 * 1024;
|
||||||
} elsif ($value =~ /(\d+)Ti$/) {
|
} elsif ($value =~ /(\d+)Ti?$/) {
|
||||||
$value = $1 * 1024 * 1024 * 1024 * 1024;
|
$value = $1 * 1024 * 1024 * 1024 * 1024;
|
||||||
|
} elsif ($value =~ /(\d+)Pi?$/) {
|
||||||
|
$value = $1 * 1024 * 1024 * 1024 * 1024 * 1024;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $value;
|
return $value;
|
||||||
|
|
Loading…
Reference in New Issue