mirror of https://github.com/containers/podman.git
make lint: enable rowserrcheck
It turns out, after iterating over rows, we need to check for errors. It also turns out that we did not do that at all. Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
This commit is contained in:
parent
f07aa1bfdc
commit
2efa7c3fa1
|
@ -12,8 +12,6 @@ run:
|
||||||
linters:
|
linters:
|
||||||
enable-all: true
|
enable-all: true
|
||||||
disable:
|
disable:
|
||||||
# All these break for one reason or another
|
|
||||||
- rowserrcheck # FIXME (urgent): sqlite error checking
|
|
||||||
# too many reports but requires attention
|
# too many reports but requires attention
|
||||||
- depguard
|
- depguard
|
||||||
- revive
|
- revive
|
||||||
|
|
|
@ -139,6 +139,9 @@ func (s *SQLiteState) Refresh() (defErr error) {
|
||||||
|
|
||||||
ctrStates[id] = string(newJSON)
|
ctrStates[id] = string(newJSON)
|
||||||
}
|
}
|
||||||
|
if err := ctrRows.Err(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
podRows, err := s.conn.Query("SELECT ID, JSON FROM PodState;")
|
podRows, err := s.conn.Query("SELECT ID, JSON FROM PodState;")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -170,6 +173,9 @@ func (s *SQLiteState) Refresh() (defErr error) {
|
||||||
|
|
||||||
podStates[id] = string(newJSON)
|
podStates[id] = string(newJSON)
|
||||||
}
|
}
|
||||||
|
if err := podRows.Err(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
volRows, err := s.conn.Query("SELECT Name, JSON FROM VolumeState;")
|
volRows, err := s.conn.Query("SELECT Name, JSON FROM VolumeState;")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -202,6 +208,9 @@ func (s *SQLiteState) Refresh() (defErr error) {
|
||||||
|
|
||||||
volumeStates[name] = string(newJSON)
|
volumeStates[name] = string(newJSON)
|
||||||
}
|
}
|
||||||
|
if err := volRows.Err(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// Write updated states back to DB, and perform additional maintenance
|
// Write updated states back to DB, and perform additional maintenance
|
||||||
// (Remove exit codes and exec sessions)
|
// (Remove exit codes and exec sessions)
|
||||||
|
@ -503,6 +512,9 @@ func (s *SQLiteState) LookupContainerID(idOrName string) (string, error) {
|
||||||
}
|
}
|
||||||
resCount++
|
resCount++
|
||||||
}
|
}
|
||||||
|
if err := rows.Err(); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
if resCount == 0 {
|
if resCount == 0 {
|
||||||
return "", define.ErrNoSuchCtr
|
return "", define.ErrNoSuchCtr
|
||||||
} else if resCount > 1 {
|
} else if resCount > 1 {
|
||||||
|
@ -544,6 +556,9 @@ func (s *SQLiteState) LookupContainer(idOrName string) (*Container, error) {
|
||||||
}
|
}
|
||||||
resCount++
|
resCount++
|
||||||
}
|
}
|
||||||
|
if err := rows.Err(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
if !exactName {
|
if !exactName {
|
||||||
if resCount == 0 {
|
if resCount == 0 {
|
||||||
return nil, fmt.Errorf("no container with name or ID %q found: %w", idOrName, define.ErrNoSuchCtr)
|
return nil, fmt.Errorf("no container with name or ID %q found: %w", idOrName, define.ErrNoSuchCtr)
|
||||||
|
@ -730,6 +745,9 @@ func (s *SQLiteState) ContainerInUse(ctr *Container) ([]string, error) {
|
||||||
}
|
}
|
||||||
deps = append(deps, dep)
|
deps = append(deps, dep)
|
||||||
}
|
}
|
||||||
|
if err := rows.Err(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
return deps, nil
|
return deps, nil
|
||||||
}
|
}
|
||||||
|
@ -770,6 +788,9 @@ func (s *SQLiteState) AllContainers(loadState bool) ([]*Container, error) {
|
||||||
|
|
||||||
ctrs = append(ctrs, ctr)
|
ctrs = append(ctrs, ctr)
|
||||||
}
|
}
|
||||||
|
if err := rows.Err(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
rows, err := s.conn.Query("SELECT JSON FROM ContainerConfig;")
|
rows, err := s.conn.Query("SELECT JSON FROM ContainerConfig;")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -794,6 +815,9 @@ func (s *SQLiteState) AllContainers(loadState bool) ([]*Container, error) {
|
||||||
|
|
||||||
ctrs = append(ctrs, ctr)
|
ctrs = append(ctrs, ctr)
|
||||||
}
|
}
|
||||||
|
if err := rows.Err(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, ctr := range ctrs {
|
for _, ctr := range ctrs {
|
||||||
|
@ -1095,6 +1119,9 @@ func (s *SQLiteState) GetContainerExecSessions(ctr *Container) ([]string, error)
|
||||||
}
|
}
|
||||||
sessions = append(sessions, session)
|
sessions = append(sessions, session)
|
||||||
}
|
}
|
||||||
|
if err := rows.Err(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
return sessions, nil
|
return sessions, nil
|
||||||
}
|
}
|
||||||
|
@ -1332,6 +1359,9 @@ func (s *SQLiteState) LookupPod(idOrName string) (*Pod, error) {
|
||||||
}
|
}
|
||||||
resCount++
|
resCount++
|
||||||
}
|
}
|
||||||
|
if err := rows.Err(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
if !exactName {
|
if !exactName {
|
||||||
if resCount == 0 {
|
if resCount == 0 {
|
||||||
return nil, fmt.Errorf("no pod with name or ID %s found: %w", idOrName, define.ErrNoSuchPod)
|
return nil, fmt.Errorf("no pod with name or ID %s found: %w", idOrName, define.ErrNoSuchPod)
|
||||||
|
@ -1421,6 +1451,9 @@ func (s *SQLiteState) PodContainersByID(pod *Pod) ([]string, error) {
|
||||||
|
|
||||||
ids = append(ids, id)
|
ids = append(ids, id)
|
||||||
}
|
}
|
||||||
|
if err := rows.Err(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
return ids, nil
|
return ids, nil
|
||||||
}
|
}
|
||||||
|
@ -1459,6 +1492,9 @@ func (s *SQLiteState) PodContainers(pod *Pod) ([]*Container, error) {
|
||||||
|
|
||||||
ctrs = append(ctrs, ctr)
|
ctrs = append(ctrs, ctr)
|
||||||
}
|
}
|
||||||
|
if err := rows.Err(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
for _, ctr := range ctrs {
|
for _, ctr := range ctrs {
|
||||||
if err := finalizeCtrSqlite(ctr); err != nil {
|
if err := finalizeCtrSqlite(ctr); err != nil {
|
||||||
|
@ -1652,6 +1688,9 @@ func (s *SQLiteState) RemovePodContainers(pod *Pod) (defErr error) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if err := rows.Err(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -1804,6 +1843,9 @@ func (s *SQLiteState) AllPods() ([]*Pod, error) {
|
||||||
|
|
||||||
pods = append(pods, pod)
|
pods = append(pods, pod)
|
||||||
}
|
}
|
||||||
|
if err := rows.Err(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
return pods, nil
|
return pods, nil
|
||||||
}
|
}
|
||||||
|
@ -1910,6 +1952,9 @@ func (s *SQLiteState) RemoveVolume(volume *Volume) (defErr error) {
|
||||||
}
|
}
|
||||||
ctrs = append(ctrs, ctr)
|
ctrs = append(ctrs, ctr)
|
||||||
}
|
}
|
||||||
|
if err := rows.Err(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
if len(ctrs) > 0 {
|
if len(ctrs) > 0 {
|
||||||
return fmt.Errorf("volume %s is in use by containers %s: %w", volume.Name(), strings.Join(ctrs, ","), define.ErrVolumeBeingUsed)
|
return fmt.Errorf("volume %s is in use by containers %s: %w", volume.Name(), strings.Join(ctrs, ","), define.ErrVolumeBeingUsed)
|
||||||
}
|
}
|
||||||
|
@ -2045,6 +2090,9 @@ func (s *SQLiteState) AllVolumes() ([]*Volume, error) {
|
||||||
|
|
||||||
volumes = append(volumes, vol)
|
volumes = append(volumes, vol)
|
||||||
}
|
}
|
||||||
|
if err := rows.Err(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
return volumes, nil
|
return volumes, nil
|
||||||
}
|
}
|
||||||
|
@ -2113,6 +2161,9 @@ func (s *SQLiteState) LookupVolume(name string) (*Volume, error) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if err := rows.Err(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
if foundName == "" {
|
if foundName == "" {
|
||||||
return nil, fmt.Errorf("no volume with name %q found: %w", name, define.ErrNoSuchVolume)
|
return nil, fmt.Errorf("no volume with name %q found: %w", name, define.ErrNoSuchVolume)
|
||||||
}
|
}
|
||||||
|
@ -2186,6 +2237,9 @@ func (s *SQLiteState) VolumeInUse(volume *Volume) ([]string, error) {
|
||||||
}
|
}
|
||||||
ctrs = append(ctrs, ctr)
|
ctrs = append(ctrs, ctr)
|
||||||
}
|
}
|
||||||
|
if err := rows.Err(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
return ctrs, nil
|
return ctrs, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue