Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding consolelink namespacedashboard #13

Merged
merged 12 commits into from
Apr 3, 2020

Conversation

akoserwal
Copy link
Contributor

Screenshot 2020-03-12 at 7 01 40 PM

@jamesnetherton
Copy link
Collaborator

Thanks for this 👍

I found some time to refactor the codebase a little and I have a ton of local changes that I'm still testing. I'll try and apply your work on top of it next week and hopefully cut a 0.2.0 release.

return reconcile.Result{}, nil
}

func (r *ReconcileAtlasMap) getClusterVersionSemVer(err error, reqLogger logr.Logger) (*semver.Version, error, reconcile.Result, bool) {
Copy link
Contributor

Choose a reason for hiding this comment

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

How does this handle vanilla k8s installations (that aren't OCP)? Check out operator-utils /utils.go/IsOpenShift & LookupOpenShiftVersion and let's evaluate if that tooling is still relevant or can be caught up as there are still a lot of teams using the IsOpenShift check & some using it for versioning as well.

I'm honestly not sure if these features translate back to k8s, but if not, we should probably gate-check that.

In particular, let's look at the bug mentioned here and see if we can clean up the util code and maybe do away with the hard-coded version mapping altogether? Not sure we can, but thought you may want to get familiar with that code and see if it has a home here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jeremyary: thanks, I'll check those utils methods and try to validate against k8s as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I verified it won't work with K8s. I will replace with utils methods

Copy link
Contributor Author

@akoserwal akoserwal Mar 30, 2020

Choose a reason for hiding this comment

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

I reported a breaking change in the operator-sdk testing framework (operator-framework/operator-sdk#2731) which is blocking me to use operator-util methods in the test-cases.

pkg/util/console_link.go Outdated Show resolved Hide resolved
pkg/util/console_link.go Outdated Show resolved Hide resolved
@jamesnetherton
Copy link
Collaborator

@akoserwal There are some conflicts that need fixing up.

@akoserwal akoserwal changed the title [WIP] adding consolelink namespacedashboard adding consolelink namespacedashboard Mar 24, 2020
@jamesnetherton
Copy link
Collaborator

The integration test needs to be a bit smarter as the CI build only runs on OpenShift 3.x at present. So we only want to do assertions on consolelink CRs if the version is 4.x.

@akoserwal
Copy link
Contributor Author

@jamesnetherton: yeah, I am working on it. thanks

@akoserwal
Copy link
Contributor Author

@jamesnetherton: you can review now.

Copy link
Collaborator

@jamesnetherton jamesnetherton left a comment

Choose a reason for hiding this comment

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

Hi @akoserwal. Thanks for your work on this.

I left a few comments.

@@ -46,6 +59,7 @@ func newOperatorActions(log logr.Logger, mgr manager.Manager) []action {
return []action{
newServiceAction(log.WithValues("type", "service"), mgr),
routeAction,
consoleLink,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think there's a potential nil pointer exception here. If the operator is not running on OpenShift >= 4.3, then consoleLink will still be appended to the actions slice as nil. When the actions loop runs during reconcile it'll encounter the nil action.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated code to handle the nil pointer case

@@ -45,7 +58,7 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error {
return err
}

// Watch for changes to primary resource AtlasMap
// Watch for changes to primary resource AtlasMap
Copy link
Collaborator

Choose a reason for hiding this comment

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

Unnecessary indentation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

if err != nil {
return err
} else if err == nil {
controllerutil.AddFinalizer(atlasMap, consoleLinkFinalizer)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just a question, does the removal of the ConsoleLink have to be done from a finalizer?

If you create the ConsoleLink with through action.deployResource(), it'll set a owner reference between the AtlasMap CR and the ConsoleLink.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Console Link (application menu, namespace dashboard) is cluster-scoped. Namespaced dashboard which is part of the console link is namespace scoped. We can not set owner reference for console-link. I am using the finalizer as a flag to allow the deletion of console-link before the Atlasmap cr gets deleted and removes the flag once console-link has been deleted.

Copy link

Choose a reason for hiding this comment

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

Agree on cascading delete not working. However, we ended up doing this without a finalizer, by picking up the CR deletion reconcile call and cleaning it up in the reconcile loop the way we do adds and updates. See kiegroup/kie-cloud-operator#397

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed the finalizer logic and handle in the reconciler. thank you for the suggestion.

@@ -113,6 +116,42 @@ func atlasMapDeploymentTest(t *testing.T, f *framework.Framework, ctx *framework
}
scheme = "https"
host = atlasMapRoute.Spec.Host

//verify Console Link NamespaceDashboard
openShiftSemVer := util.GetClusterVersionSemVer(f.KubeConfig)
Copy link
Collaborator

Choose a reason for hiding this comment

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

There's another potential nil pointer exception here. GetClusterVersionSemVer has:

if errors.IsNotFound(err) {
	// default to OpenShift 3 as ClusterVersion API was introduced in OpenShift 4
	openShiftSemVer, _ = semver.NewVersion("3")
} else {
	return nil
}

So if an error occurs that is not trapped by the IsNotFound condition, nil is returned and is not handled by the caller. I'm actually seeing this happen on a local Minishift cluster:

$ eval $(minishift docker-env)

$ make build

$ make install

$ make deploy

$ oc logs atlasmap-operator-7cdb8b594f-f2t9w
{"level":"info","ts":1585821466.9990215,"logger":"cmd","msg":"Go Version: go1.13.5"}
{"level":"info","ts":1585821466.9990773,"logger":"cmd","msg":"Go OS/Arch: linux/amd64"}
{"level":"info","ts":1585821466.9990823,"logger":"cmd","msg":"Operator SDK Version: v0.15.1"}
{"level":"info","ts":1585821466.9990854,"logger":"cmd","msg":"AtlasMap Operator Version: 0.3.0"}
{"level":"info","ts":1585821466.9990885,"logger":"cmd","msg":"AtlasMap Operator Git Commit: 3c1271f0"}
{"level":"info","ts":1585821466.9990923,"logger":"cmd","msg":"AtlasMap Default Image: docker.io/atlasmap/atlasmap:latest"}
{"level":"info","ts":1585821466.9992895,"logger":"leader","msg":"Trying to become the leader."}
{"level":"info","ts":1585821467.6745458,"logger":"leader","msg":"Found existing lock with my name. I was likely restarted."}
{"level":"info","ts":1585821467.674589,"logger":"leader","msg":"Continuing as the leader."}
{"level":"info","ts":1585821468.332753,"logger":"controller-runtime.metrics","msg":"metrics server is starting to listen","addr":"0.0.0.0:8383"}
{"level":"info","ts":1585821468.3341796,"logger":"cmd","msg":"Registering Components."}
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x53b192]
goroutine 1 [running]:
github.com/Masterminds/semver.(*Version).Prerelease(...)
	/home/james/go/pkg/mod/github.com/!masterminds/semver@v1.5.0/version.go:146
github.com/Masterminds/semver.constraintGreaterThanEqual(0x0, 0xc000403980, 0xc0001df1a0)
	/home/james/go/pkg/mod/github.com/!masterminds/semver@v1.5.0/constraints.go:289 +0x22
github.com/Masterminds/semver.(*constraint).check(...)
	/home/james/go/pkg/mod/github.com/!masterminds/semver@v1.5.0/constraints.go:176
github.com/Masterminds/semver.Constraints.Check(0xc000115380, 0x1, 0x1, 0x0, 0x0)
	/home/james/go/pkg/mod/github.com/!masterminds/semver@v1.5.0/constraints.go:49 +0x82
github.com/atlasmap/atlasmap-operator/pkg/controller/atlasmap.newOperatorActions(0x18728a0, 0xc0002669c0, 0x188b2e0, 0xc00045e900, 0xc0000b3c20, 0x0, 0x0)
	atlasmap-operator/pkg/controller/atlasmap/action.go:44 +0x872
github.com/atlasmap/atlasmap-operator/pkg/controller/atlasmap.add(0x188b2e0, 0xc00045e900, 0x182ce00, 0xc000249050, 0x0, 0x0)
	atlasmap-operator/pkg/controller/atlasmap/atlasmap_controller.go:114 +0x538
github.com/atlasmap/atlasmap-operator/pkg/controller/atlasmap.Add(0x188b2e0, 0xc00045e900, 0xb50504, 0x233a5b0)
	atlasmap-operator/pkg/controller/atlasmap/atlasmap_controller.go:48 +0x17c
github.com/atlasmap/atlasmap-operator/pkg/controller.AddToManager(0x188b2e0, 0xc00045e900, 0x0, 0x0)
	atlasmap-operator/pkg/controller/controller.go:13 +0x79

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@jamesnetherton
Copy link
Collaborator

@akoserwal I'm happy with the latest changes. Just one final request...

I just created deploy/olm-catalog/atlasmap-operator/0.3.0/atlasmap-operator.v0.3.0.clusterserviceversion.yaml. Please can you add the additional permissions for ConsoleLink.

@jamesnetherton jamesnetherton merged commit f4aa863 into atlasmap:master Apr 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants