Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions api/client/kubeclient/async.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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" {
Expand Down Expand Up @@ -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)
}
4 changes: 2 additions & 2 deletions api/client/kubeclient/streamer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion api/client/kubeclient/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions api/core/v1alpha2/virtual_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
4 changes: 4 additions & 0 deletions crds/virtualmachines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading