diff --git a/api/client/kubeclient/async.go b/api/client/kubeclient/async.go index 61ed3f56d0..2d22345fbf 100644 --- a/api/client/kubeclient/async.go +++ b/api/client/kubeclient/async.go @@ -49,7 +49,7 @@ func (aws *asyncWSRoundTripper) WebsocketCallback(ws *websocket.Conn, resp *http if resp != nil && resp.StatusCode != http.StatusOK { return enrichError(err, resp) } - return fmt.Errorf("Can't connect to websocket: %s\n", err.Error()) + return fmt.Errorf("can't connect to websocket: %w", err) } aws.Connection <- ws @@ -105,7 +105,9 @@ func asyncSubresourceHelper( } if response != nil { - defer response.Body.Close() + defer func() { + _ = response.Body.Close() + }() switch response.StatusCode { case http.StatusOK: case http.StatusNotFound: @@ -165,7 +167,7 @@ func enrichError(httpErr error, resp *http.Response) error { if resp == nil { return httpErr } - httpErr = fmt.Errorf("Can't connect to websocket (%d): %s\n", resp.StatusCode, httpErr.Error()) + httpErr = fmt.Errorf("can't connect to websocket (%d): %w", resp.StatusCode, httpErr) status := &metav1.Status{} if resp.Header.Get("Content-Type") != "application/json" { @@ -201,7 +203,9 @@ type WebsocketRoundTripper struct { func (d *WebsocketRoundTripper) RoundTrip(r *http.Request) (*http.Response, error) { conn, resp, err := d.Dialer.Dial(r.URL.String(), r.Header) if err == nil { - defer conn.Close() + defer func() { + _ = conn.Close() + }() } return resp, d.Do(conn, resp, err) } diff --git a/api/client/kubeclient/streamer.go b/api/client/kubeclient/streamer.go index 216bfd2f0e..120929a398 100644 --- a/api/client/kubeclient/streamer.go +++ b/api/client/kubeclient/streamer.go @@ -69,10 +69,10 @@ type wsConn struct { } func (c *wsConn) SetDeadline(t time.Time) error { - if err := c.Conn.SetWriteDeadline(t); err != nil { + if err := c.SetWriteDeadline(t); err != nil { return err } - return c.Conn.SetReadDeadline(t) + return c.SetReadDeadline(t) } func NewWebsocketStreamer(conn *websocket.Conn, done chan struct{}) *wsStreamer { diff --git a/api/client/kubeclient/websocket.go b/api/client/kubeclient/websocket.go index 94c2018732..2cb4e4ccfb 100644 --- a/api/client/kubeclient/websocket.go +++ b/api/client/kubeclient/websocket.go @@ -76,7 +76,9 @@ func (s *binaryWriter) Write(p []byte) (int, error) { if err != nil { return 0, convert(err) } - defer w.Close() + defer func() { + _ = w.Close() + }() n, err := w.Write(p) return n, err } diff --git a/api/core/v1alpha2/virtual_machine.go b/api/core/v1alpha2/virtual_machine.go index 62ba4393aa..5633a02610 100644 --- a/api/core/v1alpha2/virtual_machine.go +++ b/api/core/v1alpha2/virtual_machine.go @@ -41,6 +41,7 @@ const ( // +kubebuilder:subresource:status // +kubebuilder:resource:categories={all,virtualization},scope=Namespaced,shortName={vm},singular=virtualmachine // +kubebuilder:printcolumn:name="Phase",type="string",JSONPath=".status.phase",description="The phase of the virtual machine." +// +kubebuilder:printcolumn:name="PhaseAge",type="date",JSONPath=".status.stats.phasesTransitions[-1].timestamp",description="Time since the virtual machine entered the current phase." // +kubebuilder:printcolumn:name="Cores",priority=1,type="string",JSONPath=".spec.cpu.cores",description="The number of cores of the virtual machine." // +kubebuilder:printcolumn:name="CoreFraction",priority=1,type="string",JSONPath=".spec.cpu.coreFraction",description="Virtual machine core fraction. The range of available values is set in the `sizePolicy` parameter of the VirtualMachineClass; if it is not set, use values within the 1–100% range." // +kubebuilder:printcolumn:name="Memory",priority=1,type="string",JSONPath=".spec.memory.size",description="The amount of memory of the virtual machine." diff --git a/crds/virtualmachines.yaml b/crds/virtualmachines.yaml index da6d232bdc..88162c552b 100644 --- a/crds/virtualmachines.yaml +++ b/crds/virtualmachines.yaml @@ -1422,6 +1422,10 @@ spec: jsonPath: .status.phase name: Phase type: string + - description: Time since the virtual machine entered the current phase. + jsonPath: .status.stats.phasesTransitions[-1].timestamp + name: PhaseAge + type: date - description: Real number of the virtual machine cores. jsonPath: .status.resources.cpu.cores name: Cores