Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 3 additions & 2 deletions apps/types_/subdomain.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ def validate_subdomain(self):

# Check if the subdomain adheres to helm rules
regex_validator = RegexValidator(
regex=r"^(?!-)[a-z0-9-]{3,53}(?<!-)$",
regex=r"^(?!-)(?!.*mlflow)[a-z0-9-]{3,53}(?<!-)$",
message="Subdomain must be 3-53 characters long, contain only lowercase letters, digits, hyphens, "
"and cannot start or end with a hyphen",
"cannot contain 'mlflow', "
Copy link
Contributor

Choose a reason for hiding this comment

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

I personally don't like that it'll be shown for all apps, but we can discuss this

And could you please update the test case for this?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you. I used a different approach and fixed it from the secret name. The root cause of the mlflow subdomain bug is that, the chart avoids redundant naming when the release name already contains mlflow, but appends -mlflow otherwise. This conditional logic is why only mlflow-containing subdomains fail. The logic is implemented here: . From there,

If release name contains chart name it will be used as a full name.

I checked and it fixed the bug.

"and cannot start or end with a hyphen.",
)

regex_validator(self.__name)
Expand Down
71 changes: 54 additions & 17 deletions templates/apps/secrets_view.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,23 @@ <h1 class="h3 mb-3 card-title">MLflow is not provisioned yet</h1>
<h1 class="h3 mb-3 card-title">Your MLflow Credentials</h1>
<p class="card-text">Use the credentials below to access MLflow.</p>

<div class="mb-3">
<label for="mlflow-username" class="form-label">Username</label>
<div class="input-group">
<input type="text" id="mlflow-username" class="form-control" value="{{ mlflow_username }}" readonly>
<button class="btn btn-outline-secondary" onclick="copyToClipboard('mlflow-username')">Copy</button>
<!-- Updated Username Section -->
<div class="mb-3">
<label class="form-label">Username</label>
<div class="d-flex align-items-center gap-2">
<code class="p-2 bg-light rounded flex-grow-1" id="mlflow-username">{{ mlflow_username }}</code>
<button class="btn btn-outline-secondary" onclick="copyToClipboard('mlflow-username')">Copy</button>
</div>
</div>
</div>

<div class="mb-3">
<label for="mlflow-password" class="form-label">Password</label>
<div class="input-group">
<input type="text" id="mlflow-password" class="form-control" value="{{ mlflow_password }}" readonly>
<button class="btn btn-outline-secondary" onclick="copyToClipboard('mlflow-password')">Copy</button>
<!-- Updated Password Section -->
<div class="mb-3">
<label class="form-label">Password</label>
<div class="d-flex align-items-center gap-2">
<code class="p-2 bg-light rounded flex-grow-1" id="mlflow-password">{{ mlflow_password }}</code>
<button class="btn btn-outline-secondary" onclick="copyToClipboard('mlflow-password')">Copy</button>
</div>
</div>
</div>

<div class="text-center mt-4">
<a href="{{ mlflow_url }}" target="_blank" class="btn btn-dark">Open MLflow</a>
Expand Down Expand Up @@ -70,12 +72,47 @@ <h4 class="h5 mt-4">How to Use These Credentials</h4>
</div>

<script>
function copyToClipboard(elementId) {
var copyText = document.getElementById(elementId);
copyText.select();
copyText.setSelectionRange(0, 99999); // For mobile devices
navigator.clipboard.writeText(copyText.value);

async function copyToClipboard(elementId) {
const el = document.getElementById(elementId);
const text = el.textContent;
const tempTextArea = document.createElement('textarea');

try {
// Modern clipboard API (requires HTTPS)
await navigator.clipboard.writeText(text);

// Visual feedback
const btn = document.querySelector(`button[onclick*='${elementId}']`);
btn.classList.add('btn-success');
setTimeout(() => btn.classList.remove('btn-success'), 1000);

} catch (err) {
// Fallback for older browsers/HTTP
try {
tempTextArea.value = text;
document.body.appendChild(tempTextArea);
tempTextArea.select();
document.execCommand('copy');

// Fallback visual feedback
const btn = document.querySelector(`button[onclick*='${elementId}']`);
btn.classList.add('btn-info');
setTimeout(() => btn.classList.remove('btn-info'), 1000);

} catch (fallbackErr) {
// Ultimate fallback: show text and prompt manual copy
tempTextArea.style.position = 'fixed';
tempTextArea.style.top = '10px';
tempTextArea.style.left = '10px';
tempTextArea.style.zIndex = 1000;
alert('Press Ctrl/Cmd+C to copy:\n\n' + text);
}
} finally {
document.body.removeChild(tempTextArea);
}
}

</script>
{% endif %}
{% endblock %}