Skip to content

Conversation

@arjunrn
Copy link
Contributor

@arjunrn arjunrn commented Jun 14, 2021

Depends on #598

According to the documentation:

Vet examines Go source code and reports suspicious constructs

Results from the linter:

pkg/cvo/cvo_test.go:702:100                    govet  composites: `k8s.io/apimachinery/pkg/apis/meta/v1.Time` composite literal uses unkeyed fields
pkg/cvo/cvo_test.go:2172:25                    govet  composites: `k8s.io/apimachinery/pkg/apis/meta/v1.Time` composite literal uses unkeyed fields
pkg/cvo/sync_test.go:70:42                     govet  composites: `k8s.io/apimachinery/pkg/runtime/schema.GroupVersionKind` composite literal uses unkeyed fields
pkg/cvo/sync_test.go:73:42                     govet  composites: `k8s.io/apimachinery/pkg/runtime/schema.GroupVersionKind` composite literal uses unkeyed fields
pkg/cvo/sync_test.go:97:14                     govet  composites: `k8s.io/apimachinery/pkg/runtime/schema.GroupVersionKind` composite literal uses unkeyed fields
pkg/cvo/internal/operatorstatus_test.go:46:40  govet  composites: `k8s.io/apimachinery/pkg/runtime/schema.GroupResource` composite literal uses unkeyed fields
pkg/cvo/cvo_test.go:2330:9                     govet  copylocks: range var tt copies lock: struct{name string; key string; syncStatus *github.com/openshift/cluster-version-operator/pkg/cvo.SyncWorkerStatus; optr github.com/openshift/cluster-version-operator/pkg/cvo.Operator; init func(optr *github.com/openshift/cluster-version-operator/pkg/cvo.Operator); want bool; wantErr func(*testing.T, error); wantActions func(*testing.T, *github.com/openshift/cluster-version-operator/pkg/cvo.Operator); wantSync []github.com/openshift/api/config/v1.Update} contains github.com/openshift/cluster-version-operator/pkg/cvo.Operator contains sync.Mutex
pkg/cvo/cvo_test.go:2735:9                     govet  copylocks: range var tt copies lock: struct{name string; key string; handler net/http.HandlerFunc; optr github.com/openshift/cluster-version-operator/pkg/cvo.Operator; wantErr func(*testing.T, error); wantUpdates *github.com/openshift/cluster-version-operator/pkg/cvo.availableUpdates} contains github.com/openshift/cluster-version-operator/pkg/cvo.Operator contains sync.Mutex
pkg/cvo/cvo_test.go:2737:12                    govet  copylocks: assignment copies lock value to optr: github.com/openshift/cluster-version-operator/pkg/cvo.Operator contains sync.Mutex
pkg/cvo/cvo_test.go:3259:9                     govet  copylocks: range var tt copies lock: struct{name string; key string; optr github.com/openshift/cluster-version-operator/pkg/cvo.Operator; wantErr func(*testing.T, error); want *github.com/openshift/cluster-version-operator/pkg/cvo.upgradeable} contains github.com/openshift/cluster-version-operator/pkg/cvo.Operator contains sync.Mutex
pkg/cvo/cvo_test.go:3261:12                    govet  copylocks: assignment copies lock value to optr: github.com/openshift/cluster-version-operator/pkg/cvo.Operator contains sync.Mutex
pkg/cvo/status_test.go:239:9                   govet  copylocks: range var tt copies lock: struct{name string; optr github.com/openshift/cluster-version-operator/pkg/cvo.Operator; init func(optr *github.com/openshift/cluster-version-operator/pkg/cvo.Operator); wantErr func(*testing.T, error); wantActions func(*testing.T, *github.com/openshift/cluster-version-operator/pkg/cvo.Operator); wantSync []github.com/openshift/api/config/v1.Release; original *github.com/openshift/api/config/v1.ClusterVersion; ierr error} contains github.com/openshift/cluster-version-operator/pkg/cvo.Operator contains sync.Mutex

The code uses unkeyed composite literals and in the words of Rob Pike:

The argument for the complaint is that keyed composite literals are more future-proof. If you later change the layout of s, the code will fail to compile if the keys no longer work, but an unkeyed literal may compile incorrectly. In your example, if you swapped a and b in s, the first assignment of z would set 1 to b and 2 to a.

There are also some instances where structs containing locks are passed by value. This is incorrect because when passing locks by value the lock is copied and effectively there are multiple locks.

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 14, 2021
@arjunrn
Copy link
Contributor Author

arjunrn commented Jun 17, 2021

/hold cancel

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 17, 2021
@arjunrn
Copy link
Contributor Author

arjunrn commented Jun 18, 2021

/assign @LalatenduMohanty

@vrutkovs
Copy link

/retest

Copy link
Member

@LalatenduMohanty LalatenduMohanty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jun 23, 2021
@LalatenduMohanty
Copy link
Member

/retest

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jun 23, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: arjunrn, LalatenduMohanty

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 23, 2021
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

1 similar comment
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot openshift-merge-robot merged commit d0df3ac into openshift:master Jun 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants