<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<base href="https://issues.jboss.org">
<title>Message Title</title>
</head>
<body class="jira" style="color: #333333; font-family: Arial, sans-serif; font-size: 14px; line-height: 1.429">
<table id="background-table" cellpadding="0" cellspacing="0" width="100%" style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; background-color: #f5f5f5; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt" bgcolor="#f5f5f5">
<!-- header here -->
<tbody>
<tr>
<td id="header-pattern-container" style="padding: 0px; border-collapse: collapse; padding: 10px 20px">
<table id="header-pattern" cellspacing="0" cellpadding="0" border="0" style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt">
<tbody>
<tr>
<td id="header-avatar-image-container" valign="top" style="padding: 0px; border-collapse: collapse; vertical-align: top; width: 32px; padding-right: 8px" width="32"> <img id="header-avatar-image" class="image_fix" src="https://static.jboss.org/developer/gravatar/bd1946aafd256fc8796cd927befe1353?d=mm&s=48" height="32" width="32" border="0" style="border-radius: 3px; vertical-align: top"> </td>
<td id="header-text-container" valign="middle" style="padding: 0px; border-collapse: collapse; vertical-align: middle; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; mso-line-height-rule: exactly; mso-text-raise: 1px"> <a class="user-hover" rel="cmacedo86" id="email_cmacedo86" href="https://issues.jboss.org/secure/ViewProfile.jspa?name=cmacedo86" style="color:#0052cc;; color: #3b73af; text-decoration: none">Camila Macedo</a> <strong>commented</strong> on <a href="https://issues.jboss.org/browse/AEROGEAR-9089" style="color: #3b73af; text-decoration: none"><img src="cid:jira-generated-image-avatar-05ff6ea4-bb24-410d-a752-f0d832923006" height="16" width="16" border="0" align="absmiddle" alt="Task"> AEROGEAR-9089</a> </td>
</tr>
</tbody>
</table> </td>
</tr>
<tr>
<td id="email-content-container" style="padding: 0px; border-collapse: collapse; padding: 0 20px">
<table id="email-content-table" cellspacing="0" cellpadding="0" border="0" width="100%" style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; border-spacing: 0; border-collapse: separate">
<tbody>
<tr>
<!-- there needs to be content in the cell for it to render in some clients -->
<td class="email-content-rounded-top mobile-expand" style="padding: 0px; border-collapse: collapse; color: #ffffff; padding: 0 15px 0 16px; height: 15px; background-color: #ffffff; border-left: 1px solid #cccccc; border-top: 1px solid #cccccc; border-right: 1px solid #cccccc; border-bottom: 0; border-top-right-radius: 5px; border-top-left-radius: 5px; height: 10px; line-height: 10px; padding: 0 15px 0 16px; mso-line-height-rule: exactly" height="10" bgcolor="#ffffff"> </td>
</tr>
<tr>
<td class="email-content-main mobile-expand " style="padding: 0px; border-collapse: collapse; border-left: 1px solid #cccccc; border-right: 1px solid #cccccc; border-top: 0; border-bottom: 0; padding: 0 15px 0 16px; background-color: #ffffff" bgcolor="#ffffff">
<table class="page-title-pattern" cellspacing="0" cellpadding="0" border="0" width="100%" style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt">
<tbody>
<tr>
<td style="vertical-align: top;; padding: 0px; border-collapse: collapse; padding-right: 5px; font-size: 20px; line-height: 30px; mso-line-height-rule: exactly" class="page-title-pattern-header-container"> <span class="page-title-pattern-header" style="font-family: Arial, sans-serif; padding: 0; font-size: 20px; line-height: 30px; mso-text-raise: 2px; mso-line-height-rule: exactly; vertical-align: middle"> <a href="https://issues.jboss.org/browse/AEROGEAR-9089" style="color: #3b73af; text-decoration: none">Re: Change operator to watch specific namespaces and or labels</a> </span> </td>
</tr>
</tbody>
</table> </td>
</tr>
<tr>
<td id="text-paragraph-pattern-top" class="email-content-main mobile-expand comment-top-pattern" style="padding: 0px; border-collapse: collapse; border-left: 1px solid #cccccc; border-right: 1px solid #cccccc; border-top: 0; border-bottom: 0; padding: 0 15px 0 16px; background-color: #ffffff; border-bottom: none; padding-bottom: 0" bgcolor="#ffffff">
<table class="text-paragraph-pattern" cellspacing="0" cellpadding="0" border="0" width="100%" style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; mso-line-height-rule: exactly; mso-text-raise: 2px">
<tbody>
<tr>
<td class="text-paragraph-pattern-container mobile-resize-text " style="padding: 0px; border-collapse: collapse; padding: 0 0 10px 0"> <h4 style="margin: 10px 0 0 0; margin-top: 0; font-size: 14px; line-height: 1.500; margin: 20px 0 0 0; margin-top: 0"><a name="Whatwasdonehere%3F" style="color: #3b73af; text-decoration: none"></a>What was done here?</h4> <p style="margin: 10px 0 0 0">In the following PR we added a workaround to not allow apply the APP CR in a namespace which is not declared in an ENV VAR. <br> In this way, the operator will work with apps which are just applied in the specific namespaces as it is done currently for Graphana. </p> <p style="margin: 10px 0 0 0">PR: <a href="https://github.com/aerogear/mobile-security-service-operator/pull/57" class="external-link" rel="nofollow" style="color: #3b73af; text-decoration: none">https://github.com/aerogear/mobile-security-service-operator/pull/57</a></p> <h4 style="margin: 10px 0 0 0; font-size: 14px; line-height: 1.500; margin: 20px 0 0 0"><a name="WaspossibleimpltheworkarroundtocreateNmanagerstowatch%2FcachejustthedeclarednamespacesintheEnvVar%3F" style="color: #3b73af; text-decoration: none"></a>Was possible impl the workarround to create N managers to watch/cache just the declared namespaces in the EnvVar?</h4> <p style="margin: 10px 0 0 0">I tried this suggested approach but it doesn't work. Following the code impl to check it in the main.go</p>
<div class="code panel" style="border-width: 1px;; border: 1px solid #cccccc; background: #f5f5f5; font-size: 12px; line-height: 1.333; font-family: monospace; border: 1px solid #cccccc; -moz-border-radius: 3px 3px 3px 3px; border-radius: 3px 3px 3px 3px; margin: 9px 0">
<div class="codeContent panelContent" style="padding: 9px 12px">
<pre class="code-java" style="margin: 10px 0 0 0; margin-top: 0; max-height: 30em; overflow: auto; white-space: pre-wrap; word-wrap: normal">
func main() {
{....}
<span class="code-comment" style="color: #808080">//Create cmd Manager <span class="code-keyword" style="color: #000091; color: #808080">for</span> the Operator
</span>        namespace, err := k8sutil.GetWatchNamespace()
        handleManagerPerNamespace(cfg, string(namespace))
        <span class="code-comment" style="color: #808080">//Get all custom namespace which will be watched by the <span class="code-keyword" style="color: #000091; color: #808080">operator</span>
</span>        watchAppNamespacesEnvVar , err := utils.GetAppNamespaces()
        <span class="code-keyword" style="color: #000091">if</span> err != nil {
                log.Error(err, <span class="code-quote" style="color: #009100">"Failed to get APP_NAMESPACES"</span>)
                os.Exit(1)
        }
        <span class="code-comment" style="color: #808080">//Create a cmd manager and add schemas <span class="code-keyword" style="color: #000091; color: #808080">for</span> each namespace specified in the APP_NAMESPACES env <span class="code-keyword" style="color: #000091; color: #808080">var</span>
</span>        <span class="code-keyword" style="color: #000091">for</span> _, ns := range strings.Split(watchAppNamespacesEnvVar, <span class="code-quote" style="color: #009100">";"</span>) {
                log.Info(<span class="code-quote" style="color: #009100">"Creating manager <span class="code-keyword" style="color: #000091; color: #009100">for</span> the namespace: "</span> + string(ns))
                handleManagerPerNamespace(cfg, string(ns))
        }
{....}
}
<span class="code-comment" style="color: #808080">//handleManagerPerNamespace create the manager, add schemas and start it
</span>func handleManagerPerNamespace(cfg *<span class="code-keyword" style="color: #000091">rest</span>.Config, ns string) {
        mgr := createNamespaceCmdManager(cfg, ns)
        addSchemeToManager(mgr)
        startCmdManager(mgr)
}
<span class="code-comment" style="color: #808080">//createNamespaceCmdManager creates a manager <span class="code-keyword" style="color: #000091; color: #808080">for</span> an specific Namespace
</span>func createNamespaceCmdManager(cfg *<span class="code-keyword" style="color: #000091">rest</span>.Config, namespace string) manager.Manager {
        <span class="code-comment" style="color: #808080">// Create a <span class="code-keyword" style="color: #000091; color: #808080">new</span> Cmd to provide shared dependencies and start components
</span>        mgr, err := manager.New(cfg, manager.Options{
                Namespace: namespace,
        })
        <span class="code-keyword" style="color: #000091">if</span> err != nil {
                log.Error(err, "")
                os.Exit(1)
        }
        <span class="code-keyword" style="color: #000091">return</span> mgr
}
<span class="code-comment" style="color: #808080">//startCmdManager
</span>func startCmdManager(mgr manager.Manager) {
        log.Info(<span class="code-quote" style="color: #009100">"Starting the Cmd."</span>)
        <span class="code-comment" style="color: #808080">// Start the Cmd
</span>        <span class="code-keyword" style="color: #000091">if</span> err := mgr.Start(signals.SetupSignalHandler()); err != nil {
                log.Error(err, <span class="code-quote" style="color: #009100">"Manager exited non-zero"</span>)
                os.Exit(1)
        }
}
<span class="code-comment" style="color: #808080">//addSchemeToManager will register the schemas <span class="code-keyword" style="color: #000091; color: #808080">for</span> each manager
</span>func addSchemeToManager(mgr manager.Manager) {
        log.Info(<span class="code-quote" style="color: #009100">"Registering Components."</span>)
        <span class="code-comment" style="color: #808080">// Setup Scheme <span class="code-keyword" style="color: #000091; color: #808080">for</span> all resources
</span>        <span class="code-keyword" style="color: #000091">if</span> err := apis.AddToScheme(mgr.GetScheme()); err != nil {
                log.Error(err, "")
                os.Exit(1)
        }
        <span class="code-comment" style="color: #808080">//Add route Openshift scheme
</span>        <span class="code-keyword" style="color: #000091">if</span> err := routev1.AddToScheme(mgr.GetScheme().); err != nil {
                log.Error(err, "")
                os.Exit(1)
        }
        <span class="code-comment" style="color: #808080">// Setup all Controllers
</span>        <span class="code-keyword" style="color: #000091">if</span> err := controller.AddToManager(mgr); err != nil {
                log.Error(err, "")
                os.Exit(1)
        }
}
</pre>
</div>
</div> <p style="margin: 10px 0 0 0"><b>IMPORTANT:</b> The controller/reconcile impl of this oper will use the cmd.manager to manage the resources and it does not work for namespaces which are not passed as an option for its watch/cache.</p> <h4 style="margin: 10px 0 0 0; font-size: 14px; line-height: 1.500; margin: 20px 0 0 0"><a name="Willweabletodoitinthefuture%3F" style="color: #3b73af; text-decoration: none"></a>Will we able to do it in the future?</h4> <p style="margin: 10px 0 0 0">The great news that I'd like to share with you is that the solution for it is impl already and merged in the master branch see the commit<span class="error">[1]</span> and the test<span class="error">[2]</span> with this need attended. </p> <p style="margin: 10px 0 0 0">Unfortunately, show that the version released with, v0.2.0-alpha.0<span class="error">[3]</span>, has break changes and cannot be used with the current version of OCP 3.11 and the Kube used by it.</p> <p style="margin: 10px 0 0 0">We opened an issue in this repo to ask if they can release a new stable version for we are able to get this feature/implementation. See here<span class="error">[4]</span>. </p> <p style="margin: 10px 0 0 0"><span class="error">[1]</span> - <a href="https://github.com/kubernetes-sigs/controller-runtime/commit/fc804a411c06919561edbcb0453601c436556613" class="external-link" rel="nofollow" style="color: #3b73af; text-decoration: none">https://github.com/kubernetes-sigs/controller-runtime/commit/fc804a411c06919561edbcb0453601c436556613</a><br> <span class="error">[2]</span> - <a href="https://github.com/kubernetes-sigs/controller-runtime/blob/68ae79ea094aab567d78d7d8596accac2dc27fd0/pkg/manager/example_test.go#L59" class="external-link" rel="nofollow" style="color: #3b73af; text-decoration: none">https://github.com/kubernetes-sigs/controller-runtime/blob/68ae79ea094aab567d78d7d8596accac2dc27fd0/pkg/manager/example_test.go#L59</a><br> <span class="error">[3]</span> - <a href="https://github.com/kubernetes-sigs/controller-runtime/releases/tag/v0.2.0-alpha.0" class="external-link" rel="nofollow" style="color: #3b73af; text-decoration: none">https://github.com/kubernetes-sigs/controller-runtime/releases/tag/v0.2.0-alpha.0</a><br> <span class="error">[4]</span> - <a href="https://github.com/kubernetes-sigs/controller-runtime/issues/413" class="external-link" rel="nofollow" style="color: #3b73af; text-decoration: none">https://github.com/kubernetes-sigs/controller-runtime/issues/413</a></p> <p style="margin: 10px 0 0 0"><b>IMPORTANT:</b> The author of this impl works in RedHat and I already speak with him before. I am trying to contact him privately to check if they can release a new stable version with just this feature impl to attend us. </p> <p style="margin: 10px 0 0 0">c/c <a href="https://issues.jboss.org/secure/ViewProfile.jspa?name=dffrench" class="user-hover" rel="dffrench" style="color: #3b73af; text-decoration: none">David Ffrench</a> <a href="https://issues.jboss.org/secure/ViewProfile.jspa?name=weil" class="user-hover" rel="weil" style="color: #3b73af; text-decoration: none">Wei Li</a> <a href="https://issues.jboss.org/secure/ViewProfile.jspa?name=peter.braun" class="user-hover" rel="peter.braun" style="color: #3b73af; text-decoration: none">Peter Braun</a> <a href="https://issues.jboss.org/secure/ViewProfile.jspa?name=chrisfoley" class="user-hover" rel="chrisfoley" style="color: #3b73af; text-decoration: none">Christopher Foley</a></p> </td>
</tr>
</tbody>
</table> </td>
</tr>
<tr>
<td class="email-content-main mobile-expand " style="padding: 0px; border-collapse: collapse; border-left: 1px solid #cccccc; border-right: 1px solid #cccccc; border-top: 0; border-bottom: 0; padding: 0 15px 0 16px; background-color: #ffffff" bgcolor="#ffffff">
<table id="actions-pattern" cellspacing="0" cellpadding="0" border="0" width="100%" style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; mso-line-height-rule: exactly; mso-text-raise: 1px">
<tbody>
<tr>
<td id="actions-pattern-container" valign="middle" style="padding: 0px; border-collapse: collapse; padding: 10px 0 10px 24px; vertical-align: middle; padding-left: 0">
<table align="left" style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt">
<tbody>
<tr>
<td class="actions-pattern-action-icon-container" style="padding: 0px; border-collapse: collapse; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; mso-line-height-rule: exactly; mso-text-raise: 0; vertical-align: middle"> <a href="https://issues.jboss.org/browse/AEROGEAR-9089#add-comment" target="_blank" title="Add Comment" style="color: #3b73af; text-decoration: none"> <img class="actions-pattern-action-icon-image" src="cid:jira-generated-image-static-comment-icon-35a25e26-9e66-4b4f-a3c5-7a1cf4a1a989" alt="Add Comment" title="Add Comment" height="16" width="16" border="0" style="vertical-align: middle"> </a> </td>
<td class="actions-pattern-action-text-container" style="padding: 0px; border-collapse: collapse; font-family: Arial, sans-serif; font-size: 14px; line-height: 20px; mso-line-height-rule: exactly; mso-text-raise: 4px; padding-left: 5px"> <a href="https://issues.jboss.org/browse/AEROGEAR-9089#add-comment" target="_blank" title="Add Comment" style="color: #3b73af; text-decoration: none">Add Comment</a> </td>
</tr>
</tbody>
</table> </td>
</tr>
</tbody>
</table> </td>
</tr>
<!-- there needs to be content in the cell for it to render in some clients -->
<tr>
<td class="email-content-rounded-bottom mobile-expand" style="padding: 0px; border-collapse: collapse; color: #ffffff; padding: 0 15px 0 16px; height: 5px; line-height: 5px; background-color: #ffffff; border-top: 0; border-left: 1px solid #cccccc; border-bottom: 1px solid #cccccc; border-right: 1px solid #cccccc; border-bottom-right-radius: 5px; border-bottom-left-radius: 5px; mso-line-height-rule: exactly" height="5" bgcolor="#ffffff"> </td>
</tr>
</tbody>
</table> </td>
</tr>
<tr>
<td id="footer-pattern" style="padding: 0px; border-collapse: collapse; padding: 12px 20px">
<table id="footer-pattern-container" cellspacing="0" cellpadding="0" border="0" style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt">
<tbody>
<tr>
<td id="footer-pattern-text" class="mobile-resize-text" width="100%" style="padding: 0px; border-collapse: collapse; color: #999999; font-size: 12px; line-height: 18px; font-family: Arial, sans-serif; mso-line-height-rule: exactly; mso-text-raise: 2px"> This message was sent by Atlassian Jira <span id="footer-build-information">(v7.12.1#712002-<span title="609a50578ba6bc73dbf8b05dddd7c04a04b6807c" data-commit-id="609a50578ba6bc73dbf8b05dddd7c04a04b6807c}">sha1:609a505</span>)</span> </td>
<td id="footer-pattern-logo-desktop-container" valign="top" style="padding: 0px; border-collapse: collapse; padding-left: 20px; vertical-align: top">
<table style="border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt">
<tbody>
<tr>
<td id="footer-pattern-logo-desktop-padding" style="padding: 0px; border-collapse: collapse; padding-top: 3px"> <img id="footer-pattern-logo-desktop" src="https://issues.jboss.org/images/mail/atlassian-email-logo.png" alt="Atlassian logo" title="Atlassian logo" width="191" height="24" class="image_fix"> </td>
</tr>
</tbody>
</table> </td>
</tr>
</tbody>
</table> </td>
</tr>
</tbody>
</table>
</body>
</html>