@@ -70,6 +70,11 @@ public abstract class AbstractContainerBackend implements IContainerBackend {
7070 protected static final String ENV_VAR_USER_GROUPS = "SHINYPROXY_USERGROUPS" ;
7171 protected static final String ENV_VAR_REALM_ID = "SHINYPROXY_REALM_ID" ;
7272
73+ protected static final String LABEL_PROXY_ID = "openanalytics.eu/sp-proxy-id" ;
74+ protected static final String LABEL_USER_ID = "openanalytics.eu/sp-user-id" ;
75+ protected static final String LABEL_PROXY_SPEC_ID = "openanalytics.eu/sp-spec-id" ;
76+ protected static final String LABEL_STARTUP_TIMESTAMP = "openanalytics.eu/sp-proxy-startup-timestamp" ;
77+
7378 protected final Logger log = LogManager .getLogger (getClass ());
7479
7580 private boolean useInternalNetwork ;
@@ -126,9 +131,23 @@ public void startProxy(Proxy proxy) throws ContainerProxyException {
126131 protected void doStartProxy (Proxy proxy ) throws Exception {
127132 for (ContainerSpec spec : proxy .getSpec ().getContainerSpecs ()) {
128133 if (authBackend != null ) authBackend .customizeContainer (spec );
134+
135+ // add labels need for App Recovery and maintenance
136+ spec .addLabel (LABEL_PROXY_ID , proxy .getId ());
137+ spec .addLabel (LABEL_USER_ID , proxy .getUserId ());
138+ spec .addLabel (LABEL_PROXY_SPEC_ID , proxy .getSpec ().getId ());
139+ spec .addLabel (LABEL_STARTUP_TIMESTAMP , String .valueOf (proxy .getStartupTimestamp ()));
140+
129141 ExpressionAwareContainerSpec eSpec = new ExpressionAwareContainerSpec (spec , proxy , expressionResolver );
130142 Container c = startContainer (eSpec , proxy );
131143 c .setSpec (spec );
144+
145+ // remove labels needed for App Recovery since they do not really belong to the spec
146+ spec .removeLabel (LABEL_PROXY_ID );
147+ spec .removeLabel (LABEL_USER_ID );
148+ spec .removeLabel (LABEL_PROXY_SPEC_ID );
149+ spec .removeLabel (LABEL_STARTUP_TIMESTAMP );
150+
132151 proxy .getContainers ().add (c );
133152 }
134153 }
0 commit comments