Repository: skupperproject/skupper
Pull request #2154 (2025-06-09 18:11:18)

Fix application label for system sites startup scripts


Patch:
diff --git a/internal/nonkube/bundle/install.sh.template b/internal/nonkube/bundle/install.sh.template
index dfa7f772..7fb48c41 100644
--- a/internal/nonkube/bundle/install.sh.template
+++ b/internal/nonkube/bundle/install.sh.template
@@ -40,7 +40,7 @@ fi
 export NAMESPACES_PATH="${SKUPPER_OUTPUT_PATH}/namespaces"
 export PLATFORM_FILE="${NAMESPACES_PATH}/${NAMESPACE}/internal/platform.yaml"
 export USER="${USER:-$(id -un)}"
-SITE_ID="$(hostname -s)-${USER}-$(date +%s)"
+SITE_ID="$(hostname -s)-${USER}-$(date +%s-%N)"
 export SITE_ID
 export NORMAL_PORT=""
 
diff --git a/internal/nonkube/client/runtime/info.go b/internal/nonkube/client/runtime/info.go
index 6c8608c9..06bc4e57 100644
--- a/internal/nonkube/client/runtime/info.go
+++ b/internal/nonkube/client/runtime/info.go
@@ -21,5 +21,8 @@ func GetLocalRouterPort(namespace string) (int, error) {
 	if err != nil {
 		return 0, fmt.Errorf("unable to determine router port: %w", err)
 	}
+	if len(ra.Spec.Roles) == 0 {
+		return 0, fmt.Errorf("no roles defined on RouterAccess: %s", ra.Name)
+	}
 	return ra.Spec.Roles[0].Port, nil
 }
diff --git a/internal/nonkube/common/startsh-container.template b/internal/nonkube/common/startsh-container.template
index 4d053a3c..f7b0f685 100644
--- a/internal/nonkube/common/startsh-container.template
+++ b/internal/nonkube/common/startsh-container.template
@@ -3,7 +3,7 @@
 set -o errexit
 set -o nounset
 
-for container in $({{.ContainerEngine}} container ls --filter label=application=skupper --filter label=skupper.io/site-id={{.SiteId}} --format {{"{{"}}.Names{{"}}"}} --all); do
+for container in $({{.ContainerEngine}} container ls --filter label=application=skupper-v2 --filter label=skupper.io/site-id={{.SiteId}} --format {{"{{"}}.Names{{"}}"}} --all); do
     {{.ContainerEngine}} start ${container}
 done
 
diff --git a/internal/nonkube/common/stopsh-container.template b/internal/nonkube/common/stopsh-container.template
index 5c71118f..9b9f6a5c 100644
--- a/internal/nonkube/common/stopsh-container.template
+++ b/internal/nonkube/common/stopsh-container.template
@@ -3,6 +3,6 @@
 set -o errexit
 set -o nounset
 
-for container in $({{.ContainerEngine}} container ls --filter label=application=skupper --filter label=skupper.io/site-id={{.SiteId}} --format {{"{{"}}.Names{{"}}"}} --all); do
+for container in $({{.ContainerEngine}} container ls --filter label=application=skupper-v2 --filter label=skupper.io/site-id={{.SiteId}} --format {{"{{"}}.Names{{"}}"}} --all); do
     {{.ContainerEngine}} stop -t 10 ${container}
 done
diff --git a/pkg/nonkube/api/site_state.go b/pkg/nonkube/api/site_state.go
index 38421939..4b3c2b33 100644
--- a/pkg/nonkube/api/site_state.go
+++ b/pkg/nonkube/api/site_state.go
@@ -283,7 +283,8 @@ func (s *SiteState) ToRouterConfig(sslProfileBasePath string, platform string) q
 	}
 	var routerName = s.Site.Name
 	if !s.bundle {
-		routerName = fmt.Sprintf("%s-%d", s.Site.Name, time.Now().Unix())
+		now := time.Now()
+		routerName = fmt.Sprintf("%s-%d-%d", s.Site.Name, now.Unix(), now.Nanosecond())
 	}
 	routerConfig := qdr.InitialConfig(routerName, s.SiteId, version.Version, !s.IsInterior(), 3)
 	routerConfig.AddAddress(qdr.Address{
@@ -308,6 +309,7 @@ func (s *SiteState) ToRouterConfig(sslProfileBasePath string, platform string) q
 		}
 		metadataJson, _ := encodingjson.Marshal(metadata)
 		routerConfig.Metadata.Metadata = string(metadataJson)
+		routerConfig.SiteConfig.Name += "-{{.SiteNameSuffix}}"
 		routerConfig.SiteConfig.Namespace = "{{.Namespace}}"
 		routerConfig.SiteConfig.Platform = "{{.Platform}}"
 	}


Test patch:
diff --git a/internal/nonkube/client/runtime/info_test.go b/internal/nonkube/client/runtime/info_test.go
index b79f3342..28b1f3d4 100644
--- a/internal/nonkube/client/runtime/info_test.go
+++ b/internal/nonkube/client/runtime/info_test.go
@@ -32,6 +32,12 @@ func TestGetLocalRouterAddress(t *testing.T) {
 	routerAddress, err = GetLocalRouterAddress(namespace)
 	assert.Assert(t, err)
 	assert.Equal(t, routerAddress, "amqps://127.0.0.1:5671")
+
+	// Make router access invalid
+	ss.RouterAccesses["skupper-local"].Spec.Roles = nil
+	assert.Assert(t, api.MarshalSiteState(*ss, outputDir))
+	routerAddress, err = GetLocalRouterAddress(namespace)
+	assert.ErrorContains(t, err, "no roles defined on RouterAccess: skupper-local")
 }
 
 func fakeSkupperLocalRouterAccess(namespace string) *v2alpha1.RouterAccess {