Skip to content
Merged
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
4 changes: 4 additions & 0 deletions changelog/fragments/bundle-validate-verbose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
entries:
- description: Fixed debug logging in the `bundle validate` subcommand of `operator-sdk`
kind: "bugfix"
breaking: false
5 changes: 5 additions & 0 deletions changelog/fragments/csv-allnamespaces-default.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
entries:
- description: >
`generate <bundle|packagemanifests>` now generates a CSV base with only the `AllNamespaces` install mode
supported by default, since projects are cluster-scoped by default.
kind: bugfix
18 changes: 18 additions & 0 deletions changelog/fragments/gen-bundle-namespaced.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# entries is a list of entries to include in
# release notes and/or the migration guide
entries:
- description: >
When generating bundles and packagemanifests, remove `metadata.namespace` from
namespaced resources when writing them into the `manifests` directory to avoid
validation errors.
# kind is one of:
# - addition
# - change
# - deprecation
# - removal
# - bugfix
kind: bugfix
# Is this a breaking change?
breaking: false
4 changes: 4 additions & 0 deletions changelog/fragments/helm-install-status-fix.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
entries:
- description: Fixed a bug that caused the Helm operator not to set the `InstallSuccessful` and `UpgradeSuccessful` status reasons when the status update fails during installation and upgrade.
kind: "bugfix"
breaking: false
16 changes: 16 additions & 0 deletions changelog/fragments/helm-roles-permissions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# entries is a list of entries to include in
# release notes and/or the migration guide
entries:
- description: >
In Helm projects, fix operator permissions for Openshift deployments by adding a `<resource>/finalizers` rule in the operator's role.

# kind is one of:
# - addition
# - change
# - deprecation
# - removal
# - bugfix
kind: "bugfix"

# Is this a breaking change?
breaking: false
7 changes: 7 additions & 0 deletions changelog/fragments/operatorgroup-conflict.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
entries:
- description: >
Prevent `run packagemanifests` from creating an OperatorGroup if one already exists in a namespace,
and use that OperatorGroup if its target namespaces exactly match those passed in `--install-mode`.
See [#3681](https://github.com/operator-framework/operator-sdk/issues/3681).
kind: bugfix
breaking: false
9 changes: 9 additions & 0 deletions changelog/fragments/rescue-reconciliation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
entries:
- description: >
Stop reconciling tasks when the event raised is a rescue in Ansible-based Operators.
More info: [Bugzilla 1856714](https://bugzilla.redhat.com/show_bug.cgi?id=1856714)
kind: "bugfix"
breaking: false
pull_request_override: 3650
16 changes: 16 additions & 0 deletions changelog/fragments/scorecard_scaffolded_version.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# entries is a list of entries to include in
# release notes and/or the migration guide
entries:
- description: >
When scaffolding scorecard configurations, use release versions instead of `latest` in image tags.
# kind is one of:
# - addition
# - change
# - deprecation
# - removal
# - bugfix
kind: "bugfix"
# Is this a breaking change?
breaking: false
2 changes: 1 addition & 1 deletion internal/ansible/controller/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func (r *AnsibleOperatorReconciler) Reconcile(request reconcile.Request) (reconc
return reconcile.Result{}, err
}
}
if event.Event == eventapi.EventRunnerOnFailed && !event.IgnoreError() {
if event.Event == eventapi.EventRunnerOnFailed && !event.IgnoreError() && !event.Rescued() {
failureMessages = append(failureMessages, event.GetFailedPlaybookMessage())
}
}
Expand Down
12 changes: 12 additions & 0 deletions internal/ansible/runner/eventapi/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,15 @@ func (je JobEvent) IgnoreError() bool {
}
return false
}

// Rescued - Detects whether or not a task was rescued
func (je JobEvent) Rescued() bool {
if rescued, contains := je.EventData["rescued"]; contains {
for _, v := range rescued.(map[string]interface{}) {
if int(v.(float64)) == 1 {
return true
}
}
}
return false
}
16 changes: 10 additions & 6 deletions internal/cmd/operator-sdk/bundle/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,11 @@ func makeValidateCmd() *cobra.Command {
Use: "validate",
Short: "Validate an operator bundle",
RunE: func(cmd *cobra.Command, args []string) (err error) {
if viper.GetBool(flags.VerboseOpt) {
log.SetLevel(log.DebugLevel)
}

// Always print non-output logs to stderr as to not pollute actual command output.
// Note that it allows the JSON result be redirected to the Stdout. E.g
// if we run the command with `| jq . > result.json` the command will print just the logs
// and the file will have only the JSON result.
logger := log.NewEntry(internal.NewLoggerTo(os.Stderr))

logger := createLogger(viper.GetBool(flags.VerboseOpt))
if err = c.validate(args); err != nil {
return fmt.Errorf("invalid command args: %v", err)
}
Expand All @@ -126,6 +121,15 @@ func makeValidateCmd() *cobra.Command {
return cmd
}

// createLogger creates a new logrus Entry that is optionally verbose.
func createLogger(verbose bool) *log.Entry {
logger := log.NewEntry(internal.NewLoggerTo(os.Stderr))
if verbose {
logger.Logger.SetLevel(log.DebugLevel)
}
return logger
}

// validate verifies the command args
func (c bundleValidateCmd) validate(args []string) error {
if len(args) != 1 {
Expand Down
14 changes: 14 additions & 0 deletions internal/cmd/operator-sdk/bundle/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/operator-framework/operator-sdk/internal/cmd/operator-sdk/bundle/internal"
log "github.com/sirupsen/logrus"
)

var _ = Describe("Running a bundle validate command", func() {
Expand All @@ -38,6 +39,19 @@ var _ = Describe("Running a bundle validate command", func() {
})
})

Describe("Creating a logger", func() {
It("that is Info Level when not verbose", func() {
verbose := false
logger := createLogger(verbose)
Expect(logger.Logger.GetLevel()).To(Equal(log.InfoLevel))
})
It("that is Debug level if verbose", func() {
verbose := true
logger := createLogger(verbose)
Expect(logger.Logger.GetLevel()).To(Equal(log.DebugLevel))
})
})

Describe("validate", func() {
var cmd bundleValidateCmd
BeforeEach(func() {
Expand Down
27 changes: 27 additions & 0 deletions internal/cmd/operator-sdk/generate/internal/genutil_suite_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2020 The Operator-SDK Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package genutil

import (
"testing"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)

func TestGenutil(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Collector Suite")
}
14 changes: 14 additions & 0 deletions internal/cmd/operator-sdk/generate/internal/manifests.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,19 @@ func GetManifestObjects(c *collector.Manifests) (objs []controllerutil.Object) {
_, clusterRoleObjs := c.SplitCSVClusterPermissionsObjects()
objs = append(objs, clusterRoleObjs...)

removeNamespace(objs)
return objs
}

// removeNamespace removes the namespace field of resources intended to be inserted into
// an OLM manifests directory.
//
// This is required to pass OLM validations which require that namespaced resources do
// not include explicit namespace settings. OLM automatically installs namespaced
// resources in the same namespace that the operator is installed in, which is determined
// at runtime, not bundle/packagemanifests creation time.
func removeNamespace(objs []controllerutil.Object) {
for _, obj := range objs {
obj.SetNamespace("")
}
}
56 changes: 56 additions & 0 deletions internal/cmd/operator-sdk/generate/internal/manifests_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Copyright 2020 The Operator-SDK Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package genutil

import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
rbacv1 "k8s.io/api/rbac/v1"
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/operator-framework/operator-sdk/internal/generate/collector"
)

var _ = Describe("GetManifestObjects", func() {
It("should unset the namespace", func() {
m := collector.Manifests{
Roles: []rbacv1.Role{
{ObjectMeta: metav1.ObjectMeta{Namespace: "foo", Name: "foo"}},
{ObjectMeta: metav1.ObjectMeta{Namespace: "bar"}},
},
ClusterRoles: []rbacv1.ClusterRole{
{ObjectMeta: metav1.ObjectMeta{Namespace: "bar"}},
},
ServiceAccounts: []corev1.ServiceAccount{
{ObjectMeta: metav1.ObjectMeta{Namespace: "foo", Name: "foo"}},
{ObjectMeta: metav1.ObjectMeta{Namespace: "bar"}},
},
V1beta1CustomResourceDefinitions: []apiextensionsv1beta1.CustomResourceDefinition{
{ObjectMeta: metav1.ObjectMeta{Namespace: "bar"}},
},
V1CustomResourceDefinitions: []apiextensionsv1.CustomResourceDefinition{
{ObjectMeta: metav1.ObjectMeta{Namespace: "bar"}},
},
}
objs := GetManifestObjects(&m)
Expect(objs).To(HaveLen(len(m.Roles) + len(m.ClusterRoles) + len(m.ServiceAccounts) + len(m.V1CustomResourceDefinitions) + len(m.V1beta1CustomResourceDefinitions)))
for _, obj := range objs {
Expect(obj.GetNamespace()).To(BeEmpty())
}
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ func (b ClusterServiceVersion) makeNewBase() *v1alpha1.ClusterServiceVersion {
Keywords: b.Keywords,
Icon: b.Icon,
InstallModes: []v1alpha1.InstallMode{
{Type: v1alpha1.InstallModeTypeOwnNamespace, Supported: true},
{Type: v1alpha1.InstallModeTypeSingleNamespace, Supported: true},
{Type: v1alpha1.InstallModeTypeOwnNamespace, Supported: false},
{Type: v1alpha1.InstallModeTypeSingleNamespace, Supported: false},
{Type: v1alpha1.InstallModeTypeMultiNamespace, Supported: false},
{Type: v1alpha1.InstallModeTypeAllNamespaces, Supported: true},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ spec:
deployments: null
strategy: ""
installModes:
- supported: true
- supported: false
type: OwnNamespace
- supported: true
- supported: false
type: SingleNamespace
- supported: false
type: MultiNamespace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ spec:
deployments: null
strategy: ""
installModes:
- supported: true
- supported: false
type: OwnNamespace
- supported: true
- supported: false
type: SingleNamespace
- supported: false
type: MultiNamespace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ spec:
serviceAccountName: default
strategy: deployment
installModes:
- supported: true
- supported: false
type: OwnNamespace
- supported: true
- supported: false
type: SingleNamespace
- supported: false
type: MultiNamespace
Expand Down
14 changes: 14 additions & 0 deletions internal/helm/controller/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,20 @@ func (r HelmOperatorReconciler) Reconcile(request reconcile.Request) (reconcile.
}

log.Info("Reconciled release")
reason := types.ReasonUpgradeSuccessful
if expectedRelease.Version == 1 {
reason = types.ReasonInstallSuccessful
}
message := ""
if expectedRelease.Info != nil {
message = expectedRelease.Info.Notes
}
status.SetCondition(types.HelmAppCondition{
Type: types.ConditionDeployed,
Status: types.StatusTrue,
Reason: reason,
Message: message,
})
status.DeployedRelease = &types.HelmAppRelease{
Name: expectedRelease.Name,
Manifest: expectedRelease.Manifest,
Expand Down
27 changes: 27 additions & 0 deletions internal/olm/operator/operator_suite_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2020 The Operator-SDK Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package olm

import (
"testing"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)

func TestOperator(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Operator Suite")
}
Loading